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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! This is simple Rust crate for managing and querying input state.
//!
//! It treats the mouse and keyboard as an immutable data structure that you
//! can query to find which keys and buttons are pressed (or where the pointer
//! is).
//!
//! The core data structures of `Mouse` and `Keyboard` are generic, in theory
//! supporting multiple windowing libraries. You can roll your own, or you can
//! enable the `winit` which has factory methods to easily create
//! a `Mouse` and `Keyboard` which work with the `winit` library.
//!
//! As stated, the mouse and keyboard are immutable. To track input changes,
//! each provide a `begin_frame_input` method which return an object you can
//! make changes to for the frame.
//!
//! # Examples
//!
//! ```rust,ignore
//! # #[cfg(feature = "winit_0_21")]
//! # use winit_0_21 as winit;
//!
//! # #[cfg(feature = "winit_0_24")]
//! # use winit_0_24 as winit;
//!
//! # #[cfg(feature = "winit_0_27")]
//! # use winit_0_27 as winit;
//!
//! # #[cfg(feature = "winit_0_29")]
//! # use winit_0_29 as winit;
//!
//! # #[cfg(feature = "winit_0_30")]
//! # use winit_0_30 as winit;
//! # use winit::event::{Event, VirtualKeyCode, MouseButton};
//! use buttons::prelude::*;
//!
//! let mut event_loop = winit::event_loop::EventLoop::new();
//! let mut keyboard = buttons::support::winit::keyboard();
//! let mut mouse = buttons::support::winit::mouse();
//! let mut touch = buttons::support::winit::touch();
//!
//! // Track input
//! event_loop.run(move |event, _, _| {
//! keyboard.handle_event(&event);
//! mouse.handle_event(&event);
//! touch.handle_event(&event);
//!
//! // Check state
//! if keyboard.pressed(VirtualKeyCode::Escape)
//! || mouse.released(MouseButton::Right)
//! || touch.first_touch().is_some()
//! {
//! // Do something
//! }
//! });
//! ```
pub use crate;
pub use crate;
pub use crate;
/// A trait for events that can modify input state.
pub use winit_0_21 as winit;
pub use winit_0_24 as winit;
pub use winit_0_27 as winit;
pub use winit_0_29 as winit;
pub use winit_0_30 as winit;