Remove code that duplicates controllers

This commit is contained in:
ComradeEcho 2021-08-07 11:43:50 -05:00 committed by GitHub
parent 86b297e0fd
commit 35c2ec993b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1005,76 +1005,6 @@ static int iohidmanager_hid_manager_free(iohidmanager_hid_t *hid)
static int iohidmanager_hid_manager_set_device_matching(
iohidmanager_hid_t *hid)
{
/* deterministically add all device currently plugged when lanching retroarch
* order by location id which seems to correspond to usb port number */
CFSetRef set = IOHIDManagerCopyDevices(hid->ptr);
CFIndex num_devices = CFSetGetCount(set);
IOHIDDeviceRef *device_array = (IOHIDDeviceRef*)calloc(num_devices, sizeof(IOHIDDeviceRef));
CFSetGetValues(set, (const void **) device_array);
CFRelease(set);
/* re order device by location id */
typedef struct hid_list
{
IOHIDDeviceRef device;
uint32_t lid;
struct hid_list *next;
} hid_list_t;
hid_list_t* devList = NULL;
for (long i=0; i<num_devices;i++)
{
IOHIDDeviceRef dev = device_array[i];
/* filter gamepad/joystick devices */
if ( IOHIDDeviceConformsTo(dev, kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick)
|| IOHIDDeviceConformsTo(dev, kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad)
)
{
if (!devList)
{
devList = (hid_list_t *)malloc(sizeof(hid_list_t));
devList->device = dev;
devList->lid = iohidmanager_hid_device_get_location_id(dev);
devList->next = NULL;
}
else
{
hid_list_t * devnew = (hid_list_t *)malloc(sizeof(hid_list_t));
devnew->device = dev;
devnew->lid = iohidmanager_hid_device_get_location_id(dev);
devnew->next = NULL;
hid_list_t * ptr = devList;
if (devnew->lid < ptr->lid)
{
devnew->next = ptr;
devList = devnew;
}
else
{
while ( ( ptr->lid < devnew->lid ) && (ptr->next != NULL) )
ptr = ptr->next;
devnew->next = ptr->next;
ptr->next = devnew;
}
}
}
}
/* register devices */
hid_list_t * ptr = devList;
while (ptr != NULL)
{
iohidmanager_hid_device_add(ptr->device, hid);
ptr = ptr->next;
free(devList);
devList = ptr;
}
free(device_array);
/* register call back to dynamically add device plugged when retroarch is
* running
* those will be added after the one plugged when retroarch was launched,