From 2b878fd06a680db6fdbef768592fcc0a01ca53a2 Mon Sep 17 00:00:00 2001 From: Yaroslav Chvanov Date: Mon, 25 Sep 2023 18:50:54 +0300 Subject: [PATCH] libratbag: drop everything related to simple key action modifiers Macros can be used for that instead, drivers can adapt them as needed. Simple key actions will stay here for now, but I plan to completely replace them with macros eventually. --- ratbagd/ratbagd-button.c | 8 ++------ src/libratbag.c | 14 ++------------ src/libratbag.h | 22 ++++------------------ tools/ratbagc.py.in | 4 ++-- tools/shared.c | 4 +--- 5 files changed, 11 insertions(+), 41 deletions(-) diff --git a/ratbagd/ratbagd-button.c b/ratbagd/ratbagd-button.c index 9de602ec..a200fa77 100644 --- a/ratbagd/ratbagd-button.c +++ b/ratbagd/ratbagd-button.c @@ -159,9 +159,7 @@ static int ratbagd_button_get_key(sd_bus *bus, { struct ratbagd_button *button = userdata; - unsigned int *modifiers = NULL; - size_t *sz = 0; - const unsigned int key = ratbag_button_get_key(button->lib_button, modifiers, sz); + const unsigned int key = ratbag_button_get_key(button->lib_button); verify_unsigned_int(key); @@ -187,9 +185,7 @@ static int ratbagd_button_set_key(sd_bus *bus, CHECK_CALL(sd_bus_message_read(m, "v", "u", &key)); - unsigned int *modifiers = NULL; - size_t sz = 0; - r = ratbag_button_set_key(button->lib_button, key, modifiers, sz); + r = ratbag_button_set_key(button->lib_button, key); if (r == 0) { sd_bus_emit_properties_changed(bus, diff --git a/src/libratbag.c b/src/libratbag.c index 07df67db..fef0b5d4 100644 --- a/src/libratbag.c +++ b/src/libratbag.c @@ -1380,24 +1380,16 @@ ratbag_button_set_special(struct ratbag_button *button, } LIBRATBAG_EXPORT unsigned int -ratbag_button_get_key(const struct ratbag_button *button, - unsigned int *modifiers, - size_t *sz) +ratbag_button_get_key(const struct ratbag_button *button) { if (button->action.type != RATBAG_BUTTON_ACTION_TYPE_KEY) return 0; - /* FIXME: modifiers */ - if (sz != NULL) - *sz = 0; return button->action.action.key.key; } LIBRATBAG_EXPORT enum ratbag_error_code -ratbag_button_set_key(struct ratbag_button *button, - unsigned int key, - unsigned int *modifiers, - size_t sz) +ratbag_button_set_key(struct ratbag_button *button, unsigned int key) { struct ratbag_button_action action = {0}; @@ -1407,8 +1399,6 @@ ratbag_button_set_key(struct ratbag_button *button, RATBAG_BUTTON_ACTION_TYPE_KEY)) return RATBAG_ERROR_CAPABILITY; - /* FIXME: modifiers */ - action.type = RATBAG_BUTTON_ACTION_TYPE_KEY; action.action.key.key = key; diff --git a/src/libratbag.h b/src/libratbag.h index 74fd44a1..2119a2a1 100644 --- a/src/libratbag.h +++ b/src/libratbag.h @@ -1514,41 +1514,27 @@ ratbag_button_set_special(struct ratbag_button *button, * this function returns 0 and leaves modifiers and sz untouched. * * @param button A previously initialized ratbag button - * @param[out] modifiers Will be filled with the modifiers required for this - * action. The modifiers are as defined in linux/input-event-codes.h. - * @param[in,out] sz Takes the size of the modifiers array and returns the - * number of modifiers filled in. sz may be 0 if no modifiers are required. * * @note The caller must ensure that modifiers is large enough to accommodate * for the key combination. * - * @return The button number + * @return The key code as defined in linux/input-event-codes.h. */ unsigned int -ratbag_button_get_key(const struct ratbag_button *button, - unsigned int *modifiers, - size_t *sz); +ratbag_button_get_key(const struct ratbag_button *button); /** * @ingroup button * * @param button A previously initialized ratbag button - * @param key The button number to assign to this button, one of BTN_* as + * @param key The key number to assign to this button, one of KEY_* as * defined in linux/input-event-codes.h - * @param modifiers The modifiers required for this action. The - * modifiers are as defined in linux/input-event-codes.h, in the order they - * should be pressed. - * @param sz The size of the modifiers array. sz may be 0 if no modifiers - * are required. * * @return 0 on success or an error code otherwise. On success, the button's * action is set to @ref RATBAG_BUTTON_ACTION_TYPE_KEY. */ enum ratbag_error_code -ratbag_button_set_key(struct ratbag_button *button, - unsigned int key, - unsigned int *modifiers, - size_t sz); +ratbag_button_set_key(struct ratbag_button *button, unsigned int key); /** * @ingroup button diff --git a/tools/ratbagc.py.in b/tools/ratbagc.py.in index a91939f9..7052a15b 100644 --- a/tools/ratbagc.py.in +++ b/tools/ratbagc.py.in @@ -741,11 +741,11 @@ class RatbagdButton(metaclass=MetaRatbag): @property def key(self): - return libratbag.ratbag_button_get_key(self._button, None, None) + return libratbag.ratbag_button_get_key(self._button) @key.setter def key(self, key): - libratbag.ratbag_button_set_key(self._button, key, None, 0) + libratbag.ratbag_button_set_key(self._button, key) @property def action_type(self): diff --git a/tools/shared.c b/tools/shared.c index 72a3f423..8577e95a 100644 --- a/tools/shared.c +++ b/tools/shared.c @@ -143,10 +143,8 @@ char * button_action_key_to_str(struct ratbag_button *button) { const char *str; - unsigned int modifiers[10]; - size_t m_size = 10; - str = libevdev_event_code_get_name(EV_KEY, ratbag_button_get_key(button, modifiers, &m_size)); + str = libevdev_event_code_get_name(EV_KEY, ratbag_button_get_key(button)); if (!str) str = "UNKNOWN";