Model the keypad

Former-commit-id: 4f38fa754e3ee809a7386351297decb2d7f1451f
This commit is contained in:
Michel Heily 2019-07-20 22:58:19 +03:00
parent 53115a9a58
commit 61e1f055f1

33
src/core/keypad.rs Normal file
View file

@ -0,0 +1,33 @@
#[derive(Debug, Primitive, PartialEq)]
#[repr(u8)]
pub enum Keys {
ButtonA = 0,
ButtonB = 1,
Select = 2,
Start = 3,
Right = 4,
Left = 5,
Up = 6,
Down = 7,
ButtonR = 8,
ButtonL = 9,
}
pub const NUM_KEYS: usize = 10;
pub const KEYINPUT_ALL_RELEASED: u16 = 0b1111111111;
#[derive(Debug, Primitive, PartialEq)]
#[repr(u8)]
pub enum KeyState {
Pressed = 0,
Released = 1,
}
impl Into<bool> for KeyState {
fn into(self) -> bool {
match self {
KeyState::Pressed => false,
KeyState::Released => true,
}
}
}