Commit 34022b4
android: propagate InputManager device-removed to input config (FR #18178)
When a wireless controller is powered off or otherwise vanishes,
Android's InputManager fires onInputDeviceRemoved on the activity, but
RetroArch's input config layer kept the cached device-name binding, so
input_config_get_device_name(port) continued to report the controller
as present until the next autoconf event. For consumers that drive
behaviour off that check - notably the Conditional Overlay Profile
resolver added in this PR, which switches the on-screen overlay between
full and minimal presets based on hotplug state - the controller
appeared bonded indefinitely and the overlay never returned to its
full preset after disconnect.
Wire RetroActivityCommon.onInputDeviceRemoved through to
android_input.c via a JNI bridge:
Java onInputDeviceRemoved(id)
-> RetroActivityCommon.inputDeviceRemoved(id) [native]
-> push id into g_android_removed_ids[] [mutex queue]
android_input_poll()
-> android_input_drain_pending_removed(android)
-> find pad_states[port].id == removed_id
-> clear pad_states[port].id and .name[0]
-> input_config_clear_device_name(port)
8-slot queue guarded by android_app->mutex (the lock already used by
APP_CMD_* handlers in this file) so multi-device disconnect bursts (two
BT controllers powered off together) are not dropped, and the read +
drain is atomic. pad_states[port].id is cleared with -1 rather than 0
since Android InputDevice.getDeviceId() can legitimately return 0 for
internal/virtual devices.
The Conditional Overlay resolver fires the FULL transition naturally on
the next poll once the port slot is clear, with the existing debounce
(input_overlay_switch_delay_ms) in effect.
C89-compliant (variables declared at top of block, /* */ comments,
Allman braces, 3-space indent); additive only - if Android never
delivers onInputDeviceRemoved the existing behaviour is unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent cde459b commit 34022b4
2 files changed
Lines changed: 88 additions & 0 deletions
File tree
- input/drivers
- pkg/android/phoenix-common/src/com/retroarch/browser/retroactivity
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
169 | 242 | | |
170 | 243 | | |
171 | 244 | | |
| |||
1832 | 1905 | | |
1833 | 1906 | | |
1834 | 1907 | | |
| 1908 | + | |
| 1909 | + | |
1835 | 1910 | | |
1836 | 1911 | | |
1837 | 1912 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
554 | 554 | | |
555 | 555 | | |
556 | 556 | | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
557 | 561 | | |
558 | 562 | | |
559 | 563 | | |
| |||
990 | 994 | | |
991 | 995 | | |
992 | 996 | | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
993 | 1006 | | |
994 | 1007 | | |
995 | 1008 | | |
| |||
0 commit comments