Fix the toggle touch controls input (properly this time)

This commit is contained in:
Henrik Rydgård committed 2026-02-05 09:44:42 +01:00
1 parent f546dc3835
commit d6d2c24e24
6 files changed
+60 -18

No files matched your search

+10
View File
@@ -124,6 +124,16 @@ void ProcessTilt(bool landscape, float calibrationAngle, float x, float y, float
Lin::Vec3 down = Lin::Vec3(x, y, z).normalized();
if (my_isnanorinf(down.x) || my_isnanorinf(down.y) || my_isnanorinf(down.z)) {
// Invalid data - ignore.
static int count = 0;
if (count < 20) {
WARN_LOG(Log::System, "Bad accelerometer data: %f %f %f (will stop logging after 20)", x, y, z);
}
count++;
return;
}
float angleAroundX = atan2(down.z, down.y);
g_currentYAngle = angleAroundX; // TODO: Should smooth this out over time a bit.
float yAngle = angleAroundX - calibrationAngle;