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.
32 * libinput is a generic input device handling library. It abstracts
33 * commonly-used concepts such as keyboard, pointer and touchpad handling
38 * @ingroup fixed_point
40 * libinput 24.8 fixed point real number.
42 typedef int32_t li_fixed_t;
45 * Log priority for internal logging messages.
47 enum libinput_log_priority {
48 LIBINPUT_LOG_PRIORITY_DEBUG = 10,
49 LIBINPUT_LOG_PRIORITY_INFO = 20,
50 LIBINPUT_LOG_PRIORITY_ERROR = 30,
56 * Capabilities on a device. A device may have one or more capabilities
57 * at a time, and capabilities may appear or disappear during the
58 * lifteime of the device.
60 enum libinput_device_capability {
61 LIBINPUT_DEVICE_CAP_KEYBOARD = 0,
62 LIBINPUT_DEVICE_CAP_POINTER = 1,
63 LIBINPUT_DEVICE_CAP_TOUCH = 2
69 * Logical state of a key. Note that the logical state may not represent
70 * the physical state of the key.
72 enum libinput_keyboard_key_state {
73 LIBINPUT_KEYBOARD_KEY_STATE_RELEASED = 0,
74 LIBINPUT_KEYBOARD_KEY_STATE_PRESSED = 1
80 * Mask reflecting LEDs on a device.
83 LIBINPUT_LED_NUM_LOCK = (1 << 0),
84 LIBINPUT_LED_CAPS_LOCK = (1 << 1),
85 LIBINPUT_LED_SCROLL_LOCK = (1 << 2)
91 * Logical state of a physical button. Note that the logical state may not
92 * represent the physical state of the button.
94 enum libinput_pointer_button_state {
95 LIBINPUT_POINTER_BUTTON_STATE_RELEASED = 0,
96 LIBINPUT_POINTER_BUTTON_STATE_PRESSED = 1
103 * Axes on a device that are not x or y coordinates.
105 enum libinput_pointer_axis {
106 LIBINPUT_POINTER_AXIS_VERTICAL_SCROLL = 0,
107 LIBINPUT_POINTER_AXIS_HORIZONTAL_SCROLL = 1
113 * Logical touch state of a touch point. A touch point usually follows the
114 * sequence down, motion, up, with the number of motion events being zero or
115 * greater. If a touch point was used for gesture interpretation internally
116 * and will not generate any further events, the touchpoint is cancelled.
118 enum libinput_touch_type {
119 LIBINPUT_TOUCH_TYPE_DOWN = 0,
120 LIBINPUT_TOUCH_TYPE_UP = 1,
121 LIBINPUT_TOUCH_TYPE_MOTION = 2,
122 LIBINPUT_TOUCH_TYPE_CANCEL = 4
128 * Event type for events returned by libinput_get_event().
130 enum libinput_event_type {
132 * This is not a real event type, and is only used to tell the user that
133 * no new event is available in the queue. See
134 * libinput_next_event_type().
136 LIBINPUT_EVENT_NONE = 0,
139 * Signals that a device has been added to the context. The device will
140 * not be read until the next time the user calls libinput_dispatch()
141 * and data is available.
143 * This allows setting up initial device configuration before any events
146 LIBINPUT_EVENT_DEVICE_ADDED,
149 * Signals that a device has been removed. No more events from the
150 * associated device will be in the queue or be queued after this event.
152 LIBINPUT_EVENT_DEVICE_REMOVED,
154 LIBINPUT_EVENT_KEYBOARD_KEY = 300,
156 LIBINPUT_EVENT_POINTER_MOTION = 400,
157 LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE,
158 LIBINPUT_EVENT_POINTER_BUTTON,
159 LIBINPUT_EVENT_POINTER_AXIS,
161 LIBINPUT_EVENT_TOUCH_TOUCH = 500,
163 * Signals the end of a set of touchpoints at one device sample
164 * time. This event has no coordinate information attached.
166 LIBINPUT_EVENT_TOUCH_FRAME
170 struct libinput_device;
171 struct libinput_seat;
173 struct libinput_event;
174 struct libinput_event_device_notify;
175 struct libinput_event_keyboard;
176 struct libinput_event_pointer;
179 * @ingroup event_touch
180 * @struct libinput_event_touch
182 * Touch event representing a touch down, move or up, as well as a touch
183 * cancel and touch frame events. Valid event types for this event are @ref
184 * LIBINPUT_EVENT_TOUCH_TOUCH and @ref LIBINPUT_EVENT_TOUCH_FRAME.
186 struct libinput_event_touch;
189 * @defgroup fixed_point Fixed point utilities
193 * @ingroup fixed_point
195 * Convert li_fixed_t to a double
197 * @param f fixed point number
198 * @return Converted double
201 li_fixed_to_double (li_fixed_t f)
208 u.i = ((1023LL + 44LL) << 52) + (1LL << 51) + f;
210 return u.d - (3LL << 43);
214 * @ingroup fixed_point
216 * Convert li_fixed_t to a int. The fraction part is discarded.
218 * @param f fixed point number
219 * @return Converted int
222 li_fixed_to_int(li_fixed_t f)
228 * @defgroup event Acessing and destruction of events
236 * @param event An event retrieved by libinput_get_event().
239 libinput_event_destroy(struct libinput_event *event);
244 * Get the type of the event.
246 * @param event An event retrieved by libinput_get_event().
248 enum libinput_event_type
249 libinput_event_get_type(struct libinput_event *event);
254 * Get the libinput context from the event.
256 * @param event The libinput event
257 * @return The libinput context for this event.
260 libinput_event_get_context(struct libinput_event *event);
265 * Return the device associated with this event, if applicable. For device
266 * added/removed events this is the device added or removed. For all other
267 * device events, this is the device that generated the event.
269 * This device is not refcounted and its lifetime is that of the event. Use
270 * libinput_device_ref() before using the device outside of this scope.
272 * @return The device associated with this event
275 struct libinput_device *
276 libinput_event_get_device(struct libinput_event *event);
281 * Return the pointer event that is this input event. If the event type does
282 * not match the pointer event types, this function returns NULL.
284 * @return A pointer event, or NULL for other events
286 struct libinput_event_pointer *
287 libinput_event_get_pointer_event(struct libinput_event *event);
292 * Return the keyboard event that is this input event. If the event type does
293 * not match the keyboard event types, this function returns NULL.
295 * @return A keyboard event, or NULL for other events
297 struct libinput_event_keyboard *
298 libinput_event_get_keyboard_event(struct libinput_event *event);
303 * Return the touch event that is this input event. If the event type does
304 * not match the touch event types, this function returns NULL.
306 * @return A touch event, or NULL for other events
308 struct libinput_event_touch *
309 libinput_event_get_touch_event(struct libinput_event *event);
314 * Return the device event that is this input event. If the event type does
315 * not match the device event types, this function returns NULL.
317 * @return A device event, or NULL for other events
319 struct libinput_event_device_notify *
320 libinput_event_get_device_notify_event(struct libinput_event *event);
323 * @defgroup event_keyboard Keyboard events
325 * Key events are generated when a key changes its logical state, usually by
326 * being pressed or released.
330 * @ingroup event_keyboard
332 * @return The event time for this event
335 libinput_event_keyboard_get_time(struct libinput_event_keyboard *event);
338 * @ingroup event_keyboard
340 * @return The keycode that triggered this key event
343 libinput_event_keyboard_get_key(struct libinput_event_keyboard *event);
346 * @ingroup event_keyboard
348 * @return The state change of the key
350 enum libinput_keyboard_key_state
351 libinput_event_keyboard_get_key_state(struct libinput_event_keyboard *event);
354 * @defgroup event_pointer Pointer events
356 * Pointer events reflect motion, button and scroll events, as well as
357 * events from other axes.
361 * @ingroup event_pointer
363 * @return The event time for this event
366 libinput_event_pointer_get_time(struct libinput_event_pointer *event);
369 * @ingroup event_pointer
371 * Return the delta between the last event and the current event. For pointer
372 * events that are not of type LIBINPUT_EVENT_POINTER_MOTION, this function
375 * @note It is an application bug to call this function for events other than
376 * LIBINPUT_EVENT_POINTER_MOTION.
378 * @return the relative x movement since the last event
381 libinput_event_pointer_get_dx(struct libinput_event_pointer *event);
384 * @ingroup event_pointer
386 * Return the delta between the last event and the current event. For pointer
387 * events that are not of type LIBINPUT_EVENT_POINTER_MOTION, this function
390 * @note It is an application bug to call this function for events other than
391 * LIBINPUT_EVENT_POINTER_MOTION.
393 * @return the relative y movement since the last event
396 libinput_event_pointer_get_dy(struct libinput_event_pointer *event);
399 * @ingroup event_pointer
401 * Return the current absolute x coordinate of the pointer event.
403 * The coordinate is in a device specific coordinate space; to get the
404 * corresponding output screen coordinate, use
405 * libinput_event_pointer_get_x_transformed().
407 * For pointer events that are not of type
408 * LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE, this function returns 0.
410 * @note It is an application bug to call this function for events other than
411 * LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE.
413 * @return the current absolute x coordinate
416 libinput_event_pointer_get_absolute_x(struct libinput_event_pointer *event);
419 * @ingroup event_pointer
421 * Return the current absolute y coordinate of the pointer event.
423 * The coordinate is in a device specific coordinate space; to get the
424 * corresponding output screen coordinate, use
425 * libinput_event_pointer_get_y_transformed().
427 * For pointer events that are not of type
428 * LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE, this function returns 0.
430 * @note It is an application bug to call this function for events other than
431 * LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE.
433 * @return the current absolute y coordinate
436 libinput_event_pointer_get_absolute_y(struct libinput_event_pointer *event);
439 * @ingroup event_pointer
441 * Return the current absolute x coordinate of the pointer event, transformed to
442 * screen coordinates.
444 * For pointer events that are not of type
445 * LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE, the return value of this function is
448 * @note It is an application bug to call this function for events other than
449 * LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE.
451 * @param event The libinput pointer event
452 * @param width The current output screen width
453 * @return the current absolute x coordinate transformed to a screen coordinate
456 libinput_event_pointer_get_absolute_x_transformed(
457 struct libinput_event_pointer *event,
461 * @ingroup event_pointer
463 * Return the current absolute y coordinate of the pointer event, transformed to
464 * screen coordinates.
466 * For pointer events that are not of type
467 * LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE, the return value of this function is
470 * @note It is an application bug to call this function for events other than
471 * LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE.
473 * @param event The libinput pointer event
474 * @param height The current output screen height
475 * @return the current absolute y coordinate transformed to a screen coordinate
478 libinput_event_pointer_get_absolute_y_transformed(
479 struct libinput_event_pointer *event,
483 * @ingroup event_pointer
485 * Return the button that triggered this event.
486 * For pointer events that are not of type LIBINPUT_EVENT_POINTER_BUTTON,
487 * this function returns 0.
489 * @note It is an application bug to call this function for events other than
490 * LIBINPUT_EVENT_POINTER_BUTTON.
492 * @return the button triggering this event
495 libinput_event_pointer_get_button(struct libinput_event_pointer *event);
498 * @ingroup event_pointer
500 * Return the button state that triggered this event.
501 * For pointer events that are not of type LIBINPUT_EVENT_POINTER_BUTTON,
502 * this function returns 0.
504 * @note It is an application bug to call this function for events other than
505 * LIBINPUT_EVENT_POINTER_BUTTON.
507 * @return the button state triggering this event
509 enum libinput_pointer_button_state
510 libinput_event_pointer_get_button_state(struct libinput_event_pointer *event);
513 * @ingroup event_pointer
515 * Return the axis that triggered this event.
516 * For pointer events that are not of type LIBINPUT_EVENT_POINTER_AXIS,
517 * this function returns 0.
519 * @note It is an application bug to call this function for events other than
520 * LIBINPUT_EVENT_POINTER_AXIS.
522 * @return the axis triggering this event
524 enum libinput_pointer_axis
525 libinput_event_pointer_get_axis(struct libinput_event_pointer *event);
528 * @ingroup event_pointer
530 * Return the axis value of the given axis. The interpretation of the value
531 * is dependent on the axis. For the two scrolling axes
532 * LIBINPUT_POINTER_AXIS_VERTICAL_SCROLL and
533 * LIBINPUT_POINTER_AXIS_HORIZONTAL_SCROLL, the value of the event is in
534 * relative scroll units, with the positive direction being down or right,
535 * respectively. The dimension of a scroll unit is equal to one unit of
536 * motion in the respective axis, where applicable (e.g. touchpad two-finger
539 * For pointer events that are not of type LIBINPUT_EVENT_POINTER_AXIS,
540 * this function returns 0.
542 * @note It is an application bug to call this function for events other than
543 * LIBINPUT_EVENT_POINTER_AXIS.
545 * @return the axis value of this event
548 libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event);
551 * @defgroup event_touch Touch events
553 * Events from absolute touch devices.
557 * @ingroup event_touch
559 * @return The event time for this event
562 libinput_event_touch_get_time(struct libinput_event_touch *event);
565 * @ingroup event_touch
567 * Get the slot of this touch event. See the kernel's multitouch
568 * protocol B documentation for more information.
570 * If the touch event has no assigned slot, for example if it is from a
571 * single touch device, this function returns -1.
573 * @note this function should not be called for LIBINPUT_EVENT_TOUCH_FRAME.
575 * @return The slot of this touch event
578 libinput_event_touch_get_slot(struct libinput_event_touch *event);
581 * @ingroup event_touch
583 * Get the seat slot of the touch event. A seat slot is a non-negative seat
584 * wide unique identifier of an active touch point.
586 * Events from single touch devices will be represented as one individual
587 * touch point per device.
589 * @note this function should not be called for LIBINPUT_EVENT_TOUCH_FRAME.
591 * @return The seat slot of the touch event
594 libinput_event_touch_get_seat_slot(struct libinput_event_touch *event);
597 * @ingroup event_touch
599 * Return the current absolute x coordinate of the touch event.
601 * The coordinate is in a device specific coordinate space; to get the
602 * corresponding output screen coordinate, use
603 * libinput_event_touch_get_x_transformed().
605 * @note this function should not be called for LIBINPUT_EVENT_TOUCH_FRAME.
607 * @param event The libinput touch event
608 * @return the current absolute x coordinate
611 libinput_event_touch_get_x(struct libinput_event_touch *event);
614 * @ingroup event_touch
616 * Return the current absolute y coordinate of the touch event.
618 * The coordinate is in a device specific coordinate space; to get the
619 * corresponding output screen coordinate, use
620 * libinput_event_touch_get_y_transformed().
622 * @note this function should not be called for LIBINPUT_EVENT_TOUCH_FRAME.
624 * @param event The libinput touch event
625 * @return the current absolute y coordinate
628 libinput_event_touch_get_y(struct libinput_event_touch *event);
631 * @ingroup event_touch
633 * Return the current absolute x coordinate of the touch event, transformed to
634 * screen coordinates.
636 * @note this function should not be called for LIBINPUT_EVENT_TOUCH_FRAME.
638 * @param event The libinput touch event
639 * @param width The current output screen width
640 * @return the current absolute x coordinate transformed to a screen coordinate
643 libinput_event_touch_get_x_transformed(struct libinput_event_touch *event,
647 * @ingroup event_touch
649 * Return the current absolute y coordinate of the touch event, transformed to
650 * screen coordinates.
652 * @note this function should not be called for LIBINPUT_EVENT_TOUCH_FRAME.
654 * @param event The libinput touch event
655 * @param height The current output screen height
656 * @return the current absolute y coordinate transformed to a screen coordinate
659 libinput_event_touch_get_y_transformed(struct libinput_event_touch *event,
663 * @ingroup event_touch
665 * @note this function should not be called for LIBINPUT_EVENT_TOUCH_FRAME.
667 * @return the type of touch that occured on the device
669 enum libinput_touch_type
670 libinput_event_touch_get_touch_type(struct libinput_event_touch *event);
673 * @defgroup base Initialization and manipulation of libinput contexts
676 struct libinput_interface {
678 * Open the device at the given path with the flags provided and
681 * @param path The device path to open
682 * @param flags Flags as defined by open(2)
683 * @param user_data The user_data provided in
684 * libinput_udev_create_for_seat()
686 * @return the file descriptor, or a negative errno on failure.
688 int (*open_restricted)(const char *path, int flags, void *user_data);
690 * Close the file descriptor.
692 * @param fd The file descriptor to close
693 * @param user_data The user_data provided in
694 * libinput_udev_create_for_seat()
696 void (*close_restricted)(int fd, void *user_data);
702 * Create a new libinput context from udev, for input devices matching
703 * the given seat ID. New devices or devices removed will appear as events
704 * during libinput_dispatch.
706 * @param interface The callback interface
707 * @param user_data Caller-specific data passed to the various callback
709 * @param udev An already initialized udev context
710 * @param seat_id A seat identifier. This string must not be NULL.
712 * @return An initialized libinput context, ready to handle events or NULL on
716 libinput_udev_create_for_seat(const struct libinput_interface *interface,
719 const char *seat_id);
724 * Create a new libinput context that requires the caller to manually add or
725 * remove devices with libinput_path_add_device() and
726 * libinput_path_remove_device().
728 * The context is fully initialized but will not generate events until at
729 * least one device has been added.
731 * @param interface The callback interface
732 * @param user_data Caller-specific data passed to the various callback
735 * @return An initialized, empty libinput context.
738 libinput_path_create_context(const struct libinput_interface *interface,
744 * Add a device to a libinput context initialized with
745 * libinput_path_create_from_device(). If successful, the device will be
746 * added to the internal list and re-opened on libinput_resume(). The device
747 * can be removed with libinput_path_remove_device().
749 * If the device was successfully initialized, it is returned in the device
750 * argument. The lifetime of the returned device pointer is limited until
751 * the next linput_dispatch(), use libinput_device_ref() to keep a permanent
754 * @param libinput A previously initialized libinput context
755 * @param path Path to an input device
756 * @return The newly initiated device on success, or NULL on failure.
758 * @note It is an application bug to call this function on a libinput
759 * context initialize with libinput_udev_create_for_seat().
761 struct libinput_device *
762 libinput_path_add_device(struct libinput *libinput,
768 * Remove a device from a libinput context initialized with
769 * libinput_path_create_from_device() or added to such a context with
770 * libinput_path_add_device().
772 * Events already processed from this input device are kept in the queue,
773 * the LIBINPUT_EVENT_DEVICE_REMOVED event marks the end of events for this
776 * If no matching device exists, this function does nothing.
778 * @param device A libinput device
780 * @note It is an application bug to call this function on a libinput
781 * context initialize with libinput_udev_create_for_seat().
784 libinput_path_remove_device(struct libinput_device *device);
789 * libinput keeps a single file descriptor for all events. Call into
790 * libinput_dispatch() if any events become available on this fd.
792 * @return the file descriptor used to notify of pending events.
795 libinput_get_fd(struct libinput *libinput);
800 * Main event dispatchment function. Reads events of the file descriptors
801 * and processes them internally. Use libinput_get_event() to retrieve the
804 * Dispatching does not necessarily queue libinput events.
806 * @param libinput A previously initialized libinput context
808 * @return 0 on success, or a negative errno on failure
811 libinput_dispatch(struct libinput *libinput);
816 * Retrieve the next event from libinput's internal event queue.
818 * After handling the retrieved event, the caller must destroy it using
819 * libinput_event_destroy().
821 * @param libinput A previously initialized libinput context
822 * @return The next available event, or NULL if no event is available.
824 struct libinput_event *
825 libinput_get_event(struct libinput *libinput);
830 * Return the type of the next event in the internal queue. This function
831 * does not pop the event off the queue and the next call to
832 * libinput_get_event() returns that event.
834 * @param libinput A previously initialized libinput context
835 * @return The event type of the next available event or LIBINPUT_EVENT_NONE
836 * if no event is availble.
838 enum libinput_event_type
839 libinput_next_event_type(struct libinput *libinput);
844 * @param libinput A previously initialized libinput context
845 * @return the caller-specific data previously assigned in
846 * libinput_create_udev().
849 libinput_get_user_data(struct libinput *libinput);
854 * Resume a suspended libinput context. This re-enables device
855 * monitoring and adds existing devices.
857 * @param libinput A previously initialized libinput context
858 * @see libinput_suspend
860 * @return 0 on success or -1 on failure
863 libinput_resume(struct libinput *libinput);
868 * Suspend monitoring for new devices and close existing devices.
869 * This all but terminates libinput but does keep the context
870 * valid to be resumed with libinput_resume().
872 * @param libinput A previously initialized libinput context
875 libinput_suspend(struct libinput *libinput);
880 * Destroy the libinput context. After this, object references associated with
881 * the destroyed context are invalid and may not be interacted with.
883 * @param libinput A previously initialized libinput context
886 libinput_destroy(struct libinput *libinput);
891 * Set the global log priority. Messages with priorities equal to or
892 * higher than the argument will be printed to the current log handler.
894 * The default log priority is LIBINPUT_LOG_PRIORITY_ERROR.
896 * @param priority The minimum priority of log messages to print.
898 * @see libinput_log_set_handler
901 libinput_log_set_priority(enum libinput_log_priority priority);
906 * Get the global log priority. Messages with priorities equal to or
907 * higher than the argument will be printed to the current log handler.
909 * The default log priority is LIBINPUT_LOG_PRIORITY_ERROR.
911 * @return The minimum priority of log messages to print.
913 * @see libinput_log_set_handler
915 enum libinput_log_priority
916 libinput_log_get_priority(void);
921 * Log handler type for custom logging.
923 * @param priority The priority of the current message
924 * @param user_data Caller-specific data pointer as previously passed into
925 * libinput_log_set_handler()
926 * @param format Message format in printf-style
927 * @param args Message arguments
929 * @see libinput_set_log_priority
930 * @see libinput_log_set_handler
932 typedef void (*libinput_log_handler)(enum libinput_log_priority priority,
934 const char *format, va_list args);
939 * Set the global log handler. Messages with priorities equal to or higher
940 * than the current log priority will be passed to the given
943 * The default log handler prints to stderr.
945 * @param log_handler The log handler for library messages.
946 * @param user_data Caller-specific data pointer, passed into the log
949 * @see libinput_log_set_handler
952 libinput_log_set_handler(libinput_log_handler log_handler,
956 * @defgroup seat Initialization and manipulation of seats
958 * A seat has two identifiers, the physical name and the logical name. The
959 * physical name is summarized as the list of devices a process on the same
960 * physical seat has access to.
962 * The logical seat name is the seat name for a logical group of devices. A
963 * compositor may use that to create additonal seats as independent device
964 * sets. Alternatively, a compositor may limit itself to a single logical
965 * seat, leaving a second compositor to manage devices on the other logical
969 * +---+--------+------------+------------------------+------------+
970 * | | event0 | | | log seat A |
971 * | K +--------+ | +------------+
972 * | e | event1 | phys seat0 | libinput context 1 | |
973 * | r +--------+ | | log seat B |
974 * | n | event2 | | | |
975 * | e +--------+------------+------------------------+------------+
976 * | l | event3 | phys seat1 | libinput context 2 | log seat C |
977 * +---+--------+------------+------------------------+------------+
984 * Increase the refcount of the seat. A seat will be freed whenever the
985 * refcount reaches 0. This may happen during dispatch if the
986 * seat was removed from the system. A caller must ensure to reference
987 * the seat correctly to avoid dangling pointers.
989 * @param seat A previously obtained seat
992 libinput_seat_ref(struct libinput_seat *seat);
997 * Decrease the refcount of the seat. A seat will be freed whenever the
998 * refcount reaches 0. This may happen during dispatch if the
999 * seat was removed from the system. A caller must ensure to reference
1000 * the seat correctly to avoid dangling pointers.
1002 * @param seat A previously obtained seat
1005 libinput_seat_unref(struct libinput_seat *seat);
1010 * Set caller-specific data associated with this seat. libinput does
1011 * not manage, look at, or modify this data. The caller must ensure the
1014 * @param seat A previously obtained seat
1015 * @param user_data Caller-specific data pointer
1016 * @see libinput_seat_get_user_data
1019 libinput_seat_set_user_data(struct libinput_seat *seat, void *user_data);
1024 * Get the caller-specific data associated with this seat, if any.
1026 * @param seat A previously obtained seat
1027 * @return Caller-specific data pointer or NULL if none was set
1028 * @see libinput_seat_set_user_data
1031 libinput_seat_get_user_data(struct libinput_seat *seat);
1036 * Return the physical name of the seat. For libinput contexts created from
1037 * udev, this is always the same value as passed into
1038 * libinput_udev_create_for_seat() and all seats from that context will have
1039 * the same physical name.
1041 * The physical name of the seat is one that is usually set by the system or
1042 * lower levels of the stack. In most cases, this is the base filter for
1043 * devices - devices assigned to seats outside the current seat will not
1044 * be available to the caller.
1046 * @param seat A previously obtained seat
1047 * @return the physical name of this seat
1050 libinput_seat_get_physical_name(struct libinput_seat *seat);
1055 * Return the logical name of the seat. This is an identifier to group sets
1056 * of devices within the compositor.
1058 * @param seat A previously obtained seat
1059 * @return the logical name of this seat
1062 libinput_seat_get_logical_name(struct libinput_seat *seat);
1065 * @defgroup device Initialization and manipulation of input devices
1071 * Increase the refcount of the input device. An input device will be freed
1072 * whenever the refcount reaches 0. This may happen during dispatch if the
1073 * device was removed from the system. A caller must ensure to reference
1074 * the device correctly to avoid dangling pointers.
1076 * @param device A previously obtained device
1079 libinput_device_ref(struct libinput_device *device);
1084 * Decrease the refcount of the input device. An input device will be freed
1085 * whenever the refcount reaches 0. This may happen during dispatch if the
1086 * device was removed from the system. A caller must ensure to reference
1087 * the device correctly to avoid dangling pointers.
1089 * @param device A previously obtained device
1092 libinput_device_unref(struct libinput_device *device);
1097 * Set caller-specific data associated with this input device. libinput does
1098 * not manage, look at, or modify this data. The caller must ensure the
1101 * @param device A previously obtained device
1102 * @param user_data Caller-specific data pointer
1103 * @see libinput_device_get_user_data
1106 libinput_device_set_user_data(struct libinput_device *device, void *user_data);
1111 * Get the caller-specific data associated with this input device, if any.
1113 * @param device A previously obtained device
1114 * @return Caller-specific data pointer or NULL if none was set
1115 * @see libinput_device_set_user_data
1118 libinput_device_get_user_data(struct libinput_device *device);
1123 * Get the system name of the device.
1125 * @param device A previously obtained device
1126 * @return System name of the device
1129 libinput_device_get_sysname(struct libinput_device *device);
1134 * A device may be mapped to a single output, or all available outputs. If a
1135 * device is mapped to a single output only, a relative device may not move
1136 * beyond the boundaries of this output. An absolute device has its input
1137 * coordinates mapped to the extents of this output.
1139 * @return the name of the output this device is mapped to, or NULL if no
1143 libinput_device_get_output_name(struct libinput_device *device);
1148 * Get the seat associated with this input device.
1150 * A seat can be uniquely identified by the physical and logical seat name.
1151 * There will ever be only one seat instance with a given physical and logical
1152 * seat name pair at any given time, but if no external reference is kept, it
1153 * may be destroyed if no device belonging to it is left.
1155 * @param device A previously obtained device
1156 * @return The seat this input device belongs to
1158 struct libinput_seat *
1159 libinput_device_get_seat(struct libinput_device *device);
1164 * Update the LEDs on the device, if any. If the device does not have
1165 * LEDs, or does not have one or more of the LEDs given in the mask, this
1166 * function does nothing.
1168 * @param device A previously obtained device
1169 * @param leds A mask of the LEDs to set, or unset.
1172 libinput_device_led_update(struct libinput_device *device,
1173 enum libinput_led leds);
1178 * Set the bitmask in keys to the bitmask of the keys present on the device
1179 * (see linux/input.h), up to size characters.
1181 * @param device A current input device
1182 * @param keys An array filled with the bitmask for the keys
1183 * @param size Size of the keys array
1186 libinput_device_get_keys(struct libinput_device *device,
1187 char *keys, size_t size);
1192 * Apply the 3x3 transformation matrix to absolute device coordinates. This
1193 * matrix has no effect on relative events.
1195 * Given a 6-element array [a, b, c, d, e, f], the matrix is applied as
1203 libinput_device_calibrate(struct libinput_device *device,
1204 float calibration[6]);
1209 * Check if the given device has the specified capability
1211 * @return 1 if the given device has the capability or 0 if not
1214 libinput_device_has_capability(struct libinput_device *device,
1215 enum libinput_device_capability capability);
1217 #endif /* LIBINPUT_H */