| 8 | { |
| 9 | |
| 10 | void |
| 11 | updateDisplayLayout(DisplayLayout &layout, |
| 12 | float windowWidth, |
| 13 | float windowHeight) |
| 14 | { |
| 15 | // Sizes for calculating aspect ratio |
| 16 | constexpr auto TvWidth = 1280.0f; |
| 17 | constexpr auto TvHeight = 720.0f; |
| 18 | constexpr auto DrcWidth = 854.0f; |
| 19 | constexpr auto DrcHeight = 480.0f; |
| 20 | constexpr auto SplitCombinedWidth = std::max(TvWidth, DrcWidth); |
| 21 | constexpr auto SplitCombinedHeight = TvHeight + DrcHeight; |
| 22 | |
| 23 | const auto &displaySettings = gpu::config()->display; |
| 24 | const auto splitScreenSeparation = static_cast<float>(displaySettings.splitSeperation); |
| 25 | |
| 26 | auto maintainAspectRatio = |
| 27 | [&](DisplayLayout::Display &display, |
| 28 | float width, float height, |
| 29 | float referenceWidth, float referenceHeight) |
| 30 | { |
| 31 | const auto widthRatio = static_cast<float>(width) / referenceWidth; |
| 32 | const auto heightRatio = static_cast<float>(height) / referenceHeight; |
| 33 | const auto aspectRatio = std::min(widthRatio, heightRatio); |
| 34 | display.width = aspectRatio * referenceWidth; |
| 35 | display.height = aspectRatio * referenceHeight; |
| 36 | }; |
| 37 | |
| 38 | if (displaySettings.viewMode == gpu::DisplaySettings::TV) { |
| 39 | layout.tv.visible = true; |
| 40 | layout.drc.visible = false; |
| 41 | |
| 42 | if (displaySettings.maintainAspectRatio) { |
| 43 | maintainAspectRatio(layout.tv, windowWidth, windowHeight, TvWidth, TvHeight); |
| 44 | layout.tv.x = (windowWidth - layout.tv.width) / 2.0f; |
| 45 | layout.tv.y = (windowHeight - layout.tv.height) / 2.0f; |
| 46 | } else { |
| 47 | layout.tv.x = 0.0f; |
| 48 | layout.tv.y = 0.0f; |
| 49 | layout.tv.width = windowWidth; |
| 50 | layout.tv.height = windowHeight; |
| 51 | } |
| 52 | } else if (displaySettings.viewMode == gpu::DisplaySettings::Gamepad1) { |
| 53 | layout.tv.visible = false; |
| 54 | layout.drc.visible = true; |
| 55 | |
| 56 | if (displaySettings.maintainAspectRatio) { |
| 57 | maintainAspectRatio(layout.drc, windowWidth, windowHeight, DrcWidth, DrcHeight); |
| 58 | layout.drc.x = (windowWidth - layout.drc.width) / 2.0f; |
| 59 | layout.drc.y = (windowHeight - layout.drc.height) / 2.0f; |
| 60 | } else { |
| 61 | layout.drc.x = 0.0f; |
| 62 | layout.drc.y = 0.0f; |
| 63 | layout.drc.width = windowWidth; |
| 64 | layout.drc.height = windowHeight; |
| 65 | } |
| 66 | } else if (displaySettings.viewMode == gpu::DisplaySettings::Split) { |
| 67 | layout.tv.visible = true; |
no test coverage detected