pandory500: fix udev bug

The sunxi linux 3.x kernel reports extra axes on some (poor?) controllers,
causing /dev/input and udev to report too many to SDL2. This mainly occurs
when using RetroGames LTD controllers, such as The GamePad and The C64 Joystick.

This patch detects the guids of these specific controllers and filters
the extra axes so SDL2 does not react to them.
This commit is contained in:
dajoho 2023-08-15 19:04:15 +02:00
parent 424032b0ca
commit 3eca30e6dc

View file

@ -659,6 +659,9 @@ ConfigJoystick(SDL_Joystick * joystick, int fd)
unsigned long relbit[NBITS(REL_MAX)] = { 0 };
unsigned long ffbit[NBITS(FF_MAX)] = { 0 };
SDL_JoystickGUID guid = SDL_JoystickGetGUID(joystick);
char pandoryGUID[1024];
/* See if this device uses the new unified event API */
if ((ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) >= 0) &&
(ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absbit)), absbit) >= 0) &&
@ -683,6 +686,7 @@ ConfigJoystick(SDL_Joystick * joystick, int fd)
++joystick->nbuttons;
}
}
for (i = 0; i < ABS_MISC; ++i) {
/* Skip hats */
if (i == ABS_HAT0X) {
@ -695,6 +699,18 @@ ConfigJoystick(SDL_Joystick * joystick, int fd)
if (ioctl(fd, EVIOCGABS(i), &absinfo) < 0) {
continue;
}
// Pandory500 retrogames-udev-bug skip more than two axes
SDL_JoystickGetGUIDString(joystick->hwdata->guid, pandoryGUID, sizeof(pandoryGUID));
if ( strcmp(pandoryGUID, "03000000591c00002600000010010000") == 0 // 'Retro Games LTD THEGamepad'
|| strcmp(pandoryGUID, "03000000591c00002300000010010000") == 0 // ' THEC64 Joystick THEC64 Joystick '
) {
if (i > 1) {
printf("Pandory: retrogames-udev-bug - skipping absolute axis: 0x%.2x\n", i);
continue;
}
}
#ifdef DEBUG_INPUT_EVENTS
printf("Joystick has absolute axis: 0x%.2x\n", i);
printf("Values = { %d, %d, %d, %d, %d }\n",