diff options
| author | 2016-12-11 23:32:41 +0200 | |
|---|---|---|
| committer | 2016-12-26 10:52:16 +0200 | |
| commit | bcf9d20d5713e7003792bb8fa740b19a7204920e (patch) | |
| tree | a5fd21a9dd1587d8dedddc33a19b09490ceb164d /src/core/frontend/emu_window.cpp | |
| parent | Common: add Quaternion (diff) | |
| download | yuzu-bcf9d20d5713e7003792bb8fa740b19a7204920e.tar.gz yuzu-bcf9d20d5713e7003792bb8fa740b19a7204920e.tar.xz yuzu-bcf9d20d5713e7003792bb8fa740b19a7204920e.zip | |
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 f6f90f9e1..13c7f3de2 100644 --- a/src/core/frontend/emu_window.cpp +++ b/src/core/frontend/emu_window.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <cmath> | 6 | #include <cmath> |
| 7 | #include "common/assert.h" | 7 | #include "common/assert.h" |
| 8 | #include "common/profiler_reporting.h" | ||
| 8 | #include "core/frontend/emu_window.h" | 9 | #include "core/frontend/emu_window.h" |
| 9 | #include "core/frontend/key_map.h" | 10 | #include "core/frontend/key_map.h" |
| 10 | #include "video_core/video_core.h" | 11 | #include "video_core/video_core.h" |
| @@ -89,6 +90,27 @@ void EmuWindow::TouchMoved(unsigned framebuffer_x, unsigned framebuffer_y) { | |||
| 89 | TouchPressed(framebuffer_x, framebuffer_y); | 90 | TouchPressed(framebuffer_x, framebuffer_y); |
| 90 | } | 91 | } |
| 91 | 92 | ||
| 93 | void EmuWindow::AccelerometerChanged(float x, float y, float z) { | ||
| 94 | constexpr float coef = 512; | ||
| 95 | |||
| 96 | // TODO(wwylele): do a time stretch as it in GyroscopeChanged | ||
| 97 | // The time stretch formula should be like | ||
| 98 | // stretched_vector = (raw_vector - gravity) * stretch_ratio + gravity | ||
| 99 | accel_x = x * coef; | ||
| 100 | accel_y = y * coef; | ||
| 101 | accel_z = z * coef; | ||
| 102 | } | ||
| 103 | |||
| 104 | void EmuWindow::GyroscopeChanged(float x, float y, float z) { | ||
| 105 | constexpr float FULL_FPS = 60; | ||
| 106 | float coef = GetGyroscopeRawToDpsCoefficient(); | ||
| 107 | float stretch = | ||
| 108 | FULL_FPS / Common::Profiling::GetTimingResultsAggregator()->GetAggregatedResults().fps; | ||
| 109 | gyro_x = x * coef * stretch; | ||
| 110 | gyro_y = y * coef * stretch; | ||
| 111 | gyro_z = z * coef * stretch; | ||
| 112 | } | ||
| 113 | |||
| 92 | void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) { | 114 | void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) { |
| 93 | Layout::FramebufferLayout layout; | 115 | Layout::FramebufferLayout layout; |
| 94 | switch (Settings::values.layout_option) { | 116 | switch (Settings::values.layout_option) { |