100 lines
2.2 KiB
Rust
100 lines
2.2 KiB
Rust
use std::slice;
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
|
pub enum Button {
|
|
Back,
|
|
Screen1,
|
|
Screen2,
|
|
Screen3,
|
|
Screen4,
|
|
Light,
|
|
|
|
M1,
|
|
M2,
|
|
M3,
|
|
MR,
|
|
|
|
G1,
|
|
G2,
|
|
G3,
|
|
G4,
|
|
G5,
|
|
G6,
|
|
G7,
|
|
|
|
G8,
|
|
G9,
|
|
G10,
|
|
G11,
|
|
G12,
|
|
G13,
|
|
G14,
|
|
|
|
G15,
|
|
G16,
|
|
G17,
|
|
G18,
|
|
G19,
|
|
|
|
G20,
|
|
G21,
|
|
G22,
|
|
|
|
Stick1,
|
|
Stick2,
|
|
Stick3,
|
|
}
|
|
|
|
impl Button {
|
|
pub(super) fn to_evdev_button(&self) -> input_linux::Key {
|
|
use input_linux::Key::*;
|
|
|
|
match &self {
|
|
Button::Back => ButtonBack,
|
|
Button::Screen1 => Button0,
|
|
Button::Screen2 => Button1,
|
|
Button::Screen3 => Button2,
|
|
Button::Screen4 => Button3,
|
|
Button::Light => Button4,
|
|
Button::M1 => Button5,
|
|
Button::M2 => Button6,
|
|
Button::M3 => Button7,
|
|
Button::MR => Button8,
|
|
Button::G1 => Button9,
|
|
Button::G2 => Unknown10A,
|
|
Button::G3 => Unknown10B,
|
|
Button::G4 => Unknown10C,
|
|
Button::G5 => Unknown10D,
|
|
Button::G6 => Unknown10E,
|
|
Button::G7 => Unknown10F,
|
|
Button::G8 => Unknown118,
|
|
Button::G9 => Unknown119,
|
|
Button::G10 => Unknown11A,
|
|
Button::G11 => Unknown11B,
|
|
Button::G12 => Unknown11C,
|
|
Button::G13 => Unknown11D,
|
|
Button::G14 => Unknown11E,
|
|
Button::G15 => Unknown11F,
|
|
Button::G16 => Unknown12C,
|
|
Button::G17 => Unknown12D,
|
|
Button::G18 => Unknown12E,
|
|
Button::G19 => Unknown13F,
|
|
Button::G20 => Unknown152,
|
|
Button::G21 => Unknown153,
|
|
Button::G22 => Unknown154,
|
|
Button::Stick1 => Unknown155,
|
|
Button::Stick2 => Unknown156,
|
|
Button::Stick3 => Unknown157,
|
|
}
|
|
}
|
|
|
|
pub fn all_buttons() -> slice::Iter<'static, Self> {
|
|
use Button::*;
|
|
[
|
|
Back, Screen1, Screen2, Screen3, Screen4, Light, M1, M2, M3, MR, G1, G2, G3, G4, G5, G6, G7, G8, G9, G10,
|
|
G11, G12, G13, G14, G15, G16, G17, G18, G19, G20, G21, G22, Stick1, Stick2, Stick3,
|
|
]
|
|
.iter()
|
|
}
|
|
}
|