These bindings closely follow libinput's concepts and it's original API. Please refer to the libinput documentation to understand the general structure and concepts.
Add to your Cargo.toml
:
toml
input = "0.5"
Configure and run event loop:
```rust use std::fs::{File, OpenOptions}; use std::os::unix::{fs::OpenOptionsExt, io::{RawFd, FromRawFd, IntoRawFd}}; use std::path::Path;
use input::{Libinput, LibinputInterface}; use libc::{ORDONLY, ORDWR, O_WRONLY};
struct Interface;
impl LibinputInterface for Interface {
fn openrestricted(&mut self, path: &Path, flags: i32) -> Result
fn main() { let mut input = Libinput::newwithudev(Interface); input.udevassignseat("seat0").unwrap(); loop { input.dispatch().unwrap(); for event in &mut input { println!("Got event: {:?}", event); } } } ```