The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
[GameController] Input Inversion in Config
Ethan Lee
Guest

In the current SDL_GAMECONTROLLERCONFIG parser, there is no method to
invert input values received from the joystick. For instance, while the
360 controller's Y axes go from -32767 to 32767 downward, most Nintendo
hardware does the opposite (and IIRC, sometimes only for one of two
thumbsticks?!). Sometimes it can be possible to invert it at the driver
level, like we did with the Wii U GameCube Adapter's uinput driver...

https://github.com/ToadKing/wii-u-gc-adapter/blob/master/wii-u-gc-adapter.c#L334

... but this may not be possible in all cases (and for developers who
are expecting raw input unaltered it may even be considered annoying).
In FNA I still have my old SDL_Joystick config format from when it was
called MonoGame-SDL2, and it works well enough on its own...

https://github.com/flibitijibibo/FNA/blob/master/src/SDL2/Input/SDL2_GamePad.cs#L43
https://github.com/flibitijibibo/FNA/blob/master/src/SDL2/Input/SDL2_GamePad.cs#L470
https://github.com/flibitijibibo/FNA/blob/master/src/SDL2/Input/SDL2_GamePad.cs#L495

... but it awkwardly conflicts with GameControllers, and of course has
the problem of picking up weird devices like wireless receivers... So
I'd like to be able to do this at SDL_GameController's level instead.

My idea was to just allow negative integers for the numeric values,
store whether the atoi() value < 0 (or is "-0"?), and then just use
abs() to retain the iSDLButton value:

https://hg.libsdl.org/SDL/file/223fbcc6a327/src/joystick/SDL_gamecontroller.c#l380

Of course, I'd like to hear feedback on this. I imagine a lot of people
have input inversion done on their game's side, but for certain projects
that are stuck assuming 360 layouts (like FNA) it'd be really nice to have.

-Ethan
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
[GameController] Input Inversion in Config
Sam Lantinga


Joined: 10 Sep 2009
Posts: 1765
Yes, there have been proposals along this line and I am generally in favor of them. I don't know offhand how many of them made it to patch submitted status, but I would welcome a patch that does that. Please take a look and see what proposals have already been made and see how they fit in with what you're thinking.

On Fri, May 15, 2015 at 3:59 AM, Ethan Lee wrote:
Quote:
In the current SDL_GAMECONTROLLERCONFIG parser, there is no method to invert input values received from the joystick. For instance, while the 360 controller's Y axes go from -32767 to 32767 downward, most Nintendo hardware does the opposite (and IIRC, sometimes only for one of two thumbsticks?!). Sometimes it can be possible to invert it at the driver level, like we did with the Wii U GameCube Adapter's uinput driver...

https://github.com/ToadKing/wii-u-gc-adapter/blob/master/wii-u-gc-adapter.c#L334

... but this may not be possible in all cases (and for developers who are expecting raw input unaltered it may even be considered annoying). In FNA I still have my old SDL_Joystick config format from when it was called MonoGame-SDL2, and it works well enough on its own...

https://github.com/flibitijibibo/FNA/blob/master/src/SDL2/Input/SDL2_GamePad.cs#L43
https://github.com/flibitijibibo/FNA/blob/master/src/SDL2/Input/SDL2_GamePad.cs#L470
https://github.com/flibitijibibo/FNA/blob/master/src/SDL2/Input/SDL2_GamePad.cs#L495

... but it awkwardly conflicts with GameControllers, and of course has the problem of picking up weird devices like wireless receivers... So I'd like to be able to do this at SDL_GameController's level instead.

My idea was to just allow negative integers for the numeric values, store whether the atoi() value < 0 (or is "-0"?), and then just use abs() to retain the iSDLButton value:

https://hg.libsdl.org/SDL/file/223fbcc6a327/src/joystick/SDL_gamecontroller.c#l380

Of course, I'd like to hear feedback on this. I imagine a lot of people have input inversion done on their game's side, but for certain projects that are stuck assuming 360 layouts (like FNA) it'd be really nice to have.

-Ethan
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
[GameController] Input Inversion in Config
Ryan C. Gordon
Guest

On 5/23/15 12:45 AM, Sam Lantinga wrote:
Quote:
Yes, there have been proposals along this line and I am generally in
favor of them. I don't know offhand how many of them made it to patch
submitted status, but I would welcome a patch that does that. Please
take a look and see what proposals have already been made and see how
they fit in with what you're thinking.

Making the game controller config string format more robust (inverted
axes, deadzones, etc) is a big wishlist item for me for 2.0.5, fwiw.
I'll either do it or take someone else's work for it, but let's
definitely get this into revision control after 2.0.4 is done.

Various attempts have floated around before in various states, and I'd
like to get this resolved.

--ryan.


_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
[GameController] Input Inversion in Config
Sik


Joined: 26 Nov 2011
Posts: 905
Getting around to checking this.

2015-05-15 7:59 GMT-03:00, Ethan Lee:
Quote:
My idea was to just allow negative integers for the numeric values,
store whether the atoi() value < 0 (or is "-0"?), and then just use
abs() to retain the iSDLButton value:

https://hg.libsdl.org/SDL/file/223fbcc6a327/src/joystick/SDL_gamecontroller.c#l380

Bad idea, precisely because of the 0 issue. On the other hand, note
that it's a string, nothing prevents you from parsing symbols
explicitly (so you don't have to rely on atoi). In other words: it'd
be an extra character in the string, and an extra flag in SDL's
internal structure. (no symbol would be parsed to mean the default,
i.e. no inversion)

Does this sound good?
_______________________________________________
SDL mailing list

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org