1
0
forked from drath/libratbag

hidpp20: allow setting a default report rate (#969)

In case we can't get the report rate value from the device, allow
setting in the device file.

Signed-off-by: Filipe Laíns <lains@archlinux.org>
This commit is contained in:
Filipe Laíns
2021-10-11 00:14:02 +01:00
committed by GitHub
parent 9732aa009e
commit e908871e82
4 changed files with 23 additions and 2 deletions

View File

@@ -168,7 +168,7 @@ def check_section_hidpp10(section):
def check_section_hidpp20(section):
permitted = ['DeviceIndex', 'Leds', 'Quirk']
permitted = ['DeviceIndex', 'Leds', 'ReportRate', 'Quirk']
for key in section.keys():
assertIn(key, permitted)

View File

@@ -957,7 +957,7 @@ hidpp20drv_read_resolution_dpi(struct ratbag_profile *profile)
if (drv_data->capabilities & HIDPP_CAP_ADJUSTIBLE_REPORT_RATE_8060) {
rc = hidpp20drv_read_report_rate_8060(device);
if (rc < 0)
if (rc < 0 && drv_data->report_rates[0] == 0)
return rc;
ratbag_profile_set_report_rate_list(profile,
@@ -1642,6 +1642,8 @@ hidpp20drv_init_device(struct ratbag_device *device,
if (num >= 0)
drv_data->num_leds = num;
drv_data->report_rates[0] = ratbag_device_data_hidpp20_get_report_rate(device->data);;
ratbag_device_init_profiles(device,
drv_data->num_profiles,
drv_data->num_resolutions,

View File

@@ -63,6 +63,7 @@ struct data_hidpp20 {
int index;
enum hidpp20_quirk quirk;
int led_count;
int report_rate;
};
struct data_hidpp10 {
@@ -179,6 +180,13 @@ init_data_hidpp20(struct ratbag *ratbag,
if (error)
g_error_free(error);
error = NULL;
num = g_key_file_get_integer(keyfile, group, "ReportRate", &error);
if (num > 0 || !error)
data->hidpp20.report_rate = num;
if (error)
g_error_free(error);
str = g_key_file_get_string(keyfile, group, "Quirk", NULL);
data->hidpp20.quirk = HIDPP20_QUIRK_NONE;
if (str) {
@@ -606,6 +614,14 @@ ratbag_device_data_hidpp20_get_led_count(const struct ratbag_device_data *data)
return data->hidpp20.led_count;
}
int
ratbag_device_data_hidpp20_get_report_rate(const struct ratbag_device_data *data)
{
assert(data->drivertype == HIDPP20);
return data->hidpp20.report_rate;
}
enum hidpp20_quirk
ratbag_device_data_hidpp20_get_quirk(const struct ratbag_device_data *data)
{

View File

@@ -83,6 +83,9 @@ ratbag_device_data_hidpp20_get_index(const struct ratbag_device_data *data);
int
ratbag_device_data_hidpp20_get_led_count(const struct ratbag_device_data *data);
int
ratbag_device_data_hidpp20_get_report_rate(const struct ratbag_device_data *data);
enum hidpp20_quirk
ratbag_device_data_hidpp20_get_quirk(const struct ratbag_device_data *data);