diff --git a/drivers/g-wolves/g-wolves.c b/drivers/g-wolves/g-wolves.c
index d7d1bff..9532cdc 100644
--- a/drivers/g-wolves/g-wolves.c
+++ b/drivers/g-wolves/g-wolves.c
@@ -1,5 +1,7 @@
#include "g-wolves.h"
+#define DEVICE_WIRELESS(handle) (driver_get_capacity(handle) & DEVICE_CAPACITY_WIRELESS)
+
static int send_command(libusb_device_handle* hand, uint8_t command, uint8_t size, void* report, bool wireless)
{
report_header_t* head = report;
@@ -157,11 +159,7 @@ int driver_mouse_dpi_get(void* handle, struct MOUSE_DPI_LEVELS* output)
// Send command
struct REPORT_DPI_SETTINGS report = {0};
-
- bool wireless = false;
- if(driver_get_capacity(handle) & DEVICE_CAPACITY_WIRELESS) wireless = true;
-
- int res = send_command(hand, COMMAND_DPI_SETTINGS, REPORT_DPI_SETTINGS_SIZE, &report, wireless);
+ int res = send_command(hand, COMMAND_DPI_SETTINGS, REPORT_DPI_SETTINGS_SIZE, &report, DEVICE_WIRELESS(handle));
if(res <= 0) return -1;
// Format 'output' packet
@@ -196,15 +194,35 @@ int driver_mouse_motion_sync_get(void* handle, bool* output)
// Send command
struct REPORT_MOTION_SYNC report = {0};
+ int res = send_command(hand, COMMAND_MOTION_SYNC, REPORT_MOTION_SYNC_SIZE, &report, DEVICE_WIRELESS(handle));
+ if(res <= 0) return -1;
- bool wireless = false;
- if(driver_get_capacity(handle) & DEVICE_CAPACITY_WIRELESS) wireless = true;
+ // Format output boolean
+ *output = report.motion_sync;
+
+ // Close and return
+ libusb_attach_kernel_driver(hand, 0x2);
+ libusb_close(hand);
+ return 0;
+}
- int res = send_command(hand, COMMAND_MOTION_SYNC, REPORT_MOTION_SYNC_SIZE, &report, wireless);
+int driver_mouse_angle_snap_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_ANGLE_SNAP report = {0};
+ int res = send_command(hand, COMMAND_ANGLE_SNAP, REPORT_ANGLE_SNAP_SIZE, &report, DEVICE_WIRELESS(handle));
if(res <= 0) return -1;
// Format output boolean
- *output = report.motion_sync;
+ *output = report.angle_snap;
// Close and return
libusb_attach_kernel_driver(hand, 0x2);
diff --git a/src/ui/panels/mouse-panel.c b/src/ui/panels/mouse-panel.c
index b11ebeb..a86e60f 100644
--- a/src/ui/panels/mouse-panel.c
+++ b/src/ui/panels/mouse-panel.c
@@ -10,6 +10,7 @@ struct _MousePanel
AdwPreferencesGroup* dpi_preference_group;
AdwButtonContent* dpi_stage_add_button;
AdwSwitchRow* motion_sync_switchrow;
+ AdwSwitchRow* angle_snap_switchrow;
};
G_DEFINE_TYPE (MousePanel, mouse_panel, panel_get_type())
@@ -27,6 +28,7 @@ mouse_panel_class_init(MousePanelClass* klass)
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, motion_sync_switchrow);
+ gtk_widget_class_bind_template_child(widget_class, MousePanel, angle_snap_switchrow);
}
static void
@@ -103,8 +105,12 @@ void mouse_panel_set_device(MousePanel* self, device_t* device)
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);
- }
+ // Set mouse 'angle snap' feature
+ bool angle_snap = false;
+ int (*driver_mouse_angle_snap_get)(void*, bool*) = dlsym(device_driver(device), "driver_mouse_angle_snap_get");
+ int anglesnap_res = driver_mouse_angle_snap_get(device_handle(device), &angle_snap);
+ if(!anglesnap_res)
+ adw_switch_row_set_active(self->angle_snap_switchrow, angle_snap);
}
diff --git a/ui/panel-mouse.ui b/ui/panel-mouse.ui
index adab739..5751535 100644
--- a/ui/panel-mouse.ui
+++ b/ui/panel-mouse.ui
@@ -204,7 +204,7 @@ the rate of the computer update requests
10
-