diff options
| -rw-r--r-- | src/core/frontend/emu_window.cpp | 23 | ||||
| -rw-r--r-- | src/core/frontend/emu_window.h | 28 | ||||
| -rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu_cmd/emu_window/emu_window_sdl2.h | 2 |
4 files changed, 29 insertions, 26 deletions
diff --git a/src/core/frontend/emu_window.cpp b/src/core/frontend/emu_window.cpp index 474de9206..cff49899a 100644 --- a/src/core/frontend/emu_window.cpp +++ b/src/core/frontend/emu_window.cpp | |||
| @@ -60,23 +60,23 @@ EmuWindow::~EmuWindow() { | |||
| 60 | * @param framebuffer_y Framebuffer y-coordinate to check | 60 | * @param framebuffer_y Framebuffer y-coordinate to check |
| 61 | * @return True if the coordinates are within the touchpad, otherwise false | 61 | * @return True if the coordinates are within the touchpad, otherwise false |
| 62 | */ | 62 | */ |
| 63 | static bool IsWithinTouchscreen(const Layout::FramebufferLayout& layout, unsigned framebuffer_x, | 63 | static bool IsWithinTouchscreen(const Layout::FramebufferLayout& layout, u32 framebuffer_x, |
| 64 | unsigned framebuffer_y) { | 64 | u32 framebuffer_y) { |
| 65 | return (framebuffer_y >= layout.screen.top && framebuffer_y < layout.screen.bottom && | 65 | return (framebuffer_y >= layout.screen.top && framebuffer_y < layout.screen.bottom && |
| 66 | framebuffer_x >= layout.screen.left && framebuffer_x < layout.screen.right); | 66 | framebuffer_x >= layout.screen.left && framebuffer_x < layout.screen.right); |
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | std::tuple<unsigned, unsigned> EmuWindow::ClipToTouchScreen(unsigned new_x, unsigned new_y) const { | 69 | std::pair<u32, u32> EmuWindow::ClipToTouchScreen(u32 new_x, u32 new_y) const { |
| 70 | new_x = std::max(new_x, framebuffer_layout.screen.left); | 70 | new_x = std::max(new_x, framebuffer_layout.screen.left); |
| 71 | new_x = std::min(new_x, framebuffer_layout.screen.right - 1); | 71 | new_x = std::min(new_x, framebuffer_layout.screen.right - 1); |
| 72 | 72 | ||
| 73 | new_y = std::max(new_y, framebuffer_layout.screen.top); | 73 | new_y = std::max(new_y, framebuffer_layout.screen.top); |
| 74 | new_y = std::min(new_y, framebuffer_layout.screen.bottom - 1); | 74 | new_y = std::min(new_y, framebuffer_layout.screen.bottom - 1); |
| 75 | 75 | ||
| 76 | return std::make_tuple(new_x, new_y); | 76 | return std::make_pair(new_x, new_y); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | void EmuWindow::TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y, std::size_t id) { | 79 | void EmuWindow::TouchPressed(u32 framebuffer_x, u32 framebuffer_y, size_t id) { |
| 80 | if (!IsWithinTouchscreen(framebuffer_layout, framebuffer_x, framebuffer_y)) { | 80 | if (!IsWithinTouchscreen(framebuffer_layout, framebuffer_x, framebuffer_y)) { |
| 81 | return; | 81 | return; |
| 82 | } | 82 | } |
| @@ -95,7 +95,7 @@ void EmuWindow::TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y, std | |||
| 95 | touch_state->status[id] = std::make_tuple(x, y, true); | 95 | touch_state->status[id] = std::make_tuple(x, y, true); |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | void EmuWindow::TouchReleased(std::size_t id) { | 98 | void EmuWindow::TouchReleased(size_t id) { |
| 99 | if (id >= touch_state->status.size()) { | 99 | if (id >= touch_state->status.size()) { |
| 100 | return; | 100 | return; |
| 101 | } | 101 | } |
| @@ -103,20 +103,23 @@ void EmuWindow::TouchReleased(std::size_t id) { | |||
| 103 | touch_state->status[id] = std::make_tuple(0.0f, 0.0f, false); | 103 | touch_state->status[id] = std::make_tuple(0.0f, 0.0f, false); |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | void EmuWindow::TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y, std::size_t id) { | 106 | void EmuWindow::TouchMoved(u32 framebuffer_x, u32 framebuffer_y, size_t id) { |
| 107 | if (id >= touch_state->status.size()) { | 107 | if (id >= touch_state->status.size()) { |
| 108 | return; | 108 | return; |
| 109 | } | 109 | } |
| 110 | if (!std::get<2>(touch_state->status[id])) | 110 | |
| 111 | if (!std::get<2>(touch_state->status[id])) { | ||
| 111 | return; | 112 | return; |
| 113 | } | ||
| 112 | 114 | ||
| 113 | if (!IsWithinTouchscreen(framebuffer_layout, framebuffer_x, framebuffer_y)) | 115 | if (!IsWithinTouchscreen(framebuffer_layout, framebuffer_x, framebuffer_y)) { |
| 114 | std::tie(framebuffer_x, framebuffer_y) = ClipToTouchScreen(framebuffer_x, framebuffer_y); | 116 | std::tie(framebuffer_x, framebuffer_y) = ClipToTouchScreen(framebuffer_x, framebuffer_y); |
| 117 | } | ||
| 115 | 118 | ||
| 116 | TouchPressed(framebuffer_x, framebuffer_y, id); | 119 | TouchPressed(framebuffer_x, framebuffer_y, id); |
| 117 | } | 120 | } |
| 118 | 121 | ||
| 119 | void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) { | 122 | void EmuWindow::UpdateCurrentFramebufferLayout(u32 width, u32 height) { |
| 120 | NotifyFramebufferLayoutChanged(Layout::DefaultFrameLayout(width, height)); | 123 | NotifyFramebufferLayoutChanged(Layout::DefaultFrameLayout(width, height)); |
| 121 | } | 124 | } |
| 122 | 125 | ||
diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h index 2436c6580..076148698 100644 --- a/src/core/frontend/emu_window.h +++ b/src/core/frontend/emu_window.h | |||
| @@ -82,7 +82,7 @@ public: | |||
| 82 | bool fullscreen = false; | 82 | bool fullscreen = false; |
| 83 | int res_width = 0; | 83 | int res_width = 0; |
| 84 | int res_height = 0; | 84 | int res_height = 0; |
| 85 | std::pair<unsigned, unsigned> min_client_area_size; | 85 | std::pair<u32, u32> min_client_area_size; |
| 86 | }; | 86 | }; |
| 87 | 87 | ||
| 88 | /// Data describing host window system information | 88 | /// Data describing host window system information |
| @@ -119,13 +119,13 @@ public: | |||
| 119 | * @param framebuffer_y Framebuffer y-coordinate that was pressed | 119 | * @param framebuffer_y Framebuffer y-coordinate that was pressed |
| 120 | * @param id Touch event ID | 120 | * @param id Touch event ID |
| 121 | */ | 121 | */ |
| 122 | void TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y, std::size_t id); | 122 | void TouchPressed(u32 framebuffer_x, u32 framebuffer_y, size_t id); |
| 123 | 123 | ||
| 124 | /** | 124 | /** |
| 125 | * Signal that a touch released event has occurred (e.g. mouse click released) | 125 | * Signal that a touch released event has occurred (e.g. mouse click released) |
| 126 | * @param id Touch event ID | 126 | * @param id Touch event ID |
| 127 | */ | 127 | */ |
| 128 | void TouchReleased(std::size_t id); | 128 | void TouchReleased(size_t id); |
| 129 | 129 | ||
| 130 | /** | 130 | /** |
| 131 | * Signal that a touch movement event has occurred (e.g. mouse was moved over the emu window) | 131 | * Signal that a touch movement event has occurred (e.g. mouse was moved over the emu window) |
| @@ -133,7 +133,7 @@ public: | |||
| 133 | * @param framebuffer_y Framebuffer y-coordinate | 133 | * @param framebuffer_y Framebuffer y-coordinate |
| 134 | * @param id Touch event ID | 134 | * @param id Touch event ID |
| 135 | */ | 135 | */ |
| 136 | void TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y, std::size_t id); | 136 | void TouchMoved(u32 framebuffer_x, u32 framebuffer_y, size_t id); |
| 137 | 137 | ||
| 138 | /** | 138 | /** |
| 139 | * Returns currently active configuration. | 139 | * Returns currently active configuration. |
| @@ -173,7 +173,7 @@ public: | |||
| 173 | * Convenience method to update the current frame layout | 173 | * Convenience method to update the current frame layout |
| 174 | * Read from the current settings to determine which layout to use. | 174 | * Read from the current settings to determine which layout to use. |
| 175 | */ | 175 | */ |
| 176 | void UpdateCurrentFramebufferLayout(unsigned width, unsigned height); | 176 | void UpdateCurrentFramebufferLayout(u32 width, u32 height); |
| 177 | 177 | ||
| 178 | protected: | 178 | protected: |
| 179 | explicit EmuWindow(); | 179 | explicit EmuWindow(); |
| @@ -208,7 +208,7 @@ protected: | |||
| 208 | * Update internal client area size with the given parameter. | 208 | * Update internal client area size with the given parameter. |
| 209 | * @note EmuWindow implementations will usually use this in window resize event handlers. | 209 | * @note EmuWindow implementations will usually use this in window resize event handlers. |
| 210 | */ | 210 | */ |
| 211 | void NotifyClientAreaSizeChanged(const std::pair<unsigned, unsigned>& size) { | 211 | void NotifyClientAreaSizeChanged(std::pair<u32, u32> size) { |
| 212 | client_area_width = size.first; | 212 | client_area_width = size.first; |
| 213 | client_area_height = size.second; | 213 | client_area_height = size.second; |
| 214 | } | 214 | } |
| @@ -221,14 +221,19 @@ private: | |||
| 221 | * For the request to be honored, EmuWindow implementations will usually reimplement this | 221 | * For the request to be honored, EmuWindow implementations will usually reimplement this |
| 222 | * function. | 222 | * function. |
| 223 | */ | 223 | */ |
| 224 | virtual void OnMinimalClientAreaChangeRequest(std::pair<unsigned, unsigned>) { | 224 | virtual void OnMinimalClientAreaChangeRequest(std::pair<u32, u32>) { |
| 225 | // By default, ignore this request and do nothing. | 225 | // By default, ignore this request and do nothing. |
| 226 | } | 226 | } |
| 227 | 227 | ||
| 228 | /** | ||
| 229 | * Clip the provided coordinates to be inside the touchscreen area. | ||
| 230 | */ | ||
| 231 | std::pair<u32, u32> ClipToTouchScreen(u32 new_x, u32 new_y) const; | ||
| 232 | |||
| 228 | Layout::FramebufferLayout framebuffer_layout; ///< Current framebuffer layout | 233 | Layout::FramebufferLayout framebuffer_layout; ///< Current framebuffer layout |
| 229 | 234 | ||
| 230 | unsigned client_area_width; ///< Current client width, should be set by window impl. | 235 | u32 client_area_width; ///< Current client width, should be set by window impl. |
| 231 | unsigned client_area_height; ///< Current client height, should be set by window impl. | 236 | u32 client_area_height; ///< Current client height, should be set by window impl. |
| 232 | 237 | ||
| 233 | WindowConfig config; ///< Internal configuration (changes pending for being applied in | 238 | WindowConfig config; ///< Internal configuration (changes pending for being applied in |
| 234 | /// ProcessConfigurationChanges) | 239 | /// ProcessConfigurationChanges) |
| @@ -236,11 +241,6 @@ private: | |||
| 236 | 241 | ||
| 237 | class TouchState; | 242 | class TouchState; |
| 238 | std::shared_ptr<TouchState> touch_state; | 243 | std::shared_ptr<TouchState> touch_state; |
| 239 | |||
| 240 | /** | ||
| 241 | * Clip the provided coordinates to be inside the touchscreen area. | ||
| 242 | */ | ||
| 243 | std::tuple<unsigned, unsigned> ClipToTouchScreen(unsigned new_x, unsigned new_y) const; | ||
| 244 | }; | 244 | }; |
| 245 | 245 | ||
| 246 | } // namespace Core::Frontend | 246 | } // namespace Core::Frontend |
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp index 3bb555a6b..d64f81106 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp | |||
| @@ -238,6 +238,6 @@ void EmuWindow_SDL2::SetWindowIcon() { | |||
| 238 | SDL_FreeSurface(window_icon); | 238 | SDL_FreeSurface(window_icon); |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | void EmuWindow_SDL2::OnMinimalClientAreaChangeRequest(std::pair<unsigned, unsigned> minimal_size) { | 241 | void EmuWindow_SDL2::OnMinimalClientAreaChangeRequest(std::pair<u32, u32> minimal_size) { |
| 242 | SDL_SetWindowMinimumSize(render_window, minimal_size.first, minimal_size.second); | 242 | SDL_SetWindowMinimumSize(render_window, minimal_size.first, minimal_size.second); |
| 243 | } | 243 | } |
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.h b/src/yuzu_cmd/emu_window/emu_window_sdl2.h index 0e17bbca7..1b9ab5b93 100644 --- a/src/yuzu_cmd/emu_window/emu_window_sdl2.h +++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.h | |||
| @@ -71,7 +71,7 @@ protected: | |||
| 71 | void Fullscreen(); | 71 | void Fullscreen(); |
| 72 | 72 | ||
| 73 | /// Called when a configuration change affects the minimal size of the window | 73 | /// Called when a configuration change affects the minimal size of the window |
| 74 | void OnMinimalClientAreaChangeRequest(std::pair<unsigned, unsigned> minimal_size) override; | 74 | void OnMinimalClientAreaChangeRequest(std::pair<u32, u32> minimal_size) override; |
| 75 | 75 | ||
| 76 | /// Is the window still open? | 76 | /// Is the window still open? |
| 77 | bool is_open = true; | 77 | bool is_open = true; |