#[cfg_attr(feature = "strum", derive(strum::EnumIter))]
#[derive(Clone, Copy)]
pub enum KempstonKey {
Right = 0x01,
Left = 0x02,
Down = 0x04,
Up = 0x08,
Fire = 0x10,
Ext1 = 0x20,
Ext2 = 0x40,
Ext3 = 0x80,
}
#[derive(Default)]
pub(crate) struct KempstonJoy {
state: u8,
}
impl KempstonJoy {
pub fn key(&mut self, key: KempstonKey, state: bool) {
if state {
self.state |= key as u8;
} else {
self.state &= !(key as u8);
}
}
pub fn read(&self) -> u8 {
self.state
}
}