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"
37 struct libinput_source {
38 libinput_source_dispatch_t dispatch;
44 struct libinput_event {
45 enum libinput_event_type type;
46 struct libinput_device *device;
49 struct libinput_event_device_notify {
50 struct libinput_event base;
53 struct libinput_event_keyboard {
54 struct libinput_event base;
57 uint32_t seat_key_count;
58 enum libinput_keyboard_key_state state;
61 struct libinput_event_pointer {
62 struct libinput_event base;
67 uint32_t seat_button_count;
68 enum libinput_button_state state;
69 enum libinput_pointer_axis axis;
73 struct libinput_event_touch {
74 struct libinput_event base;
83 libinput_default_log_func(enum libinput_log_priority priority,
85 const char *format, va_list args)
90 case LIBINPUT_LOG_PRIORITY_DEBUG: prefix = "debug"; break;
91 case LIBINPUT_LOG_PRIORITY_INFO: prefix = "info"; break;
92 case LIBINPUT_LOG_PRIORITY_ERROR: prefix = "error"; break;
93 default: prefix="<invalid priority>"; break;
96 fprintf(stderr, "libinput %s: ", prefix);
97 vfprintf(stderr, format, args);
101 enum libinput_log_priority priority;
102 libinput_log_handler handler;
106 static struct log_data log_data = {
107 .priority = LIBINPUT_LOG_PRIORITY_ERROR,
108 .handler = libinput_default_log_func,
113 log_msg(enum libinput_log_priority priority, const char *format, ...)
117 if (log_data.handler && log_data.priority <= priority) {
118 va_start(args, format);
119 log_data.handler(priority, log_data.user_data, format, args);
125 libinput_log_set_priority(enum libinput_log_priority priority)
127 log_data.priority = priority;
130 LIBINPUT_EXPORT enum libinput_log_priority
131 libinput_log_get_priority(void)
133 return log_data.priority;
137 libinput_log_set_handler(libinput_log_handler log_handler,
140 log_data.handler = log_handler;
141 log_data.user_data = user_data;
145 libinput_post_event(struct libinput *libinput,
146 struct libinput_event *event);
148 LIBINPUT_EXPORT enum libinput_event_type
149 libinput_event_get_type(struct libinput_event *event)
154 LIBINPUT_EXPORT struct libinput *
155 libinput_event_get_context(struct libinput_event *event)
157 return event->device->seat->libinput;
160 LIBINPUT_EXPORT struct libinput_device *
161 libinput_event_get_device(struct libinput_event *event)
163 return event->device;
166 LIBINPUT_EXPORT struct libinput_event_pointer *
167 libinput_event_get_pointer_event(struct libinput_event *event)
169 switch (event->type) {
170 case LIBINPUT_EVENT_NONE:
171 abort(); /* not used as actual event type */
172 case LIBINPUT_EVENT_DEVICE_ADDED:
173 case LIBINPUT_EVENT_DEVICE_REMOVED:
174 case LIBINPUT_EVENT_KEYBOARD_KEY:
176 case LIBINPUT_EVENT_POINTER_MOTION:
177 case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
178 case LIBINPUT_EVENT_POINTER_BUTTON:
179 case LIBINPUT_EVENT_POINTER_AXIS:
180 return (struct libinput_event_pointer *) event;
181 case LIBINPUT_EVENT_TOUCH_DOWN:
182 case LIBINPUT_EVENT_TOUCH_UP:
183 case LIBINPUT_EVENT_TOUCH_MOTION:
184 case LIBINPUT_EVENT_TOUCH_CANCEL:
185 case LIBINPUT_EVENT_TOUCH_FRAME:
192 LIBINPUT_EXPORT struct libinput_event_keyboard *
193 libinput_event_get_keyboard_event(struct libinput_event *event)
195 switch (event->type) {
196 case LIBINPUT_EVENT_NONE:
197 abort(); /* not used as actual event type */
198 case LIBINPUT_EVENT_DEVICE_ADDED:
199 case LIBINPUT_EVENT_DEVICE_REMOVED:
201 case LIBINPUT_EVENT_KEYBOARD_KEY:
202 return (struct libinput_event_keyboard *) event;
203 case LIBINPUT_EVENT_POINTER_MOTION:
204 case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
205 case LIBINPUT_EVENT_POINTER_BUTTON:
206 case LIBINPUT_EVENT_POINTER_AXIS:
207 case LIBINPUT_EVENT_TOUCH_DOWN:
208 case LIBINPUT_EVENT_TOUCH_UP:
209 case LIBINPUT_EVENT_TOUCH_MOTION:
210 case LIBINPUT_EVENT_TOUCH_CANCEL:
211 case LIBINPUT_EVENT_TOUCH_FRAME:
218 LIBINPUT_EXPORT struct libinput_event_touch *
219 libinput_event_get_touch_event(struct libinput_event *event)
221 switch (event->type) {
222 case LIBINPUT_EVENT_NONE:
223 abort(); /* not used as actual event type */
224 case LIBINPUT_EVENT_DEVICE_ADDED:
225 case LIBINPUT_EVENT_DEVICE_REMOVED:
226 case LIBINPUT_EVENT_KEYBOARD_KEY:
227 case LIBINPUT_EVENT_POINTER_MOTION:
228 case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
229 case LIBINPUT_EVENT_POINTER_BUTTON:
230 case LIBINPUT_EVENT_POINTER_AXIS:
232 case LIBINPUT_EVENT_TOUCH_DOWN:
233 case LIBINPUT_EVENT_TOUCH_UP:
234 case LIBINPUT_EVENT_TOUCH_MOTION:
235 case LIBINPUT_EVENT_TOUCH_CANCEL:
236 case LIBINPUT_EVENT_TOUCH_FRAME:
237 return (struct libinput_event_touch *) event;
243 LIBINPUT_EXPORT struct libinput_event_device_notify *
244 libinput_event_get_device_notify_event(struct libinput_event *event)
246 switch (event->type) {
247 case LIBINPUT_EVENT_NONE:
248 abort(); /* not used as actual event type */
249 case LIBINPUT_EVENT_DEVICE_ADDED:
250 case LIBINPUT_EVENT_DEVICE_REMOVED:
251 return (struct libinput_event_device_notify *) event;
252 case LIBINPUT_EVENT_KEYBOARD_KEY:
253 case LIBINPUT_EVENT_POINTER_MOTION:
254 case LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE:
255 case LIBINPUT_EVENT_POINTER_BUTTON:
256 case LIBINPUT_EVENT_POINTER_AXIS:
257 case LIBINPUT_EVENT_TOUCH_DOWN:
258 case LIBINPUT_EVENT_TOUCH_UP:
259 case LIBINPUT_EVENT_TOUCH_MOTION:
260 case LIBINPUT_EVENT_TOUCH_CANCEL:
261 case LIBINPUT_EVENT_TOUCH_FRAME:
268 LIBINPUT_EXPORT uint32_t
269 libinput_event_keyboard_get_time(struct libinput_event_keyboard *event)
274 LIBINPUT_EXPORT uint32_t
275 libinput_event_keyboard_get_key(struct libinput_event_keyboard *event)
280 LIBINPUT_EXPORT enum libinput_keyboard_key_state
281 libinput_event_keyboard_get_key_state(struct libinput_event_keyboard *event)
286 LIBINPUT_EXPORT uint32_t
287 libinput_event_keyboard_get_seat_key_count(
288 struct libinput_event_keyboard *event)
290 return event->seat_key_count;
293 LIBINPUT_EXPORT uint32_t
294 libinput_event_pointer_get_time(struct libinput_event_pointer *event)
299 LIBINPUT_EXPORT double
300 libinput_event_pointer_get_dx(struct libinput_event_pointer *event)
305 LIBINPUT_EXPORT double
306 libinput_event_pointer_get_dy(struct libinput_event_pointer *event)
311 LIBINPUT_EXPORT double
312 libinput_event_pointer_get_absolute_x(struct libinput_event_pointer *event)
317 LIBINPUT_EXPORT double
318 libinput_event_pointer_get_absolute_y(struct libinput_event_pointer *event)
323 LIBINPUT_EXPORT double
324 libinput_event_pointer_get_absolute_x_transformed(
325 struct libinput_event_pointer *event,
328 struct evdev_device *device =
329 (struct evdev_device *) event->base.device;
331 return evdev_device_transform_x(device, event->x, width);
334 LIBINPUT_EXPORT double
335 libinput_event_pointer_get_absolute_y_transformed(
336 struct libinput_event_pointer *event,
339 struct evdev_device *device =
340 (struct evdev_device *) event->base.device;
342 return evdev_device_transform_y(device, event->y, height);
345 LIBINPUT_EXPORT uint32_t
346 libinput_event_pointer_get_button(struct libinput_event_pointer *event)
348 return event->button;
351 LIBINPUT_EXPORT enum libinput_button_state
352 libinput_event_pointer_get_button_state(struct libinput_event_pointer *event)
357 LIBINPUT_EXPORT uint32_t
358 libinput_event_pointer_get_seat_button_count(
359 struct libinput_event_pointer *event)
361 return event->seat_button_count;
364 LIBINPUT_EXPORT enum libinput_pointer_axis
365 libinput_event_pointer_get_axis(struct libinput_event_pointer *event)
370 LIBINPUT_EXPORT double
371 libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event)
376 LIBINPUT_EXPORT uint32_t
377 libinput_event_touch_get_time(struct libinput_event_touch *event)
382 LIBINPUT_EXPORT int32_t
383 libinput_event_touch_get_slot(struct libinput_event_touch *event)
388 LIBINPUT_EXPORT int32_t
389 libinput_event_touch_get_seat_slot(struct libinput_event_touch *event)
391 return event->seat_slot;
394 LIBINPUT_EXPORT double
395 libinput_event_touch_get_x(struct libinput_event_touch *event)
400 LIBINPUT_EXPORT double
401 libinput_event_touch_get_x_transformed(struct libinput_event_touch *event,
404 struct evdev_device *device =
405 (struct evdev_device *) event->base.device;
407 return evdev_device_transform_x(device, event->x, width);
410 LIBINPUT_EXPORT double
411 libinput_event_touch_get_y_transformed(struct libinput_event_touch *event,
414 struct evdev_device *device =
415 (struct evdev_device *) event->base.device;
417 return evdev_device_transform_y(device, event->y, height);
420 LIBINPUT_EXPORT double
421 libinput_event_touch_get_y(struct libinput_event_touch *event)
426 struct libinput_source *
427 libinput_add_fd(struct libinput *libinput,
429 libinput_source_dispatch_t dispatch,
432 struct libinput_source *source;
433 struct epoll_event ep;
435 source = malloc(sizeof *source);
439 source->dispatch = dispatch;
440 source->user_data = user_data;
443 memset(&ep, 0, sizeof ep);
445 ep.data.ptr = source;
447 if (epoll_ctl(libinput->epoll_fd, EPOLL_CTL_ADD, fd, &ep) < 0) {
457 libinput_remove_source(struct libinput *libinput,
458 struct libinput_source *source)
460 epoll_ctl(libinput->epoll_fd, EPOLL_CTL_DEL, source->fd, NULL);
462 list_insert(&libinput->source_destroy_list, &source->link);
466 libinput_init(struct libinput *libinput,
467 const struct libinput_interface *interface,
468 const struct libinput_interface_backend *interface_backend,
471 libinput->epoll_fd = epoll_create1(EPOLL_CLOEXEC);;
472 if (libinput->epoll_fd < 0)
475 libinput->events_len = 4;
476 libinput->events = zalloc(libinput->events_len * sizeof(*libinput->events));
477 if (!libinput->events) {
478 close(libinput->epoll_fd);
482 libinput->interface = interface;
483 libinput->interface_backend = interface_backend;
484 libinput->user_data = user_data;
485 list_init(&libinput->source_destroy_list);
486 list_init(&libinput->seat_list);
492 libinput_device_destroy(struct libinput_device *device);
495 libinput_seat_destroy(struct libinput_seat *seat);
498 libinput_drop_destroyed_sources(struct libinput *libinput)
500 struct libinput_source *source, *next;
502 list_for_each_safe(source, next, &libinput->source_destroy_list, link)
504 list_init(&libinput->source_destroy_list);
508 libinput_destroy(struct libinput *libinput)
510 struct libinput_event *event;
511 struct libinput_device *device, *next_device;
512 struct libinput_seat *seat, *next_seat;
514 if (libinput == NULL)
517 libinput_suspend(libinput);
519 libinput->interface_backend->destroy(libinput);
521 while ((event = libinput_get_event(libinput)))
522 libinput_event_destroy(event);
524 libinput_drop_destroyed_sources(libinput);
526 free(libinput->events);
528 list_for_each_safe(seat, next_seat, &libinput->seat_list, link) {
529 list_for_each_safe(device, next_device,
532 libinput_device_destroy(device);
534 libinput_seat_destroy(seat);
537 close(libinput->epoll_fd);
542 libinput_event_destroy(struct libinput_event *event)
548 libinput_device_unref(event->device);
554 open_restricted(struct libinput *libinput,
555 const char *path, int flags)
557 return libinput->interface->open_restricted(path,
559 libinput->user_data);
563 close_restricted(struct libinput *libinput, int fd)
565 return libinput->interface->close_restricted(fd, libinput->user_data);
569 libinput_seat_init(struct libinput_seat *seat,
570 struct libinput *libinput,
571 const char *physical_name,
572 const char *logical_name,
573 libinput_seat_destroy_func destroy)
576 seat->libinput = libinput;
577 seat->physical_name = strdup(physical_name);
578 seat->logical_name = strdup(logical_name);
579 seat->destroy = destroy;
580 list_init(&seat->devices_list);
581 list_insert(&libinput->seat_list, &seat->link);
585 libinput_seat_ref(struct libinput_seat *seat)
591 libinput_seat_destroy(struct libinput_seat *seat)
593 list_remove(&seat->link);
594 free(seat->logical_name);
595 free(seat->physical_name);
600 libinput_seat_unref(struct libinput_seat *seat)
602 assert(seat->refcount > 0);
604 if (seat->refcount == 0)
605 libinput_seat_destroy(seat);
609 libinput_seat_set_user_data(struct libinput_seat *seat, void *user_data)
611 seat->user_data = user_data;
614 LIBINPUT_EXPORT void *
615 libinput_seat_get_user_data(struct libinput_seat *seat)
617 return seat->user_data;
620 LIBINPUT_EXPORT const char *
621 libinput_seat_get_physical_name(struct libinput_seat *seat)
623 return seat->physical_name;
626 LIBINPUT_EXPORT const char *
627 libinput_seat_get_logical_name(struct libinput_seat *seat)
629 return seat->logical_name;
633 libinput_device_init(struct libinput_device *device,
634 struct libinput_seat *seat)
637 device->refcount = 1;
641 libinput_device_ref(struct libinput_device *device)
647 libinput_device_destroy(struct libinput_device *device)
649 evdev_device_destroy((struct evdev_device *) device);
653 libinput_device_unref(struct libinput_device *device)
655 assert(device->refcount > 0);
657 if (device->refcount == 0)
658 libinput_device_destroy(device);
662 libinput_get_fd(struct libinput *libinput)
664 return libinput->epoll_fd;
668 libinput_dispatch(struct libinput *libinput)
670 struct libinput_source *source;
671 struct epoll_event ep[32];
674 count = epoll_wait(libinput->epoll_fd, ep, ARRAY_LENGTH(ep), 0);
678 for (i = 0; i < count; ++i) {
679 source = ep[i].data.ptr;
680 if (source->fd == -1)
683 source->dispatch(source->user_data);
686 libinput_drop_destroyed_sources(libinput);
692 update_seat_key_count(struct libinput_seat *seat,
694 enum libinput_keyboard_key_state state)
696 assert(key >= 0 && key <= KEY_MAX);
699 case LIBINPUT_KEYBOARD_KEY_STATE_PRESSED:
700 return ++seat->button_count[key];
701 case LIBINPUT_KEYBOARD_KEY_STATE_RELEASED:
702 /* We might not have received the first PRESSED event. */
703 if (seat->button_count[key] == 0)
706 return --seat->button_count[key];
713 update_seat_button_count(struct libinput_seat *seat,
715 enum libinput_button_state state)
717 assert(button >= 0 && button <= KEY_MAX);
720 case LIBINPUT_BUTTON_STATE_PRESSED:
721 return ++seat->button_count[button];
722 case LIBINPUT_BUTTON_STATE_RELEASED:
723 /* We might not have received the first PRESSED event. */
724 if (seat->button_count[button] == 0)
727 return --seat->button_count[button];
734 init_event_base(struct libinput_event *event,
735 struct libinput_device *device,
736 enum libinput_event_type type)
739 event->device = device;
743 post_base_event(struct libinput_device *device,
744 enum libinput_event_type type,
745 struct libinput_event *event)
747 struct libinput *libinput = device->seat->libinput;
748 init_event_base(event, device, type);
749 libinput_post_event(libinput, event);
753 post_device_event(struct libinput_device *device,
754 enum libinput_event_type type,
755 struct libinput_event *event)
757 init_event_base(event, device, type);
758 libinput_post_event(device->seat->libinput, event);
762 notify_added_device(struct libinput_device *device)
764 struct libinput_event_device_notify *added_device_event;
766 added_device_event = zalloc(sizeof *added_device_event);
767 if (!added_device_event)
770 post_base_event(device,
771 LIBINPUT_EVENT_DEVICE_ADDED,
772 &added_device_event->base);
776 notify_removed_device(struct libinput_device *device)
778 struct libinput_event_device_notify *removed_device_event;
780 removed_device_event = zalloc(sizeof *removed_device_event);
781 if (!removed_device_event)
784 post_base_event(device,
785 LIBINPUT_EVENT_DEVICE_REMOVED,
786 &removed_device_event->base);
790 keyboard_notify_key(struct libinput_device *device,
793 enum libinput_keyboard_key_state state)
795 struct libinput_event_keyboard *key_event;
796 uint32_t seat_key_count;
798 key_event = zalloc(sizeof *key_event);
802 seat_key_count = update_seat_key_count(device->seat, key, state);
804 *key_event = (struct libinput_event_keyboard) {
808 .seat_key_count = seat_key_count,
811 post_device_event(device,
812 LIBINPUT_EVENT_KEYBOARD_KEY,
817 pointer_notify_motion(struct libinput_device *device,
822 struct libinput_event_pointer *motion_event;
824 motion_event = zalloc(sizeof *motion_event);
828 *motion_event = (struct libinput_event_pointer) {
834 post_device_event(device,
835 LIBINPUT_EVENT_POINTER_MOTION,
836 &motion_event->base);
840 pointer_notify_motion_absolute(struct libinput_device *device,
845 struct libinput_event_pointer *motion_absolute_event;
847 motion_absolute_event = zalloc(sizeof *motion_absolute_event);
848 if (!motion_absolute_event)
851 *motion_absolute_event = (struct libinput_event_pointer) {
857 post_device_event(device,
858 LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE,
859 &motion_absolute_event->base);
863 pointer_notify_button(struct libinput_device *device,
866 enum libinput_button_state state)
868 struct libinput_event_pointer *button_event;
869 int32_t seat_button_count;
871 button_event = zalloc(sizeof *button_event);
875 seat_button_count = update_seat_button_count(device->seat,
879 *button_event = (struct libinput_event_pointer) {
883 .seat_button_count = seat_button_count,
886 post_device_event(device,
887 LIBINPUT_EVENT_POINTER_BUTTON,
888 &button_event->base);
892 pointer_notify_axis(struct libinput_device *device,
894 enum libinput_pointer_axis axis,
897 struct libinput_event_pointer *axis_event;
899 axis_event = zalloc(sizeof *axis_event);
903 *axis_event = (struct libinput_event_pointer) {
909 post_device_event(device,
910 LIBINPUT_EVENT_POINTER_AXIS,
915 touch_notify_touch_down(struct libinput_device *device,
922 struct libinput_event_touch *touch_event;
924 touch_event = zalloc(sizeof *touch_event);
928 *touch_event = (struct libinput_event_touch) {
931 .seat_slot = seat_slot,
936 post_device_event(device,
937 LIBINPUT_EVENT_TOUCH_DOWN,
942 touch_notify_touch_motion(struct libinput_device *device,
949 struct libinput_event_touch *touch_event;
951 touch_event = zalloc(sizeof *touch_event);
955 *touch_event = (struct libinput_event_touch) {
958 .seat_slot = seat_slot,
963 post_device_event(device,
964 LIBINPUT_EVENT_TOUCH_MOTION,
969 touch_notify_touch_up(struct libinput_device *device,
974 struct libinput_event_touch *touch_event;
976 touch_event = zalloc(sizeof *touch_event);
980 *touch_event = (struct libinput_event_touch) {
983 .seat_slot = seat_slot,
986 post_device_event(device,
987 LIBINPUT_EVENT_TOUCH_UP,
992 touch_notify_frame(struct libinput_device *device,
995 struct libinput_event_touch *touch_event;
997 touch_event = zalloc(sizeof *touch_event);
1001 *touch_event = (struct libinput_event_touch) {
1005 post_device_event(device,
1006 LIBINPUT_EVENT_TOUCH_FRAME,
1007 &touch_event->base);
1012 libinput_post_event(struct libinput *libinput,
1013 struct libinput_event *event)
1015 struct libinput_event **events = libinput->events;
1016 size_t events_len = libinput->events_len;
1017 size_t events_count = libinput->events_count;
1022 if (events_count > events_len) {
1024 events = realloc(events, events_len * sizeof *events);
1026 fprintf(stderr, "Failed to reallocate event ring "
1031 if (libinput->events_count > 0 && libinput->events_in == 0) {
1032 libinput->events_in = libinput->events_len;
1033 } else if (libinput->events_count > 0 &&
1034 libinput->events_out >= libinput->events_in) {
1035 move_len = libinput->events_len - libinput->events_out;
1036 new_out = events_len - move_len;
1037 memmove(events + new_out,
1038 events + libinput->events_out,
1039 move_len * sizeof *events);
1040 libinput->events_out = new_out;
1043 libinput->events = events;
1044 libinput->events_len = events_len;
1048 libinput_device_ref(event->device);
1050 libinput->events_count = events_count;
1051 events[libinput->events_in] = event;
1052 libinput->events_in = (libinput->events_in + 1) % libinput->events_len;
1055 LIBINPUT_EXPORT struct libinput_event *
1056 libinput_get_event(struct libinput *libinput)
1058 struct libinput_event *event;
1060 if (libinput->events_count == 0)
1063 event = libinput->events[libinput->events_out];
1064 libinput->events_out =
1065 (libinput->events_out + 1) % libinput->events_len;
1066 libinput->events_count--;
1071 LIBINPUT_EXPORT enum libinput_event_type
1072 libinput_next_event_type(struct libinput *libinput)
1074 struct libinput_event *event;
1076 if (libinput->events_count == 0)
1077 return LIBINPUT_EVENT_NONE;
1079 event = libinput->events[libinput->events_out];
1083 LIBINPUT_EXPORT void *
1084 libinput_get_user_data(struct libinput *libinput)
1086 return libinput->user_data;
1090 libinput_resume(struct libinput *libinput)
1092 return libinput->interface_backend->resume(libinput);
1095 LIBINPUT_EXPORT void
1096 libinput_suspend(struct libinput *libinput)
1098 libinput->interface_backend->suspend(libinput);
1101 LIBINPUT_EXPORT void
1102 libinput_device_set_user_data(struct libinput_device *device, void *user_data)
1104 device->user_data = user_data;
1107 LIBINPUT_EXPORT void *
1108 libinput_device_get_user_data(struct libinput_device *device)
1110 return device->user_data;
1113 LIBINPUT_EXPORT const char *
1114 libinput_device_get_sysname(struct libinput_device *device)
1116 return evdev_device_get_sysname((struct evdev_device *) device);
1119 LIBINPUT_EXPORT const char *
1120 libinput_device_get_output_name(struct libinput_device *device)
1122 return evdev_device_get_output((struct evdev_device *) device);
1125 LIBINPUT_EXPORT struct libinput_seat *
1126 libinput_device_get_seat(struct libinput_device *device)
1128 return device->seat;
1131 LIBINPUT_EXPORT void
1132 libinput_device_led_update(struct libinput_device *device,
1133 enum libinput_led leds)
1135 evdev_device_led_update((struct evdev_device *) device, leds);
1139 libinput_device_get_keys(struct libinput_device *device,
1140 char *keys, size_t size)
1142 return evdev_device_get_keys((struct evdev_device *) device,
1147 LIBINPUT_EXPORT void
1148 libinput_device_calibrate(struct libinput_device *device,
1149 float calibration[6])
1151 evdev_device_calibrate((struct evdev_device *) device, calibration);
1155 libinput_device_has_capability(struct libinput_device *device,
1156 enum libinput_device_capability capability)
1158 return evdev_device_has_capability((struct evdev_device *) device,
1162 LIBINPUT_EXPORT struct libinput_event *
1163 libinput_event_device_notify_get_base_event(struct libinput_event_device_notify *event)
1165 return &event->base;
1168 LIBINPUT_EXPORT struct libinput_event *
1169 libinput_event_keyboard_get_base_event(struct libinput_event_keyboard *event)
1171 return &event->base;
1174 LIBINPUT_EXPORT struct libinput_event *
1175 libinput_event_pointer_get_base_event(struct libinput_event_pointer *event)
1177 return &event->base;
1180 LIBINPUT_EXPORT struct libinput_event *
1181 libinput_event_touch_get_base_event(struct libinput_event_touch *event)
1183 return &event->base;