From d47717fdd6b6d23cd9a0f41937fc528800c5015c Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 28 Sep 2019 16:21:24 +1000 Subject: [PATCH] SDL: Add hotkeys (F1-F8) for loading/saving state --- src/pse-sdl/sdl_interface.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/pse-sdl/sdl_interface.cpp b/src/pse-sdl/sdl_interface.cpp index 0b5c046d8..dd9e73e1c 100644 --- a/src/pse-sdl/sdl_interface.cpp +++ b/src/pse-sdl/sdl_interface.cpp @@ -92,7 +92,7 @@ bool SDLInterface::CreateGLContext() // glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); } - SDL_GL_SetSwapInterval(1); + SDL_GL_SetSwapInterval(0); return true; } @@ -277,6 +277,27 @@ bool SDLInterface::HandleSDLEvent(const SDL_Event* event) m_controller->SetButtonState(DigitalController::Button::Select, pressed); return true; + case SDL_SCANCODE_F1: + case SDL_SCANCODE_F2: + case SDL_SCANCODE_F3: + case SDL_SCANCODE_F4: + case SDL_SCANCODE_F5: + case SDL_SCANCODE_F6: + case SDL_SCANCODE_F7: + case SDL_SCANCODE_F8: + { + if (!pressed) + { + auto filename = GetSaveStateFilename(event->key.keysym.scancode - SDL_SCANCODE_F1 + 1); + if (event->key.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT)) + SaveState(filename); + else + LoadState(filename); + } + } + break; + + case SDL_SCANCODE_TAB: SDL_GL_SetSwapInterval(pressed ? 0 : 1); break;