Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let mut chip8_keys = [false; 16];
- for key in keys {
- let index = match key {
- Keycode::Num1 => Some(0x1),
- Keycode::Num2 => Some(0x2),
- Keycode::Num3 => Some(0x3),
- Keycode::Num4 => Some(0xc),
- Keycode::Q => Some(0x4),
- Keycode::W => Some(0x5),
- Keycode::E => Some(0x6),
- Keycode::R => Some(0xd),
- Keycode::A => Some(0x7),
- Keycode::S => Some(0x8),
- Keycode::D => Some(0x9),
- Keycode::F => Some(0xe),
- Keycode::Z => Some(0xa),
- Keycode::X => Some(0x0),
- Keycode::C => Some(0xb),
- Keycode::V => Some(0xf),
- _ => None,
- };
- if let Some(i) = index {
- chip8_keys[i] = true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement