Improve accelerometer algorithm

This commit is contained in:
wheremyfoodat 2024-08-16 17:54:15 +03:00
parent c772b1c702
commit dbdf21b1ab
5 changed files with 39 additions and 24 deletions

View file

@ -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;
}