diff --git a/src/hidpp10.c b/src/hidpp10.c index c7e304b6..f2a54745 100644 --- a/src/hidpp10.c +++ b/src/hidpp10.c @@ -383,6 +383,25 @@ hidpp10_get_optical_sensor_settings(struct ratbag_device *device, struct hidpp10 return 0; } +static int +hidpp10_get_usb_refresh_rate(struct ratbag_device *device, struct hidpp10_device *dev) +{ + unsigned idx = dev->index; + union hidpp10_message refresh = CMD_USB_REFRESH_RATE(idx, GET_REGISTER_REQ); + int res; + int rate; + + res = hidpp10_request_command(device, &refresh); + if (res) + return res; + + rate = 1000/refresh.msg.parameters[0]; + + log_debug(device->ratbag, "Refresh rate: %dHz\n", rate); + + return 0; +} + static int hidpp10_get_device_info(struct ratbag_device *device, struct hidpp10_device *dev) { @@ -395,6 +414,7 @@ hidpp10_get_device_info(struct ratbag_device *device, struct hidpp10_device *dev hidpp10_get_current_resolution(device, dev); hidpp10_get_led_status(device, dev); hidpp10_get_optical_sensor_settings(device, dev); + hidpp10_get_usb_refresh_rate(device, dev); return 0; } diff --git a/src/hidpp10.h b/src/hidpp10.h index afbfc21d..bac3faac 100644 --- a/src/hidpp10.h +++ b/src/hidpp10.h @@ -93,6 +93,8 @@ #define __CMD_OPTICAL_SENSOR_SETTINGS 0x61 +#define __CMD_USB_REFRESH_RATE 0x64 + #define CMD_PAIRING_INFORMATION(idx, type) { \ .msg = { \ .report_id = REPORT_ID_SHORT, \ @@ -163,6 +165,16 @@ } \ } +#define CMD_USB_REFRESH_RATE(idx, sub) { \ + .msg = { \ + .report_id = REPORT_ID_SHORT, \ + .device_idx = idx, \ + .sub_id = sub, \ + .address = __CMD_USB_REFRESH_RATE, \ + .parameters = {0x00, 0x00, 0x00 }, \ + } \ +} + #define CMD_OPTICAL_SENSOR_SETTINGS(idx, sub) { \ .msg = { \ .report_id = REPORT_ID_SHORT, \