Crate rdevin

Source
Expand description

Cross-platform simulation and global listening for keyboard and mouse input.

This crate is subject to extreme change. There is still great room for improvement. It is only presently published for use by NuhxBoard.

§Listening for input

The listen and [grab]1 functions can be used to run a callback for all input events.

rdevin::listen(|e| dbg!(e))?;

§Simulating input

The simulate function can be used to send input events.

use rdevin::{simulate, EventType, Key};

simulate(&EventType::KeyPress(Key::KeyS))?;

§Serialization

Serde support is gated behind the serde feature.

§Acknowledgements

  • This crate is a fork of a fork of a fork of Narsil’s rdev crate, created to ensure continued maintenance and to make Rustdesk’s many useful additions available on crates.io.
  • Enigo, an input simulation library, served as inspiration and reference for Narsil’s original crate.

  1. Not available on Linux 

Re-exports§

pub use crate::keycodes::linux::code_from_key;
pub use crate::keycodes::linux::key_from_code;
pub use crate::linux::Keyboard;
pub use crate::linux::ListenError;

Modules§

codes_conv
keycodes
Different OSes use different numererical representations for keys. Functions within this module provide simple, reliable conversions between the Key enum and OS-specific keycodes.
linux

Structs§

Event
An input event received from the OS.
UnicodeInfo
The Unicode information of input.

Enums§

Button
Standard mouse buttons.
DisplayError
Errors that occur when trying to get display size.
EventType
The actual input from an input event. Can either be received from the OS or constructed in code.
GrabError
Errors that occur when trying to grab OS events.
Key
Key names here assume a QWERTY layout. If you want to detect what actual character was created by a keypress, use Event.unicode instead.
RawKey
SimulateError
Error simulating an event

Traits§

KeyboardState
We can define a dummy Keyboard, that we will use to detect what kind of EventType trigger some String. We get the currently used layout for now ! Caveat : This is layout dependent. If your app needs to support layout switching don’t use this ! Caveat: On Linux, the dead keys mechanism is not implemented. Caveat: Only shift and dead keys are implemented, Alt+unicode code on windows won’t work.

Functions§

display_size
Returns the size in pixels of the main screen.
listen
React to global input events.
simulate
Simulate an input event.

Type Aliases§

KeyCode