mainpage.dox 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /**
  2. @mainpage
  3. This is the libinput API reference.
  4. This documentation is aimed at developers of Wayland compositors. User
  5. documentation is available
  6. [here](https://wayland.freedesktop.org/libinput/doc/latest).
  7. @section concepts Concepts
  8. @subsection concepts_initialization Initialization of a libinput context
  9. libinput provides two different backends:
  10. - a @ref libinput_udev_create_context "udev backend" where notifications
  11. about new and removed devices are provided by udev, and
  12. - a @ref libinput_path_create_context "path backend" where
  13. @ref libinput_path_add_device "device addition" and
  14. @ref libinput_path_remove_device "device removal" need to be handled by
  15. the caller.
  16. See section @ref base for information about initializing a libinput context.
  17. @subsection concepts_events Monitoring for events
  18. libinput exposes a single @ref libinput_get_fd "file descriptor" to the
  19. caller. This file descriptor should be monitored by the caller, whenever
  20. data is available the caller **must** immediately call libinput_dispatch().
  21. Failure to do so will result in erroneous behavior.
  22. libinput_dispatch() may result in one or more events being available to the
  23. caller. After libinput_dispatch() a caller **should** call
  24. libinput_get_event() to retrieve and process this event. Whenever
  25. libinput_get_event() returns `NULL`, no further events are available.
  26. See section @ref event for more information about events.
  27. @subsection concepts_seats Device grouping into seats
  28. All devices are grouped into physical and logical seats. Button and key
  29. states are available per-device and per-seat. See @ref seat for more
  30. information.
  31. @subsection concepts_devices Device capabilities
  32. libinput does not use device types. All devices have @ref
  33. libinput_device_has_capability "capabilities" that define which events may
  34. be generated. See @ref device for more information about devices.
  35. Specific event types include:
  36. - @ref event_keyboard
  37. - @ref event_pointer
  38. - @ref event_touch
  39. - @ref event_gesture
  40. - @ref event_tablet
  41. - @ref event_tablet_pad
  42. - @ref event_switch
  43. @subsection concepts_configuration Device configuration
  44. libinput relies on the caller for device configuration. See
  45. @ref config for more information.
  46. @subsection example An example libinput program
  47. The simplest libinput program looks like this:
  48. @code
  49. static int open_restricted(const char *path, int flags, void *user_data)
  50. {
  51. int fd = open(path, flags);
  52. return fd < 0 ? -errno : fd;
  53. }
  54. static void close_restricted(int fd, void *user_data)
  55. {
  56. close(fd);
  57. }
  58. const static struct libinput_interface interface = {
  59. .open_restricted = open_restricted,
  60. .close_restricted = close_restricted,
  61. };
  62. int main(void) {
  63. struct libinput *li;
  64. struct libinput_event *event;
  65. li = libinput_udev_create_context(&interface, NULL, udev);
  66. libinput_udev_assign_seat(li, "seat0");
  67. libinput_dispatch(li);
  68. while ((event = libinput_get_event(li)) != NULL) {
  69. // handle the event here
  70. libinput_event_destroy(event);
  71. libinput_dispatch(li);
  72. }
  73. libinput_unref(li);
  74. return 0;
  75. }
  76. @endcode
  77. @section building_against Building against libinput
  78. libinput provides a
  79. [pkg-config](https://www.freedesktop.org/wiki/Software/pkg-config/) file.
  80. Software that uses libinput should use pkg-config and the
  81. `PKG_CHECK_MODULES` autoconf macro.
  82. Otherwise, the most rudimentary way to compile and link a program against
  83. libinput is:
  84. @verbatim
  85. gcc -o myprogram myprogram.c `pkg-config --cflags --libs libinput`
  86. @endverbatim
  87. For further information on using pkgconfig see the pkg-config documentation.
  88. @section stability Backwards-compatibility
  89. libinput promises backwards-compatibility across all the 1.x.y version. An
  90. application built against libinput 1.x.y will work with any future 1.*.*
  91. release.
  92. @section About
  93. Documentation generated from git commit [__GIT_VERSION__](https://gitlab.freedesktop.org/libinput/libinput/commit/__GIT_VERSION__)
  94. */