forked from drath/libratbag
hidpp20: add suport for the G602
Signed-off-by: Filipe Laíns <lains@archlinux.org>
This commit is contained in:
committed by
Filipe Laíns
parent
2353af214b
commit
d4d9712316
@@ -6,3 +6,4 @@ Driver=hidpp20
|
||||
|
||||
[Driver/hidpp20]
|
||||
DeviceIndex=1
|
||||
Quirk=G602
|
||||
|
||||
@@ -859,7 +859,8 @@ hidpp20drv_read_resolution_dpi(struct ratbag_profile *profile)
|
||||
unsigned int default_rate = 500;
|
||||
int rc;
|
||||
|
||||
if (drv_data->capabilities & HIDPP_CAP_RESOLUTION_2200) {
|
||||
if ((drv_data->capabilities & HIDPP_CAP_RESOLUTION_2200) &&
|
||||
(drv_data->capabilities & HIDPP_CAP_SWITCHABLE_RESOLUTION_2201) == 0) {
|
||||
uint16_t resolution;
|
||||
uint8_t flags;
|
||||
|
||||
@@ -1305,6 +1306,11 @@ hidpp20drv_init_feature(struct ratbag_device *device, uint16_t feature)
|
||||
break;
|
||||
}
|
||||
case HIDPP_PAGE_COLOR_LED_EFFECTS: {
|
||||
/* The 8070 feauture implemented in the G602 doesn't follow the spec,
|
||||
* so we ignore it */
|
||||
if (ratbag_device_data_hidpp20_get_quirk(device->data) == HIDPP20_QUIRK_G602)
|
||||
break;
|
||||
|
||||
log_debug(ratbag, "device has color effects\n");
|
||||
drv_data->capabilities |= HIDPP_CAP_COLOR_LED_EFFECTS_8070;
|
||||
|
||||
|
||||
@@ -108,6 +108,7 @@ hidpp20_get_quirk_string(enum hidpp20_quirk quirk)
|
||||
switch (quirk) {
|
||||
CASE_RETURN_STRING(HIDPP20_QUIRK_NONE);
|
||||
CASE_RETURN_STRING(HIDPP20_QUIRK_G305);
|
||||
CASE_RETURN_STRING(HIDPP20_QUIRK_G602);
|
||||
}
|
||||
|
||||
abort();
|
||||
@@ -1441,6 +1442,11 @@ hidpp20_adjustable_dpi_get_dpi_list(struct hidpp20_device *device,
|
||||
.msg.parameters[0] = sensor->index,
|
||||
};
|
||||
|
||||
if (device->quirk == HIDPP20_QUIRK_G602) {
|
||||
msg.msg.parameters[0] = 1;
|
||||
i = 0;
|
||||
}
|
||||
|
||||
rc = hidpp20_request_command(device, &msg);
|
||||
if (rc)
|
||||
return rc;
|
||||
@@ -1452,6 +1458,9 @@ hidpp20_adjustable_dpi_get_dpi_list(struct hidpp20_device *device,
|
||||
get_unaligned_be_u16(&msg.msg.parameters[i]) != 0) {
|
||||
uint16_t value = get_unaligned_be_u16(&msg.msg.parameters[i]);
|
||||
|
||||
if (device->quirk == HIDPP20_QUIRK_G602 && i == 2)
|
||||
value += 0xe000;
|
||||
|
||||
if (value > 0xe000) {
|
||||
sensor->dpi_steps = value - 0xe000;
|
||||
} else {
|
||||
@@ -1481,6 +1490,9 @@ hidpp20_adjustable_dpi_get_dpi(struct hidpp20_device *device,
|
||||
.msg.parameters[0] = sensor->index,
|
||||
};
|
||||
|
||||
if (device->quirk == HIDPP20_QUIRK_G602)
|
||||
msg.msg.parameters[0] = 1;
|
||||
|
||||
rc = hidpp20_request_command(device, &msg);
|
||||
if (rc)
|
||||
return rc;
|
||||
@@ -1560,6 +1572,9 @@ int hidpp20_adjustable_dpi_set_sensor_dpi(struct hidpp20_device *device,
|
||||
.msg.parameters[0] = sensor->index,
|
||||
};
|
||||
|
||||
if (device->quirk == HIDPP20_QUIRK_G602)
|
||||
msg.msg.parameters[0] = 1;
|
||||
|
||||
set_unaligned_be_u16(&msg.msg.parameters[1], dpi);
|
||||
|
||||
feature_index = hidpp_root_get_feature_idx(device,
|
||||
|
||||
@@ -54,6 +54,7 @@ struct hidpp20_feature {
|
||||
enum hidpp20_quirk {
|
||||
HIDPP20_QUIRK_NONE,
|
||||
HIDPP20_QUIRK_G305,
|
||||
HIDPP20_QUIRK_G602,
|
||||
};
|
||||
|
||||
struct hidpp20_device {
|
||||
|
||||
@@ -169,6 +169,8 @@ init_data_hidpp20(struct ratbag *ratbag,
|
||||
if (str) {
|
||||
if (streq(str, "G305"))
|
||||
data->hidpp20.quirk = HIDPP20_QUIRK_G305;
|
||||
else if(streq(str, "G602"))
|
||||
data->hidpp20.quirk = HIDPP20_QUIRK_G602;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user