Frontend: emulate motion sensor
This commit is contained in:
parent
6479f63091
commit
bcf9d20d57
9 changed files with 239 additions and 16 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue