mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2025-07-20 03:35:46 +00:00
[android] Fix: Prevent crash on Bluetooth controller disconnect
This commit is contained in:
parent
d8bfc691d1
commit
abbc4fefee
1 changed files with 15 additions and 11 deletions
|
@ -37,19 +37,23 @@ object InputHandler {
|
|||
}
|
||||
|
||||
fun dispatchGenericMotionEvent(event: MotionEvent): Boolean {
|
||||
val controllerData =
|
||||
androidControllers[event.device.controllerNumber] ?: return false
|
||||
event.device.motionRanges.forEach {
|
||||
NativeInput.onGamePadAxisEvent(
|
||||
controllerData.getGUID(),
|
||||
controllerData.getPort(),
|
||||
it.axis,
|
||||
event.getAxisValue(it.axis)
|
||||
)
|
||||
}
|
||||
return true
|
||||
var controllerData = androidControllers[event.device.controllerNumber]
|
||||
if (controllerData == null) {
|
||||
updateControllerData()
|
||||
controllerData = androidControllers[event.device.controllerNumber] ?: return false
|
||||
}
|
||||
|
||||
event.device.motionRanges.forEach {
|
||||
NativeInput.onGamePadAxisEvent(
|
||||
controllerData.getGUID(),
|
||||
controllerData.getPort(),
|
||||
it.axis,
|
||||
event.getAxisValue(it.axis)
|
||||
)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
fun getDevices(): Map<Int, YuzuPhysicalDevice> {
|
||||
val gameControllerDeviceIds = mutableMapOf<Int, YuzuPhysicalDevice>()
|
||||
val deviceIds = InputDevice.getDeviceIds()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue