diff options
| author | 2017-08-25 23:53:07 +0200 | |
|---|---|---|
| committer | 2017-08-25 17:53:07 -0400 | |
| commit | 3cdf854e44e7ff088fa0cbdcfa2bcc6e41822b2c (patch) | |
| tree | fea4d815243451086ec4da459f3a310b02019437 | |
| parent | Merge pull request #2839 from Subv/global_kernel_lock (diff) | |
| download | yuzu-3cdf854e44e7ff088fa0cbdcfa2bcc6e41822b2c.tar.gz yuzu-3cdf854e44e7ff088fa0cbdcfa2bcc6e41822b2c.tar.xz yuzu-3cdf854e44e7ff088fa0cbdcfa2bcc6e41822b2c.zip | |
SidebySide Layout (#2859)
* added a SidebySide Layout
* Reworked, so both screen have the same height and cleaned up screen translates.
* added the option in the UI, hope this is the right way to do it. formated framebuffer_layout.cpp
* delete the x64 files
* deleted ui_configure_graphics.h
* added Option for the Layout in the xml
* got rid of SIDE_BY_SIDE_ASPECT_RATIO because it was useless. pulled translate into variables
* changed shift variables to u32 and moved them in their respective branch. remove notr="true" for the Screen layout drop down
* reworked intends :). changed function description for SideFrameLayout
* some description reworking
Diffstat (limited to '')
| -rw-r--r-- | src/citra_qt/configuration/configure_graphics.ui | 11 | ||||
| -rw-r--r-- | src/core/frontend/emu_window.cpp | 3 | ||||
| -rw-r--r-- | src/core/frontend/framebuffer_layout.cpp | 36 | ||||
| -rw-r--r-- | src/core/frontend/framebuffer_layout.h | 11 | ||||
| -rw-r--r-- | src/core/settings.cpp | 2 | ||||
| -rw-r--r-- | src/core/settings.h | 5 |
6 files changed, 61 insertions, 7 deletions
diff --git a/src/citra_qt/configuration/configure_graphics.ui b/src/citra_qt/configuration/configure_graphics.ui index 228f2a869..b340149d5 100644 --- a/src/citra_qt/configuration/configure_graphics.ui +++ b/src/citra_qt/configuration/configure_graphics.ui | |||
| @@ -146,17 +146,22 @@ | |||
| 146 | <widget class="QComboBox" name="layout_combobox"> | 146 | <widget class="QComboBox" name="layout_combobox"> |
| 147 | <item> | 147 | <item> |
| 148 | <property name="text"> | 148 | <property name="text"> |
| 149 | <string notr="true">Default</string> | 149 | <string>Default</string> |
| 150 | </property> | 150 | </property> |
| 151 | </item> | 151 | </item> |
| 152 | <item> | 152 | <item> |
| 153 | <property name="text"> | 153 | <property name="text"> |
| 154 | <string notr="true">Single Screen</string> | 154 | <string>Single Screen</string> |
| 155 | </property> | 155 | </property> |
| 156 | </item> | 156 | </item> |
| 157 | <item> | 157 | <item> |
| 158 | <property name="text"> | 158 | <property name="text"> |
| 159 | <string notr="true">Large Screen</string> | 159 | <string>Large Screen</string> |
| 160 | </property> | ||
| 161 | </item> | ||
| 162 | <item> | ||
| 163 | <property name="text"> | ||
| 164 | <string>Side by Side</string> | ||
| 160 | </property> | 165 | </property> |
| 161 | </item> | 166 | </item> |
| 162 | </widget> | 167 | </widget> |
diff --git a/src/core/frontend/emu_window.cpp b/src/core/frontend/emu_window.cpp index 60b20d4e2..54fa5c7fa 100644 --- a/src/core/frontend/emu_window.cpp +++ b/src/core/frontend/emu_window.cpp | |||
| @@ -74,6 +74,9 @@ void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) | |||
| 74 | case Settings::LayoutOption::LargeScreen: | 74 | case Settings::LayoutOption::LargeScreen: |
| 75 | layout = Layout::LargeFrameLayout(width, height, Settings::values.swap_screen); | 75 | layout = Layout::LargeFrameLayout(width, height, Settings::values.swap_screen); |
| 76 | break; | 76 | break; |
| 77 | case Settings::LayoutOption::SideScreen: | ||
| 78 | layout = Layout::SideFrameLayout(width, height, Settings::values.swap_screen); | ||
| 79 | break; | ||
| 77 | case Settings::LayoutOption::Default: | 80 | case Settings::LayoutOption::Default: |
| 78 | default: | 81 | default: |
| 79 | layout = Layout::DefaultFrameLayout(width, height, Settings::values.swap_screen); | 82 | layout = Layout::DefaultFrameLayout(width, height, Settings::values.swap_screen); |
diff --git a/src/core/frontend/framebuffer_layout.cpp b/src/core/frontend/framebuffer_layout.cpp index d2d02f9ff..e9f778fcb 100644 --- a/src/core/frontend/framebuffer_layout.cpp +++ b/src/core/frontend/framebuffer_layout.cpp | |||
| @@ -141,6 +141,40 @@ FramebufferLayout LargeFrameLayout(unsigned width, unsigned height, bool swapped | |||
| 141 | return res; | 141 | return res; |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | FramebufferLayout SideFrameLayout(unsigned width, unsigned height, bool swapped) { | ||
| 145 | ASSERT(width > 0); | ||
| 146 | ASSERT(height > 0); | ||
| 147 | |||
| 148 | FramebufferLayout res{width, height, true, true, {}, {}}; | ||
| 149 | // Aspect ratio of both screens side by side | ||
| 150 | const float emulation_aspect_ratio = static_cast<float>(Core::kScreenTopHeight) / | ||
| 151 | (Core::kScreenTopWidth + Core::kScreenBottomWidth); | ||
| 152 | float window_aspect_ratio = static_cast<float>(height) / width; | ||
| 153 | MathUtil::Rectangle<unsigned> screen_window_area{0, 0, width, height}; | ||
| 154 | // Find largest Rectangle that can fit in the window size with the given aspect ratio | ||
| 155 | MathUtil::Rectangle<unsigned> screen_rect = | ||
| 156 | maxRectangle(screen_window_area, emulation_aspect_ratio); | ||
| 157 | // Find sizes of top and bottom screen | ||
| 158 | MathUtil::Rectangle<unsigned> top_screen = maxRectangle(screen_rect, TOP_SCREEN_ASPECT_RATIO); | ||
| 159 | MathUtil::Rectangle<unsigned> bot_screen = maxRectangle(screen_rect, BOT_SCREEN_ASPECT_RATIO); | ||
| 160 | |||
| 161 | if (window_aspect_ratio < emulation_aspect_ratio) { | ||
| 162 | // Apply borders to the left and right sides of the window. | ||
| 163 | u32 shift_horizontal = (screen_window_area.GetWidth() - screen_rect.GetWidth()) / 2; | ||
| 164 | top_screen = top_screen.TranslateX(shift_horizontal); | ||
| 165 | bot_screen = bot_screen.TranslateX(shift_horizontal); | ||
| 166 | } else { | ||
| 167 | // Window is narrower than the emulation content => apply borders to the top and bottom | ||
| 168 | u32 shift_vertical = (screen_window_area.GetHeight() - screen_rect.GetHeight()) / 2; | ||
| 169 | top_screen = top_screen.TranslateY(shift_vertical); | ||
| 170 | bot_screen = bot_screen.TranslateY(shift_vertical); | ||
| 171 | } | ||
| 172 | // Move the top screen to the right if we are swapped. | ||
| 173 | res.top_screen = swapped ? top_screen.TranslateX(bot_screen.GetWidth()) : top_screen; | ||
| 174 | res.bottom_screen = swapped ? bot_screen : bot_screen.TranslateX(top_screen.GetWidth()); | ||
| 175 | return res; | ||
| 176 | } | ||
| 177 | |||
| 144 | FramebufferLayout CustomFrameLayout(unsigned width, unsigned height) { | 178 | FramebufferLayout CustomFrameLayout(unsigned width, unsigned height) { |
| 145 | ASSERT(width > 0); | 179 | ASSERT(width > 0); |
| 146 | ASSERT(height > 0); | 180 | ASSERT(height > 0); |
| @@ -158,4 +192,4 @@ FramebufferLayout CustomFrameLayout(unsigned width, unsigned height) { | |||
| 158 | res.bottom_screen = bot_screen; | 192 | res.bottom_screen = bot_screen; |
| 159 | return res; | 193 | return res; |
| 160 | } | 194 | } |
| 161 | } | 195 | } // namespace Layout |
diff --git a/src/core/frontend/framebuffer_layout.h b/src/core/frontend/framebuffer_layout.h index 9a7738969..4983cf103 100644 --- a/src/core/frontend/framebuffer_layout.h +++ b/src/core/frontend/framebuffer_layout.h | |||
| @@ -54,6 +54,17 @@ FramebufferLayout SingleFrameLayout(unsigned width, unsigned height, bool is_swa | |||
| 54 | FramebufferLayout LargeFrameLayout(unsigned width, unsigned height, bool is_swapped); | 54 | FramebufferLayout LargeFrameLayout(unsigned width, unsigned height, bool is_swapped); |
| 55 | 55 | ||
| 56 | /** | 56 | /** |
| 57 | * Factory method for constructing a Frame with the Top screen and bottom | ||
| 58 | * screen side by side | ||
| 59 | * This is useful for devices with small screens, like the GPDWin | ||
| 60 | * @param width Window framebuffer width in pixels | ||
| 61 | * @param height Window framebuffer height in pixels | ||
| 62 | * @param is_swapped if true, the bottom screen will be the left display | ||
| 63 | * @return Newly created FramebufferLayout object with default screen regions initialized | ||
| 64 | */ | ||
| 65 | FramebufferLayout SideFrameLayout(unsigned width, unsigned height, bool is_swapped); | ||
| 66 | |||
| 67 | /** | ||
| 57 | * Factory method for constructing a custom FramebufferLayout | 68 | * Factory method for constructing a custom FramebufferLayout |
| 58 | * @param width Window framebuffer width in pixels | 69 | * @param width Window framebuffer width in pixels |
| 59 | * @param height Window framebuffer height in pixels | 70 | * @param height Window framebuffer height in pixels |
diff --git a/src/core/settings.cpp b/src/core/settings.cpp index d4f0429d1..efcf1267d 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp | |||
| @@ -36,4 +36,4 @@ void Apply() { | |||
| 36 | Service::IR::ReloadInputDevices(); | 36 | Service::IR::ReloadInputDevices(); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | } // namespace | 39 | } // namespace Settings |
diff --git a/src/core/settings.h b/src/core/settings.h index 7e15b119b..ca657719a 100644 --- a/src/core/settings.h +++ b/src/core/settings.h | |||
| @@ -15,6 +15,7 @@ enum class LayoutOption { | |||
| 15 | Default, | 15 | Default, |
| 16 | SingleScreen, | 16 | SingleScreen, |
| 17 | LargeScreen, | 17 | LargeScreen, |
| 18 | SideScreen, | ||
| 18 | }; | 19 | }; |
| 19 | 20 | ||
| 20 | namespace NativeButton { | 21 | namespace NativeButton { |
| @@ -70,7 +71,7 @@ enum Values { | |||
| 70 | static const std::array<const char*, NumAnalogs> mapping = {{ | 71 | static const std::array<const char*, NumAnalogs> mapping = {{ |
| 71 | "circle_pad", "c_stick", | 72 | "circle_pad", "c_stick", |
| 72 | }}; | 73 | }}; |
| 73 | } // namespace NumAnalog | 74 | } // namespace NativeAnalog |
| 74 | 75 | ||
| 75 | struct Values { | 76 | struct Values { |
| 76 | // CheckNew3DS | 77 | // CheckNew3DS |
| @@ -137,4 +138,4 @@ struct Values { | |||
| 137 | static constexpr int REGION_VALUE_AUTO_SELECT = -1; | 138 | static constexpr int REGION_VALUE_AUTO_SELECT = -1; |
| 138 | 139 | ||
| 139 | void Apply(); | 140 | void Apply(); |
| 140 | } | 141 | } // namespace Settings |