Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. let mut chip8_keys = [false; 16];
  2.  
  3. for key in keys {
  4. let index = match key {
  5. Keycode::Num1 => Some(0x1),
  6. Keycode::Num2 => Some(0x2),
  7. Keycode::Num3 => Some(0x3),
  8. Keycode::Num4 => Some(0xc),
  9. Keycode::Q => Some(0x4),
  10. Keycode::W => Some(0x5),
  11. Keycode::E => Some(0x6),
  12. Keycode::R => Some(0xd),
  13. Keycode::A => Some(0x7),
  14. Keycode::S => Some(0x8),
  15. Keycode::D => Some(0x9),
  16. Keycode::F => Some(0xe),
  17. Keycode::Z => Some(0xa),
  18. Keycode::X => Some(0x0),
  19. Keycode::C => Some(0xb),
  20. Keycode::V => Some(0xf),
  21. _ => None,
  22. };
  23.  
  24. if let Some(i) = index {
  25. chip8_keys[i] = true;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement