mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 23:23:52 +01:00
driver-hidpp10: fill the number of buttons from the first profile
We don't know the HID++ 1.0 request to check for the number of buttons or profiles, this is the next-best thing. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
@@ -185,6 +185,26 @@ out:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
hidpp10drv_fill_from_profile(struct ratbag_device *device, struct hidpp10_device *dev)
|
||||
{
|
||||
int rc;
|
||||
struct hidpp10_profile profile;
|
||||
|
||||
/* We don't know the HID++1.0 requests to query for buttons, etc.
|
||||
* and the get_current_profile request is garbage. So get profile 1
|
||||
* and fill the device information in from that.
|
||||
*/
|
||||
rc = hidpp10_get_profile(dev, 0, &profile);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
device->num_buttons = profile.num_buttons;
|
||||
device->num_profiles = HIDPP10_NUM_PROFILES;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
hidpp10drv_probe(struct ratbag_device *device, const struct ratbag_id id)
|
||||
{
|
||||
@@ -230,8 +250,11 @@ hidpp10drv_probe(struct ratbag_device *device, const struct ratbag_id id)
|
||||
drv_data->dev = dev;
|
||||
ratbag_set_drv_data(device, drv_data);
|
||||
|
||||
device->num_profiles = 1;
|
||||
device->num_buttons = 8;
|
||||
if (hidpp10drv_fill_from_profile(device, dev)) {
|
||||
/* Fall back to something that every mouse has */
|
||||
device->num_profiles = 1;
|
||||
device->num_buttons = 3;
|
||||
}
|
||||
|
||||
return 0;
|
||||
err:
|
||||
|
||||
Reference in New Issue
Block a user