From d08671404011fd81931ba71d7396476b0d509898 Mon Sep 17 00:00:00 2001 From: Matthew Budd Date: Tue, 9 Jun 2020 21:47:07 -0400 Subject: [PATCH] Bug fix for full screen mode update. --- src/drivers/sdl/gui.cpp | 23 +++++++++++++++++++--- src/drivers/sdl/input.cpp | 40 +++++++++++---------------------------- 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/src/drivers/sdl/gui.cpp b/src/drivers/sdl/gui.cpp index 180de200..ea945496 100644 --- a/src/drivers/sdl/gui.cpp +++ b/src/drivers/sdl/gui.cpp @@ -2366,10 +2366,11 @@ unsigned int GDKToSDLKeyval (int gdk_key) } // ignore pause and screenshot hotkeys since they is handled by GTK+ as accelerators - if (sdl_key == Hotkeys[HK_PAUSE] || sdl_key == Hotkeys[HK_SCREENSHOT] || - sdl_key == Hotkeys[HK_SAVE_STATE] - || sdl_key == Hotkeys[HK_LOAD_STATE]) + if ( (sdl_key == Hotkeys[HK_PAUSE]) || (sdl_key == Hotkeys[HK_SCREENSHOT]) || + (sdl_key == Hotkeys[HK_SAVE_STATE]) || (sdl_key == Hotkeys[HK_LOAD_STATE]) ) + { return 0; + } return sdl_key; } @@ -2416,7 +2417,23 @@ static gboolean convertKeypress (GtkWidget * grab, GdkEventKey * event, // Create an SDL event from the keypress. sdlev.key.keysym.scancode = SDL_GetScancodeFromKey(sdlkey); sdlev.key.keysym.sym = sdlkey; + sdlev.key.keysym.mod = 0; + + if ( event->state & GDK_SHIFT_MASK ) + { + sdlev.key.keysym.mod |= KMOD_SHIFT; + } + if ( event->state & GDK_CONTROL_MASK ) + { + sdlev.key.keysym.mod |= KMOD_CTRL; + } + if ( event->state & GDK_MOD1_MASK ) + { + sdlev.key.keysym.mod |= KMOD_ALT; + } + sdlev.key.repeat = 0; + if (sdlkey != 0) { SDL_PushEvent (&sdlev); diff --git a/src/drivers/sdl/input.cpp b/src/drivers/sdl/input.cpp index c41665d7..618a480f 100644 --- a/src/drivers/sdl/input.cpp +++ b/src/drivers/sdl/input.cpp @@ -49,7 +49,7 @@ #include /** GLOBALS **/ -int NoWaiting = 1; +int NoWaiting = 0; extern Config *g_config; extern bool bindSavestate, frameAdvanceLagSkip, lagCounterDisplay; @@ -448,7 +448,7 @@ unsigned int *GetKeyboard(void) /** * Parse keyboard commands and execute accordingly. */ -static void KeyboardCommands () +static void KeyboardCommands (void) { int is_shift, is_alt; @@ -474,11 +474,6 @@ static void KeyboardCommands () FCEUI_DispMessage ("Family Keyboard %sabled.", 0, g_fkbEnabled ? "en" : "dis"); } -#if SDL_VERSION_ATLEAST(2, 0, 0) - // TODO - SDL2 -#else - SDL_WM_GrabInput (g_fkbEnabled ? SDL_GRAB_ON : SDL_GRAB_OFF); -#endif if (g_fkbEnabled) { return; @@ -502,23 +497,11 @@ static void KeyboardCommands () #endif { is_alt = 1; -#if !SDL_VERSION_ATLEAST(2, 0, 0) - // workaround for GDK->SDL in GTK problems where ALT release is never - // getting sent - // I know this is sort of an ugly hack to fix this, but the bug is - // rather annoying - // prg318 10/23/11 - int fullscreen; - g_config->getOption ("SDL.Fullscreen", &fullscreen); - if (!fullscreen) - { - g_keyState[SDLK_LALT] = 0; - g_keyState[SDLK_RALT] = 0; - } -#endif } else + { is_alt = 0; + } if (_keyonly (Hotkeys[HK_TOGGLE_BG])) @@ -534,12 +517,11 @@ static void KeyboardCommands () } // Alt-Enter to toggle full-screen - if (keyonly (ENTER) && is_alt) - { - ToggleFS (); - } - - + // This is already handled by GTK Accelerator + //if (keyonly (ENTER) && is_alt) + //{ + // ToggleFS (); + //} // Toggle Movie auto-backup if (keyonly (M) && is_shift) @@ -687,10 +669,10 @@ static void KeyboardCommands () } // Toggle throttling - NoWaiting &= ~1; if ( _keyonly(Hotkeys[HK_TURBO]) ) { - NoWaiting |= 1; + NoWaiting ^= 1; + //printf("NoWaiting: 0x%04x\n", NoWaiting ); } static bool frameAdvancing = false;