diff --git a/changelog.txt b/changelog.txt index c26d7b4e..f14fffe3 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,4 @@ - +23-jan-2012 - prg - sdl: pause will now show/ungrab cursor in fullscreen. this can be disabled with the SDL.NoFullscreenCursor option 12-jan-2012 - AnS - Tasedit: File->New Project, INPUT_TYPE_1P 12-jan-2012 - AnS - Tasedit: resizing TAS Editor window 08-jan-2012 - prg - sdl: switched advance one frame key from "\" to "`" diff --git a/src/drivers/sdl/config.cpp b/src/drivers/sdl/config.cpp index ba458b26..f88d8dfc 100644 --- a/src/drivers/sdl/config.cpp +++ b/src/drivers/sdl/config.cpp @@ -205,6 +205,8 @@ InitConfig() config->addOption("subtitles", "SDL.SubtitleDisplay", 1); config->addOption("fourscore", "SDL.FourScore", 0); + + config->addOption("nofscursor", "SDL.NoFullscreenCursor", 0); #ifdef _S9XLUA_H // load lua script diff --git a/src/drivers/sdl/input.cpp b/src/drivers/sdl/input.cpp index bb94e590..91ed918b 100644 --- a/src/drivers/sdl/input.cpp +++ b/src/drivers/sdl/input.cpp @@ -181,6 +181,38 @@ void setHotKeys() return; } +/*** + * This function is a wrapper for FCEUI_ToggleEmulationPause that handles + * releasing/capturing mouse pointer during pause toggles + * */ +void TogglePause() +{ + FCEUI_ToggleEmulationPause(); + int x; + g_config->getOption("SDL.Fullscreen", &x); + + if(x == 0) + return; + + g_config->getOption("SDL.NoFullscreenCursor", &x); + + if(x == 1) + return; + + if (FCEUI_EmulationPaused() == 0) + { + SDL_ShowCursor(0); + SDL_WM_GrabInput (SDL_GRAB_ON); + } + else + { + SDL_ShowCursor(1); + SDL_WM_GrabInput (SDL_GRAB_OFF); + } + + return; +} + /*** * This function opens a file chooser dialog and returns the filename the * user selected. @@ -559,7 +591,10 @@ KeyboardCommands() #endif if(_keyonly(Hotkeys[HK_PAUSE])) { - FCEUI_ToggleEmulationPause(); + //FCEUI_ToggleEmulationPause(); + // use the wrapper function instead of the fceui function directly + // so we can handle cursor grabbage + TogglePause(); } // Toggle throttling @@ -792,7 +827,7 @@ UpdatePhysicalInput() case SDL_FCEU_HOTKEY_EVENT: switch(event.user.code) { case HK_PAUSE: - FCEUI_ToggleEmulationPause(); + TogglePause(); break; default: FCEU_printf("Warning: unknown hotkey event %d\n", event.user.code);