libinput  0.6.0
A wrapper library for input devices
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
libinput.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 Jonas Ådahl
3  *
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.
13  *
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.
21  */
22 
23 #ifndef LIBINPUT_H
24 #define LIBINPUT_H
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #include <stdlib.h>
31 #include <stdint.h>
32 #include <libudev.h>
33 
34 #define LIBINPUT_ATTRIBUTE_PRINTF(_format, _args) \
35  __attribute__ ((format (printf, _format, _args)))
36 #define LIBINPUT_ATTRIBUTE_DEPRECATED __attribute__ ((deprecated))
37 
145 };
146 
158 };
159 
169 };
170 
180 };
181 
191 };
192 
193 
202 };
203 
216 
226 
232 
234 
239 
249 };
250 
251 struct libinput;
252 struct libinput_device;
253 struct libinput_seat;
254 
255 struct libinput_event;
256 struct libinput_event_device_notify;
257 struct libinput_event_keyboard;
258 struct libinput_event_pointer;
259 
270 struct libinput_event_touch;
271 
283 void
284 libinput_event_destroy(struct libinput_event *event);
285 
294 libinput_event_get_type(struct libinput_event *event);
295 
304 struct libinput *
305 libinput_event_get_context(struct libinput_event *event);
306 
320 struct libinput_device *
321 libinput_event_get_device(struct libinput_event *event);
322 
333 struct libinput_event_pointer *
334 libinput_event_get_pointer_event(struct libinput_event *event);
335 
346 struct libinput_event_keyboard *
347 libinput_event_get_keyboard_event(struct libinput_event *event);
348 
359 struct libinput_event_touch *
360 libinput_event_get_touch_event(struct libinput_event *event);
361 
373 struct libinput_event_device_notify *
374 libinput_event_get_device_notify_event(struct libinput_event *event);
375 
381 struct libinput_event *
382 libinput_event_device_notify_get_base_event(struct libinput_event_device_notify *event);
383 
396 uint32_t
397 libinput_event_keyboard_get_time(struct libinput_event_keyboard *event);
398 
404 uint32_t
405 libinput_event_keyboard_get_key(struct libinput_event_keyboard *event);
406 
413 libinput_event_keyboard_get_key_state(struct libinput_event_keyboard *event);
414 
415 
421 struct libinput_event *
422 libinput_event_keyboard_get_base_event(struct libinput_event_keyboard *event);
423 
436 uint32_t
438  struct libinput_event_keyboard *event);
439 
452 uint32_t
453 libinput_event_pointer_get_time(struct libinput_event_pointer *event);
454 
470 double
471 libinput_event_pointer_get_dx(struct libinput_event_pointer *event);
472 
488 double
489 libinput_event_pointer_get_dy(struct libinput_event_pointer *event);
490 
506 double
507 libinput_event_pointer_get_absolute_x(struct libinput_event_pointer *event);
508 
524 double
525 libinput_event_pointer_get_absolute_y(struct libinput_event_pointer *event);
526 
544 double
546  struct libinput_event_pointer *event,
547  uint32_t width);
548 
566 double
568  struct libinput_event_pointer *event,
569  uint32_t height);
570 
583 uint32_t
584 libinput_event_pointer_get_button(struct libinput_event_pointer *event);
585 
599 libinput_event_pointer_get_button_state(struct libinput_event_pointer *event);
600 
613 uint32_t
615  struct libinput_event_pointer *event);
616 
630 libinput_event_pointer_get_axis(struct libinput_event_pointer *event);
631 
652 double
653 libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event);
654 
660 struct libinput_event *
661 libinput_event_pointer_get_base_event(struct libinput_event_pointer *event);
662 
663 
675 uint32_t
677 
692 int32_t
694 
709 int32_t
711 
725 double
727 
743 double
745 
759 double
761  uint32_t width);
762 
776 double
778  uint32_t height);
779 
785 struct libinput_event *
787 
804  int (*open_restricted)(const char *path, int flags, void *user_data);
812  void (*close_restricted)(int fd, void *user_data);
813 };
814 
828 struct libinput *
829 libinput_udev_create_context(const struct libinput_interface *interface,
830  void *user_data,
831  struct udev *udev);
832 
854 int
855 libinput_udev_assign_seat(struct libinput *libinput,
856  const char *seat_id);
857 
877 struct libinput *
878 libinput_path_create_context(const struct libinput_interface *interface,
879  void *user_data);
880 
901 struct libinput_device *
902 libinput_path_add_device(struct libinput *libinput,
903  const char *path);
904 
923 void
924 libinput_path_remove_device(struct libinput_device *device);
925 
934 int
935 libinput_get_fd(struct libinput *libinput);
936 
950 int
951 libinput_dispatch(struct libinput *libinput);
952 
964 struct libinput_event *
965 libinput_get_event(struct libinput *libinput);
966 
979 libinput_next_event_type(struct libinput *libinput);
980 
988 void *
989 libinput_get_user_data(struct libinput *libinput);
990 
1002 int
1003 libinput_resume(struct libinput *libinput);
1004 
1014 void
1015 libinput_suspend(struct libinput *libinput);
1016 
1026 struct libinput *
1027 libinput_ref(struct libinput *libinput);
1028 
1039 struct libinput *
1040 libinput_unref(struct libinput *libinput);
1041 
1056 void
1057 libinput_log_set_priority(struct libinput *libinput,
1058  enum libinput_log_priority priority);
1059 
1075 libinput_log_get_priority(const struct libinput *libinput);
1076 
1090 typedef void (*libinput_log_handler)(struct libinput *libinput,
1091  enum libinput_log_priority priority,
1092  const char *format, va_list args)
1094 
1111 void
1112 libinput_log_set_handler(struct libinput *libinput,
1113  libinput_log_handler log_handler);
1114 
1152 struct libinput_seat *
1153 libinput_seat_ref(struct libinput_seat *seat);
1154 
1166 struct libinput_seat *
1167 libinput_seat_unref(struct libinput_seat *seat);
1168 
1180 void
1181 libinput_seat_set_user_data(struct libinput_seat *seat, void *user_data);
1182 
1192 void *
1193 libinput_seat_get_user_data(struct libinput_seat *seat);
1194 
1211 const char *
1212 libinput_seat_get_physical_name(struct libinput_seat *seat);
1213 
1223 const char *
1224 libinput_seat_get_logical_name(struct libinput_seat *seat);
1225 
1241 struct libinput_device *
1242 libinput_device_ref(struct libinput_device *device);
1243 
1255 struct libinput_device *
1256 libinput_device_unref(struct libinput_device *device);
1257 
1269 void
1270 libinput_device_set_user_data(struct libinput_device *device, void *user_data);
1271 
1281 void *
1282 libinput_device_get_user_data(struct libinput_device *device);
1283 
1295 const char *
1296 libinput_device_get_sysname(struct libinput_device *device);
1297 
1311 const char *
1312 libinput_device_get_name(struct libinput_device *device);
1313 
1322 unsigned int
1323 libinput_device_get_id_product(struct libinput_device *device);
1324 
1333 unsigned int
1334 libinput_device_get_id_vendor(struct libinput_device *device);
1335 
1347 const char *
1348 libinput_device_get_output_name(struct libinput_device *device);
1349 
1363 struct libinput_seat *
1364 libinput_device_get_seat(struct libinput_device *device);
1365 
1376 void
1377 libinput_device_led_update(struct libinput_device *device,
1378  enum libinput_led leds);
1379 
1392 int
1393 libinput_device_get_keys(struct libinput_device *device,
1394  char *keys, size_t size)
1396 
1402 void
1403 libinput_device_calibrate(struct libinput_device *device,
1404  float calibration[6])
1406 
1414 int
1415 libinput_device_has_capability(struct libinput_device *device,
1416  enum libinput_device_capability capability);
1417 
1432 int
1433 libinput_device_get_size(struct libinput_device *device,
1434  double *width,
1435  double *height);
1436 
1437 
1462 };
1463 
1473 const char *
1475 
1484 };
1485 
1500 int
1501 libinput_device_config_tap_get_finger_count(struct libinput_device *device);
1502 
1524 libinput_device_config_tap_set_enabled(struct libinput_device *device,
1525  enum libinput_config_tap_state enable);
1526 
1543 libinput_device_config_tap_get_enabled(struct libinput_device *device);
1544 
1559 libinput_device_config_tap_get_default_enabled(struct libinput_device *device);
1560 
1573 int
1574 libinput_device_config_calibration_has_matrix(struct libinput_device *device);
1575 
1626 libinput_device_config_calibration_set_matrix(struct libinput_device *device,
1627  const float matrix[6]);
1628 
1645 int
1646 libinput_device_config_calibration_get_matrix(struct libinput_device *device,
1647  float matrix[6]);
1648 
1682 int
1683 libinput_device_config_calibration_get_default_matrix(struct libinput_device *device,
1684  float matrix[6]);
1685 
1686 #ifdef __cplusplus
1687 }
1688 #endif
1689 #endif /* LIBINPUT_H */
const char * libinput_seat_get_physical_name(struct libinput_seat *seat)
Return the physical name of the seat.
libinput_log_priority
Log priority for internal logging messages.
Definition: libinput.h:141
void libinput_device_calibrate(struct libinput_device *device, float calibration[6]) 1
void(*) voi libinput_log_set_handler)(struct libinput *libinput, libinput_log_handler log_handler)
Set the global log handler.
Definition: libinput.h:1112
unsigned int libinput_device_get_id_product(struct libinput_device *device)
Get the product ID for this device.
Definition: libinput.h:157
uint32_t libinput_event_pointer_get_button(struct libinput_event_pointer *event)
Return the button that triggered this event.
void(* close_restricted)(int fd, void *user_data)
Close the file descriptor.
Definition: libinput.h:812
Definition: libinput.h:242
int libinput_dispatch(struct libinput *libinput)
Main event dispatchment function.
struct libinput * libinput_ref(struct libinput *libinput)
Add a reference to the context.
Definition: libinput.h:792
Definition: libinput.h:238
Definition: libinput.h:190
libinput_led
Mask reflecting LEDs on a device.
Definition: libinput.h:176
Touch event representing a touch down, move or up, as well as a touch cancel and touch frame events...
Definition: libinput.h:258
Definition: libinput.h:240
int32_t libinput_event_touch_get_slot(struct libinput_event_touch *event)
Get the slot of this touch event.
void * libinput_device_get_user_data(struct libinput_device *device)
Get the caller-specific data associated with this input device, if any.
struct libinput_seat * libinput_seat_ref(struct libinput_seat *seat)
Increase the refcount of the seat.
Definition: libinput.h:201
Signals the end of a set of touchpoints at one device sample time.
Definition: libinput.h:248
Config applied successfully.
Definition: libinput.h:1458
const char * libinput_device_get_name(struct libinput_device *device)
The descriptive device name as advertised by the kernel and/or the hardware itself.
enum libinput_config_status libinput_device_config_calibration_set_matrix(struct libinput_device *device, const float matrix[6])
Apply the 3x3 transformation matrix to absolute device coordinates.
Definition: libinput.h:179
uint32_t libinput_event_keyboard_get_seat_key_count(struct libinput_event_keyboard *event)
For the key of a LIBINPUT_EVENT_KEYBOARD_KEY event, return the total number of keys pressed on all de...
void * libinput_seat_get_user_data(struct libinput_seat *seat)
Get the caller-specific data associated with this seat, if any.
Tapping is to be enabled, or is currently enabled.
Definition: libinput.h:1482
struct libinput_event * libinput_event_device_notify_get_base_event(struct libinput_event_device_notify *event)
Definition: libinput.h:233
Signals that a device has been added to the context.
Definition: libinput.h:225
Configuration not available on this device.
Definition: libinput.h:1459
Definition: libinput.h:235
double libinput_event_pointer_get_dy(struct libinput_event_pointer *event)
Return the delta between the last event and the current event.
void libinput_path_remove_device(struct libinput_device *device)
Remove a device from a libinput context initialized with libinput_path_create_context() or added to s...
Signals that a device has been removed.
Definition: libinput.h:231
int libinput_device_config_calibration_get_default_matrix(struct libinput_device *device, float matrix[6])
Return the default calibration matrix for this device.
void libinput_log_set_priority(struct libinput *libinput, enum libinput_log_priority priority)
Set the global log priority.
libinput_button_state
Logical state of a physical button.
Definition: libinput.h:188
const char * libinput_config_status_to_str(enum libinput_config_status status)
Return a string describing the error.
enum libinput_config_tap_state libinput_device_config_tap_get_enabled(struct libinput_device *device)
Check if tap-to-click is enabled on this device.
struct libinput_device * libinput_device_ref(struct libinput_device *device)
Increase the refcount of the input device.
uint32_t libinput_event_touch_get_time(struct libinput_event_touch *event)
double libinput_event_touch_get_x(struct libinput_event_touch *event)
Return the current absolute x coordinate of the touch event, in mm from the top left corner of the de...
uint32_t libinput_event_pointer_get_seat_button_count(struct libinput_event_pointer *event)
For the button of a LIBINPUT_EVENT_POINTER_BUTTON event, return the total number of buttons pressed o...
int libinput_device_config_calibration_get_matrix(struct libinput_device *device, float matrix[6])
Return the current calibration matrix for this device.
Definition: libinput.h:237
Definition: libinput.h:143
enum libinput_key_state libinput_event_keyboard_get_key_state(struct libinput_event_keyboard *event)
double libinput_event_pointer_get_dx(struct libinput_event_pointer *event)
Return the delta between the last event and the current event.
double libinput_event_pointer_get_absolute_y_transformed(struct libinput_event_pointer *event, uint32_t height)
Return the current absolute y coordinate of the pointer event, transformed to screen coordinates...
double libinput_event_pointer_get_absolute_x(struct libinput_event_pointer *event)
Return the current absolute x coordinate of the pointer event, in mm from the top left corner of the ...
struct libinput_event_device_notify * libinput_event_get_device_notify_event(struct libinput_event *event)
Return the device event that is this input event.
libinput_pointer_axis
Axes on a device that are not x or y coordinates.
Definition: libinput.h:199
int libinput_device_config_calibration_has_matrix(struct libinput_device *device)
Check if the device can be calibrated via a calibration matrix.
libinput_config_tap_state
Definition: libinput.h:1479
int(* open_restricted)(const char *path, int flags, void *user_data)
Open the device at the given path with the flags provided and return the fd.
Definition: libinput.h:804
Definition: libinput.h:155
#define LIBINPUT_ATTRIBUTE_DEPRECATED
Definition: libinput.h:36
void(* libinput_log_handler)(struct libinput *libinput, enum libinput_log_priority priority, const char *format, va_list args) LIBINPUT_ATTRIBUTE_PRINTF(3
Log handler type for custom logging.
Definition: libinput.h:1090
enum libinput_config_status libinput_device_config_tap_set_enabled(struct libinput_device *device, enum libinput_config_tap_state enable)
Enable or disable tap-to-click on this device, with a default mapping of 1, 2, 3 finger tap mapping t...
Definition: libinput.h:167
libinput_device_capability
Capabilities on a device.
Definition: libinput.h:154
Definition: libinput.h:241
libinput_config_status
Status codes returned when applying configuration settings.
Definition: libinput.h:1457
Definition: libinput.h:168
double libinput_event_touch_get_y(struct libinput_event_touch *event)
Return the current absolute y coordinate of the touch event, in mm from the top left corner of the de...
int32_t libinput_event_touch_get_seat_slot(struct libinput_event_touch *event)
Get the seat slot of the touch event.
double libinput_event_pointer_get_absolute_y(struct libinput_event_pointer *event)
Return the current absolute y coordinate of the pointer event, in mm from the top left corner of the ...
void libinput_device_led_update(struct libinput_device *device, enum libinput_led leds)
Update the LEDs on the device, if any.
struct libinput_device * libinput_path_add_device(struct libinput *libinput, const char *path)
Add a device to a libinput context initialized with libinput_path_create_context().
double libinput_event_touch_get_x_transformed(struct libinput_event_touch *event, uint32_t width)
Return the current absolute x coordinate of the touch event, transformed to screen coordinates...
Definition: libinput.h:142
struct libinput * libinput_event_get_context(struct libinput_event *event)
Get the libinput context from the event.
Definition: libinput.h:243
#define LIBINPUT_ATTRIBUTE_PRINTF(_format, _args)
Definition: libinput.h:34
struct libinput * libinput_path_create_context(const struct libinput_interface *interface, void *user_data)
Create a new libinput context that requires the caller to manually add or remove devices with libinpu...
struct libinput_seat * libinput_seat_unref(struct libinput_seat *seat)
Decrease the refcount of the seat.
int libinput_device_config_tap_get_finger_count(struct libinput_device *device)
Check if the device supports tap-to-click.
Invalid parameter range.
Definition: libinput.h:1461
unsigned int libinput_device_get_id_vendor(struct libinput_device *device)
Get the vendor ID for this device.
enum libinput_event_type libinput_event_get_type(struct libinput_event *event)
Get the type of the event.
double libinput_event_pointer_get_axis_value(struct libinput_event_pointer *event)
Return the axis value of the given axis.
struct libinput_device * libinput_event_get_device(struct libinput_event *event)
Return the device associated with this event, if applicable.
void * libinput_get_user_data(struct libinput *libinput)
Definition: libinput.h:156
void libinput_event_destroy(struct libinput_event *event)
Destroy the event.
Definition: libinput.h:236
void libinput_suspend(struct libinput *libinput)
Suspend monitoring for new devices and close existing devices.
Definition: libinput.h:177
uint32_t libinput_event_keyboard_get_key(struct libinput_event_keyboard *event)
Tapping is to be disabled, or is currently disabled.
Definition: libinput.h:1480
Definition: libinput.h:189
int libinput_get_fd(struct libinput *libinput)
libinput keeps a single file descriptor for all events.
int libinput_resume(struct libinput *libinput)
Resume a suspended libinput context.
struct libinput * libinput_udev_create_context(const struct libinput_interface *interface, void *user_data, struct udev *udev)
Create a new libinput context from udev.
libinput_event_type
Event type for events returned by libinput_get_event().
Definition: libinput.h:209
struct libinput_event * libinput_get_event(struct libinput *libinput)
Retrieve the next event from libinput&#39;s internal event queue.
enum libinput_event_type libinput_next_event_type(struct libinput *libinput)
Return the type of the next event in the internal queue.
int libinput_device_has_capability(struct libinput_device *device, enum libinput_device_capability capability)
Check if the given device has the specified capability.
double libinput_event_pointer_get_absolute_x_transformed(struct libinput_event_pointer *event, uint32_t width)
Return the current absolute x coordinate of the pointer event, transformed to screen coordinates...
uint32_t libinput_event_keyboard_get_time(struct libinput_event_keyboard *event)
struct libinput_event_keyboard * libinput_event_get_keyboard_event(struct libinput_event *event)
Return the keyboard event that is this input event.
Definition: libinput.h:178
struct libinput_seat * libinput_device_get_seat(struct libinput_device *device)
Get the seat associated with this input device.
enum libinput_button_state libinput_event_pointer_get_button_state(struct libinput_event_pointer *event)
Return the button state that triggered this event.
Definition: libinput.h:200
struct libinput * libinput_unref(struct libinput *libinput)
Dereference the libinput context.
enum libinput_log_priority libinput_log_get_priority(const struct libinput *libinput)
Get the global log priority.
const char * libinput_device_get_sysname(struct libinput_device *device)
Get the system name of the device.
struct libinput_device * libinput_device_unref(struct libinput_device *device)
Decrease the refcount of the input device.
int libinput_device_get_size(struct libinput_device *device, double *width, double *height)
Get the physical size of a device in mm, where meaningful.
void libinput_seat_set_user_data(struct libinput_seat *seat, void *user_data)
Set caller-specific data associated with this seat.
const char * libinput_seat_get_logical_name(struct libinput_seat *seat)
Return the logical name of the seat.
int libinput_udev_assign_seat(struct libinput *libinput, const char *seat_id)
Assign a seat to this libinput context.
double libinput_event_touch_get_y_transformed(struct libinput_event_touch *event, uint32_t height)
Return the current absolute y coordinate of the touch event, transformed to screen coordinates...
enum libinput_pointer_axis libinput_event_pointer_get_axis(struct libinput_event_pointer *event)
Return the axis that triggered this event.
enum libinput_config_tap_state libinput_device_config_tap_get_default_enabled(struct libinput_device *device)
Return the default setting for whether tapping is enabled on this device.
struct libinput_event * libinput_event_keyboard_get_base_event(struct libinput_event_keyboard *event)
const char * libinput_device_get_output_name(struct libinput_device *device)
A device may be mapped to a single output, or all available outputs.
uint32_t libinput_event_pointer_get_time(struct libinput_event_pointer *event)
struct libinput_event * libinput_event_touch_get_base_event(struct libinput_event_touch *event)
libinput_key_state
Logical state of a key.
Definition: libinput.h:166
This is not a real event type, and is only used to tell the user that no new event is available in th...
Definition: libinput.h:215
void libinput_device_set_user_data(struct libinput_device *device, void *user_data)
Set caller-specific data associated with this input device.
int libinput_device_get_keys(struct libinput_device *device, char *keys, size_t size) 1
Set the bitmask in keys to the bitmask of the keys present on the device (see linux/input.h), up to size characters.
struct libinput_event * libinput_event_pointer_get_base_event(struct libinput_event_pointer *event)
struct libinput_event_pointer * libinput_event_get_pointer_event(struct libinput_event *event)
Return the pointer event that is this input event.
Definition: libinput.h:144
struct libinput_event_touch * libinput_event_get_touch_event(struct libinput_event *event)
Return the touch event that is this input event.