Motion sync loaded in UI, support in g-wolves
This commit is contained in:
		@@ -183,3 +183,31 @@ int driver_mouse_dpi_get(void* handle, struct MOUSE_DPI_LEVELS* output)
 | 
			
		||||
    libusb_close(hand);
 | 
			
		||||
    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;
 | 
			
		||||
    AdwPreferencesGroup* dpi_preference_group;
 | 
			
		||||
    AdwButtonContent* dpi_stage_add_button;
 | 
			
		||||
    AdwSwitchRow* motion_sync_switchrow;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
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, 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);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // 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>
 | 
			
		||||
 | 
			
		||||
                        <child>
 | 
			
		||||
                          <object class="AdwSwitchRow">
 | 
			
		||||
                          <object class="AdwSwitchRow" id="motion_sync_switchrow">
 | 
			
		||||
                            <property name="activatable">true</property>
 | 
			
		||||
                            <property name="width-request">200</property>
 | 
			
		||||
                            <property name="hexpand">false</property>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user