mirror of
https://gitlab.freedesktop.org/libinput/libei.git
synced 2026-05-04 18:58:03 +02:00
Export the event names through helper functions
Approximately every user of libei(s) will want something like this for easier debugging, converting the numeric event type into something that can be printed into the debug logs. Let's provide this here so this doesn't need to be duplicated.
This commit is contained in:
parent
ca06927371
commit
708aed6402
6 changed files with 21 additions and 41 deletions
|
|
@ -36,7 +36,7 @@ OBJECT_IMPLEMENT_GETTER(ei_event, device, struct ei_device*);
|
|||
_public_
|
||||
OBJECT_IMPLEMENT_GETTER(ei_event, seat, struct ei_seat*);
|
||||
|
||||
const char *
|
||||
_public_ const char *
|
||||
ei_event_type_to_string(enum ei_event_type type)
|
||||
{
|
||||
switch(type) {
|
||||
|
|
@ -65,7 +65,7 @@ ei_event_type_to_string(enum ei_event_type type)
|
|||
CASE_RETURN_STRING(EI_EVENT_TOUCH_MOTION);
|
||||
}
|
||||
|
||||
assert(!"Unhandled event type");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -82,6 +82,3 @@ ei_event_get_context(struct ei_event *event);
|
|||
|
||||
struct ei_event *
|
||||
ei_event_ref(struct ei_event *event);
|
||||
|
||||
const char *
|
||||
ei_event_type_to_string(enum ei_event_type type);
|
||||
|
|
|
|||
|
|
@ -520,6 +520,14 @@ enum ei_event_type {
|
|||
EI_EVENT_TOUCH_MOTION,
|
||||
};
|
||||
|
||||
/**
|
||||
* This is a debugging helper to return a string of the name of the event type,
|
||||
* or NULL if the event type is invalid. For example, for @ref EI_EVENT_TOUCH_UP this
|
||||
* function returns the string "EI_EVENT_TOUCH_UP".
|
||||
*/
|
||||
const char*
|
||||
ei_event_type_to_string(enum ei_event_type);
|
||||
|
||||
/**
|
||||
* This is an alias for @ref ei_new_sender.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ eis_dispatch(struct eis *eis)
|
|||
sink_dispatch(eis->sink);
|
||||
}
|
||||
|
||||
static const char *
|
||||
_public_ const char *
|
||||
eis_event_type_to_string(enum eis_event_type type)
|
||||
{
|
||||
switch(type) {
|
||||
|
|
@ -134,7 +134,7 @@ eis_event_type_to_string(enum eis_event_type type)
|
|||
CASE_RETURN_STRING(EIS_EVENT_FRAME);
|
||||
}
|
||||
|
||||
assert(!"Unhandled event type");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -348,6 +348,14 @@ enum eis_event_type {
|
|||
EIS_EVENT_TOUCH_MOTION,
|
||||
};
|
||||
|
||||
/**
|
||||
* This is a debugging helper to return a string of the name of the event type,
|
||||
* or NULL if the event type is invalid. For example, for @ref EIS_EVENT_TOUCH_UP this
|
||||
* function returns the string "EIS_EVENT_TOUCH_UP".
|
||||
*/
|
||||
const char*
|
||||
eis_event_type_to_string(enum eis_event_type);
|
||||
|
||||
/**
|
||||
* Create a new libeis context with a refcount of 1.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -81,38 +81,6 @@ usage(FILE *fp, const char *argv0)
|
|||
argv0);
|
||||
}
|
||||
|
||||
static const char *
|
||||
event_type(enum ei_event_type type)
|
||||
{
|
||||
switch(type) {
|
||||
CASE_RETURN_STRING(EI_EVENT_CONNECT);
|
||||
CASE_RETURN_STRING(EI_EVENT_DISCONNECT);
|
||||
CASE_RETURN_STRING(EI_EVENT_SEAT_ADDED);
|
||||
CASE_RETURN_STRING(EI_EVENT_SEAT_REMOVED);
|
||||
CASE_RETURN_STRING(EI_EVENT_DEVICE_ADDED);
|
||||
CASE_RETURN_STRING(EI_EVENT_DEVICE_REMOVED);
|
||||
CASE_RETURN_STRING(EI_EVENT_DEVICE_PAUSED);
|
||||
CASE_RETURN_STRING(EI_EVENT_DEVICE_RESUMED);
|
||||
CASE_RETURN_STRING(EI_EVENT_KEYBOARD_MODIFIERS);
|
||||
CASE_RETURN_STRING(EI_EVENT_FRAME);
|
||||
CASE_RETURN_STRING(EI_EVENT_DEVICE_START_EMULATING);
|
||||
CASE_RETURN_STRING(EI_EVENT_DEVICE_STOP_EMULATING);
|
||||
CASE_RETURN_STRING(EI_EVENT_POINTER_MOTION);
|
||||
CASE_RETURN_STRING(EI_EVENT_POINTER_MOTION_ABSOLUTE);
|
||||
CASE_RETURN_STRING(EI_EVENT_BUTTON_BUTTON);
|
||||
CASE_RETURN_STRING(EI_EVENT_SCROLL_DELTA);
|
||||
CASE_RETURN_STRING(EI_EVENT_SCROLL_STOP);
|
||||
CASE_RETURN_STRING(EI_EVENT_SCROLL_CANCEL);
|
||||
CASE_RETURN_STRING(EI_EVENT_SCROLL_DISCRETE);
|
||||
CASE_RETURN_STRING(EI_EVENT_KEYBOARD_KEY);
|
||||
CASE_RETURN_STRING(EI_EVENT_TOUCH_DOWN);
|
||||
CASE_RETURN_STRING(EI_EVENT_TOUCH_UP);
|
||||
CASE_RETURN_STRING(EI_EVENT_TOUCH_MOTION);
|
||||
}
|
||||
|
||||
assert(!"Unhandled event type");
|
||||
}
|
||||
|
||||
static void
|
||||
print_header(void)
|
||||
{
|
||||
|
|
@ -126,8 +94,7 @@ print_event_header(struct ei_event *event)
|
|||
run_only_once {
|
||||
printf("events:\n");
|
||||
}
|
||||
const char *type = event_type(ei_event_get_type(event));
|
||||
printf("- type: %s\n", type);
|
||||
printf("- type: %s\n", ei_event_type_to_string(ei_event_get_type(event)));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue