diff options
| author | 2015-03-09 00:14:59 -0400 | |
|---|---|---|
| committer | 2015-03-10 23:58:07 -0400 | |
| commit | d61b26b79f889603a084e148626bba3c267cf75f (patch) | |
| tree | d793edd22e25a99aa5c13cc2455a5ec2167afee7 /src/common/emu_window.h | |
| parent | EmuWindow: Made pad/touch functions non-static. (diff) | |
| download | yuzu-d61b26b79f889603a084e148626bba3c267cf75f.tar.gz yuzu-d61b26b79f889603a084e148626bba3c267cf75f.tar.xz yuzu-d61b26b79f889603a084e148626bba3c267cf75f.zip | |
HID: Complete refactor of pad/touch input to fix threading issues.
Diffstat (limited to 'src/common/emu_window.h')
| -rw-r--r-- | src/common/emu_window.h | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/src/common/emu_window.h b/src/common/emu_window.h index 8e4b510e9..2be7517bc 100644 --- a/src/common/emu_window.h +++ b/src/common/emu_window.h | |||
| @@ -78,27 +78,41 @@ public: | |||
| 78 | 78 | ||
| 79 | /** | 79 | /** |
| 80 | * Signal that a touch pressed event has occurred (e.g. mouse click pressed) | 80 | * Signal that a touch pressed event has occurred (e.g. mouse click pressed) |
| 81 | * @param layout FramebufferLayout object describing the framebuffer size and screen positions | ||
| 82 | * @param framebuffer_x Framebuffer x-coordinate that was pressed | 81 | * @param framebuffer_x Framebuffer x-coordinate that was pressed |
| 83 | * @param framebuffer_y Framebuffer y-coordinate that was pressed | 82 | * @param framebuffer_y Framebuffer y-coordinate that was pressed |
| 84 | */ | 83 | */ |
| 85 | void TouchPressed(const FramebufferLayout& layout, unsigned framebuffer_x, unsigned framebuffer_y); | 84 | void TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y); |
| 86 | 85 | ||
| 87 | /** | 86 | /// Signal that a touch released event has occurred (e.g. mouse click released) |
| 88 | * Signal that a touch released event has occurred (e.g. mouse click released) | 87 | void TouchReleased(); |
| 89 | * @param layout FramebufferLayout object describing the framebuffer size and screen positions | ||
| 90 | * @param framebuffer_x Framebuffer x-coordinate that was released | ||
| 91 | * @param framebuffer_y Framebuffer y-coordinate that was released | ||
| 92 | */ | ||
| 93 | void TouchReleased(const FramebufferLayout& layout, unsigned framebuffer_x, unsigned framebuffer_y); | ||
| 94 | 88 | ||
| 95 | /** | 89 | /** |
| 96 | * Signal that a touch movement event has occurred (e.g. mouse was moved over the emu window) | 90 | * Signal that a touch movement event has occurred (e.g. mouse was moved over the emu window) |
| 97 | * @param layout FramebufferLayout object describing the framebuffer size and screen positions | ||
| 98 | * @param framebuffer_x Framebuffer x-coordinate | 91 | * @param framebuffer_x Framebuffer x-coordinate |
| 99 | * @param framebuffer_y Framebuffer y-coordinate | 92 | * @param framebuffer_y Framebuffer y-coordinate |
| 100 | */ | 93 | */ |
| 101 | void TouchMoved(const FramebufferLayout& layout, unsigned framebuffer_x, unsigned framebuffer_y); | 94 | void TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y); |
| 95 | |||
| 96 | /** | ||
| 97 | * Gets the current pad state (which buttons are pressed and the circle pad direction). | ||
| 98 | * @note This should be called by the core emu thread to get a state set by the window thread. | ||
| 99 | * @todo Fix this function to be thread-safe. | ||
| 100 | * @return PadState object indicating the current pad state | ||
| 101 | */ | ||
| 102 | const Service::HID::PadState GetPadState() const { | ||
| 103 | return pad_state; | ||
| 104 | } | ||
| 105 | |||
| 106 | /** | ||
| 107 | * Gets the current touch screen state (touch X/Y coordinates and whether or not it is pressed). | ||
| 108 | * @note This should be called by the core emu thread to get a state set by the window thread. | ||
| 109 | * @todo Fix this function to be thread-safe. | ||
| 110 | * @return std::tuple of (x, y, pressed) where `x` and `y` are the touch coordinates and | ||
| 111 | * `pressed` is true if the touch screen is currently being pressed | ||
| 112 | */ | ||
| 113 | const std::tuple<u16, u16, bool>& GetTouchState() const { | ||
| 114 | return std::make_tuple(touch_x, touch_y, touch_pressed); | ||
| 115 | } | ||
| 102 | 116 | ||
| 103 | /** | 117 | /** |
| 104 | * Returns currently active configuration. | 118 | * Returns currently active configuration. |
| @@ -124,21 +138,15 @@ public: | |||
| 124 | return framebuffer_layout; | 138 | return framebuffer_layout; |
| 125 | } | 139 | } |
| 126 | 140 | ||
| 127 | /** | ||
| 128 | * Gets window client area width in logical coordinates. | ||
| 129 | * @note For high-DPI systems, this is smaller than the framebuffer size. | ||
| 130 | * @note This method is thread-safe | ||
| 131 | */ | ||
| 132 | std::pair<unsigned,unsigned> GetClientAreaSize() const { | ||
| 133 | return std::make_pair(client_area_width, client_area_height); | ||
| 134 | } | ||
| 135 | |||
| 136 | protected: | 141 | protected: |
| 137 | EmuWindow() | 142 | EmuWindow() { |
| 138 | { | ||
| 139 | // TODO: Find a better place to set this. | 143 | // TODO: Find a better place to set this. |
| 140 | config.min_client_area_size = std::make_pair(400u, 480u); | 144 | config.min_client_area_size = std::make_pair(400u, 480u); |
| 141 | active_config = config; | 145 | active_config = config; |
| 146 | pad_state.hex = 0; | ||
| 147 | touch_x = 0; | ||
| 148 | touch_y = 0; | ||
| 149 | touch_pressed = false; | ||
| 142 | } | 150 | } |
| 143 | virtual ~EmuWindow() {} | 151 | virtual ~EmuWindow() {} |
| 144 | 152 | ||
| @@ -194,4 +202,9 @@ private: | |||
| 194 | WindowConfig active_config; ///< Internal active configuration | 202 | WindowConfig active_config; ///< Internal active configuration |
| 195 | 203 | ||
| 196 | bool touch_pressed; ///< True if touchpad area is currently pressed, otherwise false | 204 | bool touch_pressed; ///< True if touchpad area is currently pressed, otherwise false |
| 205 | |||
| 206 | u16 touch_x; ///< Touchpad X-position in native 3DS pixel coordinates (0-320) | ||
| 207 | u16 touch_y; ///< Touchpad Y-position in native 3DS pixel coordinates (0-240) | ||
| 208 | |||
| 209 | Service::HID::PadState pad_state; | ||
| 197 | }; | 210 | }; |