Fix bug #9331 - SDL3 Android crash getVibrator() == null

(cherry picked from commit 1855ce68af)
This commit is contained in:
Sylvain
2024-03-22 21:26:23 +01:00
committed by Sam Lantinga
parent 82b449611a
commit 763d768f7d
@@ -546,6 +546,7 @@ class SDLHapticHandler {
if (haptic == null) { if (haptic == null) {
InputDevice device = InputDevice.getDevice(deviceIds[i]); InputDevice device = InputDevice.getDevice(deviceIds[i]);
Vibrator vib = device.getVibrator(); Vibrator vib = device.getVibrator();
if (vib != null) {
if (vib.hasVibrator()) { if (vib.hasVibrator()) {
haptic = new SDLHaptic(); haptic = new SDLHaptic();
haptic.device_id = deviceIds[i]; haptic.device_id = deviceIds[i];
@@ -556,6 +557,7 @@ class SDLHapticHandler {
} }
} }
} }
}
/* Check VIBRATOR_SERVICE */ /* Check VIBRATOR_SERVICE */
Vibrator vib = (Vibrator) SDL.getContext().getSystemService(Context.VIBRATOR_SERVICE); Vibrator vib = (Vibrator) SDL.getContext().getSystemService(Context.VIBRATOR_SERVICE);