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:
commit
2d6c7c94c4
|
@ -159,10 +159,12 @@ int32_t pad_connection_pad_init(joypad_connection_t *joyconn,
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
|
const bool has_name = !string_is_empty(name);
|
||||||
|
|
||||||
for (i = 0; name && pad_map[i].name; i++)
|
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. */
|
/* Never change, Nintendo. */
|
||||||
if(pad_map[i].vid == 1406 && pad_map[i].pid == 816)
|
if(pad_map[i].vid == 1406 && pad_map[i].pid == 816)
|
||||||
|
|
|
@ -684,6 +684,9 @@ static void iohidmanager_hid_device_add_device(
|
||||||
if (adapter->slot == -1)
|
if (adapter->slot == -1)
|
||||||
goto error;
|
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))
|
if (pad_connection_has_interface(hid->slots, adapter->slot))
|
||||||
IOHIDDeviceRegisterInputReportCallback(device,
|
IOHIDDeviceRegisterInputReportCallback(device,
|
||||||
adapter->data + 1, sizeof(adapter->data) - 1,
|
adapter->data + 1, sizeof(adapter->data) - 1,
|
||||||
|
@ -692,9 +695,6 @@ static void iohidmanager_hid_device_add_device(
|
||||||
IOHIDDeviceRegisterInputValueCallback(device,
|
IOHIDDeviceRegisterInputValueCallback(device,
|
||||||
iohidmanager_hid_device_input_callback, adapter);
|
iohidmanager_hid_device_input_callback, adapter);
|
||||||
|
|
||||||
if (string_is_empty(adapter->name))
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
/* scan for buttons, axis, hats */
|
/* scan for buttons, axis, hats */
|
||||||
elements_raw = IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone);
|
elements_raw = IOHIDDeviceCopyMatchingElements(device, NULL, kIOHIDOptionsTypeNone);
|
||||||
count = (int)CFArrayGetCount(elements_raw);
|
count = (int)CFArrayGetCount(elements_raw);
|
||||||
|
|
Loading…
Reference in New Issue