Skip to content

Commit

Permalink
layout: add handedness option to upright rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
vitor-k committed Jan 9, 2024
1 parent 57696b2 commit 3afee33
Show file tree
Hide file tree
Showing 11 changed files with 160 additions and 75 deletions.
2 changes: 1 addition & 1 deletion src/citra/emu_window/emu_window_sdl2_sw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ std::unique_ptr<Frontend::GraphicsContext> EmuWindow_SDL2_SW::CreateSharedContex

void EmuWindow_SDL2_SW::Present() {
const auto layout{Layout::DefaultFrameLayout(
Core::kScreenTopWidth, Core::kScreenTopHeight + Core::kScreenBottomHeight, false, false)};
Core::kScreenTopWidth, Core::kScreenTopHeight + Core::kScreenBottomHeight, false, Layout::DisplayOrientation::Landscape)};

using VideoCore::ScreenId;

Expand Down
3 changes: 2 additions & 1 deletion src/citra_qt/bootmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,8 @@ struct SoftwareRenderWidget : public RenderWidget {

using VideoCore::ScreenId;

const auto layout{Layout::DefaultFrameLayout(width(), height(), false, false)};
const auto layout{
Layout::DefaultFrameLayout(width(), height(), false, Layout::DisplayOrientation::Landscape)};
QPainter painter(this);

const auto draw_screen = [&](ScreenId screen_id) {
Expand Down
2 changes: 2 additions & 0 deletions src/citra_qt/configuration/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ void Config::ReadLayoutValues() {
ReadGlobalSetting(Settings::values.swap_screen);
ReadGlobalSetting(Settings::values.upright_screen);
ReadGlobalSetting(Settings::values.large_screen_proportion);
ReadGlobalSetting(Settings::values.rotation_hand);

if (global) {
ReadBasicSetting(Settings::values.mono_render_option);
Expand Down Expand Up @@ -1028,6 +1029,7 @@ void Config::SaveLayoutValues() {
WriteGlobalSetting(Settings::values.swap_screen);
WriteGlobalSetting(Settings::values.upright_screen);
WriteGlobalSetting(Settings::values.large_screen_proportion);
WriteGlobalSetting(Settings::values.rotation_hand);

if (global) {
WriteBasicSetting(Settings::values.mono_render_option);
Expand Down
8 changes: 8 additions & 0 deletions src/citra_qt/configuration/configure_enhancements.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,15 @@ void ConfigureEnhancements::SetConfiguration() {
!Settings::values.texture_filter.UsingGlobal());
ConfigurationShared::SetPerGameSetting(ui->layout_combobox,
&Settings::values.layout_option);
ConfigurationShared::SetPerGameSetting(ui->handedness_combobox,
&Settings::values.rotation_hand);
} else {
ui->resolution_factor_combobox->setCurrentIndex(
Settings::values.resolution_factor.GetValue());
ui->layout_combobox->setCurrentIndex(
static_cast<int>(Settings::values.layout_option.GetValue()));
ui->handedness_combobox->setCurrentIndex(
static_cast<int>(Settings::values.rotation_hand.GetValue()));
ui->texture_filter_combobox->setCurrentIndex(
static_cast<int>(Settings::values.texture_filter.GetValue()));
}
Expand Down Expand Up @@ -155,6 +159,7 @@ void ConfigureEnhancements::ApplyConfiguration() {
swap_screen);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.upright_screen,
ui->toggle_upright_screen, upright_screen);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.rotation_hand, ui->handedness_combobox);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.dump_textures,
ui->toggle_dump_textures, dump_textures);
ConfigurationShared::ApplyPerGameSetting(&Settings::values.custom_textures,
Expand Down Expand Up @@ -216,4 +221,7 @@ void ConfigureEnhancements::SetupPerGameUI() {
ConfigurationShared::SetColoredComboBox(
ui->layout_combobox, ui->widget_layout,
static_cast<int>(Settings::values.layout_option.GetValue(true)));
ConfigurationShared::SetColoredComboBox(
ui->handedness_combobox, ui->widget_hand,
static_cast<int>(Settings::values.rotation_hand.GetValue(true)));
}
39 changes: 39 additions & 0 deletions src/citra_qt/configuration/configure_enhancements.ui
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,45 @@
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_hand" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="handedness_label">
<property name="text">
<string>Rotation Handedness</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="handedness_combobox">
<item>
<property name="text">
<string>Right Handed</string>
</property>
</item>
<item>
<property name="text">
<string>Left Handed</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="toggle_swap_screen">
<property name="text">
Expand Down
6 changes: 6 additions & 0 deletions src/common/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ enum class MonoRenderOption : u32 {
RightEye = 1,
};

enum class RotationHand : u32 {
RightHanded = 0,
LeftHanded = 1,
};

enum class AudioEmulation : u32 {
HLE = 0,
LLE = 1,
Expand Down Expand Up @@ -476,6 +481,7 @@ struct Values {
SwitchableSetting<LayoutOption> layout_option{LayoutOption::Default, "layout_option"};
SwitchableSetting<bool> swap_screen{false, "swap_screen"};
SwitchableSetting<bool> upright_screen{false, "upright_screen"};
SwitchableSetting<RotationHand> rotation_hand{RotationHand::RightHanded, "rotation_hand"};
SwitchableSetting<float, true> large_screen_proportion{4.f, 1.f, 16.f,
"large_screen_proportion"};
Setting<bool> custom_layout{false, "custom_layout"};
Expand Down
19 changes: 11 additions & 8 deletions src/core/frontend/emu_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ bool EmuWindow::TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y) {
static_cast<float>(framebuffer_y - framebuffer_layout.bottom_screen.top) /
(framebuffer_layout.bottom_screen.bottom - framebuffer_layout.bottom_screen.top);

if (!framebuffer_layout.is_rotated) {
if (framebuffer_layout.orientation == Layout::DisplayOrientation::Landscape) {
std::swap(touch_state->touch_x, touch_state->touch_y);
touch_state->touch_x = 1.f - touch_state->touch_x;
}
Expand Down Expand Up @@ -183,6 +183,9 @@ void EmuWindow::UpdateCurrentFramebufferLayout(u32 width, u32 height, bool is_po
const auto min_size =
Layout::GetMinimumSizeFromLayout(layout_option, Settings::values.upright_screen.GetValue());

const Layout::DisplayOrientation orientation = Layout::MakeDisplayOrientation(
Settings::values.upright_screen.GetValue(), Settings::values.rotation_hand.GetValue());

if (Settings::values.custom_layout.GetValue() == true) {
layout = Layout::CustomFrameLayout(width, height, Settings::values.swap_screen.GetValue());
} else {
Expand All @@ -193,30 +196,30 @@ void EmuWindow::UpdateCurrentFramebufferLayout(u32 width, u32 height, bool is_po
case Settings::LayoutOption::SingleScreen:
layout =
Layout::SingleFrameLayout(width, height, Settings::values.swap_screen.GetValue(),
Settings::values.upright_screen.GetValue());
orientation);
break;
case Settings::LayoutOption::LargeScreen:
layout =
Layout::LargeFrameLayout(width, height, Settings::values.swap_screen.GetValue(),
Settings::values.upright_screen.GetValue(),
orientation,
Settings::values.large_screen_proportion.GetValue(),
Layout::VerticalAlignment::Bottom);
break;
case Settings::LayoutOption::HybridScreen:
layout =
Layout::HybridScreenLayout(width, height, Settings::values.swap_screen.GetValue(),
Settings::values.upright_screen.GetValue());
orientation);
break;
case Settings::LayoutOption::SideScreen:
layout =
Layout::LargeFrameLayout(width, height, Settings::values.swap_screen.GetValue(),
Settings::values.upright_screen.GetValue(), 1.0f,
orientation, 1.0f,
Layout::VerticalAlignment::Bottom);
break;
#ifndef ANDROID
case Settings::LayoutOption::SeparateWindows:
layout = Layout::SeparateWindowsLayout(width, height, is_secondary,
Settings::values.upright_screen.GetValue());
orientation);
break;
#endif
case Settings::LayoutOption::MobilePortrait:
Expand All @@ -226,13 +229,13 @@ void EmuWindow::UpdateCurrentFramebufferLayout(u32 width, u32 height, bool is_po
case Settings::LayoutOption::MobileLandscape:
layout =
Layout::LargeFrameLayout(width, height, Settings::values.swap_screen.GetValue(),
false, 2.25f, Layout::VerticalAlignment::Top);
Layout::DisplayOrientation::Landscape, 2.25f, Layout::VerticalAlignment::Top);
break;
case Settings::LayoutOption::Default:
default:
layout =
Layout::DefaultFrameLayout(width, height, Settings::values.swap_screen.GetValue(),
Settings::values.upright_screen.GetValue());
orientation);
break;
}
UpdateMinimumWindowSize(min_size);
Expand Down
Loading

0 comments on commit 3afee33

Please sign in to comment.