-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput.rs
108 lines (102 loc) · 2.82 KB
/
input.rs
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
96
97
98
99
100
101
102
103
104
105
106
107
108
use crate::physics::Pos2D;
use ggez::event::KeyCode;
#[derive(Default)]
pub struct Input {
pub up: bool,
pub left: bool,
pub down: bool,
pub right: bool,
pub pointing: Pos2D<f32>,
pub rightpad: Pos2D<i32>,
pub gamepad: bool,
pub mouse_left: bool,
pub mouse_right: bool,
pub controler_south: bool,
pub controler_east: bool,
pub controler_west: bool,
pub controler_north: bool,
pub controler_right_trigger_1: bool,
pub controler_left_trigger_1: bool,
pub controler_right_trigger_2: bool,
pub controler_left_trigger_2: bool,
pub controler_start: bool,
pub controler_select: bool,
pub controler_mode: bool,
pub controler_dpad_right: bool,
pub controler_dpad_up: bool,
pub controler_dpad_left: bool,
pub controler_dpad_down: bool,
pub controler_left_thumb: bool,
pub controler_right_thumb: bool,
}
pub struct KeyMap {
pub up: KeyCode,
pub down: KeyCode,
pub left: KeyCode,
pub right: KeyCode,
pub next_map: KeyCode,
pub escape: KeyCode,
pub inventory: KeyCode,
}
impl Default for KeyMap {
fn default() -> Self {
Self {
up: KeyCode::W,
down: KeyCode::S,
left: KeyCode::A,
right: KeyCode::D,
next_map: KeyCode::R,
escape: KeyCode::Escape,
inventory: KeyCode::E,
}
}
}
/*
fn egui_to_winit_key_code(key: Key) -> Option<KeyCode> {
Some(match key {
Key::Escape => KeyCode::Escape,
Key::Insert => KeyCode::Insert,
Key::Home => KeyCode::Home,
Key::Delete => KeyCode::Delete,
Key::End => KeyCode::End,
Key::PageDown => KeyCode::PageDown,
Key::PageUp => KeyCode::PageUp,
Key::ArrowLeft => KeyCode::Left,
Key::ArrowUp => KeyCode::Up,
Key::ArrowRight => KeyCode::Right,
Key::ArrowDown => KeyCode::Down,
Key::Backspace => KeyCode::Back,
Key::Enter => KeyCode::Return,
Key::Tab => KeyCode::Tab,
Key::Space => KeyCode::Space,
Key::A => KeyCode::A,
Key::B => KeyCode::B,
Key::C => KeyCode::C,
Key::D => KeyCode::D,
Key::E => KeyCode::E,
Key::F => KeyCode::F,
Key::G => KeyCode::G,
Key::H => KeyCode::H,
Key::I => KeyCode::I,
Key::J => KeyCode::J,
Key::K => KeyCode::K,
Key::L => KeyCode::L,
Key::M => KeyCode::M,
Key::N => KeyCode::N,
Key::O => KeyCode::O,
Key::P => KeyCode::P,
Key::Q => KeyCode::Q,
Key::R => KeyCode::R,
Key::S => KeyCode::S,
Key::T => KeyCode::T,
Key::U => KeyCode::U,
Key::V => KeyCode::V,
Key::W => KeyCode::W,
Key::X => KeyCode::X,
Key::Z => KeyCode::Z,
_ => {
return None;
}
})
}
*/