From 482cf8a005a3c13ac7239995fdbe2e78d12984b9 Mon Sep 17 00:00:00 2001 From: bunnei Date: Tue, 9 Jan 2018 22:36:07 -0500 Subject: frontend: Update for undocked Switch screen layout. --- src/core/frontend/emu_window.cpp | 48 +++++++++++----------------------------- 1 file changed, 13 insertions(+), 35 deletions(-) (limited to 'src/core/frontend/emu_window.cpp') 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: EmuWindow::EmuWindow() { // TODO: Find a better place to set this. - config.min_client_area_size = std::make_pair(400u, 480u); + config.min_client_area_size = + std::make_pair(Layout::ScreenUndocked::Width, Layout::ScreenUndocked::Height); active_config = config; touch_state = std::make_shared(); Input::RegisterFactory("emu_window", touch_state); @@ -60,17 +61,16 @@ EmuWindow::~EmuWindow() { */ static bool IsWithinTouchscreen(const Layout::FramebufferLayout& layout, unsigned framebuffer_x, unsigned framebuffer_y) { - return ( - framebuffer_y >= layout.bottom_screen.top && framebuffer_y < layout.bottom_screen.bottom && - framebuffer_x >= layout.bottom_screen.left && framebuffer_x < layout.bottom_screen.right); + return (framebuffer_y >= layout.screen.top && framebuffer_y < layout.screen.bottom && + framebuffer_x >= layout.screen.left && framebuffer_x < layout.screen.right); } std::tuple EmuWindow::ClipToTouchScreen(unsigned new_x, unsigned new_y) { - new_x = std::max(new_x, framebuffer_layout.bottom_screen.left); - new_x = std::min(new_x, framebuffer_layout.bottom_screen.right - 1); + new_x = std::max(new_x, framebuffer_layout.screen.left); + new_x = std::min(new_x, framebuffer_layout.screen.right - 1); - new_y = std::max(new_y, framebuffer_layout.bottom_screen.top); - new_y = std::min(new_y, framebuffer_layout.bottom_screen.bottom - 1); + new_y = std::max(new_y, framebuffer_layout.screen.top); + new_y = std::min(new_y, framebuffer_layout.screen.bottom - 1); return std::make_tuple(new_x, new_y); } @@ -80,12 +80,10 @@ void EmuWindow::TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y) { return; std::lock_guard guard(touch_state->mutex); - touch_state->touch_x = - static_cast(framebuffer_x - framebuffer_layout.bottom_screen.left) / - (framebuffer_layout.bottom_screen.right - framebuffer_layout.bottom_screen.left); - touch_state->touch_y = - static_cast(framebuffer_y - framebuffer_layout.bottom_screen.top) / - (framebuffer_layout.bottom_screen.bottom - framebuffer_layout.bottom_screen.top); + touch_state->touch_x = static_cast(framebuffer_x - framebuffer_layout.screen.left) / + (framebuffer_layout.screen.right - framebuffer_layout.screen.left); + touch_state->touch_y = static_cast(framebuffer_y - framebuffer_layout.screen.top) / + (framebuffer_layout.screen.bottom - framebuffer_layout.screen.top); touch_state->touch_pressed = true; } @@ -108,25 +106,5 @@ void EmuWindow::TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y) { } void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) { - Layout::FramebufferLayout layout; - if (Settings::values.custom_layout == true) { - layout = Layout::CustomFrameLayout(width, height); - } else { - switch (Settings::values.layout_option) { - case Settings::LayoutOption::SingleScreen: - layout = Layout::SingleFrameLayout(width, height, Settings::values.swap_screen); - break; - case Settings::LayoutOption::LargeScreen: - layout = Layout::LargeFrameLayout(width, height, Settings::values.swap_screen); - break; - case Settings::LayoutOption::SideScreen: - layout = Layout::SideFrameLayout(width, height, Settings::values.swap_screen); - break; - case Settings::LayoutOption::Default: - default: - layout = Layout::DefaultFrameLayout(width, height, Settings::values.swap_screen); - break; - } - } - NotifyFramebufferLayoutChanged(layout); + NotifyFramebufferLayoutChanged(Layout::DefaultFrameLayout(width, height)); } -- cgit v1.2.3