summaryrefslogtreecommitdiffstats
path: root/src/core/frontend/emu_window.h
diff options
context:
space:
mode:
authorwwylele <wwylele@gmail.com>2016-12-29 20:18:36 +0100
committerwwylele <wwylele@gmail.com>2016-12-29 20:18:36 +0100
commitd7d40b3c56df8e31d018477a5bd2abe3a6e4e550 (patch)
tree1a512e19bc5bfb918249218a2396f747896abee9 /src/core/frontend/emu_window.h
parentFrontend: emulate motion sensor (diff)
downloadyuzu-d7d40b3c56df8e31d018477a5bd2abe3a6e4e550.tar
yuzu-d7d40b3c56df8e31d018477a5bd2abe3a6e4e550.tar.gz
yuzu-d7d40b3c56df8e31d018477a5bd2abe3a6e4e550.tar.bz2
yuzu-d7d40b3c56df8e31d018477a5bd2abe3a6e4e550.tar.lz
yuzu-d7d40b3c56df8e31d018477a5bd2abe3a6e4e550.tar.xz
yuzu-d7d40b3c56df8e31d018477a5bd2abe3a6e4e550.tar.zst
yuzu-d7d40b3c56df8e31d018477a5bd2abe3a6e4e550.zip
Diffstat (limited to '')
-rw-r--r--src/core/frontend/emu_window.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/core/frontend/emu_window.h b/src/core/frontend/emu_window.h
index 2cdbf1742..1ba64c92b 100644
--- a/src/core/frontend/emu_window.h
+++ b/src/core/frontend/emu_window.h
@@ -4,6 +4,7 @@
#pragma once
+#include <mutex>
#include <tuple>
#include <utility>
#include "common/common_types.h"
@@ -155,10 +156,10 @@ public:
* 1 unit of return value = 1/512 g (measured by hw test),
* where g is the gravitational acceleration (9.8 m/sec2).
* @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, z)
*/
std::tuple<s16, s16, s16> GetAccelerometerState() {
+ std::lock_guard<std::mutex> lock(accel_mutex);
return std::make_tuple(accel_x, accel_y, accel_z);
}
@@ -173,10 +174,10 @@ public:
* 1 unit of return value = (1/coef) deg/sec,
* where coef is the return value of GetGyroscopeRawToDpsCoefficient().
* @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, z)
*/
std::tuple<s16, s16, s16> GetGyroscopeState() {
+ std::lock_guard<std::mutex> lock(gyro_mutex);
return std::make_tuple(gyro_x, gyro_y, gyro_z);
}
@@ -306,10 +307,12 @@ private:
s16 circle_pad_x; ///< Circle pad X-position in native 3DS pixel coordinates (-156 - 156)
s16 circle_pad_y; ///< Circle pad Y-position in native 3DS pixel coordinates (-156 - 156)
+ std::mutex accel_mutex;
s16 accel_x; ///< Accelerometer X-axis value in native 3DS units
s16 accel_y; ///< Accelerometer Y-axis value in native 3DS units
s16 accel_z; ///< Accelerometer Z-axis value in native 3DS units
+ std::mutex gyro_mutex;
s16 gyro_x; ///< Gyroscope X-axis value in native 3DS units
s16 gyro_y; ///< Gyroscope Y-axis value in native 3DS units
s16 gyro_z; ///< Gyroscope Z-axis value in native 3DS units