From 8ae35fa11b779bca4001d23e5350590381da4430 Mon Sep 17 00:00:00 2001 From: Peter Hutterer Date: Mon, 18 Feb 2019 14:56:45 +1000 Subject: [PATCH] Namespace the device capabilities better Fixes #224 Signed-off-by: Peter Hutterer --- ratbagd/ratbagd-device.c | 8 ++++---- src/driver-gskill.c | 2 +- src/driver-hidpp10.c | 6 +++--- src/driver-hidpp20.c | 4 ++-- src/driver-logitech-g300.c | 4 ++-- src/driver-logitech-g600.c | 4 ++-- src/driver-test.c | 2 +- src/libratbag-enums.h | 8 ++++---- src/libratbag.c | 8 ++++---- src/libratbag.h | 6 +++--- tools/ratbagc.py.in | 2 +- tools/ratbagctl.in | 8 ++++---- tools/ratbagd.py | 8 ++++---- 13 files changed, 35 insertions(+), 35 deletions(-) diff --git a/ratbagd/ratbagd-device.c b/ratbagd/ratbagd-device.c index 9c77335e..c33109b5 100644 --- a/ratbagd/ratbagd-device.c +++ b/ratbagd/ratbagd-device.c @@ -247,11 +247,11 @@ ratbagd_device_get_capabilities(sd_bus *bus, enum ratbag_device_capability caps[] = { RATBAG_DEVICE_CAP_QUERY_CONFIGURATION, RATBAG_DEVICE_CAP_RESOLUTION, - RATBAG_DEVICE_CAP_SWITCHABLE_RESOLUTION, + RATBAG_DEVICE_CAP_RESOLUTION_SWITCHABLE, RATBAG_DEVICE_CAP_PROFILE, - RATBAG_DEVICE_CAP_SWITCHABLE_PROFILE, - RATBAG_DEVICE_CAP_DISABLE_PROFILE, - RATBAG_DEVICE_CAP_DEFAULT_PROFILE, + RATBAG_DEVICE_CAP_PROFILE_SWITCHABLE, + RATBAG_DEVICE_CAP_PROFILE_DISABLE, + RATBAG_DEVICE_CAP_PROFILE_DEFAULT, RATBAG_DEVICE_CAP_BUTTON, RATBAG_DEVICE_CAP_BUTTON_KEY, RATBAG_DEVICE_CAP_BUTTON_MACROS, diff --git a/src/driver-gskill.c b/src/driver-gskill.c index 3f2d0189..f4b15c4d 100644 --- a/src/driver-gskill.c +++ b/src/driver-gskill.c @@ -1410,7 +1410,7 @@ gskill_probe(struct ratbag_device *device) ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON); ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_KEY); ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_MACROS); - ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_DISABLE_PROFILE); + ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_PROFILE_DISABLE); ret = gskill_get_active_profile_idx(device); if (ret < 0) diff --git a/src/driver-hidpp10.c b/src/driver-hidpp10.c index 992f8487..694e7c7b 100644 --- a/src/driver-hidpp10.c +++ b/src/driver-hidpp10.c @@ -424,7 +424,7 @@ hidpp10drv_read_profile(struct ratbag_profile *profile) xres = 0xffff; ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_RESOLUTION); - ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_SWITCHABLE_RESOLUTION); + ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_RESOLUTION_SWITCHABLE); ratbag_profile_for_each_resolution(profile, res) { unsigned int dpis[hidpp10->dpi_count]; @@ -503,8 +503,8 @@ hidpp10drv_fill_from_profile(struct ratbag_device *device, struct hidpp10_device if (dev->profile_type != HIDPP10_PROFILE_UNKNOWN) { ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_PROFILE); - ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_SWITCHABLE_PROFILE); - ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_DISABLE_PROFILE); + ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_PROFILE_SWITCHABLE); + ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_PROFILE_DISABLE); ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON); ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_KEY); ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_MACROS); diff --git a/src/driver-hidpp20.c b/src/driver-hidpp20.c index d350163e..4bf99f29 100644 --- a/src/driver-hidpp20.c +++ b/src/driver-hidpp20.c @@ -1096,7 +1096,7 @@ hidpp20drv_init_feature(struct ratbag_device *device, uint16_t feature) if (rc < 0) return 0; /* this is not a hard failure */ ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_RESOLUTION); - ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_SWITCHABLE_RESOLUTION); + ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_RESOLUTION_SWITCHABLE); drv_data->capabilities |= HIDPP_CAP_SWITCHABLE_RESOLUTION_2201; break; } @@ -1178,7 +1178,7 @@ hidpp20drv_init_feature(struct ratbag_device *device, uint16_t feature) log_debug(ratbag, "device has onboard profiles\n"); drv_data->capabilities |= HIDPP_CAP_ONBOARD_PROFILES_8100; ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_PROFILE); - ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_DISABLE_PROFILE); + ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_PROFILE_DISABLE); ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON); ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_KEY); ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_MACROS); diff --git a/src/driver-logitech-g300.c b/src/driver-logitech-g300.c index e8590c0f..c012d89c 100644 --- a/src/driver-logitech-g300.c +++ b/src/driver-logitech-g300.c @@ -499,9 +499,9 @@ logitech_g300_probe(struct ratbag_device *device) logitech_g300_read_profile(profile); ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_RESOLUTION); - ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_SWITCHABLE_RESOLUTION); + ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_RESOLUTION_SWITCHABLE); ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_PROFILE); - ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_SWITCHABLE_PROFILE); + ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_PROFILE_SWITCHABLE); ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON); ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_KEY); ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_MACROS); diff --git a/src/driver-logitech-g600.c b/src/driver-logitech-g600.c index 160edbcf..1eb023fc 100644 --- a/src/driver-logitech-g600.c +++ b/src/driver-logitech-g600.c @@ -496,9 +496,9 @@ logitech_g600_probe(struct ratbag_device *device) logitech_g600_read_profile(profile); ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_RESOLUTION); - ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_SWITCHABLE_RESOLUTION); + ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_RESOLUTION_SWITCHABLE); ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_PROFILE); - ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_SWITCHABLE_PROFILE); + ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_PROFILE_SWITCHABLE); ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON); ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_KEY); ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_MACROS); diff --git a/src/driver-test.c b/src/driver-test.c index 31d7c606..caf05e73 100644 --- a/src/driver-test.c +++ b/src/driver-test.c @@ -271,7 +271,7 @@ test_probe(struct ratbag_device *device, const void *data) if (test_device->num_profiles > 1) { ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_MACROS); - ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_DISABLE_PROFILE); + ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_PROFILE_DISABLE); } ratbag_device_for_each_profile(device, profile) diff --git a/src/libratbag-enums.h b/src/libratbag-enums.h index 29e88bf7..5c6aed9e 100644 --- a/src/libratbag-enums.h +++ b/src/libratbag-enums.h @@ -112,7 +112,7 @@ enum ratbag_device_capability { * query that, even if we can't switch it ourselves? Maybe better to * have a separate cap for that then. */ - RATBAG_DEVICE_CAP_SWITCHABLE_RESOLUTION, + RATBAG_DEVICE_CAP_RESOLUTION_SWITCHABLE, /** * The device provides read and/or write access to one or more @@ -127,7 +127,7 @@ enum ratbag_device_capability { * possibly with a button. * Devices without this capability will only have a single profile. */ - RATBAG_DEVICE_CAP_SWITCHABLE_PROFILE, + RATBAG_DEVICE_CAP_PROFILE_SWITCHABLE, /** * The device has the capability to disable and enable profiles. While @@ -136,7 +136,7 @@ enum ratbag_device_capability { * next time ratbag runs. Furthermore, the order of profiles may get * changed the next time ratbag runs if profiles are disabled. */ - RATBAG_DEVICE_CAP_DISABLE_PROFILE, + RATBAG_DEVICE_CAP_PROFILE_DISABLE, /** * The device can have one profile assigned as a default profile. @@ -144,7 +144,7 @@ enum ratbag_device_capability { * is plugged in. Devices without this capability may select the * last-used profile or a specific profile (usually the first). */ - RATBAG_DEVICE_CAP_DEFAULT_PROFILE, + RATBAG_DEVICE_CAP_PROFILE_DEFAULT, /** * The device provides read and/or write access to one or more diff --git a/src/libratbag.c b/src/libratbag.c index a59a323b..6dd3461f 100644 --- a/src/libratbag.c +++ b/src/libratbag.c @@ -720,7 +720,7 @@ ratbag_device_init_profiles(struct ratbag_device *device, if (num_profiles > 1) { ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_PROFILE); - ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_SWITCHABLE_PROFILE); + ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_PROFILE_SWITCHABLE); /* having more than one profile means we can remap the buttons * at least */ @@ -730,7 +730,7 @@ ratbag_device_init_profiles(struct ratbag_device *device, if (num_resolutions > 1) { ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_RESOLUTION); - ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_SWITCHABLE_RESOLUTION); + ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_RESOLUTION_SWITCHABLE); } if (num_leds > 0) @@ -812,7 +812,7 @@ LIBRATBAG_EXPORT enum ratbag_error_code ratbag_profile_set_enabled(struct ratbag_profile *profile, bool enabled) { if (!ratbag_device_has_capability(profile->device, - RATBAG_DEVICE_CAP_DISABLE_PROFILE)) + RATBAG_DEVICE_CAP_PROFILE_DISABLE)) return RATBAG_ERROR_CAPABILITY; profile->is_enabled = enabled; @@ -1004,7 +1004,7 @@ ratbag_profile_set_active(struct ratbag_profile *profile) struct ratbag_profile *p; int rc; - if (!ratbag_device_has_capability(device, RATBAG_DEVICE_CAP_SWITCHABLE_PROFILE)) + if (!ratbag_device_has_capability(device, RATBAG_DEVICE_CAP_PROFILE_SWITCHABLE)) return RATBAG_ERROR_CAPABILITY; assert(device->driver->set_active_profile); diff --git a/src/libratbag.h b/src/libratbag.h index bd216d02..fc560149 100644 --- a/src/libratbag.h +++ b/src/libratbag.h @@ -96,7 +96,7 @@ struct ratbag_device; * @struct ratbag_profile * * A handle to a profile context on devices with the @ref - * RATBAG_DEVICE_CAP_SWITCHABLE_PROFILE capability. + * RATBAG_DEVICE_CAP_PROFILE_SWITCHABLE capability. * This struct is refcounted, use ratbag_profile_ref() and * ratbag_profile_unref(). */ @@ -573,7 +573,7 @@ ratbag_profile_set_name(struct ratbag_profile *profile, * @ingroup profile * * Enable/disable the ratbag profile. For this to work, the device must support - * @ref RATBAG_DEVICE_CAP_DISABLE_PROFILE. + * @ref RATBAG_DEVICE_CAP_PROFILE_DISABLE. * * @param profile A previously initialized ratbag profile * @param enabled Whether to enable or disable the profile @@ -587,7 +587,7 @@ ratbag_profile_set_enabled(struct ratbag_profile *profile, bool enabled); * @ingroup profile * * Check whether the ratbag profile is enabled or not. For devices that don't - * support @ref RATBAG_DEVICE_CAP_DISABLE_PROFILE the profile will always be + * support @ref RATBAG_DEVICE_CAP_PROFILE_DISABLE the profile will always be * set to enabled. * * @param profile A previously initialized ratbag profile diff --git a/tools/ratbagc.py.in b/tools/ratbagc.py.in index 8355eab5..6d65865c 100644 --- a/tools/ratbagc.py.in +++ b/tools/ratbagc.py.in @@ -256,7 +256,7 @@ class RatbagdDevice(metaclass=MetaRatbag): """The capabilities of this device as an array. Capabilities not present on the device are not in the list. Thus use e.g. - if RatbagdDevice.CAP_SWITCHABLE_RESOLUTION is in device.capabilities: + if RatbagdDevice.CAP_RESOLUTION_SWITCHABLE is in device.capabilities: do something """ return self._capabilities diff --git a/tools/ratbagctl.in b/tools/ratbagctl.in index d9184f02..85981e29 100755 --- a/tools/ratbagctl.in +++ b/tools/ratbagctl.in @@ -258,13 +258,13 @@ def print_device(d, level): caps = {RatbagdDevice.CAP_RESOLUTION: "resolution", RatbagdDevice.CAP_PROFILE: "profile", RatbagdDevice.CAP_BUTTON: "button", - RatbagdDevice.CAP_SWITCHABLE_RESOLUTION: "switchable-resolution", - RatbagdDevice.CAP_SWITCHABLE_PROFILE: "switchable-profile", + RatbagdDevice.CAP_RESOLUTION_SWITCHABLE: "switchable-resolution", + RatbagdDevice.CAP_PROFILE_SWITCHABLE: "switchable-profile", RatbagdDevice.CAP_BUTTON_KEY: "button-keys", RatbagdDevice.CAP_BUTTON_MACROS: "button-macros", - RatbagdDevice.CAP_DEFAULT_PROFILE: "default-profile", + RatbagdDevice.CAP_PROFILE_DEFAULT: "default-profile", RatbagdDevice.CAP_QUERY_CONFIGURATION: "query-configuration", - RatbagdDevice.CAP_DISABLE_PROFILE: "disable-profile", + RatbagdDevice.CAP_PROFILE_DISABLE: "disable-profile", RatbagdDevice.CAP_LED: "led"} capabilities = [caps[c] for c in d.capabilities] diff --git a/tools/ratbagd.py b/tools/ratbagd.py index 520bede4..67047d41 100644 --- a/tools/ratbagd.py +++ b/tools/ratbagd.py @@ -320,11 +320,11 @@ class RatbagdDevice(_RatbagdDBus): CAP_NONE = 0 CAP_QUERY_CONFIGURATION = 1 CAP_RESOLUTION = 100 - CAP_SWITCHABLE_RESOLUTION = 101 + CAP_RESOLUTION_SWITCHABLE = 101 CAP_PROFILE = 200 - CAP_SWITCHABLE_PROFILE = 201 - CAP_DISABLE_PROFILE = 202 - CAP_DEFAULT_PROFILE = 203 + CAP_PROFILE_SWITCHABLE = 201 + CAP_PROFILE_DISABLE = 202 + CAP_PROFILE_DEFAULT = 203 CAP_BUTTON = 300 CAP_BUTTON_KEY = 301 CAP_BUTTON_MACROS = 302