Merge pull request #89 from bentiss/g900

G900
This commit is contained in:
Peter Hutterer
2016-05-12 12:39:37 +10:00
3 changed files with 32 additions and 2 deletions

View File

@@ -165,6 +165,12 @@ mouse:usb:v046dpc080:name:*:
mouse:usb:v046dp4011:name:*:
RATBAG_DRIVER=hidpp20
# G900 over wireless USB
mouse:usb:v046dpc539:name:*:
RATBAG_DRIVER=hidpp20
RATBAG_HIDPP20_INDEX=1
##########################################
# Roccat
##########################################

View File

@@ -812,6 +812,9 @@ hidpp20drv_probe(struct ratbag_device *device)
struct hidpp20drv_data *drv_data;
struct hidpp_device base;
struct hidpp20_device *dev;
const char *prop;
int device_idx = HIDPP_RECEIVER_IDX;
int nread = 0;
rc = ratbag_find_hidraw(device, hidpp20drv_test_hidraw);
if (rc)
@@ -822,7 +825,27 @@ hidpp20drv_probe(struct ratbag_device *device)
hidpp_device_init(&base, device->hidraw.fd);
hidpp_device_set_log_handler(&base, hidpp20_log, HIDPP_LOG_PRIORITY_RAW, device);
dev = hidpp20_device_new(&base, HIDPP_RECEIVER_IDX);
prop = ratbag_device_get_udev_property(device, "RATBAG_HIDPP20_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_HIDPP20_INDEX: '%s' for %s\n",
prop,
device->name);
device_idx = HIDPP_RECEIVER_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 0xff as device index.
*
* If there is a special need like for G900, we can pass a
* udev prop RATBAG_HIDPP20_INDEX.
*/
dev = hidpp20_device_new(&base, device_idx);
if (!dev) {
rc = -ENODEV;
goto err;

View File

@@ -1884,8 +1884,9 @@ static const enum ratbag_button_action_special hidpp20_profiles_specials[] = {
[0x09] = RATBAG_BUTTON_ACTION_SPECIAL_INVALID,
[0x0a] = RATBAG_BUTTON_ACTION_SPECIAL_PROFILE_CYCLE_UP,
[0x0b] = RATBAG_BUTTON_ACTION_SPECIAL_SECOND_MODE,
[0x0c] = RATBAG_BUTTON_ACTION_SPECIAL_BATTERY_LEVEL,
[0x0c ... 0xff] = RATBAG_BUTTON_ACTION_SPECIAL_INVALID,
[0x0d ... 0xff] = RATBAG_BUTTON_ACTION_SPECIAL_INVALID,
};
enum ratbag_button_action_special