diff options
| author | 2018-01-09 22:36:07 -0500 | |
|---|---|---|
| committer | 2018-01-10 23:28:43 -0500 | |
| commit | 482cf8a005a3c13ac7239995fdbe2e78d12984b9 (patch) | |
| tree | 0e29fe56ada3a97a1f753ad68e1430e98f66e303 /src/core/frontend/emu_window.cpp | |
| parent | NV: Move the nv device nodes to their own directory and namespace. (diff) | |
| download | yuzu-482cf8a005a3c13ac7239995fdbe2e78d12984b9.tar.gz yuzu-482cf8a005a3c13ac7239995fdbe2e78d12984b9.tar.xz yuzu-482cf8a005a3c13ac7239995fdbe2e78d12984b9.zip | |
frontend: Update for undocked Switch screen layout.
Diffstat (limited to 'src/core/frontend/emu_window.cpp')
| -rw-r--r-- | src/core/frontend/emu_window.cpp | 48 |
1 files changed, 13 insertions, 35 deletions
diff --git a/src/core/frontend/emu_window.cpp b/src/core/frontend/emu_window.cpp index e67394177..2d776c693 100644 --- a/src/core/frontend/emu_window.cpp +++ b/src/core/frontend/emu_window.cpp | |||
| @@ -41,7 +41,8 @@ private: | |||
| 41 | 41 | ||
| 42 | EmuWindow::EmuWindow() { | 42 | EmuWindow::EmuWindow() { |
| 43 | // TODO: Find a better place to set this. | 43 | // TODO: Find a better place to set this. |
| 44 | config.min_client_area_size = std::make_pair(400u, 480u); | 44 | config.min_client_area_size = |
| 45 | std::make_pair(Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height); | ||
| 45 | active_config = config; | 46 | active_config = config; |
| 46 | touch_state = std::make_shared<TouchState>(); | 47 | touch_state = std::make_shared<TouchState>(); |
| 47 | Input::RegisterFactory<Input::TouchDevice>("emu_window", touch_state); | 48 | Input::RegisterFactory<Input::TouchDevice>("emu_window", touch_state); |
| @@ -60,17 +61,16 @@ EmuWindow::~EmuWindow() { | |||
| 60 | */ | 61 | */ |
| 61 | static bool IsWithinTouchscreen(const Layout::FramebufferLayout& layout, unsigned framebuffer_x, | 62 | static bool IsWithinTouchscreen(const Layout::FramebufferLayout& layout, unsigned framebuffer_x, |
| 62 | unsigned framebuffer_y) { | 63 | unsigned framebuffer_y) { |
| 63 | return ( | 64 | return (framebuffer_y >= layout.screen.top && framebuffer_y < layout.screen.bottom && |
| 64 | framebuffer_y >= layout.bottom_screen.top && framebuffer_y < layout.bottom_screen.bottom && | 65 | framebuffer_x >= layout.screen.left && framebuffer_x < layout.screen.right); |
| 65 | framebuffer_x >= layout.bottom_screen.left && framebuffer_x < layout.bottom_screen.right); | ||
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | std::tuple<unsigned, unsigned> EmuWindow::ClipToTouchScreen(unsigned new_x, unsigned new_y) { | 68 | std::tuple<unsigned, unsigned> EmuWindow::ClipToTouchScreen(unsigned new_x, unsigned new_y) { |
| 69 | new_x = std::max(new_x, framebuffer_layout.bottom_screen.left); | 69 | new_x = std::max(new_x, framebuffer_layout.screen.left); |
| 70 | new_x = std::min(new_x, framebuffer_layout.bottom_screen.right - 1); | 70 | new_x = std::min(new_x, framebuffer_layout.screen.right - 1); |
| 71 | 71 | ||
| 72 | new_y = std::max(new_y, framebuffer_layout.bottom_screen.top); | 72 | new_y = std::max(new_y, framebuffer_layout.screen.top); |
| 73 | new_y = std::min(new_y, framebuffer_layout.bottom_screen.bottom - 1); | 73 | new_y = std::min(new_y, framebuffer_layout.screen.bottom - 1); |
| 74 | 74 | ||
| 75 | return std::make_tuple(new_x, new_y); | 75 | return std::make_tuple(new_x, new_y); |
| 76 | } | 76 | } |
| @@ -80,12 +80,10 @@ void EmuWindow::TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y) { | |||
| 80 | return; | 80 | return; |
| 81 | 81 | ||
| 82 | std::lock_guard<std::mutex> guard(touch_state->mutex); | 82 | std::lock_guard<std::mutex> guard(touch_state->mutex); |
| 83 | touch_state->touch_x = | 83 | touch_state->touch_x = static_cast<float>(framebuffer_x - framebuffer_layout.screen.left) / |
| 84 | static_cast<float>(framebuffer_x - framebuffer_layout.bottom_screen.left) / | 84 | (framebuffer_layout.screen.right - framebuffer_layout.screen.left); |
| 85 | (framebuffer_layout.bottom_screen.right - framebuffer_layout.bottom_screen.left); | 85 | touch_state->touch_y = static_cast<float>(framebuffer_y - framebuffer_layout.screen.top) / |
| 86 | touch_state->touch_y = | 86 | (framebuffer_layout.screen.bottom - framebuffer_layout.screen.top); |
| 87 | static_cast<float>(framebuffer_y - framebuffer_layout.bottom_screen.top) / | ||
| 88 | (framebuffer_layout.bottom_screen.bottom - framebuffer_layout.bottom_screen.top); | ||
| 89 | 87 | ||
| 90 | touch_state->touch_pressed = true; | 88 | touch_state->touch_pressed = true; |
| 91 | } | 89 | } |
| @@ -108,25 +106,5 @@ void EmuWindow::TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y) { | |||
| 108 | } | 106 | } |
| 109 | 107 | ||
| 110 | void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) { | 108 | void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) { |
| 111 | Layout::FramebufferLayout layout; | 109 | NotifyFramebufferLayoutChanged(Layout::DefaultFrameLayout(width, height)); |
| 112 | if (Settings::values.custom_layout == true) { | ||
| 113 | layout = Layout::CustomFrameLayout(width, height); | ||
| 114 | } else { | ||
| 115 | switch (Settings::values.layout_option) { | ||
| 116 | case Settings::LayoutOption::SingleScreen: | ||
| 117 | layout = Layout::SingleFrameLayout(width, height, Settings::values.swap_screen); | ||
| 118 | break; | ||
| 119 | case Settings::LayoutOption::LargeScreen: | ||
| 120 | layout = Layout::LargeFrameLayout(width, height, Settings::values.swap_screen); | ||
| 121 | break; | ||
| 122 | case Settings::LayoutOption::SideScreen: | ||
| 123 | layout = Layout::SideFrameLayout(width, height, Settings::values.swap_screen); | ||
| 124 | break; | ||
| 125 | case Settings::LayoutOption::Default: | ||
| 126 | default: | ||
| 127 | layout = Layout::DefaultFrameLayout(width, height, Settings::values.swap_screen); | ||
| 128 | break; | ||
| 129 | } | ||
| 130 | } | ||
| 131 | NotifyFramebufferLayoutChanged(layout); | ||
| 132 | } | 110 | } |