From 43f501907ee0926b7f841fa3d5d1353f5122b7c4 Mon Sep 17 00:00:00 2001 From: Thomas Hindoe Paaboel Andersen Date: Thu, 28 Sep 2017 23:45:56 +0200 Subject: [PATCH] hidpp10: fix setting resolution on G9 The G9 sends a short report and does not have separate DPIs for x and y. --- src/hidpp10.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/hidpp10.c b/src/hidpp10.c index 2ad99f6d..fa1ee39d 100644 --- a/src/hidpp10.c +++ b/src/hidpp10.c @@ -2109,12 +2109,24 @@ hidpp10_set_current_resolution(struct hidpp10_device *dev, uint16_t yres) { unsigned idx = dev->index; - union hidpp10_message resolution = CMD_CURRENT_RESOLUTION(REPORT_ID_LONG, idx, SET_LONG_REGISTER_REQ); + union hidpp10_message resolution = CMD_CURRENT_RESOLUTION(REPORT_ID_SHORT, idx, SET_REGISTER_REQ); + union hidpp10_message resolution_long = CMD_CURRENT_RESOLUTION(REPORT_ID_LONG, idx, SET_LONG_REGISTER_REQ); + int res; - hidpp_set_unaligned_le_u16(&resolution.data[4], hidpp10_get_dpi_mapping(dev, xres)); - hidpp_set_unaligned_le_u16(&resolution.data[6], hidpp10_get_dpi_mapping(dev, yres)); + switch (dev->profile_type) { + case HIDPP10_PROFILE_G9: + resolution.data[4] = hidpp10_get_dpi_mapping(dev, xres); + res = hidpp10_request_command(dev, &resolution); + break; + default: + hidpp_set_unaligned_le_u16(&resolution_long.data[4], hidpp10_get_dpi_mapping(dev, xres)); + hidpp_set_unaligned_le_u16(&resolution_long.data[6], hidpp10_get_dpi_mapping(dev, yres)); - return hidpp10_request_command(dev, &resolution); + res = hidpp10_request_command(dev, &resolution_long); + break; + } + + return res; } /* -------------------------------------------------------------------------- */