Motion sync loaded in UI, support in g-wolves

master
vhaudiquet 12 months ago
parent a12e682eda
commit 22cb968b64
  1. 28
      drivers/g-wolves/g-wolves.c
  2. 12
      src/ui/panels/mouse-panel.c
  3. 2
      ui/panel-mouse.ui

@ -183,3 +183,31 @@ int driver_mouse_dpi_get(void* handle, struct MOUSE_DPI_LEVELS* output)
libusb_close(hand); libusb_close(hand);
return 0; return 0;
} }
int driver_mouse_motion_sync_get(void* handle, bool* output)
{
libusb_device* dev = handle;
// Prepare usb device for transfer
libusb_device_handle* hand;
int openres = libusb_open(dev, &hand);
if(openres) return -1;
libusb_detach_kernel_driver(hand, 0x2);
// Send command
struct REPORT_MOTION_SYNC report = {0};
bool wireless = false;
if(driver_get_capacity(handle) & DEVICE_CAPACITY_WIRELESS) wireless = true;
int res = send_command(hand, COMMAND_MOTION_SYNC, REPORT_MOTION_SYNC_SIZE, &report, wireless);
if(res <= 0) return -1;
// Format output boolean
*output = report.motion_sync;
// Close and return
libusb_attach_kernel_driver(hand, 0x2);
libusb_close(hand);
return 0;
}

@ -9,6 +9,7 @@ struct _MousePanel
GtkLabel* mouse_name; GtkLabel* mouse_name;
AdwPreferencesGroup* dpi_preference_group; AdwPreferencesGroup* dpi_preference_group;
AdwButtonContent* dpi_stage_add_button; AdwButtonContent* dpi_stage_add_button;
AdwSwitchRow* motion_sync_switchrow;
}; };
G_DEFINE_TYPE (MousePanel, mouse_panel, panel_get_type()) G_DEFINE_TYPE (MousePanel, mouse_panel, panel_get_type())
@ -25,6 +26,7 @@ mouse_panel_class_init(MousePanelClass* klass)
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, 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);
} }
static void static void
@ -95,4 +97,14 @@ void mouse_panel_set_device(MousePanel* self, device_t* device)
adw_preferences_group_add(self->dpi_preference_group, GTK_WIDGET(row)); adw_preferences_group_add(self->dpi_preference_group, GTK_WIDGET(row));
} }
} }
// Set mouse 'motion sync' feature
bool motion_sync = false;
int (*driver_mouse_motion_sync_get)(void*, bool*) = dlsym(device_driver(device), "driver_mouse_motion_sync_get");
int motionsync_res = driver_mouse_motion_sync_get(device_handle(device), &motion_sync);
if(!motionsync_res)
{
adw_switch_row_set_active(self->motion_sync_switchrow, motion_sync);
}
} }

@ -183,7 +183,7 @@
<property name="margin-top">10</property> <property name="margin-top">10</property>
<child> <child>
<object class="AdwSwitchRow"> <object class="AdwSwitchRow" id="motion_sync_switchrow">
<property name="activatable">true</property> <property name="activatable">true</property>
<property name="width-request">200</property> <property name="width-request">200</property>
<property name="hexpand">false</property> <property name="hexpand">false</property>

Loading…
Cancel
Save