mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-27 02:00:41 +00:00
Wii U: Fix USB get_device_name(), don't truncate to three chars
This commit is contained in:
parent
de4e56ecf2
commit
1cd6413e24
@ -164,10 +164,9 @@ joypad_connection_entry_t *find_connection_entry(uint16_t vid, uint16_t pid, con
|
||||
name_match = has_name
|
||||
? strstr(pad_map[i].name, name)
|
||||
: NULL;
|
||||
if (has_name && strlen(name) == 3)
|
||||
if (has_name && strlen(name) < 19)
|
||||
{
|
||||
/* Wii U: Argument 'name' is only the prefix of the device name!?
|
||||
* This is not enough for a reliable name match! */
|
||||
/* Wii U: Argument 'name' may be truncated. This is not enough for a reliable name match! */
|
||||
RARCH_ERR("find_connection_entry(0x%04x,0x%04x): device name '%s' too short: assuming controller '%s'\n",
|
||||
SWAP_IF_BIG(vid), SWAP_IF_BIG(pid), name, pad_map[i].name);
|
||||
}
|
||||
|
@ -894,13 +894,20 @@ static void delete_adapter(wiiu_adapter_t *adapter)
|
||||
static void get_device_name(HIDDevice *device, wiiu_attach_event *event)
|
||||
{
|
||||
int32_t result;
|
||||
uint8_t *name_buffer = alloc_zeroed(4, device->max_packet_size_rx);
|
||||
uint8_t name_buffer_size = 46; /* enough to detect WiiU Pro controller */
|
||||
uint8_t *name_buffer = alloc_zeroed(4, name_buffer_size);
|
||||
uint8_t *top = &event->device_name[0];
|
||||
|
||||
if(name_buffer == NULL) {
|
||||
return;
|
||||
}
|
||||
result = HIDGetDescriptor(device->handle, 3, 2, 0, name_buffer, device->max_packet_size_rx, NULL, NULL);
|
||||
|
||||
/* HIDGetDescriptor() fills name_buffer in this way:
|
||||
* - First two bytes are empty
|
||||
* - Every second byte is empty
|
||||
* - Maximum name_buffer size is unknown (with 63 it starts to fail with one of my controllers)
|
||||
* - Truncates device names if name_buffer is too small */
|
||||
result = HIDGetDescriptor(device->handle, 3, 2, 0, name_buffer, name_buffer_size, NULL, NULL);
|
||||
if(result > 0) {
|
||||
for(int i = 2; i < result; i += 2) {
|
||||
top[0] = name_buffer[i];
|
||||
|
Loading…
Reference in New Issue
Block a user