From 577a7c52fc41c66049f093d5981c6f9dd9cd3e8f Mon Sep 17 00:00:00 2001 From: Thomas Hindoe Paaboel Andersen Date: Fri, 4 Mar 2016 00:04:00 +0100 Subject: [PATCH] hidpp10: Fix getting current resolution on G9 On the G9 the response to a 0x63 is a short report. The G9 does not have individual resolutions for X and Y and thus only needs to report a single value. The set version of 0x63 should probably also be updated. However, while my testing of such a change worked better than with long reports there are still strange side effects of setting resolution, like turning off all the LED's. LGS also seems to do a full profile read/write instead of using 0x63 when changing the resolution. --- src/hidpp10.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/hidpp10.c b/src/hidpp10.c index 84ac1b22..fcb06624 100644 --- a/src/hidpp10.c +++ b/src/hidpp10.c @@ -2039,18 +2039,28 @@ hidpp10_get_current_resolution(struct hidpp10_device *dev, uint16_t *yres) { unsigned idx = dev->index; - union hidpp10_message resolution = CMD_CURRENT_RESOLUTION(REPORT_ID_SHORT, idx, GET_LONG_REGISTER_REQ); + union hidpp10_message resolution = CMD_CURRENT_RESOLUTION(REPORT_ID_SHORT, idx, GET_REGISTER_REQ); + union hidpp10_message resolution_long = CMD_CURRENT_RESOLUTION(REPORT_ID_SHORT, idx, GET_LONG_REGISTER_REQ); int res; hidpp_log_raw(&dev->base, "Fetching current resolution\n"); - res = hidpp10_request_command(dev, &resolution); - if (res) - return res; - - /* resolution is in 50dpi multiples */ - *xres = hidpp10_get_dpi_value(dev, hidpp_get_unaligned_le_u16(&resolution.data[4])); - *yres = hidpp10_get_dpi_value(dev, hidpp_get_unaligned_le_u16(&resolution.data[6])); + switch (dev->profile_type) { + case HIDPP10_PROFILE_G9: + res = hidpp10_request_command(dev, &resolution); + if (res) + return res; + /* resolution is in 50dpi multiples */ + *xres = *yres = hidpp10_get_dpi_value(dev, hidpp_get_unaligned_le_u16(&resolution.data[4])); + break; + default: + res = hidpp10_request_command(dev, &resolution_long); + if (res) + return res; + /* resolution is in 50dpi multiples */ + *xres = hidpp10_get_dpi_value(dev, hidpp_get_unaligned_le_u16(&resolution_long.data[4])); + *yres = hidpp10_get_dpi_value(dev, hidpp_get_unaligned_le_u16(&resolution_long.data[6])); + } return 0; }