2 * Copyright © 2013 Red Hat, Inc.
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
30 #include <linux/input.h>
36 * **libevdev** is a library for handling evdev kernel devices. It abstracts
37 * the \ref ioctls through type-safe interfaces and provides functions to change
38 * the appearance of the device.
40 * Development of libevdev is discussed on
41 * [input-tools@lists.freedesktop.org](http://lists.freedesktop.org/mailman/listinfo/input-tools)
42 * Please submit patches, questions or general comments there.
44 * Handling events and SYN_DROPPED
45 * ===============================
47 * libevdev provides an interface for handling events, including most notably
48 * SYN_DROPPED events. SYN_DROPPED events are sent by the kernel when the
49 * process does not read events fast enough and the kernel is forced to drop
50 * some events. This causes the device to get out of sync with the process'
51 * view of it. libevdev handles this by telling the caller that a SYN_DROPPED
52 * has been received and that the state of the device is different to what is
53 * to be expected. It then provides the delta between the previous state and
54 * the actual state of the device as a set of events. See
55 * libevdev_next_event() for more information.
60 * libevdev is signal-safe for the majority of its operations. Check the API
61 * documentation to make sure, unless explicitly stated a call is <b>not</b>
67 * libevdev does not attempt duplicate detection. Initializing two libevdev
68 * devices for the same fd is valid and behaves the same as for two different
71 * libevdev does not handle the file descriptors directly, it merely uses
72 * them. The caller is responsible for opening the file descriptors, setting
73 * them to O_NONBLOCK and handling permissions.
75 * Where does libevdev sit?
76 * ========================
78 * libevdev is essentially a `read(2)` on steroids for `/dev/input/eventX
79 * devices. It sits below the process that handles input events, in between
80 * the kernel and that process. In the simplest case, e.g. an evtest-like tool
81 * the stack would look like this:
83 * kernel → libevdev → evtest
85 * For X.Org input modules, the stack would look like this:
87 * kernel → libevdev → xf86-input-evdev → X server → X client
89 * For Weston/Wayland, the stack would look like this:
91 * kernel → libevdev → Weston → Wayland client
93 * libevdev does **not** have knowledge of X clients or Wayland clients, it is
94 * too low in the stack.
98 * Below is a simple example that shows how libevdev could be used. This example
99 * opens a device, checks for relative axes and a left mouse button and if it
100 * finds them monitors the device to print the event.
103 * struct libevdev *dev = NULL;
107 * fd = open("/dev/input/event0", O_RDONLY|O_NONBLOCK);
108 * rc = libevdev_new_from_fd(fd, &dev);
110 * fprintf(stderr, "Failed to init libevdev (%s)\n", strerror(-rc));
113 * printf("Input device name: \"%s\"\n", libevdev_get_name(dev));
114 * printf("Input device ID: bus %#x vendor %#x product %#x\n",
115 * libevdev_get_id_bustype(dev),
116 * libevdev_get_id_vendor(dev),
117 * libevdev_get_id_product(dev));
118 * if (!libevdev_has_event_type(dev, EV_REL) ||
119 * !libevdev_has_event_code(dev, EV_KEY, BTN_LEFT)) {
120 * printf("This device does not look like a mouse\n");
125 * struct input_event ev;
126 * rc = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL, &ev);
128 * printf("Event: %s %s %d\n",
129 * libevdev_get_event_type_name(ev.type),
130 * libevdev_get_event_code_name(ev.type, ev.code),
132 * } while (rc == 1 || rc == 0 || rc == -EAGAIN);
135 * A more complete example is available with the libevdev-events tool here:
136 * http://cgit.freedesktop.org/libevdev/tree/tools/libevdev-events.c
138 * Backwards compatibility with older kernel
139 * =========================================
140 * libevdev attempts to build and run correctly on a number of kernel versions.
141 * If features required are not available, libevdev attempts to work around them
142 * in the most reasonable way. For more details see \ref backwardscompatibility.
144 * License information
145 * ===================
146 * libevdev is licensed under the
147 * [X11 license](http://cgit.freedesktop.org/libevdev/tree/COPYING).
151 * Please report bugs in the freedesktop.org bugzilla under the libevdev product:
152 * https://bugs.freedesktop.org/enter_bug.cgi?product=libevdev
156 * @page testing libevdev-internal test suite
158 * libevdev's internal test suite uses the
159 * [Check unit testing framework](http://check.sourceforge.net/). Tests are
160 * divided into test suites and test cases. Most tests create a uinput device,
161 * so you'll need to run as root.
163 * To run a specific suite only:
165 * export CK_RUN_SUITE="suite name"
167 * To run a specific test case only:
169 * export CK_RUN_TEST="test case name"
171 * To get a list of all suites or tests:
173 * git grep "suite_create"
174 * git grep "tcase_create"
176 * By default, check forks, making debugging harder. Run gdb as below to avoid
179 * sudo CK_FORK=no CK_RUN_TEST="test case name" gdb ./test/test-libevdev
181 * A special target `make gcov-report.txt` exists that runs gcov and leaves a
182 * `libevdev.c.gcov` file. Check that for test coverage.
184 * `make check` is hooked up to run the test and gcov (again, needs root).
186 * The test suite creates a lot of devices, very quickly. Add the following
187 * xorg.conf.d snippet to avoid the devices being added as X devices (at the
188 * time of writing, mutter can't handle these devices and exits after getting
189 * a BadDevice error).
191 * $ cat /etc/X11/xorg.conf.d/99-ignore-libevdev-devices.conf
192 * Section "InputClass"
193 * Identifier "Ignore libevdev test devices"
194 * MatchProduct "libevdev test device"
195 * Option "Ignore" "on"
201 * @page backwardscompatibility Compatibility and Behavior across kernel versions
203 * This page describes libevdev's behavior when the build-time kernel and the
204 * run-time kernel differ in their feature set.
206 * With the exception of event names, libevdev defines features that may be
207 * missing on older kernels and building on such kernels will not disable
208 * features. Running libevdev on a kernel that is missing some feature will
209 * change libevdev's behavior. In most cases, the new behavior should be
210 * obvious, but it is spelled out below in detail.
212 * Minimum requirements
213 * ====================
214 * libevdev requires a 2.6.36 kernel as minimum. Specifically, it requires
215 * ABS_MT_SLOT and the matching behavior.
217 * Event and input property names
218 * ==============================
219 * Event names and input property names are defined at build-time by the
220 * linux/input.h shipped with libevedv.
221 * The list of event names is compiled at build-time and thus any events not defined
222 * at build time will not resolve. Specifically,
223 * libevdev_event_code_get_name(type, code) for an undefined type or code will
224 * always return NULL. Likewise, libevdev_property_get_name() will return NULL
225 * for properties undefined on the build system.
229 * If the kernel does not support input properties, specifically the
230 * EVIOCGPROPS ioctl, libevdev does not expose input properties to the caller.
231 * Specifically, libevdev_has_property() will always return 0 unless the
232 * property has been manually set with libevdev_enable_property().
234 * This also applies to the libevdev-uinput code. If uinput does not honor
235 * UI_SET_PROPBIT, libevdev will continue without setting the properties on
240 * If the kernel does not support the EVIOCGMTSLOTS ioctl, libevdev continues
241 * as normal and assumes all values in all slots to be 0.
243 * SYN_DROPPED behavior
244 * ====================
245 * A kernel without SYN_DROPPED, won't send the event. libevdev_next_event()
246 * will never require the switch to sync mode.
251 * @page ioctls evdev ioctls
253 * This page lists the status of the evdev-specific ioctls in libevdev.
256 * <dt>EVIOCGVERSION:</dt>
257 * <dd>supported, see libevdev_get_driver_version()</dd>
259 * <dd>supported, see libevdev_get_id_product(), libevdev_get_id_vendor(),
260 * libevdev_get_id_bustype(), * * libevdev_get_id_version()</dd>
261 * <dt>EVIOCGREP:</dt>
262 * <dd>supported, see libevdev_get_repeat()</dd>
263 * <dt>EVIOCSREP:</dt>
264 * <dd>supported, see libevdev_enable_event_code()</dd>
265 * <dt>EVIOCGKEYCODE:</dt>
266 * <dd>currently not supported</dd>
267 * <dt>EVIOCGKEYCODE:</dt>
268 * <dd>currently not supported</dd>
269 * <dt>EVIOCSKEYCODE:</dt>
270 * <dd>currently not supported</dd>
271 * <dt>EVIOCSKEYCODE:</dt>
272 * <dd>currently not supported</dd>
273 * <dt>EVIOCGNAME:</dt>
274 * <dd>supported, see libevdev_get_name()</dd>
275 * <dt>EVIOCGPHYS:</dt>
276 * <dd>supported, see libevdev_get_phys()</dd>
277 * <dt>EVIOCGUNIQ:</dt>
278 * <dd>supported, see libevdev_get_uniq()</dd>
279 * <dt>EVIOCGPROP:</dt>
280 * <dd>supported, see libevdev_has_property()</dd>
281 * <dt>EVIOCGMTSLOTS:</dt>
282 * <dd>supported, see libevdev_get_num_slots(), libevdev_get_slot_value()</dd>
283 * <dt>EVIOCGKEY:</dt>
284 * <dd>supported, see libevdev_has_event_code(), libevdev_get_event_value()</dd>
285 * <dt>EVIOCGLED:</dt>
286 * <dd>supported, see libevdev_has_event_code(), libevdev_get_event_value()</dd>
287 * <dt>EVIOCGSND:</dt>
288 * <dd>currently not supported</dd>
290 * <dd>supported, see libevdev_has_event_code(), libevdev_get_event_value()</dd>
291 * <dt>EVIOCGBIT:</dt>
292 * <dd>supported, see libevdev_has_event_code(), libevdev_get_event_value()</dd>
293 * <dt>EVIOCGABS:</dt>
294 * <dd>supported, see libevdev_has_event_code(), libevdev_get_event_value(),
295 * libevdev_get_abs_info()</dd>
296 * <dt>EVIOCSABS:</dt>
297 * <dd>supported, see libevdev_kernel_set_abs_info()</dd>
299 * <dd>currently not supported</dd>
300 * <dt>EVIOCRMFF:</dt>
301 * <dd>currently not supported</dd>
302 * <dt>EVIOCGEFFECTS:</dt>
303 * <dd>currently not supported</dd>
304 * <dt>EVIOCGRAB:</dt>
305 * <dd>supported, see libevdev_grab()</dd>
306 * <dt>EVIOCSCLOCKID:</dt>
307 * <dd>supported, see libevdev_set_clock_id()</dd>
313 * @defgroup init Initialization and setup
315 * Initialization, initial setup and file descriptor handling.
316 * These functions are the main entry points for users of libevdev, usually a
317 * caller will use this series of calls:
320 * struct libevdev *dev;
323 * dev = libevdev_new();
327 * err = libevdev_set_fd(dev, fd);
329 * printf("Failed (errno %d): %s\n", -err, strerror(-err));
331 * libevdev_free(dev);
334 * libevdev_set_fd() is the central call and initializes the internal structs
335 * for the device at the given fd. libevdev functions will fail if called
336 * before libevdev_set_fd() unless documented otherwise.
340 * @defgroup bits Querying device capabilities
342 * Abstraction functions to handle device capabilities, specificially
343 * device propeties such as the name of the device and the bits
344 * representing the events suppported by this device.
346 * The logical state returned may lag behind the physical state of the device.
347 * libevdev queries the device state on libevdev_set_fd() and then relies on
348 * the caller to parse events through libevdev_next_fd(). If a caller does not
349 * use libevdev_next_fd(), libevdev will not update the internal state of the
350 * device and thus returns outdated values.
354 * @defgroup mt Multi-touch related functions
355 * Functions for querying multi-touch-related capabilities. MT devices
356 * following the kernel protocol B (using ABS_MT_SLOT) provide multiple touch
357 * points through so-called slots on the same axis. The slots are enumerated,
358 * a client reading from the device will first get an ABS_MT_SLOT event, then
359 * the values of axes changed in this slot. Multiple slots may be provided in
360 * before an EV_SYN event.
362 * As with @ref bits, the logical state of the device as seen by the library
363 * depends on the caller using libevdev_next_event().
367 * @defgroup kernel Modifying the appearance or capabilities of the device
369 * Modifying the set of events reported by this device. By default, the
370 * libevdev device mirrors the kernel device, enabling only those bits
371 * exported by the kernel. This set of functions enable or disable bits as
372 * seen from the caller.
374 * Enabling an event type or code does not affect event reporting - a
375 * software-enabled event will not be generated by the physical hardware.
376 * Disabling an event will prevent libevdev from routing such events to the
377 * caller. Enabling and disabling event types and codes is at the library
378 * level and thus only affects the caller.
380 * If an event type or code is enabled at kernel-level, future users of this
381 * device will see this event enabled. Currently there is no option of
382 * disabling an event type or code at kernel-level.
386 * @defgroup misc Miscellaneous helper functions
388 * Functions for printing or querying event ranges. The list of names is
389 * compiled into libevdev and will not change when the kernel changes. Adding
390 * or removing names requires a re-compilation of libevdev. Likewise, the max
391 * for each event type is compiled in and does not check the underlying
396 * @defgroup events Event handling
398 * Functions to handle events and fetch the current state of the event. Generally,
399 * libevdev updates its internal state as the event is processed and forwarded
400 * to the caller. Thus, the libevdev state of the device should always be identical
401 * to the caller's state. It may however lag behind the actual state of the device.
407 * Opaque struct representing an evdev device.
414 enum libevdev_read_flag {
415 LIBEVDEV_READ_FLAG_SYNC = 1, /**< Process data in sync mode */
416 LIBEVDEV_READ_FLAG_NORMAL = 2, /**< Process data in normal mode */
417 LIBEVDEV_READ_FLAG_FORCE_SYNC = 4, /**< Pretend the next event is a SYN_DROPPED and
418 require the caller to sync */
419 LIBEVDEV_READ_FLAG_BLOCKING = 8 /**< The fd is not in O_NONBLOCK and a read may block */
425 * Initialize a new libevdev device. This function only allocates the
426 * required memory and initializes the struct to sane default values.
427 * To actually hook up the device to a kernel device, use
430 * Memory allocated through libevdev_new() must be released by the
431 * caller with libevdev_free().
433 * @see libevdev_set_fd
436 struct libevdev* libevdev_new(void);
441 * Initialize a new libevdev device from the given fd.
443 * This is a shortcut for
447 * struct libevdev *dev = libevdev_new();
448 * err = libevdev_set_fd(dev, fd);
451 * @param fd A file descriptor to the device in O_RDWR or O_RDONLY mode.
452 * @param[out] dev The newly initialized evdev device.
454 * @return On success, zero is returned and dev is set to the newly
455 * allocated struct. On failure, a negative errno is returned and the value
456 * of dev is undefined.
460 int libevdev_new_from_fd(int fd, struct libevdev **dev);
465 * Clean up and free the libevdev struct. After completion, the <code>struct
466 * libevdev</code> is invalid and must not be used.
468 * @param dev The evdev device
470 * @note This function may be called before libevdev_set_fd().
472 void libevdev_free(struct libevdev *dev);
477 enum libevdev_log_priority {
478 LIBEVDEV_LOG_ERROR = 10, /**< critical errors and application bugs */
479 LIBEVDEV_LOG_INFO = 20, /**< informational messages */
480 LIBEVDEV_LOG_DEBUG = 30 /**< debug information */
486 * Logging function called by library-internal logging.
487 * This function is expected to treat its input like printf would.
489 * @param priority Log priority of this message
490 * @param data User-supplied data pointer (see libevdev_set_log_function())
491 * @param file libevdev source code file generating this message
492 * @param line libevdev source code line generating this message
493 * @param func libevdev source code function generating this message
494 * @param format printf-style format string
495 * @param args List of arguments
497 * @see libevdev_set_log_function
499 typedef void (*libevdev_log_func_t)(enum libevdev_log_priority priority,
501 const char *file, int line,
503 const char *format, va_list args);
508 * Set a printf-style logging handler for library-internal logging. The default
509 * logging function is to stdout.
511 * @param logfunc The logging function for this device. If NULL, the current
512 * logging function is unset and no logging is performed.
513 * @param data User-specific data passed to the log handler.
515 * @note This function may be called before libevdev_set_fd().
517 void libevdev_set_log_function(libevdev_log_func_t logfunc, void *data);
522 * Define the minimum level to be printed to the log handler.
523 * Messages higher than this level are printed, others are discarded. This
524 * is a global setting and applies to any future logging messages.
526 * @param priority Minimum priority to be printed to the log.
529 void libevdev_set_log_priority(enum libevdev_log_priority priority);
534 * @return the current log level
536 enum libevdev_log_priority libevdev_get_log_priority(void);
541 enum libevdev_grab_mode {
542 LIBEVDEV_GRAB = 3, /**< Grab the device if not currently grabbed */
543 LIBEVDEV_UNGRAB = 4 /**< Ungrab the device if currently grabbed */
549 * Grab or ungrab the device through a kernel EVIOCGRAB. This prevents other
550 * clients (including kernel-internal ones such as rfkill) from receiving
551 * events from this device.
553 * This is generally a bad idea. Don't do this.
555 * Grabbing an already grabbed device, or ungrabbing an ungrabbed device is
556 * a noop and always succeeds.
558 * @param dev The evdev device, already initialized with libevdev_set_fd()
559 * @param grab If true, grab the device. Otherwise ungrab the device.
561 * @return 0 if the device was successfull grabbed or ungrabbed, or a
562 * negative errno in case of failure.
564 int libevdev_grab(struct libevdev *dev, enum libevdev_grab_mode grab);
569 * Set the fd for this struct and initialize internal data.
570 * The fd must be in O_RDONLY or O_RDWR mode.
572 * This function may only be called once per device. If the device changed and
573 * you need to re-read a device, use libevdev_free() and libevdev_new(). If
574 * you need to change the fd after closing and re-opening the same device, use
575 * libevdev_change_fd().
577 * Unless otherwise specified, libevdev function behavior is undefined until
578 * a successfull call to libevdev_set_fd().
580 * @param dev The evdev device
581 * @param fd The file descriptor for the device
583 * @return 0 on success, or a negative error code on failure
585 * @see libevdev_change_fd
589 int libevdev_set_fd(struct libevdev* dev, int fd);
594 * Change the fd for this device, without re-reading the actual device. If the fd
595 * changes after initializing the device, for example after a VT-switch in the
596 * X.org X server, this function updates the internal fd to the newly opened.
597 * No check is made that new fd points to the same device. If the device has
598 * changed, libevdev's behavior is undefined.
600 * libevdev does not sync itself after changing the fd and keeps the current
601 * device state. Use libevdev_next_event with the LIBEVDEV_FORCE_SYNC flag to
604 * The fd may be open in O_RDONLY or O_RDWR.
606 * It is an error to call this function before calling libevdev_set_fd().
608 * @param dev The evdev device, already initialized with libevdev_set_fd()
609 * @param fd The new fd
611 * @return 0 on success, or -1 on failure.
613 * @see libevdev_set_fd
615 int libevdev_change_fd(struct libevdev* dev, int fd);
620 * @param dev The evdev device
622 * @return The previously set fd, or -1 if none had been set previously.
623 * @note This function may be called before libevdev_set_fd().
625 int libevdev_get_fd(const struct libevdev* dev);
631 enum libevdev_read_status {
633 * libevdev_next_event() has finished without an error
634 * and an event is available for processing.
636 * @see libevdev_next_event
638 LIBEVDEV_READ_STATUS_SUCCESS = 0,
640 * Depending on the libevdev_next_event() read flag:
641 * * libevdev received a SYN_DROPPED from the device, and the caller should
642 * now resync the device, or,
643 * * an event has been read in sync mode.
645 * @see libevdev_next_event
647 LIBEVDEV_READ_STATUS_SYNC = 1
652 * Get the next event from the device. This function operates in two different
653 * modes: normal mode or sync mode.
655 * In normal mode, this function returns LIBEVDEV_READ_STATUS_SUCCESS and
656 * returns the event in the parameter ev. If no events are available at this
657 * time, it returns -EAGAIN and ev is undefined.
659 * If a SYN_DROPPED is read from the device, this function returns
660 * LIBEVDEV_READ_STATUS_SYNC. The caller should now call this function with the
661 * LIBEVDEV_READ_FLAG_SYNC flag set, to get the set of events that make up the
662 * device state delta. This function returns LIBEVDEV_READ_STATUS_SYNC for
663 * each event part of that delta, until it returns -EAGAIN once all events
666 * If a device needs to be synced by the caller but the caller does not call
667 * with the LIBEVDEV_READ_STATUS_SYNC flag set, all events from the diff are
668 * dropped and event processing continues as normal.
670 * @param dev The evdev device, already initialized with libevdev_set_fd()
671 * @param flags Set of flags to determine behaviour. If LIBEVDEV_READ_FLAG_NORMAL
672 * is set, the next event is read in normal mode. If LIBEVDEV_READ_FLAG_SYNC is
673 * set, the next event is read in sync mode.
674 * @param ev On success, set to the current event.
675 * @return On failure, a negative errno is returned.
676 * @retval LIBEVDEV_READ_STATUS_SUCCESS One or more events where read of the device
677 * @retval -EAGAIN No events are currently available on the device
678 * @retval LIBEVDEV_READ_STATUS_SYNC A SYN_DROPPED event was received, or a
679 * synced event was returned.
681 * @note This function is signal-safe.
683 int libevdev_next_event(struct libevdev *dev, unsigned int flags, struct input_event *ev);
688 * Check if there are events waiting for us. This does not read an event off
689 * the fd and may not access the fd at all. If there are events queued
690 * internally this function will return non-zero. If the internal queue is empty,
691 * this function will poll the file descriptor for data.
693 * This is a convenience function for simple processes, most complex programs
694 * are expected to use select(2) or poll(2) on the file descriptor. The kernel
695 * guarantees that if data is available, it is a multiple of sizeof(struct
696 * input_event), and thus calling libevdev_next_event() when select(2) or
697 * poll(2) return is safe. You do not need libevdev_has_event_pending() if
698 * you're using select(2) or poll(2).
700 * @param dev The evdev device, already initialized with libevdev_set_fd()
701 * @return On failure, a negative errno is returned.
702 * @retval 0 No event is currently available
703 * @retval 1 One or more events are available on the fd
705 * @note This function is signal-safe.
707 int libevdev_has_event_pending(struct libevdev *dev);
712 * @param dev The evdev device, already initialized with libevdev_set_fd()
714 * @return The device name as read off the kernel device. The name is never
715 * NULL but it may be the empty string.
717 * @note This function is signal-safe.
719 const char* libevdev_get_name(const struct libevdev *dev);
724 * @param dev The evdev device
725 * @param name The new, non-NULL, name to assign to this device.
727 * @note This function may be called before libevdev_set_fd(). A call to
728 * libevdev_set_fd() will overwrite any previously set value.
730 void libevdev_set_name(struct libevdev *dev, const char *name);
735 * Virtual devices such as uinput devices have no phys location.
737 * @param dev The evdev device, already initialized with libevdev_set_fd()
739 * @return The physical location of this device, or NULL if there is none
741 * @note This function is signal safe.
743 const char * libevdev_get_phys(const struct libevdev *dev);
748 * @param dev The evdev device
749 * @param phys The new, non-NULL, phys to assign to this device.
751 * @note This function may be called before libevdev_set_fd(). A call to
752 * libevdev_set_fd() will overwrite any previously set value.
754 void libevdev_set_phys(struct libevdev *dev, const char *phys);
759 * @param dev The evdev device, already initialized with libevdev_set_fd()
761 * @return The unique identifier for this device, or NULL if there is none
763 * @note This function is signal safe.
765 const char * libevdev_get_uniq(const struct libevdev *dev);
770 * @param dev The evdev device
771 * @param uniq The new, non-NULL, uniq to assign to this device.
773 * @note This function may be called before libevdev_set_fd(). A call to
774 * libevdev_set_fd() will overwrite any previously set value.
776 void libevdev_set_uniq(struct libevdev *dev, const char *uniq);
781 * @param dev The evdev device, already initialized with libevdev_set_fd()
783 * @return The device's product ID
785 * @note This function is signal-safe.
787 int libevdev_get_id_product(const struct libevdev *dev);
792 * @param dev The evdev device
793 * @param product_id The product ID to assign to this device
795 * @note This function may be called before libevdev_set_fd(). A call to
796 * libevdev_set_fd() will overwrite any previously set value.
798 void libevdev_set_id_product(struct libevdev *dev, int product_id);
803 * @param dev The evdev device, already initialized with libevdev_set_fd()
805 * @return The device's vendor ID
807 * @note This function is signal-safe.
809 int libevdev_get_id_vendor(const struct libevdev *dev);
814 * @param dev The evdev device
815 * @param vendor_id The vendor ID to assign to this device
817 * @note This function may be called before libevdev_set_fd(). A call to
818 * libevdev_set_fd() will overwrite any previously set value.
820 void libevdev_set_id_vendor(struct libevdev *dev, int vendor_id);
825 * @param dev The evdev device, already initialized with libevdev_set_fd()
827 * @return The device's bus type
829 * @note This function is signal-safe.
831 int libevdev_get_id_bustype(const struct libevdev *dev);
836 * @param dev The evdev device
837 * @param bustype The bustype to assign to this device
839 * @note This function may be called before libevdev_set_fd(). A call to
840 * libevdev_set_fd() will overwrite any previously set value.
842 void libevdev_set_id_bustype(struct libevdev *dev, int bustype);
847 * @param dev The evdev device, already initialized with libevdev_set_fd()
849 * @return The device's firmware version
851 * @note This function is signal-safe.
853 int libevdev_get_id_version(const struct libevdev *dev);
858 * @param dev The evdev device
859 * @param version The version to assign to this device
861 * @note This function may be called before libevdev_set_fd(). A call to
862 * libevdev_set_fd() will overwrite any previously set value.
864 void libevdev_set_id_version(struct libevdev *dev, int version);
869 * @param dev The evdev device, already initialized with libevdev_set_fd()
871 * @return The driver version for this device
873 * @note This function is signal-safe.
875 int libevdev_get_driver_version(const struct libevdev *dev);
880 * @param dev The evdev device, already initialized with libevdev_set_fd()
881 * @param prop The input property to query for, one of INPUT_PROP_...
883 * @return 1 if the device provides this input property, or 0 otherwise.
885 * @note This function is signal-safe
887 int libevdev_has_property(const struct libevdev *dev, unsigned int prop);
892 * @param dev The evdev device
893 * @param prop The input property to enable, one of INPUT_PROP_...
895 * @return 0 on success or -1 on failure
897 * @note This function may be called before libevdev_set_fd(). A call to
898 * libevdev_set_fd() will overwrite any previously set value.
900 int libevdev_enable_property(struct libevdev *dev, unsigned int prop);
905 * @param dev The evdev device, already initialized with libevdev_set_fd()
906 * @param type The event type to query for, one of EV_SYN, EV_REL, etc.
908 * @return 1 if the device supports this event type, or 0 otherwise.
910 * @note This function is signal-safe.
912 int libevdev_has_event_type(const struct libevdev *dev, unsigned int type);
917 * @param dev The evdev device, already initialized with libevdev_set_fd()
918 * @param type The event type for the code to query (EV_SYN, EV_REL, etc.)
919 * @param code The event code to query for, one of ABS_X, REL_X, etc.
921 * @return 1 if the device supports this event type and code, or 0 otherwise.
923 * @note This function is signal-safe.
925 int libevdev_has_event_code(const struct libevdev *dev, unsigned int type, unsigned int code);
930 * Get the minimum axis value for the given axis, as advertised by the kernel.
932 * @param dev The evdev device, already initialized with libevdev_set_fd()
933 * @param code The EV_ABS event code to query for, one of ABS_X, ABS_Y, etc.
935 * @return axis minimum for the given axis or 0 if the axis is invalid
937 int libevdev_get_abs_minimum(const struct libevdev *dev, unsigned int code);
941 * Get the maximum axis value for the given axis, as advertised by the kernel.
943 * @param dev The evdev device, already initialized with libevdev_set_fd()
944 * @param code The EV_ABS event code to query for, one of ABS_X, ABS_Y, etc.
946 * @return axis maximum for the given axis or 0 if the axis is invalid
948 int libevdev_get_abs_maximum(const struct libevdev *dev, unsigned int code);
952 * Get the axis fuzz for the given axis, as advertised by the kernel.
954 * @param dev The evdev device, already initialized with libevdev_set_fd()
955 * @param code The EV_ABS event code to query for, one of ABS_X, ABS_Y, etc.
957 * @return axis fuzz for the given axis or 0 if the axis is invalid
959 int libevdev_get_abs_fuzz(const struct libevdev *dev, unsigned int code);
963 * Get the axis flat for the given axis, as advertised by the kernel.
965 * @param dev The evdev device, already initialized with libevdev_set_fd()
966 * @param code The EV_ABS event code to query for, one of ABS_X, ABS_Y, etc.
968 * @return axis flat for the given axis or 0 if the axis is invalid
970 int libevdev_get_abs_flat(const struct libevdev *dev, unsigned int code);
974 * Get the axis resolution for the given axis, as advertised by the kernel.
976 * @param dev The evdev device, already initialized with libevdev_set_fd()
977 * @param code The EV_ABS event code to query for, one of ABS_X, ABS_Y, etc.
979 * @return axis resolution for the given axis or 0 if the axis is invalid
981 int libevdev_get_abs_resolution(const struct libevdev *dev, unsigned int code);
986 * Get the axis info for the given axis, as advertised by the kernel.
988 * @param dev The evdev device, already initialized with libevdev_set_fd()
989 * @param code The EV_ABS event code to query for, one of ABS_X, ABS_Y, etc.
991 * @return The input_absinfo for the given code, or NULL if the device does
992 * not support this event code.
994 const struct input_absinfo* libevdev_get_abs_info(const struct libevdev *dev, unsigned int code);
999 * Behaviour of this function is undefined if the device does not provide
1002 * If the device supports ABS_MT_SLOT, the value returned for any ABS_MT_*
1003 * event code is the value of the currently active slot. You should use
1004 * libevdev_get_slot_value() instead.
1006 * @param dev The evdev device, already initialized with libevdev_set_fd()
1007 * @param type The event type for the code to query (EV_SYN, EV_REL, etc.)
1008 * @param code The event code to query for, one of ABS_X, REL_X, etc.
1010 * @return The current value of the event.
1012 * @note This function is signal-safe.
1013 * @note The value for ABS_MT_ events is undefined, use
1014 * libevdev_get_slot_value() instead
1016 * @see libevdev_get_slot_value
1018 int libevdev_get_event_value(const struct libevdev *dev, unsigned int type, unsigned int code);
1023 * Set the value for a given event type and code. This only makes sense for
1024 * some event types, e.g. setting the value for EV_REL is pointless.
1026 * This is a local modification only affecting only this representation of
1027 * this device. A future call to libevdev_get_event_value() will return this
1028 * value, unless the value was overwritten by an event.
1030 * If the device supports ABS_MT_SLOT, the value set for any ABS_MT_*
1031 * event code is the value of the currently active slot. You should use
1032 * libevdev_set_slot_value() instead.
1034 * @param dev The evdev device, already initialized with libevdev_set_fd()
1035 * @param type The event type for the code to query (EV_SYN, EV_REL, etc.)
1036 * @param code The event code to set the value for, one of ABS_X, LED_NUML, etc.
1037 * @param value The new value to set
1039 * @return 0 on success, or -1 on failure.
1040 * @retval -1 the device does not have the event type or code enabled, or the code is outside the
1041 * allowed limits for the given type, or the type cannot be set.
1043 * @see libevdev_set_slot_value
1044 * @see libevdev_get_event_value
1046 int libevdev_set_event_value(struct libevdev *dev, unsigned int type, unsigned int code, int value);
1051 * Fetch the current value of the event type. This is a shortcut for
1054 * if (libevdev_has_event_type(dev, t) && libevdev_has_event_code(dev, t, c))
1055 * val = libevdev_get_event_value(dev, t, c);
1058 * @param dev The evdev device, already initialized with libevdev_set_fd()
1059 * @param type The event type for the code to query (EV_SYN, EV_REL, etc.)
1060 * @param code The event code to query for, one of ABS_X, REL_X, etc.
1061 * @param[out] value The current value of this axis returned.
1063 * @return If the device supports this event type and code, the return value is
1064 * non-zero and value is set to the current value of this axis. Otherwise,
1065 * zero is returned and value is unmodified.
1067 * @note This function is signal-safe.
1068 * @note The value for ABS_MT_ events is undefined, use
1069 * libevdev_fetch_slot_value() instead
1071 * @see libevdev_fetch_slot_value
1073 int libevdev_fetch_event_value(const struct libevdev *dev, unsigned int type, unsigned int code, int *value);
1078 * Return the current value of the code for the given slot.
1080 * The return value is undefined for a slot exceeding the available slots on
1081 * the device, for a code that is not in the permitted ABS_MT range or for a
1082 * device that does not have slots.
1084 * @param dev The evdev device, already initialized with libevdev_set_fd()
1085 * @param slot The numerical slot number, must be smaller than the total number
1086 * of slots on this device
1087 * @param code The event code to query for, one of ABS_MT_POSITION_X, etc.
1089 * @note This function is signal-safe.
1090 * @note The value for events other than ABS_MT_ is undefined, use
1091 * libevdev_fetch_value() instead
1093 * @see libevdev_get_event_value
1095 int libevdev_get_slot_value(const struct libevdev *dev, unsigned int slot, unsigned int code);
1100 * Set the value for a given code for the given slot.
1102 * This is a local modification only affecting only this representation of
1103 * this device. A future call to libevdev_get_slot_value() will return this
1104 * value, unless the value was overwritten by an event.
1106 * This function does not set event values for axes outside the ABS_MT range,
1107 * use libevdev_set_event_value() instead.
1109 * @param dev The evdev device, already initialized with libevdev_set_fd()
1110 * @param slot The numerical slot number, must be smaller than the total number
1111 * of slots on this device
1112 * @param code The event code to set the value for, one of ABS_MT_POSITION_X, etc.
1113 * @param value The new value to set
1115 * @return 0 on success, or -1 on failure.
1116 * @retval -1 the device does not have the event code enabled, or the code is
1117 * outside the allowed limits for multitouch events, or the slot number is outside
1118 * the limits for this device, or the device does not support multitouch events.
1120 * @see libevdev_set_event_value
1121 * @see libevdev_get_slot_value
1123 int libevdev_set_slot_value(struct libevdev *dev, unsigned int slot, unsigned int code, int value);
1128 * Fetch the current value of the code for the given slot. This is a shortcut for
1131 * if (libevdev_has_event_type(dev, EV_ABS) &&
1132 * libevdev_has_event_code(dev, EV_ABS, c) &&
1133 * slot < device->number_of_slots)
1134 * val = libevdev_get_slot_value(dev, slot, c);
1137 * @param dev The evdev device, already initialized with libevdev_set_fd()
1138 * @param slot The numerical slot number, must be smaller than the total number
1139 * of slots on this * device
1140 * @param[out] value The current value of this axis returned.
1142 * @param code The event code to query for, one of ABS_MT_POSITION_X, etc.
1143 * @return If the device supports this event code, the return value is
1144 * non-zero and value is set to the current value of this axis. Otherwise, or
1145 * if the event code is not an ABS_MT_* event code, zero is returned and value
1148 * @note This function is signal-safe.
1150 int libevdev_fetch_slot_value(const struct libevdev *dev, unsigned int slot, unsigned int code, int *value);
1155 * Get the number of slots supported by this device.
1157 * @param dev The evdev device, already initialized with libevdev_set_fd()
1159 * @return The number of slots supported, or -1 if the device does not provide
1162 * @note A device may provide ABS_MT_SLOT but a total number of 0 slots. Hence
1163 * the return value of -1 for "device does not provide slots at all"
1165 int libevdev_get_num_slots(const struct libevdev *dev);
1170 * Get the currently active slot. This may differ from the value
1171 * an ioctl may return at this time as events may have been read off the fd
1172 * since changing the slot value but those events are still in the buffer
1173 * waiting to be processed. The returned value is the value a caller would
1174 * see if it were to process events manually one-by-one.
1176 * @param dev The evdev device, already initialized with libevdev_set_fd()
1178 * @return the currently active slot (logically)
1180 int libevdev_get_current_slot(const struct libevdev *dev);
1185 * Change the minimum for the given EV_ABS event code, if the code exists.
1186 * This function has no effect if libevdev_has_event_code() returns false for
1189 void libevdev_set_abs_minimum(struct libevdev *dev, unsigned int code, int min);
1194 * Change the maximum for the given EV_ABS event code, if the code exists.
1195 * This function has no effect if libevdev_has_event_code() returns false for
1198 void libevdev_set_abs_maximum(struct libevdev *dev, unsigned int code, int max);
1203 * Change the fuzz for the given EV_ABS event code, if the code exists.
1204 * This function has no effect if libevdev_has_event_code() returns false for
1207 void libevdev_set_abs_fuzz(struct libevdev *dev, unsigned int code, int fuzz);
1212 * Change the flat for the given EV_ABS event code, if the code exists.
1213 * This function has no effect if libevdev_has_event_code() returns false for
1216 void libevdev_set_abs_flat(struct libevdev *dev, unsigned int code, int flat);
1221 * Change the resolution for the given EV_ABS event code, if the code exists.
1222 * This function has no effect if libevdev_has_event_code() returns false for
1225 void libevdev_set_abs_resolution(struct libevdev *dev, unsigned int code, int resolution);
1230 * Change the abs info for the given EV_ABS event code, if the code exists.
1231 * This function has no effect if libevdev_has_event_code() returns false for
1234 void libevdev_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs);
1239 * Forcibly enable an event type on this device, even if the underlying
1240 * device does not support it. While this cannot make the device actually
1241 * report such events, it will now return true for libevdev_has_event_type().
1243 * This is a local modification only affecting only this representation of
1246 * @param dev The evdev device, already initialized with libevdev_set_fd()
1247 * @param type The event type to enable (EV_ABS, EV_KEY, ...)
1249 * @return 0 on success or -1 otherwise
1251 * @see libevdev_has_event_type
1253 int libevdev_enable_event_type(struct libevdev *dev, unsigned int type);
1258 * Forcibly disable an event type on this device, even if the underlying
1259 * device provides it. This effectively mutes the respective set of
1260 * events. libevdev will filter any events matching this type and none will
1261 * reach the caller. libevdev_has_event_type() will return false for this
1264 * In most cases, a caller likely only wants to disable a single code, not
1265 * the whole type. Use libevdev_disable_event_code() for that.
1267 * Disabling EV_SYN will not work. Don't shoot yourself in the foot.
1270 * This is a local modification only affecting only this representation of
1273 * @param dev The evdev device, already initialized with libevdev_set_fd()
1274 * @param type The event type to disable (EV_ABS, EV_KEY, ...)
1276 * @return 0 on success or -1 otherwise
1278 * @see libevdev_has_event_type
1279 * @see libevdev_disable_event_type
1281 int libevdev_disable_event_type(struct libevdev *dev, unsigned int type);
1286 * Forcibly enable an event type on this device, even if the underlying
1287 * device does not support it. While this cannot make the device actually
1288 * report such events, it will now return true for libevdev_has_event_code().
1290 * The last argument depends on the type and code:
1291 * - If type is EV_ABS, data must be a pointer to a struct input_absinfo
1292 * containing the data for this axis.
1293 * - For all other types, the argument must be NULL.
1295 * This function calls libevdev_enable_event_type() if necessary.
1297 * This is a local modification only affecting only this representation of
1300 * @param dev The evdev device, already initialized with libevdev_set_fd()
1301 * @param type The event type to enable (EV_ABS, EV_KEY, ...)
1302 * @param code The event code to enable (ABS_X, REL_X, etc.)
1303 * @param data If type is EV_ABS, data points to a struct input_absinfo. If type is EV_REP, data
1304 * points to an integer. Otherwise, data must be NULL.
1306 * @return 0 on success or -1 otherwise
1308 * @see libevdev_enable_event_type
1310 int libevdev_enable_event_code(struct libevdev *dev, unsigned int type, unsigned int code, const void *data);
1315 * Forcibly disable an event code on this device, even if the underlying
1316 * device provides it. This effectively mutes the respective set of
1317 * events. libevdev will filter any events matching this type and code and
1318 * none will reach the caller. libevdev_has_event_code() will return false for
1321 * Disabling all event codes for a given type will not disable the event
1322 * type. Use libevdev_disable_event_type() for that.
1324 * This is a local modification only affecting only this representation of
1327 * Disabling EV_SYN will not work. Don't shoot yourself in the foot.
1330 * @param dev The evdev device, already initialized with libevdev_set_fd()
1331 * @param type The event type to disable (EV_ABS, EV_KEY, ...)
1332 * @param code The event code to disable (ABS_X, REL_X, etc.)
1334 * @return 0 on success or -1 otherwise
1336 * @see libevdev_has_event_code
1337 * @see libevdev_disable_event_type
1339 int libevdev_disable_event_code(struct libevdev *dev, unsigned int type, unsigned int code);
1344 * Set the device's EV_ABS axis to the value defined in the abs
1345 * parameter. This will be written to the kernel.
1347 * @param dev The evdev device, already initialized with libevdev_set_fd()
1348 * @param code The EV_ABS event code to modify, one of ABS_X, ABS_Y, etc.
1349 * @param abs Axis info to set the kernel axis to
1351 * @return zero on success, or a negative errno on failure
1353 * @see libevdev_enable_event_code
1355 int libevdev_kernel_set_abs_info(struct libevdev *dev, unsigned int code, const struct input_absinfo *abs);
1361 enum libevdev_led_value {
1362 LIBEVDEV_LED_ON = 3,
1363 LIBEVDEV_LED_OFF = 4
1369 * Turn an LED on or off. Convenience function, if you need to modify multiple
1370 * LEDs simultaneously, use libevdev_kernel_set_led_values() instead.
1372 * @note enabling an LED requires write permissions on the device's file descriptor.
1374 * @param dev The evdev device, already initialized with libevdev_set_fd()
1375 * @param code The EV_LED event code to modify, one of LED_NUML, LED_CAPSL, ...
1376 * @param value Specifies whether to turn the LED on or off
1377 * @return zero on success, or a negative errno on failure
1379 int libevdev_kernel_set_led_value(struct libevdev *dev, unsigned int code, enum libevdev_led_value value);
1384 * Turn multiple LEDs on or off simultaneously. This function expects a pair
1385 * of LED codes and values to set them to, terminated by a -1. For example, to
1386 * switch the NumLock LED on but the CapsLock LED off, use:
1389 * libevdev_kernel_set_led_values(dev, LED_NUML, LIBEVDEV_LED_ON,
1390 * LED_CAPSL, LIBEVDEV_LED_OFF,
1394 * If any LED code or value is invalid, this function returns -EINVAL and no
1395 * LEDs are modified.
1397 * @note enabling an LED requires write permissions on the device's file descriptor.
1399 * @param dev The evdev device, already initialized with libevdev_set_fd()
1400 * @param ... A pair of LED_* event codes and libevdev_led_value_t, followed by
1401 * -1 to terminate the list.
1402 * @return zero on success, or a negative errno on failure
1404 int libevdev_kernel_set_led_values(struct libevdev *dev, ...);
1409 * Set the clock ID to be used for timestamps. Further events from this device
1410 * will report an event time based on the given clock.
1412 * This is a modification only affecting this representation of
1415 * @param dev The evdev device, already initialized with libevdev_set_fd()
1416 * @param clockid The clock to use for future events. Permitted values
1417 * are CLOCK_MONOTONIC and CLOCK_REALTIME (the default).
1418 * @return zero on success, or a negative errno on failure
1420 int libevdev_set_clock_id(struct libevdev *dev, int clockid);
1425 * Helper function to check if an event is of a specific type. This is
1426 * virtually the same as:
1430 * with the exception that some sanity checks are performed to ensure type
1433 * @note The ranges for types are compiled into libevdev. If the kernel
1434 * changes the max value, libevdev will not automatically pick these up.
1436 * @param ev The input event to check
1437 * @param type Input event type to compare the event against (EV_REL, EV_ABS,
1440 * @return 1 if the event type matches the given type, 0 otherwise (or if
1443 int libevdev_event_is_type(const struct input_event *ev, unsigned int type);
1448 * Helper function to check if an event is of a specific type and code. This
1449 * is virtually the same as:
1451 * ev->type == type && ev->code == code
1453 * with the exception that some sanity checks are performed to ensure type and
1456 * @note The ranges for types and codes are compiled into libevdev. If the kernel
1457 * changes the max value, libevdev will not automatically pick these up.
1459 * @param ev The input event to check
1460 * @param type Input event type to compare the event against (EV_REL, EV_ABS,
1462 * @param code Input event code to compare the event against (ABS_X, REL_X,
1465 * @return 1 if the event type matches the given type and code, 0 otherwise
1466 * (or if type/code are invalid)
1468 int libevdev_event_is_code(const struct input_event *ev, unsigned int type, unsigned int code);
1473 * @param type The event type to return the name for.
1475 * @return The name of the given event type (e.g. EV_ABS) or NULL for an
1478 * @note The list of names is compiled into libevdev. If the kernel adds new
1479 * defines for new properties libevdev will not automatically pick these up.
1481 const char * libevdev_event_type_get_name(unsigned int type);
1485 * @param type The event type for the code to query (EV_SYN, EV_REL, etc.)
1486 * @param code The event code to return the name for (e.g. ABS_X)
1488 * @return The name of the given event code (e.g. ABS_X) or NULL for an
1489 * invalid type or code
1491 * @note The list of names is compiled into libevdev. If the kernel adds new
1492 * defines for new properties libevdev will not automatically pick these up.
1494 const char * libevdev_event_code_get_name(unsigned int type, unsigned int code);
1499 * @param prop The input prop to return the name for (e.g. INPUT_PROP_BUTTONPAD)
1501 * @return The name of the given input prop (e.g. INPUT_PROP_BUTTONPAD) or NULL for an
1504 * @note The list of names is compiled into libevdev. If the kernel adds new
1505 * defines for new properties libevdev will not automatically pick these up.
1506 * @note On older kernels input properties may not be defined and
1507 * libevdev_property_get_name() will always return NULL
1509 const char* libevdev_property_get_name(unsigned int prop);
1514 * @param type The event type to return the maximum for (EV_ABS, EV_REL, etc.). No max is defined for
1517 * @return The max value defined for the given event type, e.g. ABS_MAX for a type of EV_ABS, or -1
1518 * for an invalid type.
1520 * @note The max value is compiled into libevdev. If the kernel changes the
1521 * max value, libevdev will not automatically pick these up.
1523 int libevdev_event_type_get_max(unsigned int type);
1528 * Look up an event-type by its name. Event-types start with "EV_" followed by
1529 * the name (eg., "EV_ABS"). The "EV_" prefix must be included in the name. It
1530 * returns the constant assigned to the event-type or -1 if not found.
1532 * @param name A non-NULL string describing an input-event type ("EV_KEY",
1533 * "EV_ABS", ...), zero-terminated.
1535 * @return The given type constant for the passed name or -1 if not found.
1537 * @note EV_MAX is also recognized.
1539 int libevdev_event_type_from_name(const char *name);
1544 * Look up an event-type by its name. Event-types start with "EV_" followed by
1545 * the name (eg., "EV_ABS"). The "EV_" prefix must be included in the name. It
1546 * returns the constant assigned to the event-type or -1 if not found.
1548 * @param name A non-NULL string describing an input-event type ("EV_KEY",
1550 * @param len The length of the passed string excluding any terminating 0
1553 * @return The given type constant for the passed name or -1 if not found.
1555 * @note EV_MAX is also recognized.
1557 int libevdev_event_type_from_name_n(const char *name, size_t len);
1562 * Look up an event-code by its type and name. Event-codes start with a fixed
1563 * prefix followed by their name (eg., "ABS_X"). The prefix must be included in
1564 * the name. It returns the constant assigned to the event-code or -1 if not
1567 * You have to pass the event-type where to look for the name. For instance, to
1568 * resolve "ABS_X" you need to pass EV_ABS as type and "ABS_X" as string.
1569 * Supported event-codes are codes starting with SYN_, KEY_, BTN_, REL_, ABS_,
1570 * MSC_, SND_, SW_, LED_, REP_, FF_.
1572 * @param type The event type (EV_* constant) where to look for the name.
1573 * @param name A non-NULL string describing an input-event code ("KEY_A",
1574 * "ABS_X", "BTN_Y", ...), zero-terminated.
1576 * @return The given code constant for the passed name or -1 if not found.
1578 int libevdev_event_code_from_name(unsigned int type, const char *name);
1583 * Look up an event-code by its type and name. Event-codes start with a fixed
1584 * prefix followed by their name (eg., "ABS_X"). The prefix must be included in
1585 * the name. It returns the constant assigned to the event-code or -1 if not
1588 * You have to pass the event-type where to look for the name. For instance, to
1589 * resolve "ABS_X" you need to pass EV_ABS as type and "ABS_X" as string.
1590 * Supported event-codes are codes starting with SYN_, KEY_, BTN_, REL_, ABS_,
1591 * MSC_, SND_, SW_, LED_, REP_, FF_.
1593 * @param type The event type (EV_* constant) where to look for the name.
1594 * @param name A non-NULL string describing an input-event code ("KEY_A",
1595 * "ABS_X", "BTN_Y", ...).
1596 * @param len The length of the passed string excluding any terminating 0
1599 * @return The given code constant for the passed name or -1 if not found.
1601 int libevdev_event_code_from_name_n(unsigned int type, const char *name,
1607 * Get the repeat delay and repeat period values for this device.
1609 * @param dev The evdev device, already initialized with libevdev_set_fd()
1610 * @param delay If not null, set to the repeat delay value
1611 * @param period If not null, set to the repeat period value
1613 * @return 0 on success, -1 if this device does not have repeat settings.
1615 * @note This function is signal-safe
1617 int libevdev_get_repeat(const struct libevdev *dev, int *delay, int *period);
1620 /********* DEPRECATED SECTION *********/
1621 #if defined(__GNUC__) && __GNUC__ >= 4
1622 #define LIBEVDEV_DEPRECATED __attribute__ ((deprecated))
1624 #define LIBEVDEV_DEPRECATED
1631 #endif /* LIBEVDEV_H */