From f7523f000e86c1aea8c5063fd6cfa2d46db022f8 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Thu, 10 Mar 2016 16:53:55 +1000 Subject: [PATCH] Add a QUERY_CONFIGURATION capability Designates a device that can be queried for the current configuration. Some devices lack this ability so we rely on the caller to upload a known configuration to the device before we can really proceed. Set by default, devices without that capability should be the exception, not the norm. This patch just adds the capability, actual handling for this needs to be added when we add the first device without this capability. Signed-off-by: Peter Hutterer --- src/libratbag.c | 7 +++++++ src/libratbag.h | 17 +++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/libratbag.c b/src/libratbag.c index 5f4b0289..896e425b 100644 --- a/src/libratbag.c +++ b/src/libratbag.c @@ -172,6 +172,13 @@ ratbag_device_new(struct ratbag *ratbag, struct udev_device *udev_device, list_insert(&ratbag->devices, &device->link); + /* We assume that most devices have this capability, so let's set it + * by default. The few devices that miss this capability should + * unset it instead. + */ + ratbag_device_set_capability(device, + RATBAG_DEVICE_CAP_QUERY_CONFIGURATION); + return device; } diff --git a/src/libratbag.h b/src/libratbag.h index 6f25c877..5e141c99 100644 --- a/src/libratbag.h +++ b/src/libratbag.h @@ -443,6 +443,23 @@ enum ratbag_device_capability { * last-used profile or a specific profile (usually the first). */ RATBAG_DEVICE_CAP_DEFAULT_PROFILE, + + /** + * The device has the capability to query the current hardware + * configuration. If this capability is missing, libratbag cannot + * query the device for its current configuration and the + * configured resolutions and button mappings are unknown. + * libratbag will still provide information about the structure of + * the device such as the number of buttons and resolutions. + * Clients that encounter a device without this resolution are + * encouraged to upload a configuration stored on-disk to the + * device to reset the device to a known state. + * + * Any changes uploaded to the device will be cached in libratbag, + * once a client has sent a full configuration to the device + * libratbag can be used to query the device as normal. + */ + RATBAG_DEVICE_CAP_QUERY_CONFIGURATION, }; /**