raw_input/
lib.rs

1//! # raw-input
2//! 
3//! A cross-platform library for capturing and simulating global input events (keyboard and mouse).
4//!
5//! ## Core Components
6//! 
7//! - **[`Core`]**: Manages the platform-specific event loop. Must be started to enable other features.
8//! - **[`Listen`]**: Provides a way to subscribe to global input events without blocking them.
9//! - **[`Simulate`]**: Allows programmatic injection of keyboard and mouse events.
10//! - **[`Grab`]**: Enables intercepting and optionally blocking input events from reaching other applications.
11//! - **[`Display`]**: Utilities for querying monitor information and cursor positions.
12//!
13//! ## Example
14//! 
15//! ```no_run
16//! use std::thread;
17//! use std::time::Duration;
18//! 
19//! use raw_input::{Core, Listen, Event};
20//! 
21//! fn main() {
22//!     // 1. Start the core engine in a background thread 
23//!     // (Crucial for processing Windows message loops)
24//!     thread::spawn(|| {
25//!         Core::start().expect("Failed to start raw-input core");
26//!     });
27//! 
28//!     // 2. Subscribe to global events
29//!     Listen::start();
30//!     let handle = Listen::subscribe(|event| {
31//!         match event {
32//!             Event::KeyDown { key } => println!("Key pressed: {:?}", key),
33//!             Event::MouseMove { delta } => println!("Mouse moved by: {}, {}", delta.x, delta.y),
34//!             _ => {},
35//!         }
36//!     });
37//! 
38//!     // 3. Manage the subscription lifecycle
39//!     thread::sleep(Duration::from_secs(5));
40//!     handle.pause();    // Stop receiving events temporarily
41//! 
42//!     thread::sleep(Duration::from_secs(2));
43//!     handle.resume();   // Start receiving events again
44//! 
45//!     thread::sleep(Duration::from_secs(2));
46//!     handle.unsubscribe(); // Permanently remove the listener
47//!     Listen::stop(); // Stop Listen
48//!     Core::stop()
49//! }
50//! ```
51
52mod dispatcher;
53mod event;
54mod keycodes;
55mod platform;
56mod subscription;
57
58pub use crate::event::{Event, FloatPoint, Key, MouseButton, Point};
59pub use crate::platform::MonitorInfo;
60pub use crate::subscription::SubscriptionHandle;
61
62pub use crate::platform::{Core, Display, Grab, Listen, Simulate};
63
64pub use crate::platform::CoreError;