Fixed deadlock introduced by 7222c04fbf

It turns out this change causes a deadlock:
The main UI thread calls synchronized handleMotionEvent() which then calls SDL_LockJoysticks()
The main app thread calls SDL_LockJoysticks() and then synchronized pollInputDevices()
This commit is contained in:
Sam Lantinga
2026-05-17 12:17:26 -07:00
parent b19ecb4032
commit 8c89a076a7

View File

@@ -346,7 +346,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;
@@ -360,7 +360,7 @@ class SDLJoystickHandler {
* @param event the event to be handled.
* @return if given event was processed.
*/
synchronized boolean handleMotionEvent(MotionEvent event) {
boolean handleMotionEvent(MotionEvent event) {
int actionPointerIndex = event.getActionIndex();
int action = event.getActionMasked();
if (action == MotionEvent.ACTION_MOVE) {
@@ -530,7 +530,7 @@ class SDLJoystickHandler {
return button_mask;
}
synchronized void setLED(int device_id, int red, int green, int blue) {
void setLED(int device_id, int red, int green, int blue) {
if (Build.VERSION.SDK_INT < 31 /* Android 12.0 (S) */) {
return;
}
@@ -548,7 +548,7 @@ class SDLJoystickHandler {
joystick.lightsSession.requestLights(lightsRequest.build());
}
synchronized void setSensorsEnabled(int device_id, boolean enabled) {
void setSensorsEnabled(int device_id, boolean enabled) {
if (Build.VERSION.SDK_INT < 31 /* Android 12.0 (S) */) {
return;
}