diff options
author | wwylele <wwylele@gmail.com> | 2016-12-11 23:32:41 +0200 |
---|---|---|
committer | wwylele <wwylele@gmail.com> | 2016-12-26 10:52:16 +0200 |
commit | bcf9d20d5713e7003792bb8fa740b19a7204920e (patch) | |
tree | a5fd21a9dd1587d8dedddc33a19b09490ceb164d /src/core/frontend/emu_window.cpp | |
parent | 6479f63091da35b1ac6f3930532cc8bde466f6c4 (diff) |
Frontend: emulate motion sensor
Diffstat (limited to 'src/core/frontend/emu_window.cpp')
-rw-r--r-- | src/core/frontend/emu_window.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/core/frontend/emu_window.cpp b/src/core/frontend/emu_window.cpp index f6f90f9e1c..13c7f3de22 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,27 @@ 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; + + // 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; + 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) { |