hidpp20: allow overwritting the led count

Signed-off-by: Filipe Laíns <lains@archlinux.org>
This commit is contained in:
Filipe Laíns
2020-04-13 01:36:27 +01:00
committed by Filipe Laíns
parent dba202ae8b
commit 88a60f55b4
3 changed files with 23 additions and 1 deletions

View File

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

View File

@@ -1636,6 +1636,11 @@ hidpp20drv_init_device(struct ratbag_device *device,
{
struct ratbag_profile *profile;
bool active_profile = false;
int num;
num = ratbag_device_data_hidpp20_get_led_count(device->data);
if (num >= 0)
drv_data->num_leds = num;
ratbag_device_init_profiles(device,
drv_data->num_profiles,

View File

@@ -56,6 +56,7 @@ enum driver {
struct data_hidpp20 {
int index;
enum hidpp20_quirk quirk;
int led_count;
};
struct data_hidpp10 {
@@ -157,6 +158,7 @@ init_data_hidpp20(struct ratbag *ratbag,
char *str;
data->hidpp20.index = -1;
data->hidpp20.led_count = -1;
num = g_key_file_get_integer(keyfile, group, "DeviceIndex", &error);
if (num != 0 || !error)
@@ -164,6 +166,13 @@ init_data_hidpp20(struct ratbag *ratbag,
if (error)
g_error_free(error);
error = NULL;
num = g_key_file_get_integer(keyfile, group, "Leds", &error);
if (!error)
data->hidpp20.led_count = 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) {
@@ -576,6 +585,14 @@ ratbag_device_data_hidpp20_get_index(const struct ratbag_device_data *data)
return data->hidpp20.index;
}
int
ratbag_device_data_hidpp20_get_led_count(const struct ratbag_device_data *data)
{
assert(data->drivertype == HIDPP20);
return data->hidpp20.led_count;
}
enum hidpp20_quirk
ratbag_device_data_hidpp20_get_quirk(const struct ratbag_device_data *data)
{