Fixed binding the D-pad on some Super NES style controllers

Fixed a case where partial trigger pull could be bound to another button

There is a fundamental problem not resolved by this commit:

Some controllers have axes (triggers, pedals, etc.) that don't start at zero, but we're guaranteed that if we get a value that it's correct. For these controllers, the current code works, where we take the first value we get and use that as the zero point and generate axis motion starting from that point on.

Other controllers have digital axes (D-pad) that assume a zero starting point, and the first value we get is the min or max axis value when the D-pad is moved. For these controllers, the current code thinks that the zero point is the axis value after the D-pad motion and this doesn't work.

My hypothesis is that the first class of devices is more common and that we should solve for that, and add an exception to SDL_JoystickAxesCenteredAtZero() as needed for the second class of devices.
This commit is contained in:
Sam Lantinga 2017-01-03 23:39:28 -08:00
parent d359180040
commit 082132a70c
8 changed files with 110 additions and 77 deletions

View file

@ -31,10 +31,10 @@
/* The SDL joystick structure */
typedef struct _SDL_JoystickAxisInfo
{
Sint16 value; /* Current axis states */
Sint16 zero; /* Zero point on the axis (-32768 for triggers) */
Sint16 intial_value; /* The very first value we saw on this axis */
SDL_bool moved; /* Whether the axis has moved */
Sint16 value; /* Current axis states */
Sint16 zero; /* Zero point on the axis (-32768 for triggers) */
SDL_bool has_initial_value; /* Whether we've seen a value on the axis yet */
SDL_bool sent_initial_value; /* Whether we've sent the initial axis value */
} SDL_JoystickAxisInfo;
struct _SDL_Joystick