summaryrefslogtreecommitdiffstats
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 @@
#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) {