All Projects → Smithay → input.rs

Smithay / input.rs

Licence: MIT license
libinput bindings for rust

Programming Languages

rust
11053 projects
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to input.rs

showmethekey
Show keys you typed on screen.
Stars: ✭ 84 (+44.83%)
Mutual labels:  wayland, libinput
cl-wlroots
Common lisp bindings for wlroots, a library for writing Wayland compositors
Stars: ✭ 32 (-44.83%)
Mutual labels:  bindings, wayland
wayland-javafx
wayland backend for javafx
Stars: ✭ 20 (-65.52%)
Mutual labels:  wayland
asc
A simple (Wayland) compositor
Stars: ✭ 26 (-55.17%)
Mutual labels:  wayland
rsmpeg
A Rust crate that exposes FFmpeg's power as much as possible.
Stars: ✭ 390 (+572.41%)
Mutual labels:  bindings
loam
Javascript wrapper for GDAL in the browser
Stars: ✭ 174 (+200%)
Mutual labels:  bindings
ocaml-tracy
Bindings to the Tracy profiler
Stars: ✭ 21 (-63.79%)
Mutual labels:  bindings
linux detect tablet mode
Detect if your laptop is in normal or tablet mode. Useful for Yoga laptops to disable keyboard/trackpoint/touchpad in a tablet mode
Stars: ✭ 110 (+89.66%)
Mutual labels:  libinput
Hotkeys
🔤 A small C# (.NET) Library which allows binding of global HotKeys to any Application's Windows (including Windows Apps such as explorer.exe), even in Background. (using P/Invokes)
Stars: ✭ 66 (+13.79%)
Mutual labels:  bindings
popsicle
Popsicle aims to bridge the JUCE c++ framework to python.
Stars: ✭ 102 (+75.86%)
Mutual labels:  bindings
wleird
A collection a Wayland clients doing weird things, for compositor testing
Stars: ✭ 36 (-37.93%)
Mutual labels:  wayland
waylandpp
Wayland C++ bindings
Stars: ✭ 64 (+10.34%)
Mutual labels:  wayland
DotNetJS
Consume C# in JavaScript with comfort: single-file UMD library, auto-generated 2-way bindings and type definitions
Stars: ✭ 551 (+850%)
Mutual labels:  bindings
ivi-homescreen
Embedded Flutter runtime targeting Embedded Linux with Wayland
Stars: ✭ 172 (+196.55%)
Mutual labels:  wayland
swift-tree-sitter
Swift bindings for the tree-sitter parsing library
Stars: ✭ 29 (-50%)
Mutual labels:  bindings
hoedown
rust bindings for hoedown
Stars: ✭ 16 (-72.41%)
Mutual labels:  bindings
htaglib
Haskell bindings for TagLib, an audio meta-data library
Stars: ✭ 20 (-65.52%)
Mutual labels:  bindings
wdisplays
Mirror of cyclopsian/wdisplays
Stars: ✭ 95 (+63.79%)
Mutual labels:  wayland
wayland
Golang Wayland
Stars: ✭ 51 (-12.07%)
Mutual labels:  wayland
jquery-bindings
Simple two-way data binding using proxies and requestIdleCallback
Stars: ✭ 17 (-70.69%)
Mutual labels:  bindings

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.7"

Install the libinput dev dependencies:

Ubuntu:

apt-get install libinput-dev

Fedora

dnf install libinput-devel

Configure and run event loop:

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::{O_RDONLY, O_RDWR, O_WRONLY};

struct Interface;

impl LibinputInterface for Interface {
    fn open_restricted(&mut self, path: &Path, flags: i32) -> Result<RawFd, i32> {
        OpenOptions::new()
            .custom_flags(flags)
            .read((flags & O_RDONLY != 0) | (flags & O_RDWR != 0))
            .write((flags & O_WRONLY != 0) | (flags & O_RDWR != 0))
            .open(path)
            .map(|file| file.into_raw_fd())
            .map_err(|err| err.raw_os_error().unwrap())
    }
    fn close_restricted(&mut self, fd: RawFd) {
        unsafe {
            File::from_raw_fd(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);
        }
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].