diff options
| author | 2017-08-09 02:57:42 +0300 | |
|---|---|---|
| committer | 2017-08-24 15:00:56 +0300 | |
| commit | 2617de1fe6f6f1fc846a8e038e1ea77a894554b2 (patch) | |
| tree | 08c5cc339ed43241359c1e0b6d7331ca69408eb4 /src/core/frontend/emu_window.h | |
| parent | HID: use TouchDevice for touch pad (diff) | |
| download | yuzu-2617de1fe6f6f1fc846a8e038e1ea77a894554b2.tar.gz yuzu-2617de1fe6f6f1fc846a8e038e1ea77a894554b2.tar.xz yuzu-2617de1fe6f6f1fc846a8e038e1ea77a894554b2.zip | |
EmuWindow: refactor touch input into a TouchDevice
Diffstat (limited to 'src/core/frontend/emu_window.h')
| -rw-r--r-- | src/core/frontend/emu_window.h | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h index 7bdee251c..c10dee51b 100644 --- a/src/core/frontend/emu_window.h +++ b/src/core/frontend/emu_window.h | |||
| @@ -4,11 +4,10 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <mutex> | 7 | #include <memory> |
| 8 | #include <tuple> | 8 | #include <tuple> |
| 9 | #include <utility> | 9 | #include <utility> |
| 10 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 11 | #include "common/math_util.h" | ||
| 12 | #include "core/frontend/framebuffer_layout.h" | 11 | #include "core/frontend/framebuffer_layout.h" |
| 13 | 12 | ||
| 14 | /** | 13 | /** |
| @@ -69,17 +68,6 @@ public: | |||
| 69 | void TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y); | 68 | void TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y); |
| 70 | 69 | ||
| 71 | /** | 70 | /** |
| 72 | * Gets the current touch screen state (touch X/Y coordinates and whether or not it is pressed). | ||
| 73 | * @note This should be called by the core emu thread to get a state set by the window thread. | ||
| 74 | * @todo Fix this function to be thread-safe. | ||
| 75 | * @return std::tuple of (x, y, pressed) where `x` and `y` are the touch coordinates and | ||
| 76 | * `pressed` is true if the touch screen is currently being pressed | ||
| 77 | */ | ||
| 78 | std::tuple<u16, u16, bool> GetTouchState() const { | ||
| 79 | return std::make_tuple(touch_x, touch_y, touch_pressed); | ||
| 80 | } | ||
| 81 | |||
| 82 | /** | ||
| 83 | * Returns currently active configuration. | 71 | * Returns currently active configuration. |
| 84 | * @note Accesses to the returned object need not be consistent because it may be modified in | 72 | * @note Accesses to the returned object need not be consistent because it may be modified in |
| 85 | * another thread | 73 | * another thread |
| @@ -113,15 +101,8 @@ public: | |||
| 113 | void UpdateCurrentFramebufferLayout(unsigned width, unsigned height); | 101 | void UpdateCurrentFramebufferLayout(unsigned width, unsigned height); |
| 114 | 102 | ||
| 115 | protected: | 103 | protected: |
| 116 | EmuWindow() { | 104 | EmuWindow(); |
| 117 | // TODO: Find a better place to set this. | 105 | virtual ~EmuWindow(); |
| 118 | config.min_client_area_size = std::make_pair(400u, 480u); | ||
| 119 | active_config = config; | ||
| 120 | touch_x = 0; | ||
| 121 | touch_y = 0; | ||
| 122 | touch_pressed = false; | ||
| 123 | } | ||
| 124 | virtual ~EmuWindow() {} | ||
| 125 | 106 | ||
| 126 | /** | 107 | /** |
| 127 | * Processes any pending configuration changes from the last SetConfig call. | 108 | * Processes any pending configuration changes from the last SetConfig call. |
| @@ -177,10 +158,8 @@ private: | |||
| 177 | /// ProcessConfigurationChanges) | 158 | /// ProcessConfigurationChanges) |
| 178 | WindowConfig active_config; ///< Internal active configuration | 159 | WindowConfig active_config; ///< Internal active configuration |
| 179 | 160 | ||
| 180 | bool touch_pressed; ///< True if touchpad area is currently pressed, otherwise false | 161 | class TouchState; |
| 181 | 162 | std::shared_ptr<TouchState> touch_state; | |
| 182 | u16 touch_x; ///< Touchpad X-position in native 3DS pixel coordinates (0-320) | ||
| 183 | u16 touch_y; ///< Touchpad Y-position in native 3DS pixel coordinates (0-240) | ||
| 184 | 163 | ||
| 185 | /** | 164 | /** |
| 186 | * Clip the provided coordinates to be inside the touchscreen area. | 165 | * Clip the provided coordinates to be inside the touchscreen area. |