mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 23:23:52 +01:00
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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user