MCPcopy Index your code
hub / github.com/Smithay/input.rs

github.com/Smithay/input.rs @v0.10.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.10.0 ↗ · + Follow
1,066 symbols 1,289 edges 42 files 656 documented · 62% updated 3mo agov0.10.0 · 2026-04-05★ 1013 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Rust libinput bindings

Build Status Crates.io License Docs

libinput bindings for Rust

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.

Note: Due to a bug within libinput, these bindings are not compatible with libinput 1.19.0. Please use the fixed 1.19.1 version.

Usage

Add to your Cargo.toml:

input = "0.8"

Install the libinput dev dependencies:

Ubuntu:

apt-get install libinput-dev

Fedora

dnf install libinput-devel

Configure and run event loop:

use input::{Libinput, LibinputInterface};
use libc::{O_ACCMODE, O_RDONLY, O_RDWR, O_WRONLY};
use std::fs::{File, OpenOptions};
use std::os::unix::{fs::OpenOptionsExt, io::OwnedFd};
use std::path::Path;

struct Interface;

impl LibinputInterface for Interface {
    fn open_restricted(&mut self, path: &Path, flags: i32) -> Result<OwnedFd, i32> {
        OpenOptions::new()
            .custom_flags(flags)
            .read((flags & O_ACCMODE == O_RDONLY) | (flags & O_ACCMODE == O_RDWR))
            .write((flags & O_ACCMODE == O_WRONLY) | (flags & O_ACCMODE == O_RDWR))
            .open(path)
            .map(|file| file.into())
            .map_err(|err| err.raw_os_error().unwrap())
    }
    fn close_restricted(&mut self, fd: OwnedFd) {
        drop(File::from(fd));
    }
}

fn main() {
    let mut input = Libinput::new_with_udev(Interface);
    input.udev_assign_seat("seat0").unwrap();
    loop {
        input.dispatch().unwrap();
        for event in &mut input {
            println!("Got event: {:?}", event);
        }
    }
}

Extension points exported contracts — how you extend this code

AsRaw (Interface)
Trait for types that allow to optain the underlying raw libinput pointer. [14 implementers]
src/lib.rs
EventTrait (Interface)
Common functions all (Sub-)Events implement. [12 implementers]
src/event.rs
TouchEventSlot (Interface)
Touch slot related functions all TouchEvents implement, that can be mapped to slots. A touch slot is grouping all event [4 …
src/event/touch.rs
LibinputInterface (Interface)
libinput does not open file descriptors to devices directly, instead `open_restricted` and `close_restricted` are called
src/context.rs
Context (Interface)
Trait to receive the underlying context [12 implementers]
src/lib.rs
GestureSwipeEventTrait (Interface)
Common functions for swipe gesture events [4 implementers]
src/event/gesture.rs
FromRaw (Interface)
Trait for types that allow to be initialized from a raw pointer [12 implementers]
src/lib.rs
GesturePinchEventTrait (Interface)
Common functions for pinch gesture events [4 implementers]
src/event/gesture.rs

Core symbols most depended-on inside this repo

as_raw_mut
called by 136
src/lib.rs
as_raw_event
called by 10
src/event.rs
context
called by 4
src/event/gesture.rs
lib_versions
called by 3
input-sys/build.rs
as_raw
called by 3
src/event.rs
as_raw
called by 3
src/context.rs
context
called by 2
src/event.rs
clone
called by 2
src/context.rs

Shape

Class 455
Enum 380
Method 206
Interface 21
Function 4

Languages

C++54%
Rust46%

Modules by API surface

src/device.rs88 symbols
input-sys/include/libinput.1.30.0.h53 symbols
input-sys/include/libinput.1.29.0.h52 symbols
input-sys/include/libinput.1.28.0.h51 symbols
input-sys/include/libinput.1.27.0.h50 symbols
input-sys/include/libinput.1.26.0.h49 symbols
input-sys/include/libinput.1.23.0.h48 symbols
input-sys/include/libinput.1.21.0.h46 symbols
input-sys/include/libinput.1.19.0.h45 symbols
input-sys/include/libinput.1.15.0.h45 symbols
input-sys/include/libinput.1.9.0.h44 symbols
input-sys/include/libinput.1.14.0.h44 symbols

For agents

$ claude mcp add input.rs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page