diff --git a/src/drivers/Qt/ConsoleWindow.cpp b/src/drivers/Qt/ConsoleWindow.cpp index 640765c1..56ac81ef 100644 --- a/src/drivers/Qt/ConsoleWindow.cpp +++ b/src/drivers/Qt/ConsoleWindow.cpp @@ -572,9 +572,11 @@ void consoleWin_t::initHotKeys(void) connect( Hotkeys[ HK_LAG_COUNTER_DISPLAY ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleLagCounterDisplay(void)) ); connect( Hotkeys[ HK_FA_LAG_SKIP ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleFrameAdvLagSkip(void)) ); connect( Hotkeys[ HK_BIND_STATE ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleMovieBindSaveState(void))); - connect( Hotkeys[ HK_TOGGLE_FRAME_DISPLAY ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleMovieFrameDisplay(void))); - connect( Hotkeys[ HK_MOVIE_TOGGLE_RW ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleMovieReadWrite(void))); - connect( Hotkeys[ HK_TOGGLE_INPUT_DISPLAY ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleInputDisplay(void))); + connect( Hotkeys[ HK_TOGGLE_FRAME_DISPLAY ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleMovieFrameDisplay(void)) ); + connect( Hotkeys[ HK_MOVIE_TOGGLE_RW ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleMovieReadWrite(void)) ); + connect( Hotkeys[ HK_TOGGLE_INPUT_DISPLAY ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleInputDisplay(void)) ); + connect( Hotkeys[ HK_TOGGLE_BG ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleBackground(void)) ); + connect( Hotkeys[ HK_TOGGLE_FG ].getShortcut(), SIGNAL(activated()), this, SLOT(toggleForeground(void)) ); } //--------------------------------------------------------------------------- void consoleWin_t::createMainMenu(void) @@ -1073,6 +1075,9 @@ void consoleWin_t::createMainMenu(void) fdsSwitchAct->setStatusTip(tr("Switch Disk")); connect(fdsSwitchAct, SIGNAL(triggered()), this, SLOT(fdsSwitchDisk(void)) ); + Hotkeys[ HK_FDS_SELECT ].setAction( fdsSwitchAct ); + connect( Hotkeys[ HK_FDS_SELECT ].getShortcut(), SIGNAL(activated()), this, SLOT(fdsSwitchDisk(void)) ); + subMenu->addAction(fdsSwitchAct); // Emulation -> FDS -> Eject Disk @@ -1081,6 +1086,9 @@ void consoleWin_t::createMainMenu(void) fdsEjectAct->setStatusTip(tr("Eject Disk")); connect(fdsEjectAct, SIGNAL(triggered()), this, SLOT(fdsEjectDisk(void)) ); + Hotkeys[ HK_FDS_EJECT ].setAction( fdsEjectAct ); + connect( Hotkeys[ HK_FDS_EJECT ].getShortcut(), SIGNAL(activated()), this, SLOT(fdsEjectDisk(void)) ); + subMenu->addAction(fdsEjectAct); // Emulation -> FDS -> Load BIOS @@ -1190,6 +1198,9 @@ void consoleWin_t::createMainMenu(void) cheatsAct->setStatusTip(tr("Open Cheat Window")); connect(cheatsAct, SIGNAL(triggered()), this, SLOT(openCheats(void)) ); + Hotkeys[ HK_CHEAT_MENU ].setAction( cheatsAct ); + connect( Hotkeys[ HK_CHEAT_MENU ].getShortcut(), SIGNAL(activated()), this, SLOT(openCheats(void)) ); + toolsMenu->addAction(cheatsAct); // Tools -> RAM Search @@ -1298,11 +1309,14 @@ void consoleWin_t::createMainMenu(void) // Movie -> Play openMovAct = new QAction(tr("&Play"), this); - openMovAct->setShortcut( QKeySequence(tr("Shift+F7"))); + //openMovAct->setShortcut( QKeySequence(tr("Shift+F7"))); openMovAct->setStatusTip(tr("Play Movie File")); openMovAct->setIcon( style()->standardIcon( QStyle::SP_MediaPlay ) ); connect(openMovAct, SIGNAL(triggered()), this, SLOT(openMovie(void)) ); + Hotkeys[ HK_PLAY_MOVIE_FROM ].setAction( openMovAct ); + connect( Hotkeys[ HK_PLAY_MOVIE_FROM ].getShortcut(), SIGNAL(activated()), this, SLOT(openMovie(void)) ); + movieMenu->addAction(openMovAct); // Movie -> Stop @@ -1312,13 +1326,16 @@ void consoleWin_t::createMainMenu(void) stopMovAct->setIcon( style()->standardIcon( QStyle::SP_MediaStop ) ); connect(stopMovAct, SIGNAL(triggered()), this, SLOT(stopMovie(void)) ); + Hotkeys[ HK_STOP_MOVIE ].setAction( stopMovAct ); + connect( Hotkeys[ HK_STOP_MOVIE ].getShortcut(), SIGNAL(activated()), this, SLOT(stopMovie(void)) ); + movieMenu->addAction(stopMovAct); movieMenu->addSeparator(); // Movie -> Record recMovAct = new QAction(tr("&Record"), this); - recMovAct->setShortcut( QKeySequence(tr("Shift+F5"))); + //recMovAct->setShortcut( QKeySequence(tr("Shift+F5"))); recMovAct->setStatusTip(tr("Record Movie")); recMovAct->setIcon( QIcon(":icons/media-record.png") ); connect(recMovAct, SIGNAL(triggered()), this, SLOT(recordMovie(void)) ); @@ -1331,6 +1348,9 @@ void consoleWin_t::createMainMenu(void) recAsMovAct->setStatusTip(tr("Record Movie")); connect(recAsMovAct, SIGNAL(triggered()), this, SLOT(recordMovieAs(void)) ); + Hotkeys[ HK_RECORD_MOVIE_TO ].setAction( recAsMovAct ); + connect( Hotkeys[ HK_RECORD_MOVIE_TO ].getShortcut(), SIGNAL(activated()), this, SLOT(recordMovieAs(void)) ); + movieMenu->addAction(recAsMovAct); //----------------------------------------------------------------------- @@ -2780,6 +2800,24 @@ void consoleWin_t::toggleInputDisplay(void) fceuWrapperUnLock(); } +void consoleWin_t::toggleBackground(void) +{ + bool fgOn, bgOn; + fceuWrapperLock(); + FCEUI_GetRenderPlanes( fgOn, bgOn ); + FCEUI_SetRenderPlanes( fgOn, !bgOn ); + fceuWrapperUnLock(); +} + +void consoleWin_t::toggleForeground(void) +{ + bool fgOn, bgOn; + fceuWrapperLock(); + FCEUI_GetRenderPlanes( fgOn, bgOn ); + FCEUI_SetRenderPlanes( !fgOn, bgOn ); + fceuWrapperUnLock(); +} + void consoleWin_t::toggleTurboMode(void) { NoWaiting ^= 1; diff --git a/src/drivers/Qt/ConsoleWindow.h b/src/drivers/Qt/ConsoleWindow.h index 75e33508..bf8ff813 100644 --- a/src/drivers/Qt/ConsoleWindow.h +++ b/src/drivers/Qt/ConsoleWindow.h @@ -312,6 +312,8 @@ class consoleWin_t : public QMainWindow void toggleMovieReadWrite(void); void toggleInputDisplay(void); void toggleTurboMode(void); + void toggleBackground(void); + void toggleForeground(void); }; diff --git a/src/drivers/Qt/GamePadConf.cpp b/src/drivers/Qt/GamePadConf.cpp index 65f14825..bd0394cf 100644 --- a/src/drivers/Qt/GamePadConf.cpp +++ b/src/drivers/Qt/GamePadConf.cpp @@ -1934,7 +1934,7 @@ void GamePadConfigHotKey_t::keyPressEvent(QKeyEvent *event) if ( captureState && !isModifier ) { - QKeySequence ks( event->modifiers() + event->key() ); + QKeySequence ks( convKeyEvent2Sequence(event) ); k->keySeq[idx].key = event->key(); k->keySeq[idx].modifier = event->modifiers(); diff --git a/src/drivers/Qt/config.cpp b/src/drivers/Qt/config.cpp index 59e4e833..9adba1ca 100644 --- a/src/drivers/Qt/config.cpp +++ b/src/drivers/Qt/config.cpp @@ -119,6 +119,9 @@ int getHotKeyConfig( int i, const char **nameOut, const char **keySeqOut ) case HK_TOGGLE_BG: name = "ToggleBG"; keySeq = ""; break; + case HK_TOGGLE_FG: + name = "ToggleFG"; keySeq = ""; + break; // Save States case HK_SAVE_STATE: name = "SaveState"; keySeq = "I"; @@ -238,6 +241,18 @@ int getHotKeyConfig( int i, const char **nameOut, const char **keySeqOut ) case HK_MOVIE_TOGGLE_RW: name = "ToggleMovieRW"; keySeq = "Q"; break; + case HK_PLAY_MOVIE_FROM: + name = "PlayMovieFrom"; keySeq = ""; + break; + case HK_MOVIE_PLAY_RESTART: + name = "PlayMovieFromBeginning"; keySeq = ""; + break; + case HK_RECORD_MOVIE_TO: + name = "RecordMovieTo"; keySeq = ""; + break; + case HK_STOP_MOVIE: + name = "StopMovie"; keySeq = ""; + break; case HK_MUTE_CAPTURE: name = "MuteCapture"; keySeq = "'"; break; diff --git a/src/drivers/Qt/config.h b/src/drivers/Qt/config.h index 74b4e420..e3f22882 100644 --- a/src/drivers/Qt/config.h +++ b/src/drivers/Qt/config.h @@ -43,10 +43,17 @@ enum HOTKEY { // VS HK_VS_INSERT_COIN, HK_VS_TOGGLE_DIPSWITCH, - HK_CHEAT_MENU, HK_BIND_STATE, HK_LOAD_LUA, HK_TOGGLE_BG, + // Movie HK_TOGGLE_FRAME_DISPLAY, HK_TOGGLE_SUBTITLE, HK_SCREENSHOT, - HK_TOGGLE_INPUT_DISPLAY, HK_MOVIE_TOGGLE_RW, HK_MUTE_CAPTURE, - HK_FA_LAG_SKIP, HK_LAG_COUNTER_DISPLAY, + HK_BIND_STATE, HK_MOVIE_TOGGLE_RW, + HK_PLAY_MOVIE_FROM, HK_MOVIE_PLAY_RESTART, HK_RECORD_MOVIE_TO, HK_STOP_MOVIE, + + // Display + HK_TOGGLE_FG, HK_TOGGLE_BG, HK_TOGGLE_INPUT_DISPLAY, HK_LAG_COUNTER_DISPLAY, + + HK_CHEAT_MENU, HK_LOAD_LUA, + HK_MUTE_CAPTURE, + HK_FA_LAG_SKIP, HK_VOLUME_DOWN, HK_VOLUME_UP, HK_FKB_ENABLE, HK_MAX}; diff --git a/src/drivers/Qt/input.cpp b/src/drivers/Qt/input.cpp index 0b45b772..1ca013f8 100644 --- a/src/drivers/Qt/input.cpp +++ b/src/drivers/Qt/input.cpp @@ -145,7 +145,7 @@ static uint32 JSreturn = 0; #include "keyscan.h" static uint8 g_keyState[SDL_NUM_SCANCODES]; static int keyModifier = 0; -static int DIPS = 0; +//static int DIPS = 0; static uint8 keyonce[SDL_NUM_SCANCODES]; #define KEY(__a) g_keyState[MKK(__a)] @@ -438,64 +438,9 @@ void hotkey_t::setModifierFromString( const char *s ) void setHotKeys (void) { - int j,k; - std::string keyText; - std::string prefix = "SDL.Hotkeys."; - char id[64], val[128]; - const char *hotKeyName, *hotKeySeq; -//SDL_Keycode SDL_GetKeyFromName(const char* name) - for (int i = 0; i < HK_MAX; i++) { Hotkeys[i].readConfig(); - //g_config->getOption (prefix + Hotkeys[i].getConfigName(), &keyText); - - //j=0; - - //while ( keyText[j] != 0 ) - //{ - // while ( isspace(keyText[j]) ) j++; - - // if ( isalpha( keyText[j] ) || (keyText[j] == '_') ) - // { - // k=0; - // while ( isalnum( keyText[j] ) || (keyText[j] == '_') ) - // { - // id[k] = keyText[j]; j++; k++; - // } - // id[k] = 0; - - // if ( keyText[j] != '=' ) - // { - // printf("Error: Invalid Hot Key Config for %s = %s \n", getHotkeyString(i), keyText.c_str() ); - // break; - // } - // j++; - - // k=0; - // while ( !isspace(keyText[j]) && (keyText[j] != 0) ) - // { - // val[k] = keyText[j]; j++; k++; - // } - // val[k] = 0; - - // //printf("ID:%s Val:%s \n", id, val ); - - // if ( strcmp( id, "key" ) == 0 ) - // { - // Hotkeys[i].sdl.value = SDL_GetKeyFromName( val ); - // } - // else if ( strcmp( id, "mod" ) == 0 ) - // { - // Hotkeys[i].setModifierFromString( val ); - // } - // } - // else - // { - // break; - // } - //} - } return; } @@ -730,7 +675,7 @@ unsigned int *GetKeyboard(void) */ static void KeyboardCommands (void) { - int is_shift, is_alt; + //int is_shift, is_alt; // get the keyboard input @@ -749,33 +694,33 @@ static void KeyboardCommands (void) } } - if (g_keyState[SDL_SCANCODE_LSHIFT] || g_keyState[SDL_SCANCODE_RSHIFT]) - { - is_shift = 1; - } - else - { - is_shift = 0; - } + //if (g_keyState[SDL_SCANCODE_LSHIFT] || g_keyState[SDL_SCANCODE_RSHIFT]) + //{ + // is_shift = 1; + //} + //else + //{ + // is_shift = 0; + //} - if (g_keyState[SDL_SCANCODE_LALT] || g_keyState[SDL_SCANCODE_RALT]) - { - is_alt = 1; - } - else - { - is_alt = 0; - } + //if (g_keyState[SDL_SCANCODE_LALT] || g_keyState[SDL_SCANCODE_RALT]) + //{ + // is_alt = 1; + //} + //else + //{ + // is_alt = 0; + //} - if ( Hotkeys[HK_TOGGLE_BG].getRisingEdge() ) - { - bool fgOn, bgOn; + //if ( Hotkeys[HK_TOGGLE_BG].getRisingEdge() ) + //{ + // bool fgOn, bgOn; - FCEUI_GetRenderPlanes( fgOn, bgOn ); + // FCEUI_GetRenderPlanes( fgOn, bgOn ); - FCEUI_SetRenderPlanes( fgOn, !bgOn ); - } + // FCEUI_SetRenderPlanes( fgOn, !bgOn ); + //} // Alt-Enter to toggle full-screen // This is already handled by Qt Menu Actions @@ -807,108 +752,108 @@ static void KeyboardCommands (void) //} // Toggle Movie auto-backup - if ( is_shift ) - { - if (keyonly (M)) - { - autoMovieBackup ^= 1; - FCEUI_DispMessage ("Automatic movie backup %sabled.", 0, - autoMovieBackup ? "en" : "dis"); - } - } + //if ( is_shift ) + //{ + // if (keyonly (M)) + // { + // autoMovieBackup ^= 1; + // FCEUI_DispMessage ("Automatic movie backup %sabled.", 0, + // autoMovieBackup ? "en" : "dis"); + // } + //} - if ( is_alt ) - { - // Start recording an FM2 movie on Alt+R - if (keyonly (R)) - { - FCEUD_MovieRecordTo (); - } - // Save a state from a file - if (keyonly (S)) - { - FCEUD_SaveStateAs (); - } - // Load a state from a file - if (keyonly (L)) - { - FCEUD_LoadStateFrom (); - } - } + //if ( is_alt ) + //{ + // // Start recording an FM2 movie on Alt+R + // if (keyonly (R)) + // { + // FCEUD_MovieRecordTo (); + // } + // // Save a state from a file + // if (keyonly (S)) + // { + // FCEUD_SaveStateAs (); + // } + // // Load a state from a file + // if (keyonly (L)) + // { + // FCEUD_LoadStateFrom (); + // } + //} // Famicom disk-system games - if (gametype == GIT_FDS) - { - if ( Hotkeys[HK_FDS_SELECT].getRisingEdge() ) - { - FCEUI_FDSSelect (); - } - if ( Hotkeys[HK_FDS_EJECT].getRisingEdge() ) - { - FCEUI_FDSInsert (); - } - } - - if ( Hotkeys[HK_SCREENSHOT].getRisingEdge() ) - { - FCEUI_SaveSnapshot (); - } +// if (gametype == GIT_FDS) +// { +// if ( Hotkeys[HK_FDS_SELECT].getRisingEdge() ) +// { +// FCEUI_FDSSelect (); +// } +// if ( Hotkeys[HK_FDS_EJECT].getRisingEdge() ) +// { +// FCEUI_FDSInsert (); +// } +// } +// +// if ( Hotkeys[HK_SCREENSHOT].getRisingEdge() ) +// { +// FCEUI_SaveSnapshot (); +// } // if not NES Sound Format - if (gametype != GIT_NSF) - { - if ( Hotkeys[HK_CHEAT_MENU].getRisingEdge() ) - { - openCheatDialog( consoleWindow ); - } - - // f5 (default) save key, hold shift to save movie - if ( Hotkeys[HK_SAVE_STATE].getRisingEdge() ) - { - if (is_shift) - { - std::string movie_fname = FCEU_MakeFName (FCEUMKF_MOVIE, 0, 0); - FCEUI_printf ("Recording movie to %s\n", movie_fname.c_str() ); - FCEUI_SaveMovie(movie_fname.c_str() , MOVIE_FLAG_NONE, L""); - } - else - { - FCEUI_SaveState (NULL); - } - } - - // f7 to load state, Shift-f7 to load movie - if ( Hotkeys[HK_LOAD_STATE].getRisingEdge() ) - { - if (is_shift) - { - FCEUI_StopMovie (); - std::string fname; - fname = - GetFilename ("Open FM2 movie for playback...", false, - "FM2 movies|*.fm2"); - if (fname != "") - { - if (fname.find (".fm2") != std::string::npos - || fname.find (".fm3") != std::string::npos) - { - FCEUI_printf ("Playing back movie located at %s\n", - fname.c_str ()); - FCEUI_LoadMovie (fname.c_str (), false, false); - } - else - { - FCEUI_printf - ("Only .fm2 and .fm3 movies are supported.\n"); - } - } - } - else - { - FCEUI_LoadState(NULL); - } - } - } +// if (gametype != GIT_NSF) +// { +// if ( Hotkeys[HK_CHEAT_MENU].getRisingEdge() ) +// { +// openCheatDialog( consoleWindow ); +// } +// +// // f5 (default) save key, hold shift to save movie +// if ( Hotkeys[HK_SAVE_STATE].getRisingEdge() ) +// { +// if (is_shift) +// { +// std::string movie_fname = FCEU_MakeFName (FCEUMKF_MOVIE, 0, 0); +// FCEUI_printf ("Recording movie to %s\n", movie_fname.c_str() ); +// FCEUI_SaveMovie(movie_fname.c_str() , MOVIE_FLAG_NONE, L""); +// } +// else +// { +// FCEUI_SaveState (NULL); +// } +// } +// +// // f7 to load state, Shift-f7 to load movie +// if ( Hotkeys[HK_LOAD_STATE].getRisingEdge() ) +// { +// if (is_shift) +// { +// FCEUI_StopMovie (); +// std::string fname; +// fname = +// GetFilename ("Open FM2 movie for playback...", false, +// "FM2 movies|*.fm2"); +// if (fname != "") +// { +// if (fname.find (".fm2") != std::string::npos +// || fname.find (".fm3") != std::string::npos) +// { +// FCEUI_printf ("Playing back movie located at %s\n", +// fname.c_str ()); +// FCEUI_LoadMovie (fname.c_str (), false, false); +// } +// else +// { +// FCEUI_printf +// ("Only .fm2 and .fm3 movies are supported.\n"); +// } +// } +// } +// else +// { +// FCEUI_LoadState(NULL); +// } +// } +// } //if ( Hotkeys[HK_DECREASE_SPEED].getRisingEdge() ) @@ -1139,25 +1084,26 @@ static void KeyboardCommands (void) // { // barcoder = 0; // } -// -//#define SSM(x) \ -//do { \ -// if(barcoder) { \ -// if(bbuft < 13) { \ -// bbuf[bbuft++] = '0' + x; \ -// bbuf[bbuft] = 0; \ -// } \ -// FCEUI_DispMessage("Barcode: %s",0, bbuf); \ -// } \ -//} while(0) -// -// DIPSless: -// for(int i=0; i<10;i++) -// { -// if (keyonly (i)) -// SSM (i); -// } -//#undef SSM +/* +#define SSM(x) +do { \ + if(barcoder) { \ + if(bbuft < 13) { \ + bbuf[bbuft++] = '0' + x; \ + bbuf[bbuft] = 0; \ + } \ + FCEUI_DispMessage("Barcode: %s",0, bbuf); \ + } \ +} while(0) + + DIPSless: + for(int i=0; i<10;i++) + { + if (keyonly (i)) + SSM (i); + } +#undef SSM +*/ // } }