Add ability to "reserve" devices by player in Android using settings
Description
I use RetroArch on an Arcade1Up Simpsons arcade cabinet running Android 10. I wanted to be able to have a controller always map to a specific player when it's plugged in, regardless of the order that it was initialized by RetroArch.
This PR adds settings to the configuration, so that you can "reserve" a device for a given player, based on it's VID/PID, or name. I based this on how the input_android_physical_keyboard setting is handled. This is very useful in my specific situation (running a MAME 2003-plus core where the player order needs to match the order of the controllers mounted in the cabinet), but I could image it being useful in other situations, too.
Right now, only the Android input driver is checking to see if a port is reserved, based on the config value. However, other input drivers utilize this change by calling input_device_get_reserved_port.
Related Issues
#12924
Reviewers
I'm not sure who to tag for a review, but I'll post the PR in Discord
let's see if @sonninnos and/or @LibretroAdmin care to take a look
In this commit (https://github.com/libretro/RetroArch/pull/16269/commits/7658c802c9776029f49ba9d69761ee761dd1a574), I made it so that the settings themselves, and the method to get a reserved port based on the settings, was no longer Android specific. However, the only place that it's being used is in the Android input driver: https://github.com/libretro/RetroArch/blob/7658c802c9776029f49ba9d69761ee761dd1a574/input/drivers/android_input.c#L1401-L1407
So it only works on Android, but it makes it so that other platforms and input drivers can use it, too
@LibretroAdmin This is good for another review now 👍
Hi @PatrickStankard,
this is one of the requests that are recurring, thank you for taking the effort!
I lifted your code and moved it to autoconfig part, and it works there as well: https://github.com/libretro/RetroArch/compare/master...zoltanvb:RetroArch:input_driver_reserve_device
The advantage of having it in the autoconfig part would be that it is then automatically valid for all joypad drivers, Matching the driver defined ports to the player* settings is done by input_joypad_index. On the other hand, I did not see how android input driver calls the autoconfig, so that may be an exception.
I extended the test joypad driver and ran a few tests, looks OK so far but there may still be some corner cases, removing devices, multiple devices with same vid/pid, etc... so at least this modified version still needs work. If you agree, we could collaborate on this in some form.
This was merged as a part of #16647