lighthouse_protocol/input/
gamepad_button_event.rs1use serde::{Deserialize, Serialize};
2
3use crate::Direction;
4
5#[derive(Debug, Serialize, Deserialize, PartialEq, Clone)]
7#[serde(tag = "control", rename_all = "camelCase")]
8pub struct GamepadButtonEvent {
9 pub index: usize,
11 pub down: bool,
13 pub value: f64,
15}
16
17impl GamepadButtonEvent {
18 pub fn d_pad_direction(&self) -> Option<Direction> {
21 match self.index {
22 12 => Some(Direction::Up),
23 13 => Some(Direction::Down),
24 14 => Some(Direction::Left),
25 15 => Some(Direction::Right),
26 _ => None,
27 }
28 }
29}