pub const UP: ButtonSet = ButtonSet {
flag_set: 0b10000000,
};
pub const RIGHT: ButtonSet = ButtonSet {
flag_set: 0b01000000,
};
pub const LEFT: ButtonSet = ButtonSet {
flag_set: 0b00100000,
};
pub const DOWN: ButtonSet = ButtonSet {
flag_set: 0b00010000,
};
pub const A: ButtonSet = ButtonSet {
flag_set: 0b00001000,
};
pub const B: ButtonSet = ButtonSet {
flag_set: 0b00000100,
};
pub const ANY_BUTTON: ButtonSet = ButtonSet {
flag_set: 0b11111111,
};
pub const UP_BUTTON: ButtonSet = UP;
pub const RIGHT_BUTTON: ButtonSet = RIGHT;
pub const DOWN_BUTTON: ButtonSet = DOWN;
pub const LEFT_BUTTON: ButtonSet = LEFT;
pub const A_BUTTON: ButtonSet = A;
pub const B_BUTTON: ButtonSet = B;
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct ButtonSet {
pub flag_set: u8,
}
impl ButtonSet {
pub fn pressed(&self) -> bool {
unsafe { crate::libraries::arduboy2_library::binding::pressed(self.flag_set) }
}
pub fn just_pressed(&self) -> bool {
unsafe { crate::libraries::arduboy2_library::binding::just_pressed(self.flag_set) }
}
pub fn just_released(&self) -> bool {
unsafe { crate::libraries::arduboy2_library::binding::just_released(self.flag_set) }
}
pub fn not_pressed(&self) -> bool {
unsafe { crate::libraries::arduboy2_library::binding::not_pressed(self.flag_set) }
}
}
impl core::ops::BitOr for ButtonSet {
type Output = Self;
fn bitor(self, other: Self) -> Self {
Self {
flag_set: self.flag_set | other.flag_set,
}
}
}