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.cpp25
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 @@
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,30 @@ 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 std::lock_guard<std::mutex> lock(accel_mutex);
97
98 // TODO(wwylele): do a time stretch as it in GyroscopeChanged
99 // The time stretch formula should be like
100 // stretched_vector = (raw_vector - gravity) * stretch_ratio + gravity
101 accel_x = x * coef;
102 accel_y = y * coef;
103 accel_z = z * coef;
104}
105
106void EmuWindow::GyroscopeChanged(float x, float y, float z) {
107 constexpr float FULL_FPS = 60;
108 float coef = GetGyroscopeRawToDpsCoefficient();
109 float stretch =
110 FULL_FPS / Common::Profiling::GetTimingResultsAggregator()->GetAggregatedResults().fps;
111 std::lock_guard<std::mutex> lock(gyro_mutex);
112 gyro_x = x * coef * stretch;
113 gyro_y = y * coef * stretch;
114 gyro_z = z * coef * stretch;
115}
116
92void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) { 117void EmuWindow::UpdateCurrentFramebufferLayout(unsigned width, unsigned height) {
93 Layout::FramebufferLayout layout; 118 Layout::FramebufferLayout layout;
94 switch (Settings::values.layout_option) { 119 switch (Settings::values.layout_option) {