aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/common/emu_window.h
diff options
context:
space:
mode:
authorGravatar bunnei <bunneidev@gmail.com>2015-03-09 00:14:59 -0400
committerGravatar bunnei <bunneidev@gmail.com>2015-03-10 23:58:07 -0400
commitd61b26b79f889603a084e148626bba3c267cf75f (patch)
treed793edd22e25a99aa5c13cc2455a5ec2167afee7 /src/common/emu_window.h
parent953e09ddb5cab8f4d8606966020e8eefa20e04ce (diff)
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.h57
1 files changed, 35 insertions, 22 deletions
diff --git a/src/common/emu_window.h b/src/common/emu_window.h
index 8e4b510e..2be7517b 100644
--- a/src/common/emu_window.h
+++ b/src/common/emu_window.h
@@ -78,27 +78,41 @@ public:
/**
* Signal that a touch pressed event has occurred (e.g. mouse click pressed)
- * @param layout FramebufferLayout object describing the framebuffer size and screen positions
* @param framebuffer_x Framebuffer x-coordinate that was pressed
* @param framebuffer_y Framebuffer y-coordinate that was pressed
*/
- void TouchPressed(const FramebufferLayout& layout, unsigned framebuffer_x, unsigned framebuffer_y);
+ void TouchPressed(unsigned framebuffer_x, unsigned framebuffer_y);
- /**
- * Signal that a touch released event has occurred (e.g. mouse click released)
- * @param layout FramebufferLayout object describing the framebuffer size and screen positions
- * @param framebuffer_x Framebuffer x-coordinate that was released
- * @param framebuffer_y Framebuffer y-coordinate that was released
- */
- void TouchReleased(const FramebufferLayout& layout, unsigned framebuffer_x, unsigned framebuffer_y);
+ /// Signal that a touch released event has occurred (e.g. mouse click released)
+ void TouchReleased();
/**
* Signal that a touch movement event has occurred (e.g. mouse was moved over the emu window)
- * @param layout FramebufferLayout object describing the framebuffer size and screen positions
* @param framebuffer_x Framebuffer x-coordinate
* @param framebuffer_y Framebuffer y-coordinate
*/
- void TouchMoved(const FramebufferLayout& layout, unsigned framebuffer_x, unsigned framebuffer_y);
+ void TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y);
+
+ /**
+ * Gets the current pad state (which buttons are pressed and the circle pad direction).
+ * @note This should be called by the core emu thread to get a state set by the window thread.
+ * @todo Fix this function to be thread-safe.
+ * @return PadState object indicating the current pad state
+ */
+ const Service::HID::PadState GetPadState() const {
+ return pad_state;
+ }
+
+ /**
+ * Gets the current touch screen state (touch X/Y coordinates and whether or not it is pressed).
+ * @note This should be called by the core emu thread to get a state set by the window thread.
+ * @todo Fix this function to be thread-safe.
+ * @return std::tuple of (x, y, pressed) where `x` and `y` are the touch coordinates and
+ * `pressed` is true if the touch screen is currently being pressed
+ */
+ const std::tuple<u16, u16, bool>& GetTouchState() const {
+ return std::make_tuple(touch_x, touch_y, touch_pressed);
+ }
/**
* Returns currently active configuration.
@@ -124,21 +138,15 @@ public:
return framebuffer_layout;
}
- /**
- * Gets window client area width in logical coordinates.
- * @note For high-DPI systems, this is smaller than the framebuffer size.
- * @note This method is thread-safe
- */
- std::pair<unsigned,unsigned> GetClientAreaSize() const {
- return std::make_pair(client_area_width, client_area_height);
- }
-
protected:
- EmuWindow()
- {
+ EmuWindow() {
// TODO: Find a better place to set this.
config.min_client_area_size = std::make_pair(400u, 480u);
active_config = config;
+ pad_state.hex = 0;
+ touch_x = 0;
+ touch_y = 0;
+ touch_pressed = false;
}
virtual ~EmuWindow() {}
@@ -194,4 +202,9 @@ private:
WindowConfig active_config; ///< Internal active configuration
bool touch_pressed; ///< True if touchpad area is currently pressed, otherwise false
+
+ u16 touch_x; ///< Touchpad X-position in native 3DS pixel coordinates (0-320)
+ u16 touch_y; ///< Touchpad Y-position in native 3DS pixel coordinates (0-240)
+
+ Service::HID::PadState pad_state;
};