pub fn keycode_to_hex(&self, key: Keycode) -> Option<u8> {
        match key {
            // row 1
            Keycode::Num1 => Some(0x1),
            Keycode::Num2 => Some(0x2),
            Keycode::Num3 => Some(0x3),
            Keycode::Num4 => Some(0xC),
            // row 2
            Keycode::Q => Some(0x4),
            Keycode::W => Some(0x5),
            Keycode::E => Some(0x6),
            Keycode::R => Some(0xD),
            // row 3
            Keycode::A => Some(0x7),
            Keycode::S => Some(0x8),
            Keycode::D => Some(0x9),
            Keycode::F => Some(0xE),
            // row 4
            Keycode::Z => Some(0xA),
            Keycode::X => Some(0x0),
            Keycode::C => Some(0xB),
            Keycode::V => Some(0xF),
            // ignore any other key
            _ => None,
        }
    }
/// Maps an SDL2 Keycode to the hex digit it represents in CHIP-8.
Maps an SDL2 Keycode to the hex digit it represents in CHIP-8.
Maps an SDL2 Keycode to the hex digit it represents in CHIP - 8 .
pub fn keycode_to_hex(&self, key: Keycode) -> Option<u8> {
        match key {
            // row 1
            Keycode::Num1 => Some(0x1),
            Keycode::Num2 => Some(0x2),
            Keycode::Num3 => Some(0x3),
            Keycode::Num4 => Some(0xC),
            // row 2
            Keycode::Q => Some(0x4),
            Keycode::W => Some(0x5),
            Keycode::E => Some(0x6),
            Keycode::R => Some(0xD),
            // row 3
            Keycode::A => Some(0x7),
            Keycode::S => Some(0x8),
            Keycode::D => Some(0x9),
            Keycode::F => Some(0xE),
            // row 4
            Keycode::Z => Some(0xA),
            Keycode::X => Some(0x0),
            Keycode::C => Some(0xB),
            Keycode::V => Some(0xF),
            // ignore any other key
            _ => None,
        }
    }
pub fn keycode_to_hex ( & self , key : Keycode ) -> Option < u8 > { match key { // row 1 Keycode :: Num1 => Some ( 0x1 ) , Keycode :: Num2 => Some ( 0x2 ) , Keycode :: Num3 => Some ( 0x3 ) , Keycode :: Num4 => Some ( 0xC ) , // row 2 Keycode :: Q => Some ( 0x4 ) , Keycode :: W => Some ( 0x5 ) , Keycode :: E => Some ( 0x6 ) , Keycode :: R => Some ( 0xD ) , // row 3 Keycode :: A => Some ( 0x7 ) , Keycode :: S => Some ( 0x8 ) , Keycode :: D => Some ( 0x9 ) , Keycode :: F => Some ( 0xE ) , // row 4 Keycode :: Z => Some ( 0xA ) , Keycode :: X => Some ( 0x0 ) , Keycode :: C => Some ( 0xB ) , Keycode :: V => Some ( 0xF ) , // ignore any other key _ => None , } }
Maps an SDL2 Keycode to the hex digit it represents in CHIP-8.
Maps an SDL2 Keycode to the hex digit it represents in CHIP - 8 .
&self
key
Keycode
&self
key
Keycode