git.y1.nz

SameBoy

Accurate GB/GBC emulator
download: https://git.y1.nz/archives/sameboy.tar.gz
README | Files | Log | Refs | LICENSE

commit aa2bdf2a1c2e1e004703b6e8bb61cb1cd7e257fc
parent 8f64f49c3be597f57377e4926ca2a61f2848c8c9
Author: Lior Halphon <LIJI32@gmail.com>
Date:   Wed, 23 Dec 2020 23:50:19 +0200

Better support for non-QWERTY Latin layouts

Diffstat:
MSDL/gui.c4++--
MSDL/gui.h9+++++++++
MSDL/main.c3+--
3 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/SDL/gui.c b/SDL/gui.c @@ -1206,7 +1206,7 @@ void run_gui(bool is_running) } case SDL_KEYDOWN: - if (event.key.keysym.scancode == SDL_SCANCODE_F && event.key.keysym.mod & MODIFIER) { + if (event_hotkey_code(&event) == SDL_SCANCODE_F && event.key.keysym.mod & MODIFIER) { if ((SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN_DESKTOP) == false) { SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); } @@ -1215,7 +1215,7 @@ void run_gui(bool is_running) } update_viewport(); } - if (event.key.keysym.scancode == SDL_SCANCODE_O) { + if (event_hotkey_code(&event) == SDL_SCANCODE_O) { if (event.key.keysym.mod & MODIFIER) { char *filename = do_open_rom_dialog(); if (filename) { diff --git a/SDL/gui.h b/SDL/gui.h @@ -122,4 +122,13 @@ void connect_joypad(void); joypad_button_t get_joypad_button(uint8_t physical_button); joypad_axis_t get_joypad_axis(uint8_t physical_axis); +static SDL_Scancode event_hotkey_code(SDL_Event *event) +{ + if (event->key.keysym.sym >= SDLK_a && event->key.keysym.sym < SDLK_z) { + return SDL_SCANCODE_A + event->key.keysym.sym - SDLK_a; + } + + return event->key.keysym.scancode; +} + #endif diff --git a/SDL/main.c b/SDL/main.c @@ -233,7 +233,7 @@ static void handle_events(GB_gameboy_t *gb) }; case SDL_KEYDOWN: - switch (event.key.keysym.scancode) { + switch (event_hotkey_code(&event)) { case SDL_SCANCODE_ESCAPE: { open_menu(); break; @@ -241,7 +241,6 @@ static void handle_events(GB_gameboy_t *gb) case SDL_SCANCODE_C: if (event.type == SDL_KEYDOWN && (event.key.keysym.mod & KMOD_CTRL)) { GB_debugger_break(gb); - } break;

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.