Added 4 auxiliary buttons to the game controller API

Xbox Elite controllers use AUX1-AUX4 to represent the paddle buttons when using the HIDAPI driver
PS4 and PS5 controllers use AUX1 to represent the touchpad button
Nintendo Switch Pro controllers use AUX1 to represent the capture button
This commit is contained in:
Sam Lantinga 2020-11-06 11:30:52 -08:00
parent a22beef402
commit 3a3aaac221
16 changed files with 299 additions and 223 deletions

View file

@ -390,6 +390,26 @@ HIDAPI_ShutdownDiscovery()
#endif
}
void
HIDAPI_DumpPacket(const char *prefix, Uint8 *data, int size)
{
int i;
char *buffer;
size_t length = SDL_strlen(prefix) + 11*(USB_PACKET_LENGTH/8) + (5*USB_PACKET_LENGTH) + 1 + 1;
buffer = (char *)SDL_malloc(length);
SDL_snprintf(buffer, length, prefix, size);
for (i = 0; i < size; ++i) {
if ((i % 8) == 0) {
SDL_snprintf(&buffer[SDL_strlen(buffer)], length - SDL_strlen(buffer), "\n%.2d: ", i);
}
SDL_snprintf(&buffer[SDL_strlen(buffer)], length - SDL_strlen(buffer), " 0x%.2x", data[i]);
}
SDL_strlcat(buffer, "\n", length);
SDL_Log("%s", buffer);
SDL_free(buffer);
}
static void HIDAPI_JoystickDetect(void);
static void HIDAPI_JoystickClose(SDL_Joystick * joystick);