Namespace the device capabilities better

Fixes #224

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Peter Hutterer
2019-02-18 14:56:45 +10:00
parent 561f0ac866
commit 8ae35fa11b
13 changed files with 35 additions and 35 deletions

View File

@@ -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,

View File

@@ -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)

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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)

View File

@@ -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

View File

@@ -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);

View File

@@ -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

View File

@@ -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

View File

@@ -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]

View File

@@ -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