1use serde::{Deserialize, Serialize};
2use std::convert::AsRef;
3use strum::{AsRefStr, EnumIter, EnumString};
4
5#[derive(
7 Clone,
8 Copy,
9 Debug,
10 PartialEq,
11 Eq,
12 PartialOrd,
13 Ord,
14 Hash,
15 Deserialize,
16 Serialize,
17 AsRefStr,
18 EnumIter,
19 EnumString,
20)]
21pub enum GameInput {
22 #[strum(serialize = "gameinput-primary")]
23 Primary,
24 #[strum(serialize = "gameinput-secondary")]
25 Secondary,
26 #[strum(serialize = "gameinput-block")]
27 Block,
28 #[strum(serialize = "gameinput-slot1")]
29 Slot1,
30 #[strum(serialize = "gameinput-slot2")]
31 Slot2,
32 #[strum(serialize = "gameinput-slot3")]
33 Slot3,
34 #[strum(serialize = "gameinput-slot4")]
35 Slot4,
36 #[strum(serialize = "gameinput-slot5")]
37 Slot5,
38 #[strum(serialize = "gameinput-slot6")]
39 Slot6,
40 #[strum(serialize = "gameinput-slot7")]
41 Slot7,
42 #[strum(serialize = "gameinput-slot8")]
43 Slot8,
44 #[strum(serialize = "gameinput-slot9")]
45 Slot9,
46 #[strum(serialize = "gameinput-slot10")]
47 Slot10,
48 #[strum(serialize = "gameinput-togglecursor")]
49 ToggleCursor,
50 #[strum(serialize = "gameinput-moveforward")]
51 MoveForward,
52 #[strum(serialize = "gameinput-moveback")]
53 MoveBack,
54 #[strum(serialize = "gameinput-moveleft")]
55 MoveLeft,
56 #[strum(serialize = "gameinput-moveright")]
57 MoveRight,
58 #[strum(serialize = "gameinput-jump")]
59 Jump,
60 #[strum(serialize = "gameinput-sit")]
61 Sit,
62 #[strum(serialize = "gameinput-crawl")]
63 Crawl,
64 #[strum(serialize = "gameinput-dance")]
65 Dance,
66 #[strum(serialize = "gameinput-greet")]
67 Greet,
68 #[strum(serialize = "gameinput-glide")]
69 Glide,
70 #[strum(serialize = "gameinput-swimup")]
71 SwimUp,
72 #[strum(serialize = "gameinput-swimdown")]
73 SwimDown,
74 #[strum(serialize = "gameinput-fly")]
75 Fly,
76 #[strum(serialize = "gameinput-sneak")]
77 Sneak,
78 #[strum(serialize = "gameinput-cancelclimb")]
79 CancelClimb,
80 #[strum(serialize = "gameinput-togglelantern")]
81 ToggleLantern,
82 #[strum(serialize = "gameinput-mount")]
83 Mount,
84 #[strum(serialize = "gameinput-stayfollow")]
85 StayFollow,
86 #[strum(serialize = "gameinput-chat")]
87 Chat,
88 #[strum(serialize = "gameinput-command")]
89 Command,
90 #[strum(serialize = "gameinput-escape")]
91 Escape,
92 #[strum(serialize = "gameinput-map")]
93 Map,
94 #[strum(serialize = "gameinput-inventory")]
95 Inventory,
96 #[strum(serialize = "gameinput-trade")]
97 Trade,
98 #[strum(serialize = "gameinput-social")]
99 Social,
100 #[strum(serialize = "gameinput-crafting")]
101 Crafting,
102 #[strum(serialize = "gameinput-diary")]
103 Diary,
104 #[strum(serialize = "gameinput-settings")]
105 Settings,
106 #[strum(serialize = "gameinput-controls")]
107 Controls,
108 #[strum(serialize = "gameinput-toggleinterface")]
109 ToggleInterface,
110 #[strum(serialize = "gameinput-toggledebug")]
111 ToggleDebug,
112 #[cfg(feature = "egui-ui")]
113 #[strum(serialize = "gameinput-toggle_egui_debug")]
114 ToggleEguiDebug,
115 #[strum(serialize = "gameinput-togglechat")]
116 ToggleChat,
117 #[strum(serialize = "gameinput-fullscreen")]
118 Fullscreen,
119 #[strum(serialize = "gameinput-screenshot")]
120 Screenshot,
121 #[strum(serialize = "gameinput-toggleingameui")]
122 ToggleIngameUi,
123 #[strum(serialize = "gameinput-roll")]
124 Roll,
125 #[strum(serialize = "gameinput-giveup")]
126 GiveUp,
127 #[strum(serialize = "gameinput-respawn")]
128 Respawn,
129 #[strum(serialize = "gameinput-interact")]
130 Interact,
131 #[strum(serialize = "gameinput-togglewield")]
132 ToggleWield,
133 #[strum(serialize = "gameinput-swaploadout")]
134 SwapLoadout,
135 #[strum(serialize = "gameinput-freelook")]
136 FreeLook,
137 #[strum(serialize = "gameinput-autowalk")]
138 AutoWalk,
139 #[strum(serialize = "gameinput-zoomin")]
140 ZoomIn,
141 #[strum(serialize = "gameinput-zoomout")]
142 ZoomOut,
143 #[strum(serialize = "gameinput-zoomlock")]
144 ZoomLock,
145 #[strum(serialize = "gameinput-cameraclamp")]
146 CameraClamp,
147 #[strum(serialize = "gameinput-cyclecamera")]
148 CycleCamera,
149 #[strum(serialize = "gameinput-select")]
150 Select,
151 #[strum(serialize = "gameinput-acceptgroupinvite")]
152 AcceptGroupInvite,
153 #[strum(serialize = "gameinput-declinegroupinvite")]
154 DeclineGroupInvite,
155 #[strum(serialize = "gameinput-mapzoomin")]
156 MapZoomIn,
157 #[strum(serialize = "gameinput-mapzoomout")]
158 MapZoomOut,
159 #[strum(serialize = "gameinput-map-locationmarkerbutton")]
160 MapSetMarker,
161 #[strum(serialize = "gameinput-spectatespeedboost")]
162 SpectateSpeedBoost,
163 #[strum(serialize = "gameinput-spectateviewpoint")]
164 SpectateViewpoint,
165 #[strum(serialize = "gameinput-mutemaster")]
166 MuteMaster,
167 #[strum(serialize = "gameinput-muteinactivemaster")]
168 MuteInactiveMaster,
169 #[strum(serialize = "gameinput-mutemusic")]
170 MuteMusic,
171 #[strum(serialize = "gameinput-mutesfx")]
172 MuteSfx,
173 #[strum(serialize = "gameinput-muteambience")]
174 MuteAmbience,
175 #[strum(serialize = "gameinput-togglewalk")]
176 ToggleWalk,
177}
178
179impl GameInput {
180 pub fn get_localization_key(&self) -> &str { self.as_ref() }
181
182 pub fn can_share_bindings(a: GameInput, b: GameInput) -> bool {
186 a.get_representative_binding() == b.get_representative_binding()
187 }
188
189 fn get_representative_binding(&self) -> GameInput {
194 match self {
195 GameInput::Jump => GameInput::Jump,
196 GameInput::SwimUp => GameInput::Jump,
197 GameInput::Respawn => GameInput::Jump,
198
199 GameInput::FreeLook => GameInput::FreeLook,
200 GameInput::AutoWalk => GameInput::FreeLook,
201
202 _ => *self,
203 }
204 }
205}