From bd92388d2f36c32dee474cbcb5a0e0bba5035656 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 7 Feb 2026 16:36:37 +0100 Subject: Android: Rework input device hotplug Previously, when an input device was connected or disconnected, we would recreate all devices. This commit makes it so we only touch the relevant device instead. This matters because recreating a device causes us to drop all held buttons for that device. Due to Android only delivering inputs as events, we're unable to poll for currently held buttons when recreating a device. This recently became a problem for users of Ayn devices due to a firmware update. Every now and then, something about the display viewports changes, triggering an update to an input device that I assume is a touch input device. This input device isn't something users normally map in Dolphin's controller settings, but it changing was causing Dolphin to drop all held buttons for the device's built-in gamepad as well as any other connected gamepads. --- .../dolphinemu/features/input/model/ControllerInterface.kt | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'Source/Android/app/src/main/java') diff --git a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/ControllerInterface.kt b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/ControllerInterface.kt index 360800d656..71b37ff513 100644 --- a/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/ControllerInterface.kt +++ b/Source/Android/app/src/main/java/org/dolphinemu/dolphinemu/features/input/model/ControllerInterface.kt @@ -95,11 +95,6 @@ object ControllerInterface { deviceQualifier: String, axisNames: Array, suspended: Boolean ) - /** - * Rescans for input devices. - */ - external fun refreshDevices() - external fun getAllDeviceStrings(): Array external fun getDevice(deviceString: String): CoreDevice? @@ -193,13 +188,10 @@ object ControllerInterface { } private class InputDeviceListener : InputManager.InputDeviceListener { - // Simple implementation for now. We could do something fancier if we wanted to. - override fun onInputDeviceAdded(deviceId: Int) = refreshDevices() + override external fun onInputDeviceAdded(deviceId: Int) - // Simple implementation for now. We could do something fancier if we wanted to. - override fun onInputDeviceRemoved(deviceId: Int) = refreshDevices() + override external fun onInputDeviceRemoved(deviceId: Int) - // Simple implementation for now. We could do something fancier if we wanted to. - override fun onInputDeviceChanged(deviceId: Int) = refreshDevices() + override external fun onInputDeviceChanged(deviceId: Int) } } -- cgit v1.2.3