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.
34 #define LIBINPUT_ATTRIBUTE_PRINTF(_format, _args) \
35 __attribute__ ((format (printf, _format, _args)))
39 * libinput is a generic input device handling library. It abstracts
40 * commonly-used concepts such as keyboard, pointer and touchpad handling
45 * @page tpbuttons Touchpad button behavior
47 * For touchpad devices without physical buttons, libinput enables an
48 * emulated right button area through either of two methods.
50 * Software button areas
51 * =====================
52 * On most touchpads, the bottom area of the touchpad is split into a a left
53 * and a right-button area. Pressing the touchpad down with a finger in
54 * those areas will generate clicks as shown in the diagram below:
57 +------------------------+
63 +------------------------+
65 +------------------------+
68 * Generally, the touchpad will emulate a right-button click if the finger
69 * was set down in the right button area and did not leave the
70 * right button area before clicking, even if another finger was already
71 * down on the touchpad in another area.
72 * A middle click is generated by clicking the touchpad when one finger is
73 * in the bottom left button area, and one finger is in the botton right
75 * The exact behavior of the touchpad is implementation-dependent.
77 * Top software button area
78 * ========================
79 * On selected touchpads, the top area of the touchpad is a separate set of
80 * software buttons split into a left, middle and right button area.
81 * Pressing the touchpad down with a finger in those areas will generate
82 * clicks as shown in the diagram below:
85 +------------------------+
86 | LEFT | MIDDLE | RIGHT |
87 +------------------------+
91 +------------------------+
93 +------------------------+
95 * This behavior is enabled on the Lenovo *40 series (T440, T540, T240...)
96 * and the Lenovo Helix, Yoga S1 and Carbon X1 2nd.
100 * On Apple touchpads, no button areas are provided. Instead, use a
101 * two-finger click for a right button click, and a three-finger click for a
102 * middle button click.
106 * Log priority for internal logging messages.
108 enum libinput_log_priority {
109 LIBINPUT_LOG_PRIORITY_DEBUG = 10,
110 LIBINPUT_LOG_PRIORITY_INFO = 20,
111 LIBINPUT_LOG_PRIORITY_ERROR = 30,
117 * Capabilities on a device. A device may have one or more capabilities
118 * at a time, and capabilities may appear or disappear during the
119 * lifetime of the device.
121 enum libinput_device_capability {
122 LIBINPUT_DEVICE_CAP_KEYBOARD = 0,
123 LIBINPUT_DEVICE_CAP_POINTER = 1,
124 LIBINPUT_DEVICE_CAP_TOUCH = 2
130 * Logical state of a key. Note that the logical state may not represent
131 * the physical state of the key.
133 enum libinput_key_state {
134 LIBINPUT_KEY_STATE_RELEASED = 0,
135 LIBINPUT_KEY_STATE_PRESSED = 1
141 * Mask reflecting LEDs on a device.
144 LIBINPUT_LED_NUM_LOCK = (1 << 0),
145 LIBINPUT_LED_CAPS_LOCK = (1 << 1),
146 LIBINPUT_LED_SCROLL_LOCK = (1 << 2)
152 * Logical state of a physical button. Note that the logical state may not
153 * represent the physical state of the button.
155 enum libinput_button_state {
156 LIBINPUT_BUTTON_STATE_RELEASED = 0,
157 LIBINPUT_BUTTON_STATE_PRESSED = 1
164 * Axes on a device that are not x or y coordinates.
166 enum libinput_pointer_axis {
167 LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL = 0,
168 LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL = 1,
171 /** @deprecated Use @ref LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL instead */
172 LIBINPUT_POINTER_AXIS_VERTICAL_SCROLL = LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL,
173 /** @deprecated Use @ref LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL instead */
174 LIBINPUT_POINTER_AXIS_HORIZONTAL_SCROLL = LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL
180 * Event type for events returned by libinput_get_event().
182 enum libinput_event_type {
184 * This is not a real event type, and is only used to tell the user that
185 * no new event is available in the queue. See
186 * libinput_next_event_type().
188 LIBINPUT_EVENT_NONE = 0,
191 * Signals that a device has been added to the context. The device will
192 * not be read until the next time the user calls libinput_dispatch()
193 * and data is available.
195 * This allows setting up initial device configuration before any events
198 LIBINPUT_EVENT_DEVICE_ADDED,
201 * Signals that a device has been removed. No more events from the
202 * associated device will be in the queue or be queued after this event.
204 LIBINPUT_EVENT_DEVICE_REMOVED,
206 LIBINPUT_EVENT_KEYBOARD_KEY = 300,
208 LIBINPUT_EVENT_POINTER_MOTION = 400,
209 LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE,
210 LIBINPUT_EVENT_POINTER_BUTTON,
211 LIBINPUT_EVENT_POINTER_AXIS,
213 LIBINPUT_EVENT_TOUCH_DOWN = 500,
214 LIBINPUT_EVENT_TOUCH_UP,
215 LIBINPUT_EVENT_TOUCH_MOTION,
216 LIBINPUT_EVENT_TOUCH_CANCEL,
218 * Signals the end of a set of touchpoints at one device sample
219 * time. This event has no coordinate information attached.
221 LIBINPUT_EVENT_TOUCH_FRAME
225 struct libinput_device;
226 struct libinput_seat;
228 struct libinput_event;
229 struct libinput_event_device_notify;
230 struct libinput_event_keyboard;
231 struct libinput_event_pointer;
234 * @ingroup event_touch
235 * @struct libinput_event_touch
237 * Touch event representing a touch down, move or up, as well as a touch
238 * cancel and touch frame events. Valid event types for this event are @ref
239 * LIBINPUT_EVENT_TOUCH_DOWN, @ref LIBINPUT_EVENT_TOUCH_MOTION, @ref
240 * LIBINPUT_EVENT_TOUCH_UP, @ref LIBINPUT_EVENT_TOUCH_CANCEL and @ref
241 * LIBINPUT_EVENT_TOUCH_FRAME.
243 struct libinput_event_touch;
246 * @defgroup event Accessing and destruction of events
254 * @param event An event retrieved by libinput_get_event().
257 libinput_event_destroy(struct libinput_event *event);
262 * Get the type of the event.
264 * @param event An event retrieved by libinput_get_event().
266 enum libinput_event_type
267 libinput_event_get_type(struct libinput_event *event);
272 * Get the libinput context from the event.
274 * @param event The libinput event
275 * @return The libinput context for this event.
278 libinput_event_get_context(struct libinput_event *event);
283 * Return the device associated with this event, if applicable. For device
284 * added/removed events this is the device added or removed. For all other
285 * device events, this is the device that generated the event.
287 * This device is not refcounted and its lifetime is that of the event. Use
288 * libinput_device_ref() before using the device outside of this scope.
290 * @return The device associated with this event
293 struct libinput_device *
294 libinput_event_get_device(struct libinput_event *event);
299 * Return the pointer event that is this input event. If the event type does
300 * not match the pointer event types, this function returns NULL.
302 * The inverse of this function is libinput_event_pointer_get_base_event().
304 * @return A pointer event, or NULL for other events
306 struct libinput_event_pointer *
307 libinput_event_get_pointer_event(struct libinput_event *event);
312 * Return the keyboard event that is this input event. If the event type does
313 * not match the keyboard event types, this function returns NULL.
315 * The inverse of this function is libinput_event_keyboard_get_base_event().
317 * @return A keyboard event, or NULL for other events
319 struct libinput_event_keyboard *
320 libinput_event_get_keyboard_event(struct libinput_event *event);
325 * Return the touch event that is this input event. If the event type does
326 * not match the touch event types, this function returns NULL.
328 * The inverse of this function is libinput_event_touch_get_base_event().
330 * @return A touch event, or NULL for other events
332 struct libinput_event_touch *
333 libinput_event_get_touch_event(struct libinput_event *event);
338 * Return the device event that is this input event. If the event type does
339 * not match the device event types, this function returns NULL.
341 * The inverse of this function is
342 * libinput_event_device_notify_get_base_event().
344 * @return A device event, or NULL for other events
346 struct libinput_event_device_notify *
347 libinput_event_get_device_notify_event(struct libinput_event *event);
352 * @return The generic libinput_event of this event
354 struct libinput_event *
355 libinput_event_device_notify_get_base_event(struct libinput_event_device_notify *event);
358 * @defgroup event_keyboard Keyboard events
360 * Key events are generated when a key changes its logical state, usually by
361 * being pressed or released.
365 * @ingroup event_keyboard
367 * @return The event time for this event
370 libinput_event_keyboard_get_time(struct libinput_event_keyboard *event);
373 * @ingroup event_keyboard
375 * @return The keycode that triggered this key event
378 libinput_event_keyboard_get_key(struct libinput_event_keyboard *event);
381 * @ingroup event_keyboard
383 * @return The state change of the key
385 enum libinput_key_state
386 libinput_event_keyboard_get_key_state(struct libinput_event_keyboard *event);
390 * @ingroup event_keyboard
392 * @return The generic libinput_event of this event
394 struct libinput_event *
395 libinput_event_keyboard_get_base_event(struct libinput_event_keyboard *event);
398 * @ingroup event_keyboard
400 * For the key of a LIBINPUT_EVENT_KEYBOARD_KEY event, return the total number
401 * of keys pressed on all devices on the associated seat after the event was
404 " @note It is an application bug to call this function for events other than
405 * LIBINPUT_EVENT_KEYBOARD_KEY. For other events, this function returns 0.
407 * @return the seat wide pressed key count for the key of this event
410 libinput_event_keyboard_get_seat_key_count(
411 struct libinput_event_keyboard *event);
414 * @defgroup event_pointer Pointer events
416 * Pointer events reflect motion, button and scroll events, as well as
417 * events from other axes.
421 * @ingroup event_pointer
423 * @return The event time for this event
426 libinput_event_pointer_get_time(struct libinput_event_pointer *event);
429 * @ingroup event_pointer
431 * Return the delta between the last event and the current event. For pointer
432 * events that are not of type LIBINPUT_EVENT_POINTER_MOTION, this function
435 * @note It is an application bug to call this function for events other than
436 * LIBINPUT_EVENT_POINTER_MOTION.
438 * @return the relative x movement since the last event
441 libinput_event_pointer_get_dx(struct libinput_event_pointer *event);
444 * @ingroup event_pointer
446 * Return the delta between the last event and the current event. For pointer
447 * events that are not of type LIBINPUT_EVENT_POINTER_MOTION, this function
450 * @note It is an application bug to call this function for events other than
451 * LIBINPUT_EVENT_POINTER_MOTION.
453 * @return the relative y movement since the last event
456 libinput_event_pointer_get_dy(struct libinput_event_pointer *event);
459 * @ingroup event_pointer
461 * Return the current absolute x coordinate of the pointer event, in mm from
462 * the top left corner of the device. To get the corresponding output screen
463 * coordinate, use libinput_event_pointer_get_x_transformed().
465 * For pointer events that are not of type
466 * LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE, this function returns 0.
468 * @note It is an application bug to call this function for events other than
469 * LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE.
471 * @return the current absolute x coordinate
474 libinput_event_pointer_get_absolute_x(struct libinput_event_pointer *event);
477 * @ingroup event_pointer
479 * Return the current absolute y coordinate of the pointer event, in mm from
480 * the top left corner of the device. To get the corresponding output screen
481 * coordinate, use libinput_event_pointer_get_x_transformed().
483 * For pointer events that are not of type
484 * LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE, this function returns 0.
486 * @note It is an application bug to call this function for events other than
487 * LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE.
489 * @return the current absolute y coordinate
492 libinput_event_pointer_get_absolute_y(struct libinput_event_pointer *event);
495 * @ingroup event_pointer
497 * Return the current absolute x coordinate of the pointer event, transformed to
498 * screen coordinates.
500 * For pointer events that are not of type
501 * LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE, the return value of this function is
504 * @note It is an application bug to call this function for events other than
505 * LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE.
507 * @param event The libinput pointer event
508 * @param width The current output screen width
509 * @return the current absolute x coordinate transformed to a screen coordinate
512 libinput_event_pointer_get_absolute_x_transformed(
513 struct libinput_event_pointer *event,
517 * @ingroup event_pointer
519 * Return the current absolute y coordinate of the pointer event, transformed to
520 * screen coordinates.
522 * For pointer events that are not of type
523 * LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE, the return value of this function is
526 * @note It is an application bug to call this function for events other than
527 * LIBINPUT_EVENT_POINTER_MOTION_ABSOLUTE.
529 * @param event The libinput pointer event
530 * @param height The current output screen height
531 * @return the current absolute y coordinate transformed to a screen coordinate
534 libinput_event_pointer_get_absolute_y_transformed(
535 struct libinput_event_pointer *event,
539 * @ingroup event_pointer
541 * Return the button that triggered this event.
542 * For pointer events that are not of type LIBINPUT_EVENT_POINTER_BUTTON,
543 * this function returns 0.
545 * @note It is an application bug to call this function for events other than
546 * LIBINPUT_EVENT_POINTER_BUTTON.
548 * @return the button triggering this event
551 libinput_event_pointer_get_button(struct libinput_event_pointer *event);
554 * @ingroup event_pointer
556 * Return the button state that triggered this event.
557 * For pointer events that are not of type LIBINPUT_EVENT_POINTER_BUTTON,
558 * this function returns 0.
560 * @note It is an application bug to call this function for events other than
561 * LIBINPUT_EVENT_POINTER_BUTTON.
563 * @return the button state triggering this event
565 enum libinput_button_state
566 libinput_event_pointer_get_button_state(struct libinput_event_pointer *event);
569 * @ingroup event_pointer
571 * For the button of a LIBINPUT_EVENT_POINTER_BUTTON event, return the total
572 * number of buttons pressed on all devices on the associated seat after the
573 * the event was triggered.
575 " @note It is an application bug to call this function for events other than
576 * LIBINPUT_EVENT_POINTER_BUTTON. For other events, this function returns 0.
578 * @return the seat wide pressed button count for the key of this event
581 libinput_event_pointer_get_seat_button_count(
582 struct libinput_event_pointer *event);
585 * @ingroup event_pointer
587 * Return the axis that triggered this event.
588 * For pointer events that are not of type LIBINPUT_EVENT_POINTER_AXIS,
589 * this function returns 0.
591 * @note It is an application bug to call this function for events other than
592 * LIBINPUT_EVENT_POINTER_AXIS.
594 * @return the axis triggering this event
596 enum libinput_pointer_axis
597 libinput_event_pointer_get_axis(struct libinput_event_pointer *event);
600 * @ingroup event_pointer
602 * Return the axis value of the given axis. The interpretation of the value
603 * is dependent on the axis. For the two scrolling axes
604 * LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL and
605 * LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, the value of the event is in
606 * relative scroll units, with the positive direction being down or right,
607 * respectively. The dimension of a scroll unit is equal to one unit of
608 * motion in the respective axis, where applicable (e.g. touchpad two-finger
611 * For pointer events that are not of type LIBINPUT_EVENT_POINTER_AXIS,
612 * this function returns 0.
614 * @note It is an application bug to call this function for events other than
615 * LIBINPUT_EVENT_POINTER_AXIS.
617 * @return the axis value of this event
620 libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event);
623 * @ingroup event_pointer
625 * @return The generic libinput_event of this event
627 struct libinput_event *
628 libinput_event_pointer_get_base_event(struct libinput_event_pointer *event);
632 * @defgroup event_touch Touch events
634 * Events from absolute touch devices.
638 * @ingroup event_touch
640 * @return The event time for this event
643 libinput_event_touch_get_time(struct libinput_event_touch *event);
646 * @ingroup event_touch
648 * Get the slot of this touch event. See the kernel's multitouch
649 * protocol B documentation for more information.
651 * If the touch event has no assigned slot, for example if it is from a
652 * single touch device, this function returns -1.
654 * @note this function should not be called for LIBINPUT_EVENT_TOUCH_CANCEL or
655 * LIBINPUT_EVENT_TOUCH_FRAME.
657 * @return The slot of this touch event
660 libinput_event_touch_get_slot(struct libinput_event_touch *event);
663 * @ingroup event_touch
665 * Get the seat slot of the touch event. A seat slot is a non-negative seat
666 * wide unique identifier of an active touch point.
668 * Events from single touch devices will be represented as one individual
669 * touch point per device.
671 * @note this function should not be called for LIBINPUT_EVENT_TOUCH_CANCEL or
672 * LIBINPUT_EVENT_TOUCH_FRAME.
674 * @return The seat slot of the touch event
677 libinput_event_touch_get_seat_slot(struct libinput_event_touch *event);
680 * @ingroup event_touch
682 * Return the current absolute x coordinate of the touch event, in mm from
683 * the top left corner of the device. To get the corresponding output screen
684 * coordinate, use libinput_event_touch_get_x_transformed().
686 * @note this function should only be called for LIBINPUT_EVENT_TOUCH_DOWN and
687 * LIBINPUT_EVENT_TOUCH_MOTION.
689 * @param event The libinput touch event
690 * @return the current absolute x coordinate
693 libinput_event_touch_get_x(struct libinput_event_touch *event);
696 * @ingroup event_touch
698 * Return the current absolute y coordinate of the touch event, in mm from
699 * the top left corner of the device. To get the corresponding output screen
700 * coordinate, use libinput_event_touch_get_y_transformed().
702 * For LIBINPUT_EVENT_TOUCH_UP 0 is returned.
704 * @note this function should only be called for LIBINPUT_EVENT_TOUCH_DOWN and
705 * LIBINPUT_EVENT_TOUCH_MOTION.
707 * @param event The libinput touch event
708 * @return the current absolute y coordinate
711 libinput_event_touch_get_y(struct libinput_event_touch *event);
714 * @ingroup event_touch
716 * Return the current absolute x coordinate of the touch event, transformed to
717 * screen coordinates.
719 * @note this function should only be called for LIBINPUT_EVENT_TOUCH_DOWN and
720 * LIBINPUT_EVENT_TOUCH_MOTION.
722 * @param event The libinput touch event
723 * @param width The current output screen width
724 * @return the current absolute x coordinate transformed to a screen coordinate
727 libinput_event_touch_get_x_transformed(struct libinput_event_touch *event,
731 * @ingroup event_touch
733 * Return the current absolute y coordinate of the touch event, transformed to
734 * screen coordinates.
736 * @note this function should only be called for LIBINPUT_EVENT_TOUCH_DOWN and
737 * LIBINPUT_EVENT_TOUCH_MOTION.
739 * @param event The libinput touch event
740 * @param height The current output screen height
741 * @return the current absolute y coordinate transformed to a screen coordinate
744 libinput_event_touch_get_y_transformed(struct libinput_event_touch *event,
748 * @ingroup event_touch
750 * @return The generic libinput_event of this event
752 struct libinput_event *
753 libinput_event_touch_get_base_event(struct libinput_event_touch *event);
756 * @defgroup base Initialization and manipulation of libinput contexts
759 struct libinput_interface {
761 * Open the device at the given path with the flags provided and
764 * @param path The device path to open
765 * @param flags Flags as defined by open(2)
766 * @param user_data The user_data provided in
767 * libinput_udev_create_for_seat()
769 * @return the file descriptor, or a negative errno on failure.
771 int (*open_restricted)(const char *path, int flags, void *user_data);
773 * Close the file descriptor.
775 * @param fd The file descriptor to close
776 * @param user_data The user_data provided in
777 * libinput_udev_create_for_seat()
779 void (*close_restricted)(int fd, void *user_data);
785 * Create a new libinput context from udev, for input devices matching
786 * the given seat ID. New devices or devices removed will appear as events
787 * during libinput_dispatch.
789 * libinput_udev_create_for_seat() succeeds even if no input device is
790 * available in this seat, or if devices are available but fail to open in
791 * @ref libinput_interface::open_restricted. Devices that do not have the
792 * minimum capabilities to be recognized as pointer, keyboard or touch
793 * device are ignored. Such devices and those that failed to open
794 * ignored until the next call to libinput_resume().
796 * @param interface The callback interface
797 * @param user_data Caller-specific data passed to the various callback
799 * @param udev An already initialized udev context
800 * @param seat_id A seat identifier. This string must not be NULL.
802 * @return An initialized libinput context, ready to handle events or NULL on
806 libinput_udev_create_for_seat(const struct libinput_interface *interface,
809 const char *seat_id);
814 * Create a new libinput context that requires the caller to manually add or
815 * remove devices with libinput_path_add_device() and
816 * libinput_path_remove_device().
818 * The context is fully initialized but will not generate events until at
819 * least one device has been added.
821 * @param interface The callback interface
822 * @param user_data Caller-specific data passed to the various callback
825 * @return An initialized, empty libinput context.
828 libinput_path_create_context(const struct libinput_interface *interface,
834 * Add a device to a libinput context initialized with
835 * libinput_path_create_context(). If successful, the device will be
836 * added to the internal list and re-opened on libinput_resume(). The device
837 * can be removed with libinput_path_remove_device().
839 * If the device was successfully initialized, it is returned in the device
840 * argument. The lifetime of the returned device pointer is limited until
841 * the next libinput_dispatch(), use libinput_device_ref() to keep a permanent
844 * @param libinput A previously initialized libinput context
845 * @param path Path to an input device
846 * @return The newly initiated device on success, or NULL on failure.
848 * @note It is an application bug to call this function on a libinput
849 * context initialized with libinput_udev_create_for_seat().
851 struct libinput_device *
852 libinput_path_add_device(struct libinput *libinput,
858 * Remove a device from a libinput context initialized with
859 * libinput_path_create_context() or added to such a context with
860 * libinput_path_add_device().
862 * Events already processed from this input device are kept in the queue,
863 * the LIBINPUT_EVENT_DEVICE_REMOVED event marks the end of events for this
866 * If no matching device exists, this function does nothing.
868 * @param device A libinput device
870 * @note It is an application bug to call this function on a libinput
871 * context initialized with libinput_udev_create_for_seat().
874 libinput_path_remove_device(struct libinput_device *device);
879 * libinput keeps a single file descriptor for all events. Call into
880 * libinput_dispatch() if any events become available on this fd.
882 * @return the file descriptor used to notify of pending events.
885 libinput_get_fd(struct libinput *libinput);
890 * Main event dispatchment function. Reads events of the file descriptors
891 * and processes them internally. Use libinput_get_event() to retrieve the
894 * Dispatching does not necessarily queue libinput events.
896 * @param libinput A previously initialized libinput context
898 * @return 0 on success, or a negative errno on failure
901 libinput_dispatch(struct libinput *libinput);
906 * Retrieve the next event from libinput's internal event queue.
908 * After handling the retrieved event, the caller must destroy it using
909 * libinput_event_destroy().
911 * @param libinput A previously initialized libinput context
912 * @return The next available event, or NULL if no event is available.
914 struct libinput_event *
915 libinput_get_event(struct libinput *libinput);
920 * Return the type of the next event in the internal queue. This function
921 * does not pop the event off the queue and the next call to
922 * libinput_get_event() returns that event.
924 * @param libinput A previously initialized libinput context
925 * @return The event type of the next available event or LIBINPUT_EVENT_NONE
926 * if no event is availble.
928 enum libinput_event_type
929 libinput_next_event_type(struct libinput *libinput);
934 * @param libinput A previously initialized libinput context
935 * @return the caller-specific data previously assigned in
936 * libinput_create_udev().
939 libinput_get_user_data(struct libinput *libinput);
944 * Resume a suspended libinput context. This re-enables device
945 * monitoring and adds existing devices.
947 * @param libinput A previously initialized libinput context
948 * @see libinput_suspend
950 * @return 0 on success or -1 on failure
953 libinput_resume(struct libinput *libinput);
958 * Suspend monitoring for new devices and close existing devices.
959 * This all but terminates libinput but does keep the context
960 * valid to be resumed with libinput_resume().
962 * @param libinput A previously initialized libinput context
965 libinput_suspend(struct libinput *libinput);
970 * Destroy the libinput context. After this, object references associated with
971 * the destroyed context are invalid and may not be interacted with.
973 * @param libinput A previously initialized libinput context
976 libinput_destroy(struct libinput *libinput);
981 * Set the global log priority. Messages with priorities equal to or
982 * higher than the argument will be printed to the current log handler.
984 * The default log priority is LIBINPUT_LOG_PRIORITY_ERROR.
986 * @param priority The minimum priority of log messages to print.
988 * @see libinput_log_set_handler
989 * @see libinput_log_get_priority
992 libinput_log_set_priority(enum libinput_log_priority priority);
997 * Get the global log priority. Messages with priorities equal to or
998 * higher than the argument will be printed to the current log handler.
1000 * The default log priority is LIBINPUT_LOG_PRIORITY_ERROR.
1002 * @return The minimum priority of log messages to print.
1004 * @see libinput_log_set_handler
1005 * @see libinput_log_set_priority
1007 enum libinput_log_priority
1008 libinput_log_get_priority(void);
1013 * Log handler type for custom logging.
1015 * @param priority The priority of the current message
1016 * @param user_data Caller-specific data pointer as previously passed into
1017 * libinput_log_set_handler()
1018 * @param format Message format in printf-style
1019 * @param args Message arguments
1021 * @see libinput_set_log_priority
1022 * @see libinput_log_set_handler
1024 typedef void (*libinput_log_handler)(enum libinput_log_priority priority,
1026 const char *format, va_list args)
1027 LIBINPUT_ATTRIBUTE_PRINTF(3, 0);
1032 * Set the global log handler. Messages with priorities equal to or higher
1033 * than the current log priority will be passed to the given
1036 * The default log handler prints to stderr.
1038 * @param log_handler The log handler for library messages.
1039 * @param user_data Caller-specific data pointer, passed into the log
1042 * @see libinput_log_set_handler
1045 libinput_log_set_handler(libinput_log_handler log_handler,
1049 * @defgroup seat Initialization and manipulation of seats
1051 * A seat has two identifiers, the physical name and the logical name. The
1052 * physical name is summarized as the list of devices a process on the same
1053 * physical seat has access to.
1055 * The logical seat name is the seat name for a logical group of devices. A
1056 * compositor may use that to create additonal seats as independent device
1057 * sets. Alternatively, a compositor may limit itself to a single logical
1058 * seat, leaving a second compositor to manage devices on the other logical
1062 * +---+--------+------------+------------------------+------------+
1063 * | | event0 | | | log seat A |
1064 * | K +--------+ | +------------+
1065 * | e | event1 | phys seat0 | libinput context 1 | |
1066 * | r +--------+ | | log seat B |
1067 * | n | event2 | | | |
1068 * | e +--------+------------+------------------------+------------+
1069 * | l | event3 | phys seat1 | libinput context 2 | log seat C |
1070 * +---+--------+------------+------------------------+------------+
1077 * Increase the refcount of the seat. A seat will be freed whenever the
1078 * refcount reaches 0. This may happen during dispatch if the
1079 * seat was removed from the system. A caller must ensure to reference
1080 * the seat correctly to avoid dangling pointers.
1082 * @param seat A previously obtained seat
1085 libinput_seat_ref(struct libinput_seat *seat);
1090 * Decrease the refcount of the seat. A seat will be freed whenever the
1091 * refcount reaches 0. This may happen during dispatch if the
1092 * seat was removed from the system. A caller must ensure to reference
1093 * the seat correctly to avoid dangling pointers.
1095 * @param seat A previously obtained seat
1098 libinput_seat_unref(struct libinput_seat *seat);
1103 * Set caller-specific data associated with this seat. libinput does
1104 * not manage, look at, or modify this data. The caller must ensure the
1107 * @param seat A previously obtained seat
1108 * @param user_data Caller-specific data pointer
1109 * @see libinput_seat_get_user_data
1112 libinput_seat_set_user_data(struct libinput_seat *seat, void *user_data);
1117 * Get the caller-specific data associated with this seat, if any.
1119 * @param seat A previously obtained seat
1120 * @return Caller-specific data pointer or NULL if none was set
1121 * @see libinput_seat_set_user_data
1124 libinput_seat_get_user_data(struct libinput_seat *seat);
1129 * Return the physical name of the seat. For libinput contexts created from
1130 * udev, this is always the same value as passed into
1131 * libinput_udev_create_for_seat() and all seats from that context will have
1132 * the same physical name.
1134 * The physical name of the seat is one that is usually set by the system or
1135 * lower levels of the stack. In most cases, this is the base filter for
1136 * devices - devices assigned to seats outside the current seat will not
1137 * be available to the caller.
1139 * @param seat A previously obtained seat
1140 * @return the physical name of this seat
1143 libinput_seat_get_physical_name(struct libinput_seat *seat);
1148 * Return the logical name of the seat. This is an identifier to group sets
1149 * of devices within the compositor.
1151 * @param seat A previously obtained seat
1152 * @return the logical name of this seat
1155 libinput_seat_get_logical_name(struct libinput_seat *seat);
1158 * @defgroup device Initialization and manipulation of input devices
1164 * Increase the refcount of the input device. An input device will be freed
1165 * whenever the refcount reaches 0. This may happen during dispatch if the
1166 * device was removed from the system. A caller must ensure to reference
1167 * the device correctly to avoid dangling pointers.
1169 * @param device A previously obtained device
1172 libinput_device_ref(struct libinput_device *device);
1177 * Decrease the refcount of the input device. An input device will be freed
1178 * whenever the refcount reaches 0. This may happen during dispatch if the
1179 * device was removed from the system. A caller must ensure to reference
1180 * the device correctly to avoid dangling pointers.
1182 * @param device A previously obtained device
1185 libinput_device_unref(struct libinput_device *device);
1190 * Set caller-specific data associated with this input device. libinput does
1191 * not manage, look at, or modify this data. The caller must ensure the
1194 * @param device A previously obtained device
1195 * @param user_data Caller-specific data pointer
1196 * @see libinput_device_get_user_data
1199 libinput_device_set_user_data(struct libinput_device *device, void *user_data);
1204 * Get the caller-specific data associated with this input device, if any.
1206 * @param device A previously obtained device
1207 * @return Caller-specific data pointer or NULL if none was set
1208 * @see libinput_device_set_user_data
1211 libinput_device_get_user_data(struct libinput_device *device);
1216 * Get the system name of the device.
1218 * @param device A previously obtained device
1219 * @return System name of the device
1222 libinput_device_get_sysname(struct libinput_device *device);
1227 * A device may be mapped to a single output, or all available outputs. If a
1228 * device is mapped to a single output only, a relative device may not move
1229 * beyond the boundaries of this output. An absolute device has its input
1230 * coordinates mapped to the extents of this output.
1232 * @return the name of the output this device is mapped to, or NULL if no
1236 libinput_device_get_output_name(struct libinput_device *device);
1241 * Get the seat associated with this input device.
1243 * A seat can be uniquely identified by the physical and logical seat name.
1244 * There will ever be only one seat instance with a given physical and logical
1245 * seat name pair at any given time, but if no external reference is kept, it
1246 * may be destroyed if no device belonging to it is left.
1248 * @param device A previously obtained device
1249 * @return The seat this input device belongs to
1251 struct libinput_seat *
1252 libinput_device_get_seat(struct libinput_device *device);
1257 * Update the LEDs on the device, if any. If the device does not have
1258 * LEDs, or does not have one or more of the LEDs given in the mask, this
1259 * function does nothing.
1261 * @param device A previously obtained device
1262 * @param leds A mask of the LEDs to set, or unset.
1265 libinput_device_led_update(struct libinput_device *device,
1266 enum libinput_led leds);
1271 * Set the bitmask in keys to the bitmask of the keys present on the device
1272 * (see linux/input.h), up to size characters.
1274 * @param device A current input device
1275 * @param keys An array filled with the bitmask for the keys
1276 * @param size Size of the keys array
1278 * @return The number of valid bytes in keys, or a negative errno on failure
1281 libinput_device_get_keys(struct libinput_device *device,
1282 char *keys, size_t size);
1287 * Apply the 3x3 transformation matrix to absolute device coordinates. This
1288 * matrix has no effect on relative events.
1290 * Given a 6-element array [a, b, c, d, e, f], the matrix is applied as
1298 libinput_device_calibrate(struct libinput_device *device,
1299 float calibration[6]);
1304 * Check if the given device has the specified capability
1306 * @return 1 if the given device has the capability or 0 if not
1309 libinput_device_has_capability(struct libinput_device *device,
1310 enum libinput_device_capability capability);
1315 * Get the physical size of a device in mm, where meaningful. This function
1316 * only succeeds on devices with the required data, i.e. tablets, touchpads
1319 * If this function returns nonzero, width and height are unmodified.
1321 * @param device The device
1322 * @param width Set to the width of the device
1323 * @param height Set to the height of the device
1324 * @return 0 on success, or nonzero otherwise
1327 libinput_device_get_size(struct libinput_device *device,
1335 #endif /* LIBINPUT_H */