diff --git a/src/libinput.c b/src/libinput.c index 713593e4..a9e458f2 100644 --- a/src/libinput.c +++ b/src/libinput.c @@ -910,6 +910,18 @@ libinput_get_event(struct libinput *libinput) return event; } +LIBINPUT_EXPORT enum libinput_event_type +libinput_next_event_type(struct libinput *libinput) +{ + struct libinput_event *event; + + if (libinput->events_count == 0) + return LIBINPUT_EVENT_NONE; + + event = libinput->events[libinput->events_out]; + return event->type; +} + LIBINPUT_EXPORT void * libinput_get_user_data(struct libinput *libinput) { diff --git a/src/libinput.h b/src/libinput.h index 586d0f48..22642fbd 100644 --- a/src/libinput.h +++ b/src/libinput.h @@ -488,6 +488,20 @@ libinput_dispatch(struct libinput *libinput); struct libinput_event * libinput_get_event(struct libinput *libinput); +/** + * @ingroup base + * + * Return the type of the next event in the internal queue. This function + * does not pop the event off the queue and the next call to + * libinput_get_event() returns that event. + * + * @param libinput A previously initialized libinput context + * @return The event type of the next available event or LIBINPUT_EVENT_NONE + * if no event is availble. + */ +enum libinput_event_type +libinput_next_event_type(struct libinput *libinput); + /** * @ingroup base *