rich_sdl2_rust/event/game_controller/
map.rs1use crate::bind;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
7#[non_exhaustive]
8pub enum MapInput {
9 Button {
11 index: u32,
13 },
14 Axis {
16 index: u32,
18 },
19 Hat {
21 index: u32,
23 mask: u32,
25 },
26}
27
28impl From<bind::SDL_GameControllerButtonBind> for MapInput {
29 fn from(raw: bind::SDL_GameControllerButtonBind) -> Self {
30 match raw.bindType {
31 bind::SDL_CONTROLLER_BINDTYPE_BUTTON => MapInput::Button {
32 index: unsafe { raw.value.button } as u32,
33 },
34 bind::SDL_CONTROLLER_BINDTYPE_AXIS => MapInput::Axis {
35 index: unsafe { raw.value.axis } as u32,
36 },
37 bind::SDL_CONTROLLER_BINDTYPE_HAT => MapInput::Hat {
38 index: unsafe { raw.value.hat.hat } as u32,
39 mask: unsafe { raw.value.hat.hat_mask } as u32,
40 },
41 _ => unreachable!(), }
43 }
44}