48 lines
1.4 KiB
Rust
48 lines
1.4 KiB
Rust
/// State of all GSA buttons
|
|
#[derive(Default, Copy, Clone)]
|
|
pub struct Buttons {
|
|
/// UP on dpad
|
|
pub dpad_up: bool,
|
|
/// DOWN on dpad
|
|
pub dpad_down: bool,
|
|
/// LEFT on dpad
|
|
pub dpad_left: bool,
|
|
/// RIGHT on dpad
|
|
pub dpad_right: bool,
|
|
/// X on nintendo, Y on microsoft, TRIANGLE on sony
|
|
pub face_up: bool,
|
|
/// B on nintendo, A on microsoft, CROSS on sony
|
|
pub face_down: bool,
|
|
/// Y on nintendo, X on microsoft, SQUARE on sony
|
|
pub face_left: bool,
|
|
/// A on nintendo, B on microsoft, CIRCLE on sony
|
|
pub face_right: bool,
|
|
/// left shoulder button
|
|
pub l: bool,
|
|
/// right shoulder button
|
|
pub r: bool,
|
|
/// start button
|
|
pub start: bool,
|
|
/// select button
|
|
pub select: bool,
|
|
}
|
|
|
|
impl Buttons {
|
|
pub(crate) fn pressed(old: &Buttons, new: &Buttons) -> Buttons {
|
|
Buttons {
|
|
dpad_up: !old.dpad_up && new.dpad_up,
|
|
dpad_down: !old.dpad_down && new.dpad_down,
|
|
dpad_left: !old.dpad_left && new.dpad_left,
|
|
dpad_right: !old.dpad_right && new.dpad_right,
|
|
face_up: !old.face_up && new.face_up,
|
|
face_down: !old.face_down && new.face_down,
|
|
face_left: !old.face_left && new.face_left,
|
|
face_right: !old.face_right && new.face_right,
|
|
l: !old.l && new.l,
|
|
r: !old.r && new.r,
|
|
start: !old.start && new.start,
|
|
select: !old.select && new.select,
|
|
}
|
|
}
|
|
}
|