Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
edendev
abbc4fefee
[android] Fix: Prevent crash on Bluetooth controller disconnect 2025-07-04 23:33:32 +00:00

View file

@ -37,19 +37,23 @@ object InputHandler {
} }
fun dispatchGenericMotionEvent(event: MotionEvent): Boolean { fun dispatchGenericMotionEvent(event: MotionEvent): Boolean {
val controllerData = var controllerData = androidControllers[event.device.controllerNumber]
androidControllers[event.device.controllerNumber] ?: return false if (controllerData == null) {
event.device.motionRanges.forEach { updateControllerData()
NativeInput.onGamePadAxisEvent( controllerData = androidControllers[event.device.controllerNumber] ?: return false
controllerData.getGUID(),
controllerData.getPort(),
it.axis,
event.getAxisValue(it.axis)
)
}
return true
} }
event.device.motionRanges.forEach {
NativeInput.onGamePadAxisEvent(
controllerData.getGUID(),
controllerData.getPort(),
it.axis,
event.getAxisValue(it.axis)
)
}
return true
}
fun getDevices(): Map<Int, YuzuPhysicalDevice> { fun getDevices(): Map<Int, YuzuPhysicalDevice> {
val gameControllerDeviceIds = mutableMapOf<Int, YuzuPhysicalDevice>() val gameControllerDeviceIds = mutableMapOf<Int, YuzuPhysicalDevice>()
val deviceIds = InputDevice.getDeviceIds() val deviceIds = InputDevice.getDeviceIds()