https://github.com/maxbla/gel-o
Provides a Iterator interface to Linux InputEvents
https://github.com/maxbla/gel-o
evdev linux rust-library
Last synced: 4 months ago
JSON representation
Provides a Iterator interface to Linux InputEvents
- Host: GitHub
- URL: https://github.com/maxbla/gel-o
- Owner: maxbla
- License: apache-2.0
- Created: 2020-05-09T00:19:59.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-07-28T18:54:14.000Z (over 4 years ago)
- Last Synced: 2025-10-05T00:43:52.880Z (4 months ago)
- Topics: evdev, linux, rust-library
- Language: Rust
- Homepage:
- Size: 58.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE-Apache
Awesome Lists containing this project
README
# Gel-O
Gel-O is a library that provides a `std::iter::Iterator` interface over Linux `InputEvent`s. You can map, filter and loop over input events without dealing with the low-level details of obtaining those events.
Gel-O is so named for examples/delay.rs, which delays all user input, making a computer feel like Jell-O.
# Stability
Gel-O is experimental. Expect many breaking changes to come.
## Similar crates
- [evdev](https://github.com/emberian/evdev)
- A pure-rust Iterator over `InputEvents`, with no support for writing to devices (simulating user input).
- [evdev-rs](https://github.com/ndesh26/evdev-rs)
- Low-level safe bindings to [libevdev](https://www.freedesktop.org/wiki/Software/libevdev/). Gel-O is built atop evdev-rs.
## Requirements
- Linux
- epoll (Linux 2.6.27+)
- kernel supporting evdev (~ 2.4+)
- Rust toolchain
- version 1.40 or higher
- cargo
- Transitive dependencies
- C toolchain
- autoconf and libtool
- `#apt install autoconf libtool`
- `#yum install autoconf libtool`
- `#pacman -S autoconf libtool`
macOS and Windows are not supported and support is not planned. BSD support may be easy to add, as evdev was recently added to FreeBSD.
## FAQ
- How does it work?
- Gel-O monitors device files in `/dev/input`, reading `InputEvents` lazily only when user code calls `.next()`.
- Does it work when using the [Wayland Display Server Protocol](https://wayland.freedesktop.org/)?
- Yes. Gel-O works everywhere linux does - on Xorg, Wayland, and even the Linux virtual terminal
- What is the computational overhead of Gel-O?
- Gel-O is pretty leightweight. Most of the examples use around 1MB of RAM. Mouse movement is smooth on low-power devices (such as Raspberry Pi) due to efficient epoll-based architecture. On raspberry pi 3, expect Gel-O to use ~2% CPU during rapid mouse movement and 0% otherwise.
- What devices does Gel-O work with?
- Gel-O works with every input device Linux does because Gel-O operates just above the driver level. Gel-O has been tested specifically with mice, keyboards, power buttons and gamepads.
- What happens if I unplug my device and plug it back in?
- Gel-O detects new devices being plugged in, and starts monitoring them. Unplugging and plugging in might mean a few events are lost, but everything will continue smoothly after that loss.
## Limitations
- Requires read/write access to files in `/dev/input` and the file `/dev/uinput`
- This can be acomplished by running as root (sudo)
## Developing
Download the source
```
git clone [this repo]
```
Compile the source. You need a rust toolchain and cargo.
```
cargo build --release --example delay
```
Run the produced binary with root privledges
```
sudo ./target/release/examples/delay [number of ms to delay]
```
make changes to source files. Before committing, run `checks.sh` (this checks formatting and for compiler warnings) and test you changes locally
```
./checks.sh && cargo test --no-run && sudo --preserve-env cargo test
```