mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-26 16:50:06 +01:00
Add an enum for configuration return codes
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Jonas Ådahl <jadahl@gmail.com>
This commit is contained in:
parent
5cecefeea0
commit
4b88bf30d4
3 changed files with 77 additions and 0 deletions
|
|
@ -1255,3 +1255,23 @@ libinput_event_touch_get_base_event(struct libinput_event_touch *event)
|
|||
{
|
||||
return &event->base;
|
||||
}
|
||||
|
||||
LIBINPUT_EXPORT const char *
|
||||
libinput_config_status_to_str(enum libinput_config_status status)
|
||||
{
|
||||
const char *str = NULL;
|
||||
|
||||
switch(status) {
|
||||
case LIBINPUT_CONFIG_STATUS_SUCCESS:
|
||||
str = "Success";
|
||||
break;
|
||||
case LIBINPUT_CONFIG_STATUS_UNSUPPORTED:
|
||||
str = "Unsupported configuration option";
|
||||
break;
|
||||
case LIBINPUT_CONFIG_STATUS_INVALID:
|
||||
str = "Invalid argument range";
|
||||
break;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1402,6 +1402,40 @@ libinput_device_get_size(struct libinput_device *device,
|
|||
double *width,
|
||||
double *height);
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup config Device configuration
|
||||
*
|
||||
* Enable, disable, change and/or check for device-specific features. For
|
||||
* all features, libinput assigns a default based on the hardware
|
||||
* configuration. This default can be obtained with the respective
|
||||
* get_default call.
|
||||
*
|
||||
* Some configuration option may be dependent on or mutually exclusive with
|
||||
* with other options. The behavior in those cases is
|
||||
* implementation-defined, the caller must ensure that the options are set
|
||||
* in the right order.
|
||||
*/
|
||||
|
||||
enum libinput_config_status {
|
||||
LIBINPUT_CONFIG_STATUS_SUCCESS = 0, /**< Config applied successfully */
|
||||
LIBINPUT_CONFIG_STATUS_UNSUPPORTED, /**< Configuration not available on
|
||||
this device */
|
||||
LIBINPUT_CONFIG_STATUS_INVALID, /**< Invalid parameter range */
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup config Device configuration
|
||||
*
|
||||
* Return a string describing the error.
|
||||
*
|
||||
* @param status The status to translate to a string
|
||||
* @return A human-readable string representing the error or NULL for an
|
||||
* invalid status.
|
||||
*/
|
||||
const char *
|
||||
libinput_config_status_to_str(enum libinput_config_status status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
23
test/misc.c
23
test/misc.c
|
|
@ -26,6 +26,7 @@
|
|||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <libinput.h>
|
||||
#include <libinput-util.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "litest.h"
|
||||
|
|
@ -409,6 +410,27 @@ START_TEST(device_ids)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(config_status_string)
|
||||
{
|
||||
const char *strs[3];
|
||||
const char *invalid;
|
||||
size_t i, j;
|
||||
|
||||
strs[0] = libinput_config_status_to_str(LIBINPUT_CONFIG_STATUS_SUCCESS);
|
||||
strs[1] = libinput_config_status_to_str(LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
|
||||
strs[2] = libinput_config_status_to_str(LIBINPUT_CONFIG_STATUS_INVALID);
|
||||
|
||||
for (i = 0; i < ARRAY_LENGTH(strs) - 1; i++)
|
||||
for (j = i + 1; j < ARRAY_LENGTH(strs); j++)
|
||||
ck_assert_str_ne(strs[i], strs[j]);
|
||||
|
||||
invalid = libinput_config_status_to_str(LIBINPUT_CONFIG_STATUS_INVALID + 1);
|
||||
ck_assert(invalid == NULL);
|
||||
invalid = libinput_config_status_to_str(LIBINPUT_CONFIG_STATUS_SUCCESS - 1);
|
||||
ck_assert(invalid == NULL);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
litest_add_no_device("events:conversion", event_conversion_device_notify);
|
||||
litest_add_no_device("events:conversion", event_conversion_pointer);
|
||||
|
|
@ -417,6 +439,7 @@ int main (int argc, char **argv) {
|
|||
litest_add_no_device("events:conversion", event_conversion_touch);
|
||||
litest_add_no_device("context:refcount", context_ref_counting);
|
||||
litest_add("device:id", device_ids, LITEST_ANY, LITEST_ANY);
|
||||
litest_add_no_device("config:status string", config_status_string);
|
||||
|
||||
return litest_run(argc, argv);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue