1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! A simple library for querying mouse and keyboard state without requiring
//! an active window. Currently works in Windows, Linux, and macOS.
//!
//! ```no_run
//! use device_query::{DeviceQuery, DeviceState, MouseState, Keycode};
//!
//! let device_state = DeviceState::new();
//!
//! let mouse: MouseState = device_state.get_mouse();
//! println!("Current Mouse Coordinates: {:?}", mouse.coords);
//!
//! let keys: Vec<Keycode> = device_state.get_keys();
//! println!("Is A pressed? {}", keys.contains(&Keycode::A));
//! ```
//!
//! It's also possible to listen for events.
//! ```no_run
//! use device_query::{DeviceEvents, DeviceState};
//!
//! let device_state = DeviceState::new();
//!
//! let _guard = device_state.on_mouse_move(|position| {
//! println!("Mouse position: {:#?}", position);
//! });
//! let _guard = device_state.on_mouse_down(|button| {
//! println!("Mouse button down: {:#?}", button);
//! });
//! let _guard = device_state.on_mouse_up(|button| {
//! println!("Mouse button up: {:#?}", button);
//! });
//! let _guard = device_state.on_key_down(|key| {
//! println!("Keyboard key down: {:#?}", key);
//! });
//! let _guard = device_state.on_key_up(|key| {
//! println!("Keyboard key up: {:#?}", key);
//! });
//!
//! loop {}
//! ```
extern crate lazy_static;
extern crate windows;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;