From 05db50beed47b67d522fe734b811a8b9ddea9b7e Mon Sep 17 00:00:00 2001 From: pepper-jelly <45047877+pepper-jelly@users.noreply.github.com> Date: Wed, 31 Jul 2024 23:47:07 +0300 Subject: [PATCH] fix: rest accel while changing set, fix #991 (#1015) PR: https://github.com/AntiMicroX/antimicrox/pull/1015 --- src/joyaccelerometersensor.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/joyaccelerometersensor.cpp b/src/joyaccelerometersensor.cpp index 0c80adf67..1106c228d 100644 --- a/src/joyaccelerometersensor.cpp +++ b/src/joyaccelerometersensor.cpp @@ -185,6 +185,11 @@ JoySensorDirection JoyAccelerometerSensor::calculateSensorDirection() bool inPitch = pitch_abs < m_dead_zone; bool inRoll = roll_abs < range; + if (isnan(roll)) + { + return SENSOR_CENTERED; + } + if (!inPitch) { if (!inRoll)