@hackage evdev1.3.0.0
Bindings to libevdev
Categories
License
BSD-3-Clause
Maintainer
George Thomas
Links
Versions
Installation
Dependencies (16)
- base ^>=4.11 || ^>=4.12 || ^>=4.13
- bytestring ^>=0.10
- containers ^>=0.6.2
- either ^>=5.0.1
- extra ^>=1.6.18
- hinotify ^>=0.4 Show all…
Dependents (1)
@hackage/evdev-streamly
Haskell evdev library
http://hackage.haskell.org/package/evdev
This library provides access to the Linux evdev interface, for reading input events from devices. It uses c2hs-generated bindings to libevdev, which should be available on almost any modern Linux distro.
Modules
Evdevprovides the basic functionality for initialising devices, reading events etc.Evdev.Codescontains datatypes corresponding to the constants ininput-event-codes.h, such as keys and device properties.Evdev.Streamprovides a higher-level Streamly-based interface, for obtaining a stream of events.
Why streamly?
Compared to other Haskell streaming libraries, I've found streamly to have a remarkably easy-to-use API, and the best, simplest support for concurrency. For example, merging concurrent streams of events, from different devices, is trivial.
If you wish to use this library alongside conduit, pipes etc. then see here for a guide on interoperation.
Getting started
Your user will need to be a member of the input group in order to read from devices. Try usermod -a -G input [username].
If you wish to make use of concurrency, e.g. to use functions like allEvents, be sure to pass the option -threaded to GHC, in order to enable the threaded runtime.
The evdev-examples folder contains a basic evtest clone, with the added ability to read events from multiple devices concurrently.
See Hackage for further documentation.
Still to come
Haddock documentation for the non-stream interface. I intend to redesign the interface in some minor ways first. Until then, everything maps quite directly to the C library, while taking care of the nitty-gritty low-level stuff.
There are many more methods in the C library that I'd like to expose. So far the emphasis has very much been on squeezing out the functionality I personally needed.
Some of the streaming functions print exceptions straight to stderr. Again, this was convenient at the time, but it would be cleaner to allow specifying a Writer, or passing callbacks.