|
|
@ -4,11 +4,22 @@ struct _MousePanel |
|
|
|
{ |
|
|
|
{ |
|
|
|
Panel parent_instance; |
|
|
|
Panel parent_instance; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Mouse presentation
|
|
|
|
GtkImage* mouse_image; |
|
|
|
GtkImage* mouse_image; |
|
|
|
GtkLabel* mouse_manufacturer; |
|
|
|
GtkLabel* mouse_manufacturer; |
|
|
|
GtkLabel* mouse_name; |
|
|
|
GtkLabel* mouse_name; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Wireless informations
|
|
|
|
|
|
|
|
AdwPreferencesGroup* wireless; |
|
|
|
|
|
|
|
GtkLevelBar* battery_level; |
|
|
|
|
|
|
|
GtkLabel* battery_level_label; |
|
|
|
|
|
|
|
GtkLabel* charging_state; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// DPI
|
|
|
|
AdwPreferencesGroup* dpi_preference_group; |
|
|
|
AdwPreferencesGroup* dpi_preference_group; |
|
|
|
AdwButtonContent* dpi_stage_add_button; |
|
|
|
AdwButtonContent* dpi_stage_add_button; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Features
|
|
|
|
AdwSwitchRow* motion_sync_switchrow; |
|
|
|
AdwSwitchRow* motion_sync_switchrow; |
|
|
|
AdwSwitchRow* angle_snap_switchrow; |
|
|
|
AdwSwitchRow* angle_snap_switchrow; |
|
|
|
}; |
|
|
|
}; |
|
|
@ -25,6 +36,10 @@ mouse_panel_class_init(MousePanelClass* klass) |
|
|
|
gtk_widget_class_bind_template_child(widget_class, MousePanel, mouse_image); |
|
|
|
gtk_widget_class_bind_template_child(widget_class, MousePanel, mouse_image); |
|
|
|
gtk_widget_class_bind_template_child(widget_class, MousePanel, mouse_manufacturer); |
|
|
|
gtk_widget_class_bind_template_child(widget_class, MousePanel, mouse_manufacturer); |
|
|
|
gtk_widget_class_bind_template_child(widget_class, MousePanel, mouse_name); |
|
|
|
gtk_widget_class_bind_template_child(widget_class, MousePanel, mouse_name); |
|
|
|
|
|
|
|
gtk_widget_class_bind_template_child(widget_class, MousePanel, wireless); |
|
|
|
|
|
|
|
gtk_widget_class_bind_template_child(widget_class, MousePanel, battery_level); |
|
|
|
|
|
|
|
gtk_widget_class_bind_template_child(widget_class, MousePanel, battery_level_label); |
|
|
|
|
|
|
|
gtk_widget_class_bind_template_child(widget_class, MousePanel, charging_state); |
|
|
|
gtk_widget_class_bind_template_child(widget_class, MousePanel, dpi_preference_group); |
|
|
|
gtk_widget_class_bind_template_child(widget_class, MousePanel, dpi_preference_group); |
|
|
|
gtk_widget_class_bind_template_child(widget_class, MousePanel, dpi_stage_add_button); |
|
|
|
gtk_widget_class_bind_template_child(widget_class, MousePanel, dpi_stage_add_button); |
|
|
|
gtk_widget_class_bind_template_child(widget_class, MousePanel, motion_sync_switchrow); |
|
|
|
gtk_widget_class_bind_template_child(widget_class, MousePanel, motion_sync_switchrow); |
|
|
@ -59,6 +74,31 @@ void mouse_panel_set_device(MousePanel* self, device_t* device) |
|
|
|
char* device_name = device_get_name(device); |
|
|
|
char* device_name = device_get_name(device); |
|
|
|
gtk_label_set_label(self->mouse_name, device_name); |
|
|
|
gtk_label_set_label(self->mouse_name, device_name); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set mouse wireless status
|
|
|
|
|
|
|
|
if(device_get_capacity(device) & DEVICE_CAPACITY_WIRELESS) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
int (*driver_wireless_battery_state_get)(void*, int*, bool*) = dlsym(device_driver(device), "driver_wireless_battery_state_get"); |
|
|
|
|
|
|
|
int battery_level; |
|
|
|
|
|
|
|
bool charging; |
|
|
|
|
|
|
|
int battery_res = driver_wireless_battery_state_get(device_handle(device), &battery_level, &charging); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!battery_res) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Set battery level
|
|
|
|
|
|
|
|
gtk_level_bar_set_value(self->battery_level, (double) battery_level); |
|
|
|
|
|
|
|
char battery_level_str[10]; |
|
|
|
|
|
|
|
sprintf(battery_level_str, "%u %%", battery_level); |
|
|
|
|
|
|
|
gtk_label_set_label(self->battery_level_label, battery_level_str); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set battery status
|
|
|
|
|
|
|
|
if(charging) |
|
|
|
|
|
|
|
gtk_label_set_label(self->charging_state, "Charging"); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
gtk_label_set_label(self->charging_state, "Not charging"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else gtk_widget_set_visible(GTK_WIDGET(self->wireless), false); |
|
|
|
|
|
|
|
|
|
|
|
// Set mouse dpi
|
|
|
|
// Set mouse dpi
|
|
|
|
struct MOUSE_DPI_LEVELS dpi; |
|
|
|
struct MOUSE_DPI_LEVELS dpi; |
|
|
|
int (*driver_mouse_dpi_get)(void*, void*) = dlsym(device_driver(device), "driver_mouse_dpi_get"); |
|
|
|
int (*driver_mouse_dpi_get)(void*, void*) = dlsym(device_driver(device), "driver_mouse_dpi_get"); |
|
|
|