From f4777e7b71153c419da267571e8acc679df05e7e Mon Sep 17 00:00:00 2001 From: Benjamin Tissoires Date: Sun, 11 Oct 2015 10:24:03 -0400 Subject: [PATCH] hidpp20: fix adjustable DPI for older mice The G502 uses the version 0 of the adjustable DPI feature. This version does not echo the given parameters which raised a -EIO in libratbag. Signed-off-by: Benjamin Tissoires --- src/hidpp20.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/hidpp20.c b/src/hidpp20.c index fbe8c0b3..08c1860b 100644 --- a/src/hidpp20.c +++ b/src/hidpp20.c @@ -883,6 +883,7 @@ int hidpp20_adjustable_dpi_set_sensor_dpi(struct ratbag_device *device, struct hidpp20_sensor *sensor, uint16_t dpi) { uint8_t feature_index, feature_type, feature_version; + uint16_t returned_parameters; int rc; union hidpp20_message msg = { .msg.report_id = REPORT_ID_LONG, @@ -907,7 +908,10 @@ int hidpp20_adjustable_dpi_set_sensor_dpi(struct ratbag_device *device, if (rc) return rc; - if (hidpp20_get_unaligned_u16(&msg.msg.parameters[1]) != dpi) + returned_parameters = hidpp20_get_unaligned_u16(&msg.msg.parameters[1]); + + /* version 0 of the protocol does not echo the parameters */ + if (returned_parameters != dpi && returned_parameters) return -EIO; return 0;