package libinput

  1. Overview
  2. Docs
OCaml bindings for libinput

Install

dune-project
 Dependency

Authors

Maintainers

Sources

libinput-1.29.tbz
sha256=3de44543b3995d15d0c3ff2dbc1788403427a2c907716552cded9134681880fd
sha512=9e92438c6183d0e6e7d76c28e67133ce25d230686881a47a874a07d0e79163d3033606f69d07225d2d6eaea687a57d943429b9d5b533d344a773262e951e662e

Description

Input device management and event handling library

Published: 23 Mar 2026

README

OCaml bindings for libinput.

This provides access to almost all of the libinput C API. The missing functions are:

  • libinput_next_event_type: the OCaml bindings combine the event type and payload, so providing this would require exporting a second large type, and it doesn't seem useful.
  • The various *_set_user_data and *_get_user_data functions. Attaching data to callbacks is easy in OCaml, and you can use ephemerons to attach extra data to things if needed.
  • Some *_get_context functions, as it's easy to pass the context explicitly in OCaml.
  • libinput_device_get_udev_device would only be useful with compatible udev bindings.

examples/simple.ml shows a simple example of using the library. For example:

$ sudo chown "$USER" /dev/input/event2
$ dune exec -- ./examples/simple.exe /dev/input/event2
Adding device "/dev/input/event2"
libinput info: event2  - Logitech USB Optical Mouse: is tagged by udev as: Mouse
libinput info: event2  - Logitech USB Optical Mouse: device is a pointer
Created libinput context
{type = `Device_added _;
 device = {sysname = "event2"; name = "Logitech USB Optical Mouse";
           bustype = 0x3; vendor = 0x46d; product = 0xc077; output = null;
           seat = {physical_name = "seat0"; logical_name = "default"}}]}
Waiting for events...
{type = `Pointer_button {time = 57416.335901;
                         button = 272;
                         state = `Pressed;
                         seat_key_count = 1};
 device = {sysname = "event2"; name = "Logitech USB Optical Mouse"; ...}]}
{type = `Pointer_button {time = 57416.383910;
                         button = 272;
                         state = `Released;
                         seat_key_count = 0};
 device = {sysname = "event2"; name = "Logitech USB Optical Mouse"; ...}]}

Dependencies (6)

  1. conf-libinput
  2. fmt >= "0.8.9"
  3. ctypes-foreign >= "0.23.0"
  4. ctypes >= "0.23.0"
  5. ocaml >= "5.3.0"
  6. dune >= "3.18"

Dev Dependencies (1)

  1. odoc with-doc

Used by

None

Conflicts

None