Merge pull request #11292 from th-in-gs/XK-PC2004-controller-fix

Allow controllers with no/empty names to work.
This commit is contained in:
Autechre 2020-09-07 14:30:47 +02:00 committed by GitHub
commit 2d6c7c94c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View File

@ -159,10 +159,12 @@ int32_t pad_connection_pad_init(joypad_connection_t *joyconn,
if (s)
{
unsigned i;
const bool has_name = !string_is_empty(name);
for (i = 0; name && pad_map[i].name; i++)
{
const char *name_match = strstr(pad_map[i].name, name);
const char *name_match = has_name ? strstr(pad_map[i].name, name) : NULL;
/* Never change, Nintendo. */
if(pad_map[i].vid == 1406 && pad_map[i].pid == 816)

View File

@ -684,6 +684,9 @@ static void iohidmanager_hid_device_add_device(
if (adapter->slot == -1)
goto error;
if (string_is_empty(adapter->name))
strcpy(adapter->name, "Unknown Controller With No Name");
if (pad_connection_has_interface(hid->slots, adapter->slot))
IOHIDDeviceRegisterInputReportCallback(device,
adapter->data + 1, sizeof(adapter->data) - 1,
@ -692,9 +695,6 @@ static void iohidmanager_hid_device_add_device(
IOHIDDeviceRegisterInputValueCallback(device,
iohidmanager_hid_device_input_callback, adapter);
if (string_is_empty(adapter->name))
goto error;
/* scan for buttons, axis, hats */
elements_raw = IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone);
count = (int)CFArrayGetCount(elements_raw);