diff options
| author | wwylele <wwylele@gmail.com> | 2016-12-29 21:18:36 +0200 |
|---|---|---|
| committer | wwylele <wwylele@gmail.com> | 2016-12-29 21:18:36 +0200 |
| commit | d7d40b3c56df8e31d018477a5bd2abe3a6e4e550 (patch) | |
| tree | 1a512e19bc5bfb918249218a2396f747896abee9 /src/core/frontend/emu_window.cpp | |
| parent | bcf9d20d5713e7003792bb8fa740b19a7204920e (diff) | |
Frontend: make motion sensor interfaced thread-safe
Diffstat (limited to 'src/core/frontend/emu_window.cpp')
| -rw-r--r-- | src/core/frontend/emu_window.cpp | 3 |
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) { void EmuWindow::AccelerometerChanged(float x, float y, float z) { constexpr float coef = 512; + std::lock_guard<std::mutex> lock(accel_mutex); + // TODO(wwylele): do a time stretch as it in GyroscopeChanged // The time stretch formula should be like // stretched_vector = (raw_vector - gravity) * stretch_ratio + gravity @@ -106,6 +108,7 @@ void EmuWindow::GyroscopeChanged(float x, float y, float z) { float coef = GetGyroscopeRawToDpsCoefficient(); float stretch = FULL_FPS / Common::Profiling::GetTimingResultsAggregator()->GetAggregatedResults().fps; + std::lock_guard<std::mutex> lock(gyro_mutex); gyro_x = x * coef * stretch; gyro_y = y * coef * stretch; gyro_z = z * coef * stretch; |
