Make it so XInput devices are listed before DirectInput devices, and that the XInput
devices are sorted by userid in ascending numeric order (so device 0 comes first).
Now multiple XInput controllers map correctly to device indexes instead of grabbing
the first available userid, and are completely separated out from DirectInput.
Also, the hardcoded limitation on number of DirectInput devices is gone. I don't
expect there to really ever be more than eight joysticks plugged into a machine, but
it was a leftover limitation for a static array we didn't actually use anymore.
Fixes Bugzilla #1984. (etc?)
If ac_x_libraries is empty it means that the library's found in the default path,
so we skip adding it to the XLIB variable as it screws up the search path.
- also adds OS X specific magic for bundled apps adding an Info.plist property of name SDL_FILESYSTEM_BASE_DIR_TYPE to the following values will change the bahaviour.
* bundle -- use the bundle directory e.g. "/Applications/MyGame/Blah.app/"
* parent -- use the bundle parent directory e.g. "/Applications/MyGame/"
* resource -- use the bundle resource directory (default) e.g. "/Applications/MyGame/Blah.app/Contents/Resources/"
- detect that you tried to open a gamecontroller in xinput mode and failed, then re-get the mapping for the dinput variant you did open (and most likely now just fail the open)
CR: SamL
This entire function is kind of a mess and more complicated than needed, but I don't want to refactor it too heavily tonight. May look at improving how the indexes are assigned more significanly later. The way it handles not finding a valid "gamepad" type device is also super broken, it leaves in place the xinput bindings but opens the controller with dinput and ends up with completely wrong mappings, not solving that now, but fixing the bug where we'd very frequently not find a controller due to gaps in assigned player numbers should mostly avoid it.