Regarding the joystick mapping differently under XInput versus
DirectInput: Blame Microsoft. If you want to know what I mean by
that, read here:
And then curse them for ever and ever for deliberately making
triggers STUPID. Despite this idiocy, you’ll find SDL does the
intelligent thing in its GameController API.
Which RetroLink pad have you got? I don’t have one here to test, but
I might be willing to get one?they tend to be like $10 on Amazon. As
I have kind of made the joystick subsystem a hobby of mine lately?
Now, regarding SDL: If you want to use an XBox 360 controller (or
anything that is basically close enough), SDL 2.x has a great option
for you: GameController. Any XInput-compatible device will just work
for you using that API and be automatically and correctly mapped.
The API’s a little verbose in its naming and enums, and the functions
all use Microsoftian lolomgwtfbbqVAR naming (which Sam won’t let me
change into reasonable and descriptive names that make sense to the
rest of the world), but that’s a documentation issue and I really
ought to get back to writing it at some point soon. 
For some idea how to use it, have a look at test/testgamecontroller.c
(which I am completely rewriting?within the next week or so, it will
hopefully become IMO a much better example!)
The major thing testgamecontroller does NOT do yet, even in my code,
is handle device added/removed events. Short form: Device added
event.which contains the device index to open the thing. You’ll want
to keep the SDL_GameController pointer around so you can close it if
you get a device removed, whose event.which contains an instance ID
that isn’t the same as a device index.
At the moment, when I open a device, I immediately get its instance
ID and save both. If I get a device removed event, I go through my
list of open devices and close it if it’s opened. I proposed an
alternative solution, but Sam pointed out it wouldn’t work. Since I
haven’t got a more brilliant suggestion, existing behavior stands.
Any joystick can be mapped to a SDL_GameController. Steam will do it
for you, though getting the data out of Steam and its database for
use with SDL is currently not the most user-friendly process in the
world. (This will be addressed too!)
Programmatically speaking, SDL_GameControllers are 14 buttons (A, B,
X, Y, Back, Guide, Start, LSB, RSB, LB, RB, and four DPad buttons)
plus 6 axes (left stick, right stick, left trigger, and right
trigger), consequently in that order actually.
(But that’s an
implementation detail?) Your triggers range 0 to 32767 instead of
the usual -32768 to 32767, and they may be digital buttons. Guide
often doesn’t exist, and retro controllers can be expected to map to
the DPad rather than the analog stick.
On the whole it’s a good API. I’d like to see the Windows 7+ XInput
controller type hints used in SDL, but other targets may provide
different (and sometimes more) information than XInput does.
JosephOn Sat, Oct 19, 2013 at 10:28:06PM +0000, rainwarrior wrote:
In SDL_SYS_JoystickOpen, I added:
Code:
joystickdevice->bXInputDevice = SDL_FALSE;
Doing this before that value is tested seems to get my 360 style gamepad working as expected again. I am not sure what’s going on in the XInputDevice code path there, but it’s a disaster for this controller in particular.
Still not sure why the retrolink pad is getting a duplicated X axis instead of X and Y.