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

@ -522,12 +522,8 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joy)
v *= 32768 / ((ymax - ymin + 1) / 2);
SDL_PrivateJoystickAxis(joy, 1, v);
}
if (gameport.b1 != joy->buttons[0]) {
SDL_PrivateJoystickButton(joy, 0, gameport.b1);
}
if (gameport.b2 != joy->buttons[1]) {
SDL_PrivateJoystickButton(joy, 1, gameport.b2);
}
SDL_PrivateJoystickButton(joy, 0, gameport.b1);
SDL_PrivateJoystickButton(joy, 1, gameport.b2);
}
return;
}
@ -563,9 +559,7 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joy)
v *= 32768 /
((hitem.logical_maximum -
hitem.logical_minimum + 1) / 2);
if (v != joy->axes[naxe].value) {
SDL_PrivateJoystickAxis(joy, naxe, v);
}
SDL_PrivateJoystickAxis(joy, naxe, v);
} else if (usage == HUG_HAT_SWITCH) {
v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem);
SDL_PrivateJoystickHat(joy, 0,
@ -576,9 +570,7 @@ SDL_SYS_JoystickUpdate(SDL_Joystick * joy)
}
case HUP_BUTTON:
v = (Sint32) hid_get_data(REP_BUF_DATA(rep), &hitem);
if (joy->buttons[nbutton] != v) {
SDL_PrivateJoystickButton(joy, nbutton, v);
}
SDL_PrivateJoystickButton(joy, nbutton, v);
nbutton++;
break;
default: