summaryrefslogtreecommitdiff
path: root/src/core/frontend/emu_window.cpp
diff options
context:
space:
mode:
authorGravatar wwylele2016-12-29 21:18:36 +0200
committerGravatar wwylele2016-12-29 21:18:36 +0200
commitd7d40b3c56df8e31d018477a5bd2abe3a6e4e550 (patch)
tree1a512e19bc5bfb918249218a2396f747896abee9 /src/core/frontend/emu_window.cpp
parentFrontend: emulate motion sensor (diff)
downloadyuzu-d7d40b3c56df8e31d018477a5bd2abe3a6e4e550.tar.gz
yuzu-d7d40b3c56df8e31d018477a5bd2abe3a6e4e550.tar.xz
yuzu-d7d40b3c56df8e31d018477a5bd2abe3a6e4e550.zip
Frontend: make motion sensor interfaced thread-safe
Diffstat (limited to 'src/core/frontend/emu_window.cpp')
-rw-r--r--src/core/frontend/emu_window.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/core/frontend/emu_window.cpp b/src/core/frontend/emu_window.cpp
index 13c7f3de2..1541cc39d 100644
--- a/src/core/frontend/emu_window.cpp
+++ b/src/core/frontend/emu_window.cpp
@@ -93,6 +93,8 @@ void EmuWindow::TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y) {
93void EmuWindow::AccelerometerChanged(float x, float y, float z) { 93void EmuWindow::AccelerometerChanged(float x, float y, float z) {
94 constexpr float coef = 512; 94 constexpr float coef = 512;
95 95
96 std::lock_guard<std::mutex> lock(accel_mutex);
97
96 // TODO(wwylele): do a time stretch as it in GyroscopeChanged 98 // TODO(wwylele): do a time stretch as it in GyroscopeChanged
97 // The time stretch formula should be like 99 // The time stretch formula should be like
98 // stretched_vector = (raw_vector - gravity) * stretch_ratio + gravity 100 // stretched_vector = (raw_vector - gravity) * stretch_ratio + gravity
@@ -106,6 +108,7 @@ void EmuWindow::GyroscopeChanged(float x, float y, float z) {
106 float coef = GetGyroscopeRawToDpsCoefficient(); 108 float coef = GetGyroscopeRawToDpsCoefficient();
107 float stretch = 109 float stretch =
108 FULL_FPS / Common::Profiling::GetTimingResultsAggregator()->GetAggregatedResults().fps; 110 FULL_FPS / Common::Profiling::GetTimingResultsAggregator()->GetAggregatedResults().fps;
111 std::lock_guard<std::mutex> lock(gyro_mutex);
109 gyro_x = x * coef * stretch; 112 gyro_x = x * coef * stretch;
110 gyro_y = y * coef * stretch; 113 gyro_y = y * coef * stretch;
111 gyro_z = z * coef * stretch; 114 gyro_z = z * coef * stretch;