Android: prevent SDLActivity and Main Thread to access mJoystick at the

same time. same for mHapticHandler

(cherry picked from commit a35bcad0be)
This commit is contained in:
Sylvain
2026-02-10 13:34:37 +01:00
committed by Sam Lantinga
parent a806a9092b
commit a7bac75470
@@ -211,7 +211,7 @@ class SDLJoystickHandler {
/** /**
* Handles adding and removing of input devices. * Handles adding and removing of input devices.
*/ */
void pollInputDevices() { synchronized void pollInputDevices() {
int[] deviceIds = InputDevice.getDeviceIds(); int[] deviceIds = InputDevice.getDeviceIds();
for (int device_id : deviceIds) { for (int device_id : deviceIds) {
@@ -307,7 +307,7 @@ class SDLJoystickHandler {
} }
} }
protected SDLJoystick getJoystick(int device_id) { synchronized protected SDLJoystick getJoystick(int device_id) {
for (SDLJoystick joystick : mJoysticks) { for (SDLJoystick joystick : mJoysticks) {
if (joystick.device_id == device_id) { if (joystick.device_id == device_id) {
return joystick; return joystick;
@@ -642,7 +642,7 @@ class SDLHapticHandler {
} }
} }
void pollHapticDevices() { synchronized void pollHapticDevices() {
final int deviceId_VIBRATOR_SERVICE = 999999; final int deviceId_VIBRATOR_SERVICE = 999999;
boolean hasVibratorService = false; boolean hasVibratorService = false;
@@ -690,7 +690,7 @@ class SDLHapticHandler {
} }
} }
protected SDLHaptic getHaptic(int device_id) { synchronized protected SDLHaptic getHaptic(int device_id) {
for (SDLHaptic haptic : mHaptics) { for (SDLHaptic haptic : mHaptics) {
if (haptic.device_id == device_id) { if (haptic.device_id == device_id) {
return haptic; return haptic;