Added functions to get the platform dependent name for a joystick or game controller

This commit is contained in:
Sam Lantinga 2022-04-26 14:54:14 -07:00
parent b293888c7d
commit e551384a99
28 changed files with 306 additions and 26 deletions

View file

@ -783,6 +783,21 @@ HIDAPI_JoystickGetDeviceName(int device_index)
return name;
}
static const char *
HIDAPI_JoystickGetDevicePath(int device_index)
{
SDL_HIDAPI_Device *device;
const char *path = NULL;
device = HIDAPI_GetDeviceByIndex(device_index, NULL);
if (device) {
/* FIXME: The device could be freed after this path is returned... */
path = device->path;
}
return path;
}
static int
HIDAPI_JoystickGetDevicePlayerIndex(int device_index)
{
@ -1030,6 +1045,7 @@ SDL_JoystickDriver SDL_HIDAPI_JoystickDriver =
HIDAPI_JoystickGetCount,
HIDAPI_JoystickDetect,
HIDAPI_JoystickGetDeviceName,
HIDAPI_JoystickGetDevicePath,
HIDAPI_JoystickGetDevicePlayerIndex,
HIDAPI_JoystickSetDevicePlayerIndex,
HIDAPI_JoystickGetDeviceGUID,