diff --git a/Sources/Jazz2/Actors/Enemies/EnemyBase.cpp b/Sources/Jazz2/Actors/Enemies/EnemyBase.cpp index c470ac32..720318d4 100644 --- a/Sources/Jazz2/Actors/Enemies/EnemyBase.cpp +++ b/Sources/Jazz2/Actors/Enemies/EnemyBase.cpp @@ -97,8 +97,7 @@ namespace Jazz2::Actors::Enemies return false; } - bool tilesetReduced = GetState(ActorState::CollideWithTilesetReduced); - bool skipPerPixelCollisions = GetState(ActorState::SkipPerPixelCollisions); + ActorState prevState = GetState(); SetState(ActorState::CollideWithTilesetReduced, false); SetState(ActorState::SkipPerPixelCollisions, true); @@ -111,9 +110,8 @@ namespace Jazz2::Actors::Enemies } else { success = false; } - - SetState(ActorState::CollideWithTilesetReduced, tilesetReduced); - SetState(ActorState::SkipPerPixelCollisions, skipPerPixelCollisions); + + SetState(prevState); return success; } diff --git a/Sources/nCine/Backends/Android/AndroidInputManager.cpp b/Sources/nCine/Backends/Android/AndroidInputManager.cpp index d1cd71bc..2827d6f5 100644 --- a/Sources/nCine/Backends/Android/AndroidInputManager.cpp +++ b/Sources/nCine/Backends/Android/AndroidInputManager.cpp @@ -856,6 +856,21 @@ namespace nCine } LOGI("Device (%d, %d) - Axes%s", deviceId, joyId, deviceInfoString); #endif + if (numAxes >= 4) { + // Android sometimes returns strange range for the first axis, all other axes are fine + if (std::abs(joyState.axesMinValues_[0]) < 0.01f && joyState.axesRangeValues_[0] > 128.0f && + std::abs(joyState.axesMinValues_[1]) < 0.01f && joyState.axesRangeValues_[1] > 128.0f && + joyState.axesMinValues_[2] == -1.0f && joyState.axesRangeValues_[2] == 2.0f && + joyState.axesMinValues_[3] == -1.0f && joyState.axesRangeValues_[3] == 2.0f) { + LOGW("Device (%d, %d) - Axis %d:%d reported strange range %.2f, using %.2f to %.2f instead", deviceId, joyId, 0, joyState.axesMapping_[0], joyState.axesRangeValues_[0], -1.0f, 1.0f); + LOGW("Device (%d, %d) - Axis %d:%d reported strange range %.2f, using %.2f to %.2f instead", deviceId, joyId, 1, joyState.axesMapping_[1], joyState.axesRangeValues_[1], -1.0f, 1.0f); + joyState.axesMinValues_[0] = -1.0f; + joyState.axesRangeValues_[0] = 2.0f; + joyState.axesMinValues_[1] = -1.0f; + joyState.axesRangeValues_[1] = 2.0f; + } + } + joyState.numAxes_ = numAxes; joyState.numAxesMapped_ = numAxesMapped;