mirror of
https://github.com/libratbag/libratbag.git
synced 2026-11-07 23:23:52 +01:00
Add a ratbag_button_set_type
This might not be part of the final API, but it is rather convenient to use right now. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
This commit is contained in:
@@ -609,6 +609,22 @@ ratbag_button_get_type(struct ratbag_button *button)
|
||||
return button->type;
|
||||
}
|
||||
|
||||
LIBRATBAG_EXPORT int
|
||||
ratbag_button_set_type(struct ratbag_button *button, enum ratbag_button_type type)
|
||||
{
|
||||
enum ratbag_button_type orig_type = button->type;
|
||||
int rc;
|
||||
|
||||
if (!button->device->driver->write_button)
|
||||
return -ENOTSUP;
|
||||
|
||||
button->type = type;
|
||||
rc = button->device->driver->write_button(button->device, button->profile, button);
|
||||
if (rc)
|
||||
button->type = orig_type;
|
||||
return rc;
|
||||
}
|
||||
|
||||
LIBRATBAG_EXPORT struct ratbag_button *
|
||||
ratbag_button_ref(struct ratbag_button *button)
|
||||
{
|
||||
|
||||
@@ -521,6 +521,21 @@ enum ratbag_button_type {
|
||||
enum ratbag_button_type
|
||||
ratbag_button_get_type(struct ratbag_button *button);
|
||||
|
||||
/**
|
||||
* @ingroup device
|
||||
*
|
||||
* Change the type of the physical button. This function is intended to be
|
||||
* used by configuration tools to configure devices.
|
||||
*
|
||||
* FIXME: if we do this with linux/input.h instead, we need to add things like
|
||||
* BTN_RESOLUTION_UP/DOWN there. But this is supposed to describe the
|
||||
* physical location of the button, so input.h is not a good match.
|
||||
*
|
||||
* @return The error code or 0 on success.
|
||||
*/
|
||||
int
|
||||
ratbag_button_set_type(struct ratbag_button *button, enum ratbag_button_type type);
|
||||
|
||||
/**
|
||||
* @ingroup device
|
||||
*
|
||||
|
||||
@@ -5,6 +5,7 @@ global:
|
||||
ratbag_create_context;
|
||||
ratbag_button_ref;
|
||||
ratbag_button_get_type;
|
||||
ratbag_button_set_type;
|
||||
ratbag_button_unref;
|
||||
ratbag_device_unref;
|
||||
ratbag_device_get_active_profile;
|
||||
|
||||
Reference in New Issue
Block a user