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
#[derive(Clone, Copy, Hash, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[repr(u8)]
pub enum GamepadButton {
    Up,
    Down,
    Left,
    Right,
    A,
    B,
    X,
    Y,
    Start,
    Select,
    LeftShoulder,
    RightShoulder,
    LeftTrigger,
    RightTrigger,
    LeftStick,
    RightStick,
}

#[derive(Clone, Copy, Hash, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[repr(u8)]
pub enum GamepadAxis {
    LeftUp,
    LeftDown,
    LeftLeft,
    LeftRight,
    RightUp,
    RightDown,
    RightLeft,
    RightRight,
}

#[link(wasm_import_module = "qwac_input")]
extern "C" {
    /// Get the button press states for all 4 gamepads
    pub fn gamepad_buttons() -> i64;

    /// Get the axis state for one gamepad axis, range [-1, 1].
    pub fn gamepad_axis(player: i32, axis: i32) -> f32;
}