1pub use sys::input::{Button, Key};
2
3pub struct Input;
5
6impl Input {
7 pub fn is_button_down(button: Button) -> bool {
9 unsafe { sys::input::forge_input_isDown(button) }
10 }
11
12 pub fn is_button_pressed(button: Button) -> bool {
14 unsafe { sys::input::forge_input_isPressed(button) }
15 }
16
17 pub fn is_button_released(button: Button) -> bool {
19 unsafe { sys::input::forge_input_isReleased(button) }
20 }
21
22 pub fn get_stick_l() -> (f32, f32) {
24 let mut x = 0.0;
25 let mut y = 0.0;
26 unsafe { sys::input::forge_input_getStickL(&mut x, &mut y) };
27 (x, y)
28 }
29
30 pub fn get_stick_r() -> (f32, f32) {
32 let mut x = 0.0;
33 let mut y = 0.0;
34 unsafe { sys::input::forge_input_getStickR(&mut x, &mut y) };
35 (x, y)
36 }
37
38 pub fn is_connected() -> bool {
40 unsafe { sys::input::forge_input_isConnected() }
41 }
42
43 pub fn get_touch() -> Option<(f32, f32)> {
45 let mut x = 0.0;
46 let mut y = 0.0;
47 if unsafe { sys::input::forge_input_getTouch(&mut x, &mut y) } {
48 Some((x, y))
49 } else {
50 None
51 }
52 }
53
54 pub fn is_key_down(key: Key) -> bool {
56 unsafe { sys::input::forge_input_isKeyDown(key) }
57 }
58
59 pub fn is_key_pressed(key: Key) -> bool {
61 unsafe { sys::input::forge_input_isKeyPressed(key) }
62 }
63
64 pub fn is_key_released(key: Key) -> bool {
66 unsafe { sys::input::forge_input_isKeyReleased(key) }
67 }
68
69 pub fn is_shift_down() -> bool {
71 unsafe { sys::input::forge_input_isShiftDown() }
72 }
73
74 pub fn is_ctrl_down() -> bool {
76 unsafe { sys::input::forge_input_isCtrlDown() }
77 }
78
79 pub fn is_alt_down() -> bool {
81 unsafe { sys::input::forge_input_isAltDown() }
82 }
83}