terminal_gameboy 0.1.2

A terminal-based Game Boy emulator with ASCII and block rendering modes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crossterm::event::KeyCode;
use gameboy_core::Button;

/// Map keyboard keys to GameBoy buttons
pub fn map_key_to_button(key: KeyCode) -> Option<Button> {
    match key {
        KeyCode::Up => Some(Button::Up),
        KeyCode::Down => Some(Button::Down),
        KeyCode::Left => Some(Button::Left),
        KeyCode::Right => Some(Button::Right),
        KeyCode::Char('z') | KeyCode::Char('Z') => Some(Button::A),
        KeyCode::Char('x') | KeyCode::Char('X') => Some(Button::B),
        KeyCode::Enter => Some(Button::Start),
        KeyCode::Char(' ') => Some(Button::Select),
        _ => None,
    }
}