mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 15:14:38 +01:00
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.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -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";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user