mirror of
https://github.com/Ryujinx/SDL.git
synced 2024-12-24 01:05:42 +00:00
Include the child serial numbers in the serial number for a HIDAPI combined device
This commit is contained in:
parent
523bedac1a
commit
d90c0d41cc
|
@ -27,7 +27,7 @@
|
||||||
#include "SDL_joystick.h"
|
#include "SDL_joystick.h"
|
||||||
#include "SDL_gamecontroller.h"
|
#include "SDL_gamecontroller.h"
|
||||||
#include "SDL_hidapijoystick_c.h"
|
#include "SDL_hidapijoystick_c.h"
|
||||||
|
#include "../SDL_sysjoystick.h"
|
||||||
|
|
||||||
static SDL_bool
|
static SDL_bool
|
||||||
HIDAPI_DriverCombined_IsSupportedDevice(const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol)
|
HIDAPI_DriverCombined_IsSupportedDevice(const char *name, SDL_GameControllerType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol)
|
||||||
|
@ -63,6 +63,8 @@ static SDL_bool
|
||||||
HIDAPI_DriverCombined_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
HIDAPI_DriverCombined_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joystick)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
char *serial = NULL, *new_serial;
|
||||||
|
size_t serial_length = 0, new_length;
|
||||||
|
|
||||||
for (i = 0; i < device->num_children; ++i) {
|
for (i = 0; i < device->num_children; ++i) {
|
||||||
SDL_HIDAPI_Device *child = device->children[i];
|
SDL_HIDAPI_Device *child = device->children[i];
|
||||||
|
@ -71,9 +73,36 @@ HIDAPI_DriverCombined_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joystick *joys
|
||||||
child = device->children[i];
|
child = device->children[i];
|
||||||
child->driver->CloseJoystick(child, joystick);
|
child->driver->CloseJoystick(child, joystick);
|
||||||
}
|
}
|
||||||
|
if (serial) {
|
||||||
|
SDL_free(serial);
|
||||||
|
}
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Extend the serial number with the child serial number */
|
||||||
|
if (joystick->serial) {
|
||||||
|
new_length = serial_length + 1 + SDL_strlen(joystick->serial);
|
||||||
|
new_serial = (char *)SDL_realloc(serial, new_length);
|
||||||
|
if (new_serial) {
|
||||||
|
if (serial) {
|
||||||
|
SDL_strlcat(new_serial, ",", new_length);
|
||||||
|
SDL_strlcat(new_serial, joystick->serial, new_length);
|
||||||
|
} else {
|
||||||
|
SDL_strlcpy(new_serial, joystick->serial, new_length);
|
||||||
|
}
|
||||||
|
SDL_free(serial);
|
||||||
|
serial = new_serial;
|
||||||
|
serial_length = new_length;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Update the joystick with the combined serial numbers */
|
||||||
|
if (joystick->serial) {
|
||||||
|
SDL_free(joystick->serial);
|
||||||
|
}
|
||||||
|
joystick->serial = serial;
|
||||||
|
|
||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue