2014-08-06 20:26 GMT-03:00, Robotic-Brain :
Since scan codes aren’t standardized in any way this only works if you
got the scan code from the user initially.
OK, I really want to know from where do you get the idea that
scancodes are not standarized, because they definitely are (there are
some ancient scancode sets from like two decades ago, but even in the
rare case you have those the operating system will remap them to the
newer scancodes).
And SDL has its own set of scancodes, so in theory if some system
decides to use a completely different set SDL can just remap them to
what they’re usually. Scancodes should be considered safe.
The API tries to simplify remapping exactly because it’s a big mess!
Additionally it provides some common mappings but it’s not perfect at
all.
It’s not supposed to work “automagically”.
So your only bet is, hope the device is supported, if not, tell the user
about it, and ask for a mapping.
Yeah but you’re telling me to do it even if the mapping is known
because, you know, maybe the user wants to change them! So what’s the
point of the API if I should just disregard it anyway?
look for SDL_GameControllerAddMapping and friends.
Ideally you would build the mapping string with a wizard, save it to a
file, and load it on startup.
OK, let’s put the example of the six button controller I mentioned
earlier. It lacks a lot of inputs, so I assume they could be just
ignored. But it also adds two new inputs (two face buttons). To what
should they be mapped? Because mapping them to some of the missing
inputs probably wouldn’t make much sense. And even then, the other
four face buttons don’t really follow the expected layout anyway, how
do you arrange what would be ABXY?
And don’t tell me it’s an unusual case. I kept looking for my other
testers to see if I could find somebody else with a 360 controller.
Practically nobody does. Several of them had controllers that had
nothing to do with the 360 layout, though. Yeah, I also found it
surprising, but I guess this means controllers with unusual layouts
are more common than one would think.
what now, SDL_JoystickGetDeviceGUID or SDL_JoystickGetGUID?
one uses the Joystick instance, the other the index from the event. Make
sure not to confuse them!
Yeah, I noticed that later, but I wasn’t going to send three
consecutive e-mails 
Also, you know about SDL_JoystickGetGUIDString right?
Noticed about it later, I don’t remember why I didn’t use it :S The
printing code seems to work though, unless there’s something
non-obvious.
Also for the record, I decided to try it with the other controllers
the other testers have - it does show a correct GUID in those cases.
In other words, it seems SDL can actually retrieve the GUID of the
controllers. This makes things weirder though, because the way SDL
decides to switch to XInput is through the GUID, so that means it
should be able to retrieve the GUID of a 360 controller even if XInput
isn’t working.
…unless XInput is indeed working and showing an invalid GUID turns
out to be an accidental side-effect. I do remember that if SDL finds
the 360 GUID it will stop the current initialization code and go with
the XInput code instead.