diff options
| author | 2016-05-12 13:09:36 +0300 | |
|---|---|---|
| committer | 2016-05-15 13:24:22 +0300 | |
| commit | 03631f9b8fe75cf1c3a70a3094aeddcebffa4cf9 (patch) | |
| tree | 95edc62b3b8520a533e534bf4991159875fef3e5 /src/common/emu_window.h | |
| parent | AudioCore: Implement time stretcher (#1737) (diff) | |
| download | yuzu-03631f9b8fe75cf1c3a70a3094aeddcebffa4cf9.tar.gz yuzu-03631f9b8fe75cf1c3a70a3094aeddcebffa4cf9.tar.xz yuzu-03631f9b8fe75cf1c3a70a3094aeddcebffa4cf9.zip | |
Refactor input subsystem
Diffstat (limited to 'src/common/emu_window.h')
| -rw-r--r-- | src/common/emu_window.h | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/src/common/emu_window.h b/src/common/emu_window.h index 7c3486dea..0ae3ea2af 100644 --- a/src/common/emu_window.h +++ b/src/common/emu_window.h | |||
| @@ -12,10 +12,6 @@ | |||
| 12 | 12 | ||
| 13 | #include "core/hle/service/hid/hid.h" | 13 | #include "core/hle/service/hid/hid.h" |
| 14 | 14 | ||
| 15 | namespace KeyMap { | ||
| 16 | struct HostDeviceKey; | ||
| 17 | } | ||
| 18 | |||
| 19 | /** | 15 | /** |
| 20 | * Abstraction class used to provide an interface between emulation code and the frontend | 16 | * Abstraction class used to provide an interface between emulation code and the frontend |
| 21 | * (e.g. SDL, QGLWidget, GLFW, etc...). | 17 | * (e.g. SDL, QGLWidget, GLFW, etc...). |
| @@ -76,11 +72,27 @@ public: | |||
| 76 | 72 | ||
| 77 | virtual void ReloadSetKeymaps() = 0; | 73 | virtual void ReloadSetKeymaps() = 0; |
| 78 | 74 | ||
| 79 | /// Signals a key press action to the HID module | 75 | /** |
| 80 | void KeyPressed(KeyMap::HostDeviceKey key); | 76 | * Signals a button press action to the HID module. |
| 77 | * @param pad_state indicates which button to press | ||
| 78 | * @note only handle real buttons (A/B/X/Y/...), excluding analog input like circle pad. | ||
| 79 | */ | ||
| 80 | void ButtonPressed(Service::HID::PadState pad_state); | ||
| 81 | |||
| 82 | /** | ||
| 83 | * Signals a button release action to the HID module. | ||
| 84 | * @param pad_state indicates which button to press | ||
| 85 | * @note only handle real buttons (A/B/X/Y/...), excluding analog input like circle pad. | ||
| 86 | */ | ||
| 87 | void ButtonReleased(Service::HID::PadState pad_state); | ||
| 81 | 88 | ||
| 82 | /// Signals a key release action to the HID module | 89 | /** |
| 83 | void KeyReleased(KeyMap::HostDeviceKey key); | 90 | * Signals a circle pad change action to the HID module. |
| 91 | * @param x new x-coordinate of the circle pad, in the range [-1.0, 1.0] | ||
| 92 | * @param y new y-coordinate of the circle pad, in the range [-1.0, 1.0] | ||
| 93 | * @note the coordinates will be normalized if the radius is larger than 1 | ||
| 94 | */ | ||
| 95 | void CirclePadUpdated(float x, float y); | ||
| 84 | 96 | ||
| 85 | /** | 97 | /** |
| 86 | * Signal that a touch pressed event has occurred (e.g. mouse click pressed) | 98 | * Signal that a touch pressed event has occurred (e.g. mouse click pressed) |
| @@ -100,8 +112,9 @@ public: | |||
| 100 | void TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y); | 112 | void TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y); |
| 101 | 113 | ||
| 102 | /** | 114 | /** |
| 103 | * Gets the current pad state (which buttons are pressed and the circle pad direction). | 115 | * Gets the current pad state (which buttons are pressed). |
| 104 | * @note This should be called by the core emu thread to get a state set by the window thread. | 116 | * @note This should be called by the core emu thread to get a state set by the window thread. |
| 117 | * @note This doesn't include analog input like circle pad direction | ||
| 105 | * @todo Fix this function to be thread-safe. | 118 | * @todo Fix this function to be thread-safe. |
| 106 | * @return PadState object indicating the current pad state | 119 | * @return PadState object indicating the current pad state |
| 107 | */ | 120 | */ |
| @@ -110,6 +123,16 @@ public: | |||
| 110 | } | 123 | } |
| 111 | 124 | ||
| 112 | /** | 125 | /** |
| 126 | * Gets the current cirle pad state. | ||
| 127 | * @note This should be called by the core emu thread to get a state set by the window thread. | ||
| 128 | * @todo Fix this function to be thread-safe. | ||
| 129 | * @return std::tuple of (x, y), where `x` and `y` are the circle pad coordinates | ||
| 130 | */ | ||
| 131 | std::tuple<s16, s16> GetCirclePadState() const { | ||
| 132 | return std::make_tuple(circle_pad_x, circle_pad_y); | ||
| 133 | } | ||
| 134 | |||
| 135 | /** | ||
| 113 | * Gets the current touch screen state (touch X/Y coordinates and whether or not it is pressed). | 136 | * Gets the current touch screen state (touch X/Y coordinates and whether or not it is pressed). |
| 114 | * @note This should be called by the core emu thread to get a state set by the window thread. | 137 | * @note This should be called by the core emu thread to get a state set by the window thread. |
| 115 | * @todo Fix this function to be thread-safe. | 138 | * @todo Fix this function to be thread-safe. |
| @@ -200,6 +223,8 @@ protected: | |||
| 200 | pad_state.hex = 0; | 223 | pad_state.hex = 0; |
| 201 | touch_x = 0; | 224 | touch_x = 0; |
| 202 | touch_y = 0; | 225 | touch_y = 0; |
| 226 | circle_pad_x = 0; | ||
| 227 | circle_pad_y = 0; | ||
| 203 | touch_pressed = false; | 228 | touch_pressed = false; |
| 204 | } | 229 | } |
| 205 | virtual ~EmuWindow() {} | 230 | virtual ~EmuWindow() {} |
| @@ -260,6 +285,9 @@ private: | |||
| 260 | u16 touch_x; ///< Touchpad X-position in native 3DS pixel coordinates (0-320) | 285 | u16 touch_x; ///< Touchpad X-position in native 3DS pixel coordinates (0-320) |
| 261 | u16 touch_y; ///< Touchpad Y-position in native 3DS pixel coordinates (0-240) | 286 | u16 touch_y; ///< Touchpad Y-position in native 3DS pixel coordinates (0-240) |
| 262 | 287 | ||
| 288 | s16 circle_pad_x; ///< Circle pad X-position in native 3DS pixel coordinates (-156 - 156) | ||
| 289 | s16 circle_pad_y; ///< Circle pad Y-position in native 3DS pixel coordinates (-156 - 156) | ||
| 290 | |||
| 263 | /** | 291 | /** |
| 264 | * Clip the provided coordinates to be inside the touchscreen area. | 292 | * Clip the provided coordinates to be inside the touchscreen area. |
| 265 | */ | 293 | */ |