diff --git a/ratbagd/ratbagd-device.c b/ratbagd/ratbagd-device.c index bf7fb411..194f2a16 100644 --- a/ratbagd/ratbagd-device.c +++ b/ratbagd/ratbagd-device.c @@ -250,7 +250,6 @@ ratbagd_device_get_capabilities(sd_bus *bus, RATBAG_DEVICE_CAP_RESOLUTION_SWITCHABLE, RATBAG_DEVICE_CAP_PROFILE, RATBAG_DEVICE_CAP_PROFILE_SWITCHABLE, - RATBAG_DEVICE_CAP_PROFILE_DISABLE, RATBAG_DEVICE_CAP_BUTTON, RATBAG_DEVICE_CAP_BUTTON_KEY, RATBAG_DEVICE_CAP_BUTTON_MACROS, diff --git a/ratbagd/ratbagd-profile.c b/ratbagd/ratbagd-profile.c index b3644738..b9d4eab3 100644 --- a/ratbagd/ratbagd-profile.c +++ b/ratbagd/ratbagd-profile.c @@ -410,6 +410,7 @@ ratbagd_profile_get_capabilities(sd_bus *bus, enum ratbag_profile_capability caps[] = { RATBAG_PROFILE_CAP_WRITABLE_NAME, RATBAG_PROFILE_CAP_SET_DEFAULT, + RATBAG_PROFILE_CAP_DISABLE, }; size_t i; diff --git a/src/driver-gskill.c b/src/driver-gskill.c index f4b15c4d..e198a485 100644 --- a/src/driver-gskill.c +++ b/src/driver-gskill.c @@ -1410,7 +1410,6 @@ 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_PROFILE_DISABLE); ret = gskill_get_active_profile_idx(device); if (ret < 0) @@ -1425,6 +1424,8 @@ gskill_probe(struct ratbag_device *device) ratbag_profile_for_each_button(profile, button) gskill_read_button(button); + ratbag_profile_set_cap(profile, RATBAG_PROFILE_CAP_DISABLE); + if (profile->index == active_idx) profile->is_active = true; } diff --git a/src/driver-hidpp10.c b/src/driver-hidpp10.c index 694e7c7b..be71e799 100644 --- a/src/driver-hidpp10.c +++ b/src/driver-hidpp10.c @@ -408,6 +408,8 @@ hidpp10drv_read_profile(struct ratbag_profile *profile) return; ratbag_profile_set_cap(profile, RATBAG_PROFILE_CAP_WRITABLE_NAME); + if (hidpp10->profile_type != HIDPP10_PROFILE_UNKNOWN) + ratbag_profile_set_cap(profile, RATBAG_PROFILE_CAP_DISABLE); profile->is_enabled = p.enabled; @@ -504,7 +506,6 @@ 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_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 4bf99f29..c19c79f5 100644 --- a/src/driver-hidpp20.c +++ b/src/driver-hidpp20.c @@ -1048,6 +1048,7 @@ hidpp20drv_read_profile(struct ratbag_profile *profile) if (drv_data->capabilities & HIDPP_CAP_ONBOARD_PROFILES_8100) { hidpp20drv_read_profile_8100(profile); + ratbag_profile_set_cap(profile, RATBAG_PROFILE_CAP_DISABLE); } else { hidpp20drv_read_resolution_dpi(profile); hidpp20drv_read_special_key_mouse(device); @@ -1178,7 +1179,6 @@ 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_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-test.c b/src/driver-test.c index caf05e73..84f8db9d 100644 --- a/src/driver-test.c +++ b/src/driver-test.c @@ -269,10 +269,8 @@ test_probe(struct ratbag_device *device, const void *data) test_device->num_buttons, test_device->num_leds); - if (test_device->num_profiles > 1) { + if (test_device->num_profiles > 1) ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_MACROS); - ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_PROFILE_DISABLE); - } ratbag_device_for_each_profile(device, profile) test_read_profile(profile); diff --git a/src/libratbag-enums.h b/src/libratbag-enums.h index 33757980..cad4f6cd 100644 --- a/src/libratbag-enums.h +++ b/src/libratbag-enums.h @@ -129,16 +129,6 @@ enum ratbag_device_capability { */ RATBAG_DEVICE_CAP_PROFILE_SWITCHABLE, - /** - * The device has the capability to disable and enable profiles. While - * profiles are not immediately deleted after being disabled, it is not - * guaranteed that the device will remember any disabled profiles the - * next time ratbag runs. Furthermore, the order of profiles may get - * changed the next time ratbag runs if profiles are disabled. - */ - RATBAG_DEVICE_CAP_PROFILE_DISABLE, - - /** * The device provides read and/or write access to one or more * buttons. @@ -185,6 +175,21 @@ enum ratbag_profile_capability { * profile (usually the first). */ RATBAG_PROFILE_CAP_SET_DEFAULT, + + /** + * The profile can be disabled and enabled. Profiles are not + * immediately deleted after being disabled, it is not guaranteed + * that the device will remember any disabled profiles the next time + * ratbag runs. Furthermore, the order of profiles may get changed + * the next time ratbag runs if profiles are disabled. + * + * Note that this capability only notes the general capability. A + * specific profile may still fail to be disabled, e.g. when it is + * the last enabled profile on the device. + */ + RATBAG_PROFILE_CAP_DISABLE, + + }; /** diff --git a/src/libratbag.c b/src/libratbag.c index 6dd3461f..6709bda2 100644 --- a/src/libratbag.c +++ b/src/libratbag.c @@ -811,8 +811,7 @@ ratbag_device_get_profile(struct ratbag_device *device, unsigned int index) 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_PROFILE_DISABLE)) + if (!ratbag_profile_has_capability(profile, RATBAG_PROFILE_CAP_DISABLE)) return RATBAG_ERROR_CAPABILITY; profile->is_enabled = enabled; diff --git a/src/libratbag.h b/src/libratbag.h index fc560149..f4395938 100644 --- a/src/libratbag.h +++ b/src/libratbag.h @@ -572,8 +572,8 @@ 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_PROFILE_DISABLE. + * Enable/disable the ratbag profile. For this to work, the profile must support + * @ref RATBAG_PROFILE_CAP_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_PROFILE_DISABLE the profile will always be + * support @ref RATBAG_PROFILE_CAP_DISABLE the profile will always be * set to enabled. * * @param profile A previously initialized ratbag profile diff --git a/tools/ratbagctl.in b/tools/ratbagctl.in index 739535c8..38f6a112 100755 --- a/tools/ratbagctl.in +++ b/tools/ratbagctl.in @@ -263,7 +263,6 @@ def print_device(d, level): RatbagdDevice.CAP_BUTTON_KEY: "button-keys", RatbagdDevice.CAP_BUTTON_MACROS: "button-macros", RatbagdDevice.CAP_QUERY_CONFIGURATION: "query-configuration", - 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 acea5e28..b64a59b9 100644 --- a/tools/ratbagd.py +++ b/tools/ratbagd.py @@ -323,7 +323,6 @@ class RatbagdDevice(_RatbagdDBus): CAP_RESOLUTION_SWITCHABLE = 101 CAP_PROFILE = 200 CAP_PROFILE_SWITCHABLE = 201 - CAP_PROFILE_DISABLE = 202 CAP_BUTTON = 300 CAP_BUTTON_KEY = 301 CAP_BUTTON_MACROS = 302 @@ -424,6 +423,7 @@ class RatbagdProfile(_RatbagdDBus): CAP_WRITABLE_NAME = 100 CAP_SET_DEFAULT = 101 + CAP_DISABLE = 102 def __init__(self, object_path): _RatbagdDBus.__init__(self, "Profile", object_path)