From 0419e22179ffdeedeb6da5f4a999612b24f89373 Mon Sep 17 00:00:00 2001 From: mjbudd77 Date: Mon, 5 Apr 2021 22:42:59 -0400 Subject: [PATCH] Further hot key rework, fixed Qt Turbo hot key function. --- src/drivers/Qt/ConsoleWindow.cpp | 11 ++++++--- src/drivers/Qt/ConsoleWindow.h | 1 + src/drivers/Qt/input.cpp | 42 +++++++++++++++++--------------- src/drivers/Qt/sdl-throttle.cpp | 2 +- 4 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/drivers/Qt/ConsoleWindow.cpp b/src/drivers/Qt/ConsoleWindow.cpp index bb8e0dd7..640765c1 100644 --- a/src/drivers/Qt/ConsoleWindow.cpp +++ b/src/drivers/Qt/ConsoleWindow.cpp @@ -563,10 +563,8 @@ void consoleWin_t::initHotKeys(void) } // Frame Advance uses key state directly, disable shortcut events - if ( Hotkeys[HK_FRAME_ADVANCE].getShortcut() != nullptr ) - { - Hotkeys[HK_FRAME_ADVANCE].getShortcut()->setEnabled(false); - } + Hotkeys[HK_FRAME_ADVANCE].getShortcut()->setEnabled(false); + Hotkeys[HK_TURBO ].getShortcut()->setEnabled(false); connect( Hotkeys[ HK_VOLUME_DOWN ].getShortcut(), SIGNAL(activated()), this, SLOT(decrSoundVolume(void)) ); connect( Hotkeys[ HK_VOLUME_UP ].getShortcut(), SIGNAL(activated()), this, SLOT(incrSoundVolume(void)) ); @@ -2782,6 +2780,11 @@ void consoleWin_t::toggleInputDisplay(void) fceuWrapperUnLock(); } +void consoleWin_t::toggleTurboMode(void) +{ + NoWaiting ^= 1; +} + void consoleWin_t::openMovie(void) { MoviePlayDialog_t *win; diff --git a/src/drivers/Qt/ConsoleWindow.h b/src/drivers/Qt/ConsoleWindow.h index 082953dd..75e33508 100644 --- a/src/drivers/Qt/ConsoleWindow.h +++ b/src/drivers/Qt/ConsoleWindow.h @@ -311,6 +311,7 @@ class consoleWin_t : public QMainWindow void toggleMovieFrameDisplay(void); void toggleMovieReadWrite(void); void toggleInputDisplay(void); + void toggleTurboMode(void); }; diff --git a/src/drivers/Qt/input.cpp b/src/drivers/Qt/input.cpp index 633ffbe9..0b45b772 100644 --- a/src/drivers/Qt/input.cpp +++ b/src/drivers/Qt/input.cpp @@ -955,9 +955,13 @@ static void KeyboardCommands (void) //} // Toggle throttling - if ( Hotkeys[HK_TURBO].getRisingEdge() ) + if ( Hotkeys[HK_TURBO].getState() ) { - NoWaiting ^= 1; + NoWaiting |= 0x01; + } + else + { + NoWaiting &= 0x02; //printf("NoWaiting: 0x%04x\n", NoWaiting ); } @@ -989,23 +993,23 @@ static void KeyboardCommands (void) //{ // FCEUI_PowerNES(); //} - if ( Hotkeys[HK_QUIT].getRisingEdge() ) - { - CloseGame(); - FCEUI_Kill(); - SDL_Quit(); - exit(0); - } - else -#ifdef _S9XLUA_H - if ( Hotkeys[HK_LOAD_LUA].getRisingEdge() ) - { - std::string fname; - fname = GetFilename ("Open LUA script...", 3, "Lua scripts|*.lua"); - if (fname != "") - FCEU_LoadLuaCode (fname.c_str ()); - } -#endif +// if ( Hotkeys[HK_QUIT].getRisingEdge() ) +// { +// CloseGame(); +// FCEUI_Kill(); +// SDL_Quit(); +// exit(0); +// } +// else +//#ifdef _S9XLUA_H +// if ( Hotkeys[HK_LOAD_LUA].getRisingEdge() ) +// { +// std::string fname; +// fname = GetFilename ("Open LUA script...", 3, "Lua scripts|*.lua"); +// if (fname != "") +// FCEU_LoadLuaCode (fname.c_str ()); +// } +//#endif //for (int i = 0; i < 10; i++) //{ diff --git a/src/drivers/Qt/sdl-throttle.cpp b/src/drivers/Qt/sdl-throttle.cpp index 37121ac6..8718977c 100644 --- a/src/drivers/Qt/sdl-throttle.cpp +++ b/src/drivers/Qt/sdl-throttle.cpp @@ -250,7 +250,7 @@ int highPrecSleep( double timeSeconds ) int SpeedThrottle(void) { - if (g_fpsScale >= 32) + if ( (g_fpsScale >= 32) || (NoWaiting & 0x01) ) { return 0; /* Done waiting */ }