Improve accelerometer algorithm
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "cheats.hpp"
|
||||
#include "input_mappings.hpp"
|
||||
#include "sdl_gyro.hpp"
|
||||
#include "sdl_sensors.hpp"
|
||||
#include "services/dsp.hpp"
|
||||
|
||||
MainWindow::MainWindow(QApplication* app, QWidget* parent) : QMainWindow(parent), keyboardMappings(InputMappings::defaultKeyboardMappings()) {
|
||||
@@ -606,7 +606,7 @@ void MainWindow::pollControllers() {
|
||||
|
||||
case SDL_CONTROLLERSENSORUPDATE: {
|
||||
if (event.csensor.sensor == SDL_SENSOR_GYRO) {
|
||||
auto rotation = Gyro::SDL::convertRotation({
|
||||
auto rotation = Sensors::SDL::convertRotation({
|
||||
event.csensor.data[0],
|
||||
event.csensor.data[1],
|
||||
event.csensor.data[2],
|
||||
@@ -616,7 +616,8 @@ void MainWindow::pollControllers() {
|
||||
hid.setRoll(s16(rotation.y));
|
||||
hid.setYaw(s16(rotation.z));
|
||||
} else if (event.csensor.sensor == SDL_SENSOR_ACCEL) {
|
||||
hid.setAccel(s16(event.csensor.data[0]), s16(-event.csensor.data[1]), s16(event.csensor.data[2]));
|
||||
auto accel = Sensors::SDL::convertAcceleration(event.csensor.data);
|
||||
hid.setAccel(accel.x, accel.y, accel.z);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <glad/gl.h>
|
||||
|
||||
#include "sdl_gyro.hpp"
|
||||
#include "sdl_sensors.hpp"
|
||||
|
||||
FrontendSDL::FrontendSDL() : keyboardMappings(InputMappings::defaultKeyboardMappings()) {
|
||||
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) {
|
||||
@@ -289,7 +289,7 @@ void FrontendSDL::run() {
|
||||
|
||||
case SDL_CONTROLLERSENSORUPDATE: {
|
||||
if (event.csensor.sensor == SDL_SENSOR_GYRO) {
|
||||
auto rotation = Gyro::SDL::convertRotation({
|
||||
auto rotation = Sensors::SDL::convertRotation({
|
||||
event.csensor.data[0],
|
||||
event.csensor.data[1],
|
||||
event.csensor.data[2],
|
||||
@@ -299,7 +299,8 @@ void FrontendSDL::run() {
|
||||
hid.setRoll(s16(rotation.y));
|
||||
hid.setYaw(s16(rotation.z));
|
||||
} else if (event.csensor.sensor == SDL_SENSOR_ACCEL) {
|
||||
hid.setAccel(s16(event.csensor.data[0]), s16(-event.csensor.data[1]), s16(event.csensor.data[2]));
|
||||
auto accel = Sensors::SDL::convertAcceleration(event.csensor.data);
|
||||
hid.setAccel(accel.x, accel.y, accel.z);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user