From cd6859ef6f449f3f61db312addea9d656069736e Mon Sep 17 00:00:00 2001 From: gal20 <71563441+gal20@users.noreply.github.com> Date: Mon, 18 Jan 2021 23:51:39 +0200 Subject: [PATCH] Add hotkey to swap screens (#953) --- src/frontend/qt_sdl/InputConfigDialog.cpp | 8 +++++--- src/frontend/qt_sdl/InputConfigDialog.h | 2 +- src/frontend/qt_sdl/PlatformConfig.cpp | 2 ++ src/frontend/qt_sdl/PlatformConfig.h | 1 + src/frontend/qt_sdl/main.cpp | 3 +++ src/frontend/qt_sdl/main.h | 2 ++ 6 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/frontend/qt_sdl/InputConfigDialog.cpp b/src/frontend/qt_sdl/InputConfigDialog.cpp index eaf1e9bd..d13d3485 100644 --- a/src/frontend/qt_sdl/InputConfigDialog.cpp +++ b/src/frontend/qt_sdl/InputConfigDialog.cpp @@ -57,6 +57,7 @@ const int hk_general[] = HK_FullscreenToggle, HK_Lid, HK_Mic, + HK_SwapScreens }; const char* hk_general_labels[] = @@ -68,6 +69,7 @@ const char* hk_general_labels[] = "Toggle Fullscreen", "Close/open lid", "Microphone", + "Swap screens" }; @@ -88,7 +90,7 @@ InputConfigDialog::InputConfigDialog(QWidget* parent) : QDialog(parent), ui(new addonsJoyMap[i] = Config::HKJoyMapping[hk_addons[i]]; } - for (int i = 0; i < 7; i++) + for (int i = 0; i < 8; i++) { hkGeneralKeyMap[i] = Config::HKKeyMapping[hk_general[i]]; hkGeneralJoyMap[i] = Config::HKJoyMapping[hk_general[i]]; @@ -96,7 +98,7 @@ InputConfigDialog::InputConfigDialog(QWidget* parent) : QDialog(parent), ui(new populatePage(ui->tabInput, 12, dskeylabels, keypadKeyMap, keypadJoyMap); populatePage(ui->tabAddons, 2, hk_addons_labels, addonsKeyMap, addonsJoyMap); - populatePage(ui->tabHotkeysGeneral, 7, hk_general_labels, hkGeneralKeyMap, hkGeneralJoyMap); + populatePage(ui->tabHotkeysGeneral, 8, hk_general_labels, hkGeneralKeyMap, hkGeneralJoyMap); int njoy = SDL_NumJoysticks(); if (njoy > 0) @@ -179,7 +181,7 @@ void InputConfigDialog::on_InputConfigDialog_accepted() Config::HKJoyMapping[hk_addons[i]] = addonsJoyMap[i]; } - for (int i = 0; i < 7; i++) + for (int i = 0; i < 8; i++) { Config::HKKeyMapping[hk_general[i]] = hkGeneralKeyMap[i]; Config::HKJoyMapping[hk_general[i]] = hkGeneralJoyMap[i]; diff --git a/src/frontend/qt_sdl/InputConfigDialog.h b/src/frontend/qt_sdl/InputConfigDialog.h index 95e05320..d1ac57ac 100644 --- a/src/frontend/qt_sdl/InputConfigDialog.h +++ b/src/frontend/qt_sdl/InputConfigDialog.h @@ -64,7 +64,7 @@ private: int keypadKeyMap[12], keypadJoyMap[12]; int addonsKeyMap[2], addonsJoyMap[2]; - int hkGeneralKeyMap[7], hkGeneralJoyMap[7]; + int hkGeneralKeyMap[8], hkGeneralJoyMap[8]; }; diff --git a/src/frontend/qt_sdl/PlatformConfig.cpp b/src/frontend/qt_sdl/PlatformConfig.cpp index 30d9172b..03c7285f 100644 --- a/src/frontend/qt_sdl/PlatformConfig.cpp +++ b/src/frontend/qt_sdl/PlatformConfig.cpp @@ -114,6 +114,7 @@ ConfigEntry PlatformConfigFile[] = {"HKKey_FastForward", 0, &HKKeyMapping[HK_FastForward], -1, NULL, 0}, {"HKKey_FastForwardToggle", 0, &HKKeyMapping[HK_FastForwardToggle], -1, NULL, 0}, {"HKKey_FullscreenToggle", 0, &HKKeyMapping[HK_FullscreenToggle], -1, NULL, 0}, + {"HKKey_SwapScreens", 0, &HKKeyMapping[HK_SwapScreens], -1, NULL, 0}, {"HKKey_SolarSensorDecrease", 0, &HKKeyMapping[HK_SolarSensorDecrease], -1, NULL, 0}, {"HKKey_SolarSensorIncrease", 0, &HKKeyMapping[HK_SolarSensorIncrease], -1, NULL, 0}, @@ -124,6 +125,7 @@ ConfigEntry PlatformConfigFile[] = {"HKJoy_FastForward", 0, &HKJoyMapping[HK_FastForward], -1, NULL, 0}, {"HKJoy_FastForwardToggle", 0, &HKJoyMapping[HK_FastForwardToggle], -1, NULL, 0}, {"HKJoy_FullscreenToggle", 0, &HKJoyMapping[HK_FullscreenToggle], -1, NULL, 0}, + {"HKJoy_SwapScreens", 0, &HKJoyMapping[HK_SwapScreens], -1, NULL, 0}, {"HKJoy_SolarSensorDecrease", 0, &HKJoyMapping[HK_SolarSensorDecrease], -1, NULL, 0}, {"HKJoy_SolarSensorIncrease", 0, &HKJoyMapping[HK_SolarSensorIncrease], -1, NULL, 0}, diff --git a/src/frontend/qt_sdl/PlatformConfig.h b/src/frontend/qt_sdl/PlatformConfig.h index 0bfbb20d..1d996c8a 100644 --- a/src/frontend/qt_sdl/PlatformConfig.h +++ b/src/frontend/qt_sdl/PlatformConfig.h @@ -30,6 +30,7 @@ enum HK_FastForward, HK_FastForwardToggle, HK_FullscreenToggle, + HK_SwapScreens, HK_SolarSensorDecrease, HK_SolarSensorIncrease, HK_MAX diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp index cbaee03f..6cfb7b89 100644 --- a/src/frontend/qt_sdl/main.cpp +++ b/src/frontend/qt_sdl/main.cpp @@ -282,6 +282,7 @@ EmuThread::EmuThread(QObject* parent) : QThread(parent) connect(this, SIGNAL(windowLimitFPSChange()), mainWindow->actLimitFramerate, SLOT(trigger())); connect(this, SIGNAL(screenLayoutChange()), mainWindow->panel, SLOT(onScreenLayoutChanged())); connect(this, SIGNAL(windowFullscreenToggle()), mainWindow, SLOT(onFullscreenToggled())); + connect(this, SIGNAL(swapScreensToggle()), mainWindow->actScreenSwap, SLOT(trigger())); if (mainWindow->hasOGL) initOpenGL(); } @@ -387,6 +388,8 @@ void EmuThread::run() if (Input::HotkeyPressed(HK_FullscreenToggle)) emit windowFullscreenToggle(); + if (Input::HotkeyPressed(HK_SwapScreens)) emit swapScreensToggle(); + if (GBACart::CartInserted && GBACart::HasSolarSensor) { if (Input::HotkeyPressed(HK_SolarSensorDecrease)) diff --git a/src/frontend/qt_sdl/main.h b/src/frontend/qt_sdl/main.h index 6dfbd8c2..22fe0f1e 100644 --- a/src/frontend/qt_sdl/main.h +++ b/src/frontend/qt_sdl/main.h @@ -72,6 +72,8 @@ signals: void windowFullscreenToggle(); + void swapScreensToggle(); + private: volatile int EmuStatus; int PrevEmuStatus;