summaryrefslogtreecommitdiff
path: root/src/core/frontend/emu_window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/frontend/emu_window.cpp')
-rw-r--r--src/core/frontend/emu_window.cpp22
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
93void 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
104void 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
92void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) { 114void 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) {