2 * Copyright © 2013 Jonas Ådahl
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation for any purpose is hereby granted without fee, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of the copyright holders not be used in
9 * advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. The copyright holders make
11 * no representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
15 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
17 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
18 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
19 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
29 #include <sys/epoll.h>
34 #include "libinput-private.h"
38 struct libinput_source {
39 libinput_source_dispatch_t dispatch;
45 struct libinput_event {
46 enum libinput_event_type type;
47 struct libinput_device *device;
50 struct libinput_event_device_notify {
51 struct libinput_event base;
54 struct libinput_event_keyboard {
55 struct libinput_event base;
58 uint32_t seat_key_count;
59 enum libinput_keyboard_key_state state;
62 struct libinput_event_pointer {
63 struct libinput_event base;
68 uint32_t seat_button_count;
69 enum libinput_button_state state;
70 enum libinput_pointer_axis axis;
74 struct libinput_event_touch {
75 struct libinput_event base;
84 libinput_default_log_func(enum libinput_log_priority priority,
86 const char *format, va_list args)
91 case LIBINPUT_LOG_PRIORITY_DEBUG: prefix = "debug"; break;
92 case LIBINPUT_LOG_PRIORITY_INFO: prefix = "info"; break;
93 case LIBINPUT_LOG_PRIORITY_ERROR: prefix = "error"; break;
94 default: prefix="<invalid priority>"; break;
97 fprintf(stderr, "libinput %s: ", prefix);
98 vfprintf(stderr, format, args);
102 enum libinput_log_priority priority;
103 libinput_log_handler handler;
107 static struct log_data log_data = {
108 .priority = LIBINPUT_LOG_PRIORITY_ERROR,
109 .handler = libinput_default_log_func,
114 log_msg(enum libinput_log_priority priority, const char *format, ...)
118 if (log_data.handler && log_data.priority <= priority) {
119 va_start(args, format);
120 log_data.handler(priority, log_data.user_data, format, args);
126 libinput_log_set_priority(enum libinput_log_priority priority)
128 log_data.priority = priority;
131 LIBINPUT_EXPORT enum libinput_log_priority
132 libinput_log_get_priority(void)
134 return log_data.priority;
138 libinput_log_set_handler(libinput_log_handler log_handler,
141 log_data.handler = log_handler;
142 log_data.user_data = user_data;
146 libinput_post_event(struct libinput *libinput,
147 struct libinput_event *event);
149 LIBINPUT_EXPORT enum libinput_event_type
150 libinput_event_get_type(struct libinput_event *event)
155 LIBINPUT_EXPORT struct libinput *
156 libinput_event_get_context(struct libinput_event *event)
158 return event->device->seat->libinput;
161 LIBINPUT_EXPORT struct libinput_device *
162 libinput_event_get_device(struct libinput_event *event)
164 return event->device;
167 LIBINPUT_EXPORT struct libinput_event_pointer *
168 libinput_event_get_pointer_event(struct libinput_event *event)
170 switch (event->type) {
171 case LIBINPUT_EVENT_NONE:
172 abort(); /* not used as actual event type */
173 case LIBINPUT_EVENT_DEVICE_ADDED:
174 case LIBINPUT_EVENT_DEVICE_REMOVED:
175 case LIBINPUT_EVENT_KEYBOARD_KEY:
177 case LIBINPUT_EVENT_POINTER_MOTION:
178 case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
179 case LIBINPUT_EVENT_POINTER_BUTTON:
180 case LIBINPUT_EVENT_POINTER_AXIS:
181 return (struct libinput_event_pointer *) event;
182 case LIBINPUT_EVENT_TOUCH_DOWN:
183 case LIBINPUT_EVENT_TOUCH_UP:
184 case LIBINPUT_EVENT_TOUCH_MOTION:
185 case LIBINPUT_EVENT_TOUCH_CANCEL:
186 case LIBINPUT_EVENT_TOUCH_FRAME:
193 LIBINPUT_EXPORT struct libinput_event_keyboard *
194 libinput_event_get_keyboard_event(struct libinput_event *event)
196 switch (event->type) {
197 case LIBINPUT_EVENT_NONE:
198 abort(); /* not used as actual event type */
199 case LIBINPUT_EVENT_DEVICE_ADDED:
200 case LIBINPUT_EVENT_DEVICE_REMOVED:
202 case LIBINPUT_EVENT_KEYBOARD_KEY:
203 return (struct libinput_event_keyboard *) event;
204 case LIBINPUT_EVENT_POINTER_MOTION:
205 case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
206 case LIBINPUT_EVENT_POINTER_BUTTON:
207 case LIBINPUT_EVENT_POINTER_AXIS:
208 case LIBINPUT_EVENT_TOUCH_DOWN:
209 case LIBINPUT_EVENT_TOUCH_UP:
210 case LIBINPUT_EVENT_TOUCH_MOTION:
211 case LIBINPUT_EVENT_TOUCH_CANCEL:
212 case LIBINPUT_EVENT_TOUCH_FRAME:
219 LIBINPUT_EXPORT struct libinput_event_touch *
220 libinput_event_get_touch_event(struct libinput_event *event)
222 switch (event->type) {
223 case LIBINPUT_EVENT_NONE:
224 abort(); /* not used as actual event type */
225 case LIBINPUT_EVENT_DEVICE_ADDED:
226 case LIBINPUT_EVENT_DEVICE_REMOVED:
227 case LIBINPUT_EVENT_KEYBOARD_KEY:
228 case LIBINPUT_EVENT_POINTER_MOTION:
229 case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
230 case LIBINPUT_EVENT_POINTER_BUTTON:
231 case LIBINPUT_EVENT_POINTER_AXIS:
233 case LIBINPUT_EVENT_TOUCH_DOWN:
234 case LIBINPUT_EVENT_TOUCH_UP:
235 case LIBINPUT_EVENT_TOUCH_MOTION:
236 case LIBINPUT_EVENT_TOUCH_CANCEL:
237 case LIBINPUT_EVENT_TOUCH_FRAME:
238 return (struct libinput_event_touch *) event;
244 LIBINPUT_EXPORT struct libinput_event_device_notify *
245 libinput_event_get_device_notify_event(struct libinput_event *event)
247 switch (event->type) {
248 case LIBINPUT_EVENT_NONE:
249 abort(); /* not used as actual event type */
250 case LIBINPUT_EVENT_DEVICE_ADDED:
251 case LIBINPUT_EVENT_DEVICE_REMOVED:
252 return (struct libinput_event_device_notify *) event;
253 case LIBINPUT_EVENT_KEYBOARD_KEY:
254 case LIBINPUT_EVENT_POINTER_MOTION:
255 case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
256 case LIBINPUT_EVENT_POINTER_BUTTON:
257 case LIBINPUT_EVENT_POINTER_AXIS:
258 case LIBINPUT_EVENT_TOUCH_DOWN:
259 case LIBINPUT_EVENT_TOUCH_UP:
260 case LIBINPUT_EVENT_TOUCH_MOTION:
261 case LIBINPUT_EVENT_TOUCH_CANCEL:
262 case LIBINPUT_EVENT_TOUCH_FRAME:
269 LIBINPUT_EXPORT uint32_t
270 libinput_event_keyboard_get_time(struct libinput_event_keyboard *event)
275 LIBINPUT_EXPORT uint32_t
276 libinput_event_keyboard_get_key(struct libinput_event_keyboard *event)
281 LIBINPUT_EXPORT enum libinput_keyboard_key_state
282 libinput_event_keyboard_get_key_state(struct libinput_event_keyboard *event)
287 LIBINPUT_EXPORT uint32_t
288 libinput_event_keyboard_get_seat_key_count(
289 struct libinput_event_keyboard *event)
291 return event->seat_key_count;
294 LIBINPUT_EXPORT uint32_t
295 libinput_event_pointer_get_time(struct libinput_event_pointer *event)
300 LIBINPUT_EXPORT double
301 libinput_event_pointer_get_dx(struct libinput_event_pointer *event)
306 LIBINPUT_EXPORT double
307 libinput_event_pointer_get_dy(struct libinput_event_pointer *event)
312 LIBINPUT_EXPORT double
313 libinput_event_pointer_get_absolute_x(struct libinput_event_pointer *event)
318 LIBINPUT_EXPORT double
319 libinput_event_pointer_get_absolute_y(struct libinput_event_pointer *event)
324 LIBINPUT_EXPORT double
325 libinput_event_pointer_get_absolute_x_transformed(
326 struct libinput_event_pointer *event,
329 struct evdev_device *device =
330 (struct evdev_device *) event->base.device;
332 return evdev_device_transform_x(device, event->x, width);
335 LIBINPUT_EXPORT double
336 libinput_event_pointer_get_absolute_y_transformed(
337 struct libinput_event_pointer *event,
340 struct evdev_device *device =
341 (struct evdev_device *) event->base.device;
343 return evdev_device_transform_y(device, event->y, height);
346 LIBINPUT_EXPORT uint32_t
347 libinput_event_pointer_get_button(struct libinput_event_pointer *event)
349 return event->button;
352 LIBINPUT_EXPORT enum libinput_button_state
353 libinput_event_pointer_get_button_state(struct libinput_event_pointer *event)
358 LIBINPUT_EXPORT uint32_t
359 libinput_event_pointer_get_seat_button_count(
360 struct libinput_event_pointer *event)
362 return event->seat_button_count;
365 LIBINPUT_EXPORT enum libinput_pointer_axis
366 libinput_event_pointer_get_axis(struct libinput_event_pointer *event)
371 LIBINPUT_EXPORT double
372 libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event)
377 LIBINPUT_EXPORT uint32_t
378 libinput_event_touch_get_time(struct libinput_event_touch *event)
383 LIBINPUT_EXPORT int32_t
384 libinput_event_touch_get_slot(struct libinput_event_touch *event)
389 LIBINPUT_EXPORT int32_t
390 libinput_event_touch_get_seat_slot(struct libinput_event_touch *event)
392 return event->seat_slot;
395 LIBINPUT_EXPORT double
396 libinput_event_touch_get_x(struct libinput_event_touch *event)
401 LIBINPUT_EXPORT double
402 libinput_event_touch_get_x_transformed(struct libinput_event_touch *event,
405 struct evdev_device *device =
406 (struct evdev_device *) event->base.device;
408 return evdev_device_transform_x(device, event->x, width);
411 LIBINPUT_EXPORT double
412 libinput_event_touch_get_y_transformed(struct libinput_event_touch *event,
415 struct evdev_device *device =
416 (struct evdev_device *) event->base.device;
418 return evdev_device_transform_y(device, event->y, height);
421 LIBINPUT_EXPORT double
422 libinput_event_touch_get_y(struct libinput_event_touch *event)
427 struct libinput_source *
428 libinput_add_fd(struct libinput *libinput,
430 libinput_source_dispatch_t dispatch,
433 struct libinput_source *source;
434 struct epoll_event ep;
436 source = malloc(sizeof *source);
440 source->dispatch = dispatch;
441 source->user_data = user_data;
444 memset(&ep, 0, sizeof ep);
446 ep.data.ptr = source;
448 if (epoll_ctl(libinput->epoll_fd, EPOLL_CTL_ADD, fd, &ep) < 0) {
458 libinput_remove_source(struct libinput *libinput,
459 struct libinput_source *source)
461 epoll_ctl(libinput->epoll_fd, EPOLL_CTL_DEL, source->fd, NULL);
463 list_insert(&libinput->source_destroy_list, &source->link);
467 libinput_init(struct libinput *libinput,
468 const struct libinput_interface *interface,
469 const struct libinput_interface_backend *interface_backend,
472 libinput->epoll_fd = epoll_create1(EPOLL_CLOEXEC);;
473 if (libinput->epoll_fd < 0)
476 libinput->events_len = 4;
477 libinput->events = zalloc(libinput->events_len * sizeof(*libinput->events));
478 if (!libinput->events) {
479 close(libinput->epoll_fd);
483 libinput->interface = interface;
484 libinput->interface_backend = interface_backend;
485 libinput->user_data = user_data;
486 list_init(&libinput->source_destroy_list);
487 list_init(&libinput->seat_list);
489 if (libinput_timer_subsys_init(libinput) != 0) {
490 free(libinput->events);
491 close(libinput->epoll_fd);
499 libinput_device_destroy(struct libinput_device *device);
502 libinput_seat_destroy(struct libinput_seat *seat);
505 libinput_drop_destroyed_sources(struct libinput *libinput)
507 struct libinput_source *source, *next;
509 list_for_each_safe(source, next, &libinput->source_destroy_list, link)
511 list_init(&libinput->source_destroy_list);
515 libinput_destroy(struct libinput *libinput)
517 struct libinput_event *event;
518 struct libinput_device *device, *next_device;
519 struct libinput_seat *seat, *next_seat;
521 if (libinput == NULL)
524 libinput_suspend(libinput);
526 libinput->interface_backend->destroy(libinput);
528 while ((event = libinput_get_event(libinput)))
529 libinput_event_destroy(event);
531 free(libinput->events);
533 list_for_each_safe(seat, next_seat, &libinput->seat_list, link) {
534 list_for_each_safe(device, next_device,
537 libinput_device_destroy(device);
539 libinput_seat_destroy(seat);
542 libinput_timer_subsys_destroy(libinput);
543 libinput_drop_destroyed_sources(libinput);
544 close(libinput->epoll_fd);
549 libinput_event_destroy(struct libinput_event *event)
555 libinput_device_unref(event->device);
561 open_restricted(struct libinput *libinput,
562 const char *path, int flags)
564 return libinput->interface->open_restricted(path,
566 libinput->user_data);
570 close_restricted(struct libinput *libinput, int fd)
572 return libinput->interface->close_restricted(fd, libinput->user_data);
576 libinput_seat_init(struct libinput_seat *seat,
577 struct libinput *libinput,
578 const char *physical_name,
579 const char *logical_name,
580 libinput_seat_destroy_func destroy)
583 seat->libinput = libinput;
584 seat->physical_name = strdup(physical_name);
585 seat->logical_name = strdup(logical_name);
586 seat->destroy = destroy;
587 list_init(&seat->devices_list);
588 list_insert(&libinput->seat_list, &seat->link);
592 libinput_seat_ref(struct libinput_seat *seat)
598 libinput_seat_destroy(struct libinput_seat *seat)
600 list_remove(&seat->link);
601 free(seat->logical_name);
602 free(seat->physical_name);
607 libinput_seat_unref(struct libinput_seat *seat)
609 assert(seat->refcount > 0);
611 if (seat->refcount == 0)
612 libinput_seat_destroy(seat);
616 libinput_seat_set_user_data(struct libinput_seat *seat, void *user_data)
618 seat->user_data = user_data;
621 LIBINPUT_EXPORT void *
622 libinput_seat_get_user_data(struct libinput_seat *seat)
624 return seat->user_data;
627 LIBINPUT_EXPORT const char *
628 libinput_seat_get_physical_name(struct libinput_seat *seat)
630 return seat->physical_name;
633 LIBINPUT_EXPORT const char *
634 libinput_seat_get_logical_name(struct libinput_seat *seat)
636 return seat->logical_name;
640 libinput_device_init(struct libinput_device *device,
641 struct libinput_seat *seat)
644 device->refcount = 1;
648 libinput_device_ref(struct libinput_device *device)
654 libinput_device_destroy(struct libinput_device *device)
656 evdev_device_destroy((struct evdev_device *) device);
660 libinput_device_unref(struct libinput_device *device)
662 assert(device->refcount > 0);
664 if (device->refcount == 0)
665 libinput_device_destroy(device);
669 libinput_get_fd(struct libinput *libinput)
671 return libinput->epoll_fd;
675 libinput_dispatch(struct libinput *libinput)
677 struct libinput_source *source;
678 struct epoll_event ep[32];
681 count = epoll_wait(libinput->epoll_fd, ep, ARRAY_LENGTH(ep), 0);
685 for (i = 0; i < count; ++i) {
686 source = ep[i].data.ptr;
687 if (source->fd == -1)
690 source->dispatch(source->user_data);
693 libinput_drop_destroyed_sources(libinput);
699 update_seat_key_count(struct libinput_seat *seat,
701 enum libinput_keyboard_key_state state)
703 assert(key >= 0 && key <= KEY_MAX);
706 case LIBINPUT_KEYBOARD_KEY_STATE_PRESSED:
707 return ++seat->button_count[key];
708 case LIBINPUT_KEYBOARD_KEY_STATE_RELEASED:
709 /* We might not have received the first PRESSED event. */
710 if (seat->button_count[key] == 0)
713 return --seat->button_count[key];
720 update_seat_button_count(struct libinput_seat *seat,
722 enum libinput_button_state state)
724 assert(button >= 0 && button <= KEY_MAX);
727 case LIBINPUT_BUTTON_STATE_PRESSED:
728 return ++seat->button_count[button];
729 case LIBINPUT_BUTTON_STATE_RELEASED:
730 /* We might not have received the first PRESSED event. */
731 if (seat->button_count[button] == 0)
734 return --seat->button_count[button];
741 init_event_base(struct libinput_event *event,
742 struct libinput_device *device,
743 enum libinput_event_type type)
746 event->device = device;
750 post_base_event(struct libinput_device *device,
751 enum libinput_event_type type,
752 struct libinput_event *event)
754 struct libinput *libinput = device->seat->libinput;
755 init_event_base(event, device, type);
756 libinput_post_event(libinput, event);
760 post_device_event(struct libinput_device *device,
761 enum libinput_event_type type,
762 struct libinput_event *event)
764 init_event_base(event, device, type);
765 libinput_post_event(device->seat->libinput, event);
769 notify_added_device(struct libinput_device *device)
771 struct libinput_event_device_notify *added_device_event;
773 added_device_event = zalloc(sizeof *added_device_event);
774 if (!added_device_event)
777 post_base_event(device,
778 LIBINPUT_EVENT_DEVICE_ADDED,
779 &added_device_event->base);
783 notify_removed_device(struct libinput_device *device)
785 struct libinput_event_device_notify *removed_device_event;
787 removed_device_event = zalloc(sizeof *removed_device_event);
788 if (!removed_device_event)
791 post_base_event(device,
792 LIBINPUT_EVENT_DEVICE_REMOVED,
793 &removed_device_event->base);
797 keyboard_notify_key(struct libinput_device *device,
800 enum libinput_keyboard_key_state state)
802 struct libinput_event_keyboard *key_event;
803 uint32_t seat_key_count;
805 key_event = zalloc(sizeof *key_event);
809 seat_key_count = update_seat_key_count(device->seat, key, state);
811 *key_event = (struct libinput_event_keyboard) {
815 .seat_key_count = seat_key_count,
818 post_device_event(device,
819 LIBINPUT_EVENT_KEYBOARD_KEY,
824 pointer_notify_motion(struct libinput_device *device,
829 struct libinput_event_pointer *motion_event;
831 motion_event = zalloc(sizeof *motion_event);
835 *motion_event = (struct libinput_event_pointer) {
841 post_device_event(device,
842 LIBINPUT_EVENT_POINTER_MOTION,
843 &motion_event->base);
847 pointer_notify_motion_absolute(struct libinput_device *device,
852 struct libinput_event_pointer *motion_absolute_event;
854 motion_absolute_event = zalloc(sizeof *motion_absolute_event);
855 if (!motion_absolute_event)
858 *motion_absolute_event = (struct libinput_event_pointer) {
864 post_device_event(device,
865 LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE,
866 &motion_absolute_event->base);
870 pointer_notify_button(struct libinput_device *device,
873 enum libinput_button_state state)
875 struct libinput_event_pointer *button_event;
876 int32_t seat_button_count;
878 button_event = zalloc(sizeof *button_event);
882 seat_button_count = update_seat_button_count(device->seat,
886 *button_event = (struct libinput_event_pointer) {
890 .seat_button_count = seat_button_count,
893 post_device_event(device,
894 LIBINPUT_EVENT_POINTER_BUTTON,
895 &button_event->base);
899 pointer_notify_axis(struct libinput_device *device,
901 enum libinput_pointer_axis axis,
904 struct libinput_event_pointer *axis_event;
906 axis_event = zalloc(sizeof *axis_event);
910 *axis_event = (struct libinput_event_pointer) {
916 post_device_event(device,
917 LIBINPUT_EVENT_POINTER_AXIS,
922 touch_notify_touch_down(struct libinput_device *device,
929 struct libinput_event_touch *touch_event;
931 touch_event = zalloc(sizeof *touch_event);
935 *touch_event = (struct libinput_event_touch) {
938 .seat_slot = seat_slot,
943 post_device_event(device,
944 LIBINPUT_EVENT_TOUCH_DOWN,
949 touch_notify_touch_motion(struct libinput_device *device,
956 struct libinput_event_touch *touch_event;
958 touch_event = zalloc(sizeof *touch_event);
962 *touch_event = (struct libinput_event_touch) {
965 .seat_slot = seat_slot,
970 post_device_event(device,
971 LIBINPUT_EVENT_TOUCH_MOTION,
976 touch_notify_touch_up(struct libinput_device *device,
981 struct libinput_event_touch *touch_event;
983 touch_event = zalloc(sizeof *touch_event);
987 *touch_event = (struct libinput_event_touch) {
990 .seat_slot = seat_slot,
993 post_device_event(device,
994 LIBINPUT_EVENT_TOUCH_UP,
999 touch_notify_frame(struct libinput_device *device,
1002 struct libinput_event_touch *touch_event;
1004 touch_event = zalloc(sizeof *touch_event);
1008 *touch_event = (struct libinput_event_touch) {
1012 post_device_event(device,
1013 LIBINPUT_EVENT_TOUCH_FRAME,
1014 &touch_event->base);
1019 libinput_post_event(struct libinput *libinput,
1020 struct libinput_event *event)
1022 struct libinput_event **events = libinput->events;
1023 size_t events_len = libinput->events_len;
1024 size_t events_count = libinput->events_count;
1029 if (events_count > events_len) {
1031 events = realloc(events, events_len * sizeof *events);
1033 fprintf(stderr, "Failed to reallocate event ring "
1038 if (libinput->events_count > 0 && libinput->events_in == 0) {
1039 libinput->events_in = libinput->events_len;
1040 } else if (libinput->events_count > 0 &&
1041 libinput->events_out >= libinput->events_in) {
1042 move_len = libinput->events_len - libinput->events_out;
1043 new_out = events_len - move_len;
1044 memmove(events + new_out,
1045 events + libinput->events_out,
1046 move_len * sizeof *events);
1047 libinput->events_out = new_out;
1050 libinput->events = events;
1051 libinput->events_len = events_len;
1055 libinput_device_ref(event->device);
1057 libinput->events_count = events_count;
1058 events[libinput->events_in] = event;
1059 libinput->events_in = (libinput->events_in + 1) % libinput->events_len;
1062 LIBINPUT_EXPORT struct libinput_event *
1063 libinput_get_event(struct libinput *libinput)
1065 struct libinput_event *event;
1067 if (libinput->events_count == 0)
1070 event = libinput->events[libinput->events_out];
1071 libinput->events_out =
1072 (libinput->events_out + 1) % libinput->events_len;
1073 libinput->events_count--;
1078 LIBINPUT_EXPORT enum libinput_event_type
1079 libinput_next_event_type(struct libinput *libinput)
1081 struct libinput_event *event;
1083 if (libinput->events_count == 0)
1084 return LIBINPUT_EVENT_NONE;
1086 event = libinput->events[libinput->events_out];
1090 LIBINPUT_EXPORT void *
1091 libinput_get_user_data(struct libinput *libinput)
1093 return libinput->user_data;
1097 libinput_resume(struct libinput *libinput)
1099 return libinput->interface_backend->resume(libinput);
1102 LIBINPUT_EXPORT void
1103 libinput_suspend(struct libinput *libinput)
1105 libinput->interface_backend->suspend(libinput);
1108 LIBINPUT_EXPORT void
1109 libinput_device_set_user_data(struct libinput_device *device, void *user_data)
1111 device->user_data = user_data;
1114 LIBINPUT_EXPORT void *
1115 libinput_device_get_user_data(struct libinput_device *device)
1117 return device->user_data;
1120 LIBINPUT_EXPORT const char *
1121 libinput_device_get_sysname(struct libinput_device *device)
1123 return evdev_device_get_sysname((struct evdev_device *) device);
1126 LIBINPUT_EXPORT const char *
1127 libinput_device_get_output_name(struct libinput_device *device)
1129 return evdev_device_get_output((struct evdev_device *) device);
1132 LIBINPUT_EXPORT struct libinput_seat *
1133 libinput_device_get_seat(struct libinput_device *device)
1135 return device->seat;
1138 LIBINPUT_EXPORT void
1139 libinput_device_led_update(struct libinput_device *device,
1140 enum libinput_led leds)
1142 evdev_device_led_update((struct evdev_device *) device, leds);
1146 libinput_device_get_keys(struct libinput_device *device,
1147 char *keys, size_t size)
1149 return evdev_device_get_keys((struct evdev_device *) device,
1154 LIBINPUT_EXPORT void
1155 libinput_device_calibrate(struct libinput_device *device,
1156 float calibration[6])
1158 evdev_device_calibrate((struct evdev_device *) device, calibration);
1162 libinput_device_has_capability(struct libinput_device *device,
1163 enum libinput_device_capability capability)
1165 return evdev_device_has_capability((struct evdev_device *) device,
1169 LIBINPUT_EXPORT struct libinput_event *
1170 libinput_event_device_notify_get_base_event(struct libinput_event_device_notify *event)
1172 return &event->base;
1175 LIBINPUT_EXPORT struct libinput_event *
1176 libinput_event_keyboard_get_base_event(struct libinput_event_keyboard *event)
1178 return &event->base;
1181 LIBINPUT_EXPORT struct libinput_event *
1182 libinput_event_pointer_get_base_event(struct libinput_event_pointer *event)
1184 return &event->base;
1187 LIBINPUT_EXPORT struct libinput_event *
1188 libinput_event_touch_get_base_event(struct libinput_event_touch *event)
1190 return &event->base;