Display layout: No editing while the TV shows a layout for another orientation

With the game on a TV (landscape) and the device in portrait, the display
layout screen edited the portrait layout, which the TV doesn't use, so
nothing seemed to change. Its controls are now disabled in that case, and
work as before with the device held the same way as the TV.

The screen rotation hotkeys change the layout the game is shown with, the
TV's, instead.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-10-22 23:06:07 +02:00
1 parent b642984755
commit 080470d041
3 files changed
+51 -6

No files matched your search

+26 -6
View File
@@ -861,27 +861,28 @@ void EmuScreen::ProcessVKey(VirtKey virtKey, bool down) {
}
break;
// These change the layout the game is shown with, which on a TV isn't the device orientation's.
case VIRTKEY_SCREEN_ROTATION_VERTICAL:
if (down) {
DisplayLayoutConfig &config = g_Config.GetDisplayLayoutConfig(GetDeviceOrientation());
DisplayLayoutConfig &config = g_Config.GetDisplayLayoutConfig(GameLayoutOrientation());
config.iInternalScreenRotation = ROTATION_LOCKED_VERTICAL;
}
break;
case VIRTKEY_SCREEN_ROTATION_VERTICAL180:
if (down) {
DisplayLayoutConfig &config = g_Config.GetDisplayLayoutConfig(GetDeviceOrientation());
DisplayLayoutConfig &config = g_Config.GetDisplayLayoutConfig(GameLayoutOrientation());
config.iInternalScreenRotation = ROTATION_LOCKED_VERTICAL180;
}
break;
case VIRTKEY_SCREEN_ROTATION_HORIZONTAL:
if (down) {
DisplayLayoutConfig &config = g_Config.GetDisplayLayoutConfig(GetDeviceOrientation());
DisplayLayoutConfig &config = g_Config.GetDisplayLayoutConfig(GameLayoutOrientation());
config.iInternalScreenRotation = ROTATION_LOCKED_HORIZONTAL;
}
break;
case VIRTKEY_SCREEN_ROTATION_HORIZONTAL180:
if (down) {
DisplayLayoutConfig &config = g_Config.GetDisplayLayoutConfig(GetDeviceOrientation());
DisplayLayoutConfig &config = g_Config.GetDisplayLayoutConfig(GameLayoutOrientation());
config.iInternalScreenRotation = ROTATION_LOCKED_HORIZONTAL180;
}
break;
@@ -1672,6 +1673,21 @@ ScreenRenderFlags EmuScreen::PreRender(ScreenRenderMode mode) {
// Sends the game to a Game output, if there is one. Not in non-buffered mode, which draws straight
// into the backbuffer during emulation.
static DeviceOrientation OutputOrientation(int width, int height) {
return height > width * 1.1f ? DeviceOrientation::Portrait : DeviceOrientation::Landscape;
}
bool GetGameOutputOrientation(ScreenManager *screenManager, DeviceOrientation *orientation) {
const OutputDisplay *output = screenManager->FindOutput(OutputRole::Game);
if (!output || !output->swapchain) {
return false;
}
int width, height;
screenManager->getDrawContext()->GetFramebufferDimensions(output->swapchain, &width, &height);
*orientation = OutputOrientation(width, height);
return true;
}
void EmuScreen::UpdateGameOutput() {
const OutputDisplay *output = screenManager()->FindOutput(OutputRole::Game);
gameOnOutput_ = output && gpu && !skipBufferEffects_ && GPUIsBuffered();
@@ -1684,13 +1700,17 @@ void EmuScreen::UpdateGameOutput() {
}
OutputParams params;
screenManager()->getDrawContext()->GetFramebufferDimensions(output->swapchain, &params.pixelWidth, &params.pixelHeight);
params.orientation = params.pixelHeight > params.pixelWidth * 1.1f ? DeviceOrientation::Portrait : DeviceOrientation::Landscape;
params.orientation = OutputOrientation(params.pixelWidth, params.pixelHeight);
gameOutputOrientation_ = params.orientation;
gpu->SetPresentationOutput(&params);
}
DeviceOrientation EmuScreen::GameLayoutOrientation() const {
return gameOnOutput_ ? gameOutputOrientation_ : GetDeviceOrientation();
}
const DisplayLayoutConfig &EmuScreen::GameLayoutConfig() const {
return g_Config.GetDisplayLayoutConfig(gameOnOutput_ ? gameOutputOrientation_ : GetDeviceOrientation());
return g_Config.GetDisplayLayoutConfig(GameLayoutOrientation());
}
bool EmuScreen::renderOutput(const OutputDisplay &output) {