Better support for non-QWERTY Latin layouts

This commit is contained in:
Lior Halphon 2020-12-23 23:50:19 +02:00
parent 8f64f49c3b
commit aa2bdf2a1c
3 changed files with 12 additions and 4 deletions

View File

@ -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) {

View File

@ -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

View File

@ -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;