diff options
author | bunnei <bunneidev@gmail.com> | 2017-01-07 18:39:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-07 18:39:20 +0100 |
commit | 7cfe3ef0463ace034b1e5786c9581cfa5f2e810c (patch) | |
tree | 6b06cb03d276b29070ca29599fc4c5fcf77edb39 /src/core/frontend/emu_window.cpp | |
parent | Merge pull request #2410 from Subv/sleepthread (diff) | |
parent | Frontend: make motion sensor interfaced thread-safe (diff) | |
download | yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.tar yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.tar.gz yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.tar.bz2 yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.tar.lz yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.tar.xz yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.tar.zst yuzu-7cfe3ef0463ace034b1e5786c9581cfa5f2e810c.zip |
Diffstat (limited to 'src/core/frontend/emu_window.cpp')
-rw-r--r-- | src/core/frontend/emu_window.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/core/frontend/emu_window.cpp b/src/core/frontend/emu_window.cpp index f6f90f9e1..1541cc39d 100644 --- a/src/core/frontend/emu_window.cpp +++ b/src/core/frontend/emu_window.cpp @@ -5,6 +5,7 @@ #include <algorithm> #include <cmath> #include "common/assert.h" +#include "common/profiler_reporting.h" #include "core/frontend/emu_window.h" #include "core/frontend/key_map.h" #include "video_core/video_core.h" @@ -89,6 +90,30 @@ void EmuWindow::TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y) { TouchPressed(framebuffer_x, 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 + accel_x = x * coef; + accel_y = y * coef; + accel_z = z * coef; +} + +void EmuWindow::GyroscopeChanged(float x, float y, float z) { + constexpr float FULL_FPS = 60; + 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; +} + void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) { Layout::FramebufferLayout layout; switch (Settings::values.layout_option) { |