mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 15:14:38 +01:00
sinowealth: read profile count from the device file
This commit is contained in:
@@ -1579,7 +1579,20 @@ sinowealth_init_profile(struct ratbag_device *device)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
drv_data->profile_count = 1;
|
||||
rc = device_data->profile_count;
|
||||
if (rc == -1) {
|
||||
drv_data->profile_count = 1;
|
||||
} else if (rc <= 0 || rc > SINOWEALTH_NUM_PROFILES_MAX) {
|
||||
log_error(device->ratbag,
|
||||
"Device file for firmware version %s specifies incorrect profile count: %d"
|
||||
" (should be in range %d-%d)\n",
|
||||
fw_version,
|
||||
rc, 1, SINOWEALTH_NUM_PROFILES_MAX);
|
||||
return -EINVAL;
|
||||
} else {
|
||||
drv_data->profile_count = (unsigned int)rc;
|
||||
}
|
||||
|
||||
|
||||
rc = sinowealth_read_raw_configs(device);
|
||||
if (rc)
|
||||
|
||||
@@ -36,6 +36,7 @@ struct sinowealth_device_data {
|
||||
char *device_name;
|
||||
enum sinowealth_led_format led_type;
|
||||
unsigned int button_count;
|
||||
int profile_count;
|
||||
|
||||
struct list link;
|
||||
};
|
||||
|
||||
@@ -234,6 +234,7 @@ init_data_sinowealth(struct ratbag *ratbag,
|
||||
const char *devices_group = "Driver/sinowealth/devices/";
|
||||
|
||||
GError *error = NULL;
|
||||
int rc;
|
||||
|
||||
size_t group_count = 0;
|
||||
_cleanup_(g_strfreevp) char **groups = g_key_file_get_groups(keyfile, &group_count);
|
||||
@@ -247,6 +248,8 @@ init_data_sinowealth(struct ratbag *ratbag,
|
||||
|
||||
struct sinowealth_device_data *device = zalloc(sizeof(struct sinowealth_device_data));
|
||||
|
||||
device->profile_count = -1;
|
||||
|
||||
device->button_count = g_key_file_get_integer(keyfile, device_group, "ButtonCount", &error);
|
||||
g_clear_error(&error);
|
||||
|
||||
@@ -272,6 +275,10 @@ init_data_sinowealth(struct ratbag *ratbag,
|
||||
}
|
||||
g_clear_error(&error);
|
||||
|
||||
rc = g_key_file_get_integer(keyfile, device_group, "ProfileCount", &error);
|
||||
if (rc != 0 && !error)
|
||||
device->profile_count = rc;
|
||||
|
||||
list_insert(&data->sinowealth.supported_devices, &device->link);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user