mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 23:23:52 +01:00
Drop the button key/macro device capability
The same information is supposed to be available in the button's action types Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
@@ -249,8 +249,6 @@ ratbagd_device_get_capabilities(sd_bus *bus,
|
||||
RATBAG_DEVICE_CAP_RESOLUTION,
|
||||
RATBAG_DEVICE_CAP_PROFILE,
|
||||
RATBAG_DEVICE_CAP_BUTTON,
|
||||
RATBAG_DEVICE_CAP_BUTTON_KEY,
|
||||
RATBAG_DEVICE_CAP_BUTTON_MACROS,
|
||||
RATBAG_DEVICE_CAP_LED,
|
||||
};
|
||||
size_t i;
|
||||
|
||||
@@ -669,7 +669,6 @@ etekcity_probe(struct ratbag_device *device)
|
||||
etekcity_read_profile(profile);
|
||||
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON);
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_MACROS);
|
||||
|
||||
active_idx = etekcity_current_profile(device);
|
||||
if (active_idx < 0) {
|
||||
|
||||
@@ -1408,8 +1408,6 @@ gskill_probe(struct ratbag_device *device)
|
||||
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_QUERY_CONFIGURATION);
|
||||
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);
|
||||
|
||||
ret = gskill_get_active_profile_idx(device);
|
||||
if (ret < 0)
|
||||
|
||||
@@ -505,8 +505,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_BUTTON);
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_KEY);
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_MACROS);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -1104,7 +1104,6 @@ hidpp20drv_init_feature(struct ratbag_device *device, uint16_t feature)
|
||||
log_debug(ratbag, "device has programmable keys/buttons\n");
|
||||
drv_data->capabilities |= HIDPP_CAP_BUTTON_KEY_1b04;
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON);
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_KEY);
|
||||
/* we read the profile once to get the correct number of
|
||||
* supported buttons. */
|
||||
if (!hidpp20drv_read_special_key_mouse(device))
|
||||
@@ -1179,8 +1178,6 @@ hidpp20drv_init_feature(struct ratbag_device *device, uint16_t feature)
|
||||
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_BUTTON);
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_KEY);
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_MACROS);
|
||||
|
||||
rc = hidpp20_onboard_profiles_allocate(drv_data->dev, &drv_data->profiles);
|
||||
if (rc < 0)
|
||||
|
||||
@@ -501,8 +501,6 @@ logitech_g300_probe(struct ratbag_device *device)
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_RESOLUTION);
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_PROFILE);
|
||||
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);
|
||||
|
||||
active_idx = logitech_g300_get_active_profile_and_resolution(device);
|
||||
|
||||
|
||||
@@ -498,8 +498,6 @@ logitech_g600_probe(struct ratbag_device *device)
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_RESOLUTION);
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_PROFILE);
|
||||
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);
|
||||
|
||||
rc = logitech_g600_get_active_profile_and_resolution(device);
|
||||
|
||||
|
||||
@@ -806,7 +806,6 @@ roccat_probe(struct ratbag_device *device)
|
||||
roccat_read_profile(profile);
|
||||
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON);
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_MACROS);
|
||||
|
||||
active_idx = roccat_current_profile(device);
|
||||
if (active_idx < 0) {
|
||||
|
||||
@@ -304,10 +304,6 @@ steelseries_probe(struct ratbag_device *device)
|
||||
if (ratbag_device_data_steelseries_get_macro_length(device->data) > 0) {
|
||||
/* set these caps manually as they are not assumed with only 1 profile */
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON);
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_KEY);
|
||||
if (short_button == 0) {
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_MACROS);
|
||||
}
|
||||
}
|
||||
|
||||
ratbag_device_unset_capability(device, RATBAG_DEVICE_CAP_QUERY_CONFIGURATION);
|
||||
|
||||
@@ -269,9 +269,6 @@ test_probe(struct ratbag_device *device, const void *data)
|
||||
test_device->num_buttons,
|
||||
test_device->num_leds);
|
||||
|
||||
if (test_device->num_profiles > 1)
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_MACROS);
|
||||
|
||||
ratbag_device_for_each_profile(device, profile)
|
||||
test_read_profile(profile);
|
||||
|
||||
|
||||
@@ -116,17 +116,6 @@ enum ratbag_device_capability {
|
||||
*/
|
||||
RATBAG_DEVICE_CAP_BUTTON = 300,
|
||||
|
||||
/**
|
||||
* The device supports assigning button numbers, key events or key +
|
||||
* modifier combinations.
|
||||
*/
|
||||
RATBAG_DEVICE_CAP_BUTTON_KEY,
|
||||
|
||||
/**
|
||||
* The device supports user-defined key or button sequences.
|
||||
*/
|
||||
RATBAG_DEVICE_CAP_BUTTON_MACROS,
|
||||
|
||||
/**
|
||||
* The device supports assigning LED colors and effects
|
||||
*/
|
||||
|
||||
@@ -724,7 +724,6 @@ ratbag_device_init_profiles(struct ratbag_device *device,
|
||||
/* having more than one profile means we can remap the buttons
|
||||
* at least */
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON);
|
||||
ratbag_device_set_capability(device, RATBAG_DEVICE_CAP_BUTTON_KEY);
|
||||
}
|
||||
|
||||
if (num_resolutions > 1)
|
||||
@@ -1360,8 +1359,8 @@ ratbag_button_set_button(struct ratbag_button *button, unsigned int btn)
|
||||
{
|
||||
struct ratbag_button_action action = {0};
|
||||
|
||||
if (!ratbag_device_has_capability(button->profile->device,
|
||||
RATBAG_DEVICE_CAP_BUTTON_KEY))
|
||||
if (!ratbag_button_has_action_type(button,
|
||||
RATBAG_BUTTON_ACTION_TYPE_BUTTON))
|
||||
return RATBAG_ERROR_CAPABILITY;
|
||||
|
||||
action.type = RATBAG_BUTTON_ACTION_TYPE_BUTTON;
|
||||
@@ -1391,8 +1390,8 @@ ratbag_button_set_special(struct ratbag_button *button,
|
||||
|
||||
/* FIXME: range checks */
|
||||
|
||||
if (!ratbag_device_has_capability(button->profile->device,
|
||||
RATBAG_DEVICE_CAP_BUTTON_KEY))
|
||||
if (!ratbag_button_has_action_type(button,
|
||||
RATBAG_BUTTON_ACTION_TYPE_SPECIAL))
|
||||
return RATBAG_ERROR_CAPABILITY;
|
||||
|
||||
action.type = RATBAG_BUTTON_ACTION_TYPE_SPECIAL;
|
||||
@@ -1428,8 +1427,8 @@ ratbag_button_set_key(struct ratbag_button *button,
|
||||
|
||||
/* FIXME: range checks */
|
||||
|
||||
if (!ratbag_device_has_capability(button->profile->device,
|
||||
RATBAG_DEVICE_CAP_BUTTON_KEY))
|
||||
if (!ratbag_button_has_action_type(button,
|
||||
RATBAG_BUTTON_ACTION_TYPE_KEY))
|
||||
return RATBAG_ERROR_CAPABILITY;
|
||||
|
||||
/* FIXME: modifiers */
|
||||
@@ -1449,8 +1448,8 @@ ratbag_button_disable(struct ratbag_button *button)
|
||||
{
|
||||
struct ratbag_button_action action = {0};
|
||||
|
||||
if (!ratbag_device_has_capability(button->profile->device,
|
||||
RATBAG_DEVICE_CAP_BUTTON_KEY))
|
||||
if (!ratbag_button_has_action_type(button,
|
||||
RATBAG_BUTTON_ACTION_TYPE_KEY))
|
||||
return RATBAG_ERROR_CAPABILITY;
|
||||
|
||||
action.type = RATBAG_BUTTON_ACTION_TYPE_NONE;
|
||||
@@ -1790,8 +1789,8 @@ LIBRATBAG_EXPORT enum ratbag_error_code
|
||||
ratbag_button_set_macro(struct ratbag_button *button,
|
||||
const struct ratbag_button_macro *macro)
|
||||
{
|
||||
if (!ratbag_device_has_capability(button->profile->device,
|
||||
RATBAG_DEVICE_CAP_BUTTON_MACROS))
|
||||
if (!ratbag_button_has_action_type(button,
|
||||
RATBAG_BUTTON_ACTION_TYPE_MACRO))
|
||||
return RATBAG_ERROR_CAPABILITY;
|
||||
|
||||
ratbag_button_copy_macro(button, macro);
|
||||
|
||||
@@ -258,8 +258,6 @@ def print_device(d, level):
|
||||
caps = {RatbagdDevice.CAP_RESOLUTION: "resolution",
|
||||
RatbagdDevice.CAP_PROFILE: "profile",
|
||||
RatbagdDevice.CAP_BUTTON: "button",
|
||||
RatbagdDevice.CAP_BUTTON_KEY: "button-keys",
|
||||
RatbagdDevice.CAP_BUTTON_MACROS: "button-macros",
|
||||
RatbagdDevice.CAP_QUERY_CONFIGURATION: "query-configuration",
|
||||
RatbagdDevice.CAP_LED: "led"}
|
||||
capabilities = [caps[c] for c in d.capabilities]
|
||||
@@ -397,7 +395,7 @@ def func_button_action_set_special(r, args):
|
||||
|
||||
def func_button_action_set_macro(r, args):
|
||||
b, p, d = find_button(r, args)
|
||||
if not d.CAP_BUTTON_MACROS in d.capabilities:
|
||||
if not b.ACTION_TYPE_MACRO in b.action_types:
|
||||
raise RatbagErrorCapability("assigning a macro is not supported on this device")
|
||||
|
||||
macro_keys = args.target_macro
|
||||
|
||||
@@ -322,8 +322,6 @@ class RatbagdDevice(_RatbagdDBus):
|
||||
CAP_RESOLUTION = 100
|
||||
CAP_PROFILE = 200
|
||||
CAP_BUTTON = 300
|
||||
CAP_BUTTON_KEY = 301
|
||||
CAP_BUTTON_MACROS = 302
|
||||
CAP_LED = 400
|
||||
|
||||
__gsignals__ = {
|
||||
|
||||
Reference in New Issue
Block a user