summaryrefslogtreecommitdiff
path: root/src/core/frontend/emu_window.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/frontend/emu_window.h')
-rw-r--r--src/core/frontend/emu_window.h52
1 files changed, 44 insertions, 8 deletions
diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h
index 835c4d500..1ba64c92b 100644
--- a/src/core/frontend/emu_window.h
+++ b/src/core/frontend/emu_window.h
@@ -4,6 +4,7 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <mutex>
7#include <tuple> 8#include <tuple>
8#include <utility> 9#include <utility>
9#include "common/common_types.h" 10#include "common/common_types.h"
@@ -93,6 +94,27 @@ public:
93 void TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y); 94 void TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y);
94 95
95 /** 96 /**
97 * Signal accelerometer state has changed.
98 * @param x X-axis accelerometer value
99 * @param y Y-axis accelerometer value
100 * @param z Z-axis accelerometer value
101 * @note all values are in unit of g (gravitational acceleration).
102 * e.g. x = 1.0 means 9.8m/s^2 in x direction.
103 * @see GetAccelerometerState for axis explanation.
104 */
105 void AccelerometerChanged(float x, float y, float z);
106
107 /**
108 * Signal gyroscope state has changed.
109 * @param x X-axis accelerometer value
110 * @param y Y-axis accelerometer value
111 * @param z Z-axis accelerometer value
112 * @note all values are in deg/sec.
113 * @see GetGyroscopeState for axis explanation.
114 */
115 void GyroscopeChanged(float x, float y, float z);
116
117 /**
96 * Gets the current pad state (which buttons are pressed). 118 * Gets the current pad state (which buttons are pressed).
97 * @note This should be called by the core emu thread to get a state set by the window thread. 119 * @note This should be called by the core emu thread to get a state set by the window thread.
98 * @note This doesn't include analog input like circle pad direction 120 * @note This doesn't include analog input like circle pad direction
@@ -134,12 +156,11 @@ public:
134 * 1 unit of return value = 1/512 g (measured by hw test), 156 * 1 unit of return value = 1/512 g (measured by hw test),
135 * where g is the gravitational acceleration (9.8 m/sec2). 157 * where g is the gravitational acceleration (9.8 m/sec2).
136 * @note This should be called by the core emu thread to get a state set by the window thread. 158 * @note This should be called by the core emu thread to get a state set by the window thread.
137 * @todo Implement accelerometer input in front-end.
138 * @return std::tuple of (x, y, z) 159 * @return std::tuple of (x, y, z)
139 */ 160 */
140 std::tuple<s16, s16, s16> GetAccelerometerState() const { 161 std::tuple<s16, s16, s16> GetAccelerometerState() {
141 // stubbed 162 std::lock_guard<std::mutex> lock(accel_mutex);
142 return std::make_tuple(0, -512, 0); 163 return std::make_tuple(accel_x, accel_y, accel_z);
143 } 164 }
144 165
145 /** 166 /**
@@ -153,12 +174,11 @@ public:
153 * 1 unit of return value = (1/coef) deg/sec, 174 * 1 unit of return value = (1/coef) deg/sec,
154 * where coef is the return value of GetGyroscopeRawToDpsCoefficient(). 175 * where coef is the return value of GetGyroscopeRawToDpsCoefficient().
155 * @note This should be called by the core emu thread to get a state set by the window thread. 176 * @note This should be called by the core emu thread to get a state set by the window thread.
156 * @todo Implement gyroscope input in front-end.
157 * @return std::tuple of (x, y, z) 177 * @return std::tuple of (x, y, z)
158 */ 178 */
159 std::tuple<s16, s16, s16> GetGyroscopeState() const { 179 std::tuple<s16, s16, s16> GetGyroscopeState() {
160 // stubbed 180 std::lock_guard<std::mutex> lock(gyro_mutex);
161 return std::make_tuple(0, 0, 0); 181 return std::make_tuple(gyro_x, gyro_y, gyro_z);
162 } 182 }
163 183
164 /** 184 /**
@@ -216,6 +236,12 @@ protected:
216 circle_pad_x = 0; 236 circle_pad_x = 0;
217 circle_pad_y = 0; 237 circle_pad_y = 0;
218 touch_pressed = false; 238 touch_pressed = false;
239 accel_x = 0;
240 accel_y = -512;
241 accel_z = 0;
242 gyro_x = 0;
243 gyro_y = 0;
244 gyro_z = 0;
219 } 245 }
220 virtual ~EmuWindow() {} 246 virtual ~EmuWindow() {}
221 247
@@ -281,6 +307,16 @@ private:
281 s16 circle_pad_x; ///< Circle pad X-position in native 3DS pixel coordinates (-156 - 156) 307 s16 circle_pad_x; ///< Circle pad X-position in native 3DS pixel coordinates (-156 - 156)
282 s16 circle_pad_y; ///< Circle pad Y-position in native 3DS pixel coordinates (-156 - 156) 308 s16 circle_pad_y; ///< Circle pad Y-position in native 3DS pixel coordinates (-156 - 156)
283 309
310 std::mutex accel_mutex;
311 s16 accel_x; ///< Accelerometer X-axis value in native 3DS units
312 s16 accel_y; ///< Accelerometer Y-axis value in native 3DS units
313 s16 accel_z; ///< Accelerometer Z-axis value in native 3DS units
314
315 std::mutex gyro_mutex;
316 s16 gyro_x; ///< Gyroscope X-axis value in native 3DS units
317 s16 gyro_y; ///< Gyroscope Y-axis value in native 3DS units
318 s16 gyro_z; ///< Gyroscope Z-axis value in native 3DS units
319
284 /** 320 /**
285 * Clip the provided coordinates to be inside the touchscreen area. 321 * Clip the provided coordinates to be inside the touchscreen area.
286 */ 322 */