diff --git a/hwdb/70-libratbag-mouse.hwdb b/hwdb/70-libratbag-mouse.hwdb index fce7ffa9..c2bcd5b8 100644 --- a/hwdb/70-libratbag-mouse.hwdb +++ b/hwdb/70-libratbag-mouse.hwdb @@ -115,6 +115,13 @@ mouse:usb:v046dpc06b:name:*: RATBAG_HIDPP10_DPI=0:5700@23.53 RATBAG_HIDPP10_PROFILE=G700 +# G700 over wireless USB +mouse:usb:v046dpc531:name:*: + RATBAG_DRIVER=hidpp10 + RATBAG_HIDPP10_DPI=0:5700@23.53 + RATBAG_HIDPP10_PROFILE=G700 + RATBAG_HIDPP10_INDEX=1 + # MX Master over unifying mouse:usb:v046dp4041:name:*: # MX Master over bluetooth diff --git a/src/driver-hidpp10.c b/src/driver-hidpp10.c index a3ddf945..3c37b763 100644 --- a/src/driver-hidpp10.c +++ b/src/driver-hidpp10.c @@ -302,6 +302,8 @@ hidpp10drv_probe(struct ratbag_device *device) struct hidpp_device base; enum hidpp10_profile_type type = HIDPP10_PROFILE_UNKNOWN; const char *prop; + int device_idx = HIDPP_WIRED_DEVICE_IDX; + int nread = 0; rc = ratbag_find_hidraw(device, hidpp10drv_test_hidraw); if (rc == -ENODEV) { @@ -326,12 +328,27 @@ hidpp10drv_probe(struct ratbag_device *device) else if (strcasecmp("G700", prop) == 0) type = HIDPP10_PROFILE_G700; } - /* We can treat all devices as wired devices here. If we talk to the - * correct hidraw device the kernel adjusts the device index for us, - * so even for unifying receiver devices we can just 0x00 as device - * index. + + prop = ratbag_device_get_udev_property(device, "RATBAG_HIDPP10_INDEX"); + if (prop) { + sscanf(prop, "%d%n", &device_idx, &nread); + if (!nread || (prop[nread]) != '\0' || device_idx < 0) { + log_error(device->ratbag, + "Error parsing RATBAG_HIDPP10_INDEX: '%s' for %s\n", + prop, + device->name); + device_idx = HIDPP_WIRED_DEVICE_IDX; + } + } + /* In the general case, we can treat all devices as wired devices + * here. If we talk to the correct hidraw device the kernel adjusts + * the device index for us, so even for unifying receiver devices + * we can just use 0x00 as device index. + * + * If there is a special need like for G700(s), we can pass a + * udev prop RATBAG_HIDPP10_INDEX. */ - dev = hidpp10_device_new(&base, HIDPP_WIRED_DEVICE_IDX, type); + dev = hidpp10_device_new(&base, device_idx, type); if (!dev) { log_error(device->ratbag,