Skip to main content

joycon_driver/
button.rs

1use enumflags2::{bitflags, BitFlags};
2
3#[bitflags]
4#[repr(u16)]
5#[derive(Debug, Clone, Copy)]
6#[allow(non_camel_case_types)]
7#[rustfmt::skip]
8pub enum SimpleButton {
9    Down       = 0b0000_0000_0000_0001,
10    Right      = 0b0000_0000_0000_0010,
11    Left       = 0b0000_0000_0000_0100,
12    Up         = 0b0000_0000_0000_1000,
13    SL         = 0b0000_0000_0001_0000,
14    SR         = 0b0000_0000_0010_0000,
15    Unknown1   = 0b0000_0000_0100_0000,
16    Unknown2   = 0b0000_0000_1000_0000,
17    Minus      = 0b0000_0001_0000_0000,
18    Plus       = 0b0000_0010_0000_0000,
19    LeftStick  = 0b0000_0100_0000_0000,
20    RightStick = 0b0000_1000_0000_0000,
21    Home       = 0b0001_0000_0000_0000,
22    Capture    = 0b0010_0000_0000_0000,
23    L_OR_R     = 0b0100_0000_0000_0000,
24    ZL_OR_ZR   = 0b1000_0000_0000_0000,
25}
26
27pub type SimpleButtons = BitFlags<SimpleButton>;
28
29#[bitflags]
30#[repr(u8)]
31#[derive(Debug, Clone, Copy)]
32#[rustfmt::skip]
33pub enum RightButton {
34    Y  = 0b0000_0001,
35    X  = 0b0000_0010,
36    B  = 0b0000_0100,
37    A  = 0b0000_1000,
38    SR = 0b0001_0000,
39    SL = 0b0010_0000,
40    R  = 0b0100_0000,
41    ZR = 0b1000_0000,
42}
43
44pub type RightButtons = BitFlags<RightButton>;
45
46#[bitflags]
47#[repr(u8)]
48#[derive(Debug, Clone, Copy)]
49#[rustfmt::skip]
50pub enum SharedButton {
51    Minus        = 0b0000_0001,
52    Plus         = 0b0000_0010,
53    RStick       = 0b0000_0100,
54    LStick       = 0b0000_1000,
55    Home         = 0b0001_0000,
56    Capture      = 0b0010_0000,
57    Unknown      = 0b0100_0000,
58    ChargingGrip = 0b1000_0000,
59}
60
61pub type SharedButtons = BitFlags<SharedButton>;
62
63#[bitflags]
64#[repr(u8)]
65#[derive(Debug, Clone, Copy)]
66#[rustfmt::skip]
67pub enum LeftButton {
68    Down  = 0b0000_0001,
69    Up    = 0b0000_0010,
70    Right = 0b0000_0100,
71    Left  = 0b0000_1000,
72    SR    = 0b0001_0000,
73    SL    = 0b0010_0000,
74    L     = 0b0100_0000,
75    ZL    = 0b1000_0000,
76}
77
78pub type LeftButtons = BitFlags<LeftButton>;