Skip to content

Commit da68aa7

Browse files
committed
add hotkey to cycle layout
Closes #1868. Supersedes #1020.
1 parent bdd85c9 commit da68aa7

8 files changed

Lines changed: 30 additions & 0 deletions

File tree

src/frontend/qt_sdl/Config.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ LegacyEntry LegacyFile[] =
162162
{"HKKey_FastForward", 0, "Keyboard.HK_FastForward", true},
163163
{"HKKey_FastForwardToggle", 0, "Keyboard.HK_FrameLimitToggle", true},
164164
{"HKKey_FullscreenToggle", 0, "Keyboard.HK_FullscreenToggle", true},
165+
{"HKKey_SwapScreenLayouts", 0, "Keyboard.HK_SwapScreenLayouts", true},
165166
{"HKKey_SwapScreens", 0, "Keyboard.HK_SwapScreens", true},
166167
{"HKKey_SwapScreenEmphasis", 0, "Keyboard.HK_SwapScreenEmphasis", true},
167168
{"HKKey_SolarSensorDecrease", 0, "Keyboard.HK_SolarSensorDecrease", true},
@@ -182,6 +183,7 @@ LegacyEntry LegacyFile[] =
182183
{"HKJoy_FastForward", 0, "Joystick.HK_FastForward", true},
183184
{"HKJoy_FastForwardToggle", 0, "Joystick.HK_FrameLimitToggle", true},
184185
{"HKJoy_FullscreenToggle", 0, "Joystick.HK_FullscreenToggle", true},
186+
{"HKJoy_SwapScreenLayouts", 0, "Joystick.HK_SwapScreenLayouts", true},
185187
{"HKJoy_SwapScreens", 0, "Joystick.HK_SwapScreens", true},
186188
{"HKJoy_SwapScreenEmphasis", 0, "Joystick.HK_SwapScreenEmphasis", true},
187189
{"HKJoy_SolarSensorDecrease", 0, "Joystick.HK_SolarSensorDecrease", true},

src/frontend/qt_sdl/EmuInstance.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ enum
4040
HK_FastForward,
4141
HK_FrameLimitToggle,
4242
HK_FullscreenToggle,
43+
HK_SwapScreenLayouts,
4344
HK_SwapScreens,
4445
HK_SwapScreenEmphasis,
4546
HK_SolarSensorDecrease,

src/frontend/qt_sdl/EmuInstanceInput.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const char* EmuInstance::hotkeyNames[HK_MAX] =
5252
"HK_FastForward",
5353
"HK_FrameLimitToggle",
5454
"HK_FullscreenToggle",
55+
"HK_SwapScreenLayouts",
5556
"HK_SwapScreens",
5657
"HK_SwapScreenEmphasis",
5758
"HK_SolarSensorDecrease",

src/frontend/qt_sdl/EmuThread.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ void EmuThread::attachWindow(MainWindow* window)
7676
connect(this, SIGNAL(windowEmuReset()), window, SLOT(onEmuReset()));
7777
connect(this, SIGNAL(autoScreenSizingChange(int)), window->panel, SLOT(onAutoScreenSizingChanged(int)));
7878
connect(this, SIGNAL(windowFullscreenToggle()), window, SLOT(onFullscreenToggled()));
79+
connect(this, SIGNAL(screenLayoutToggle()), window, SLOT(onScreenLayoutToggled()));
7980
connect(this, SIGNAL(screenEmphasisToggle()), window, SLOT(onScreenEmphasisToggled()));
8081

8182
if (window->winHasMenu())
@@ -94,6 +95,7 @@ void EmuThread::detachWindow(MainWindow* window)
9495
disconnect(this, SIGNAL(windowEmuReset()), window, SLOT(onEmuReset()));
9596
disconnect(this, SIGNAL(autoScreenSizingChange(int)), window->panel, SLOT(onAutoScreenSizingChanged(int)));
9697
disconnect(this, SIGNAL(windowFullscreenToggle()), window, SLOT(onFullscreenToggled()));
98+
disconnect(this, SIGNAL(screenLayoutToggle()), window, SLOT(onScreenLayoutToggled()));
9799
disconnect(this, SIGNAL(screenEmphasisToggle()), window, SLOT(onScreenEmphasisToggled()));
98100

99101
if (window->winHasMenu())
@@ -165,6 +167,7 @@ void EmuThread::run()
165167

166168
if (emuInstance->hotkeyPressed(HK_FullscreenToggle)) emit windowFullscreenToggle();
167169

170+
if (emuInstance->hotkeyPressed(HK_SwapScreenLayouts)) emit screenLayoutToggle();
168171
if (emuInstance->hotkeyPressed(HK_SwapScreens)) emit swapScreensToggle();
169172
if (emuInstance->hotkeyPressed(HK_SwapScreenEmphasis)) emit screenEmphasisToggle();
170173

src/frontend/qt_sdl/EmuThread.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class EmuThread : public QThread
155155

156156
void windowFullscreenToggle();
157157

158+
void screenLayoutToggle();
158159
void swapScreensToggle();
159160
void screenEmphasisToggle();
160161

src/frontend/qt_sdl/InputConfig/InputConfigDialog.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ static constexpr std::initializer_list<int> hk_general =
6363
HK_FullscreenToggle,
6464
HK_Lid,
6565
HK_Mic,
66+
HK_SwapScreenLayouts,
6667
HK_SwapScreens,
6768
HK_SwapScreenEmphasis,
6869
HK_PowerButton,
@@ -84,6 +85,7 @@ static constexpr std::initializer_list<const char*> hk_general_labels =
8485
"Toggle fullscreen",
8586
"Close/open lid",
8687
"Microphone",
88+
"Swap screen layouts",
8789
"Swap screens",
8890
"Swap screen emphasis",
8991
"DSi Power button",

src/frontend/qt_sdl/Window.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,6 +2210,25 @@ void MainWindow::onFullscreenToggled()
22102210
toggleFullscreen();
22112211
}
22122212

2213+
void MainWindow::onScreenLayoutToggled()
2214+
{
2215+
int layout = windowCfg.GetInt("ScreenLayout");
2216+
int rotation = windowCfg.GetInt("ScreenRotation");
2217+
bool horizontal = rotation == screenRot_0Deg || rotation == screenRot_180Deg;
2218+
2219+
// Skip layouts with no visible difference.
2220+
if (layout == screenLayout_Natural && horizontal ||
2221+
layout == screenLayout_Vertical && !horizontal) {
2222+
layout++;
2223+
}
2224+
layout = (layout + 1) % 4;
2225+
2226+
windowCfg.SetInt("ScreenLayout", layout);
2227+
actScreenLayout[layout]->setChecked(true);
2228+
2229+
emit screenLayoutChange();
2230+
}
2231+
22132232
void MainWindow::onScreenEmphasisToggled()
22142233
{
22152234
int currentSizing = windowCfg.GetInt("ScreenSizing");

src/frontend/qt_sdl/Window.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ private slots:
182182
void onUpdateVideoSettings(bool glchange);
183183

184184
void onFullscreenToggled();
185+
void onScreenLayoutToggled();
185186
void onScreenEmphasisToggled();
186187

187188
private:

0 commit comments

Comments
 (0)