mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 15:14:38 +01:00
hidpp10: add support for G700 over wireless
The G700 can use a wireless receiver too. It is close enough to the normal Logitech Unifying receiver, but is truncated as it can not pair multiple devices. We currently don't treat it in the kernel as an Unifying device, and so giving the device index of 0x00 fails as the device is actually on 0x01. While there is no proper kernel solution (if there will ever be one), allow to add a parameter in the hwdb to specify the device index. We might need it for some other devices too, we will see. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user