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

same time. same for mHapticHandler
This commit is contained in:
Sylvain
2026-02-10 13:34:37 +01:00
committed by Sam Lantinga
parent 6f45f97af0
commit a35bcad0be

View File

@@ -211,7 +211,7 @@ class SDLJoystickHandler {
/**
* Handles adding and removing of input devices.
*/
void pollInputDevices() {
synchronized void pollInputDevices() {
int[] deviceIds = InputDevice.getDeviceIds();
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) {
if (joystick.device_id == device_id) {
return joystick;
@@ -642,7 +642,7 @@ class SDLHapticHandler {
}
}
void pollHapticDevices() {
synchronized void pollHapticDevices() {
final int deviceId_VIBRATOR_SERVICE = 999999;
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) {
if (haptic.device_id == device_id) {
return haptic;