Skip to content

Commit

Permalink
Remove References to uniqueId
Browse files Browse the repository at this point in the history
It seems the intention of uniqueId added in 9008684 was to reconnect controllers to their previous port based on the "uniqueId" of the device reported by the operating system. However, as noted in the comments, the uniqueId changes every time a device is reconnected and so this code can never accomplish its goal.
  • Loading branch information
ComradeEcho committed Aug 4, 2021
1 parent 327f220 commit 62f29bd
Showing 1 changed file with 11 additions and 47 deletions.
58 changes: 11 additions & 47 deletions input/drivers_hid/iohidmanager_hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ struct iohidmanager_hid_adapter
apple_input_rec_t *hats;
apple_input_rec_t *buttons;
uint8_t data[2048];
#if !(defined(__ppc__) || defined(__ppc64__))
uint32_t uniqueId;
#endif
};

CFComparisonResult iohidmanager_sort_elements(const void *val1, const void *val2, void *context)
Expand Down Expand Up @@ -555,15 +552,7 @@ static uint32_t iohidmanager_hid_device_get_location_id(IOHIDDeviceRef device)
CFSTR(kIOHIDLocationIDKey));
}

#if !(defined(__ppc__) || defined(__ppc64__))
static uint32_t iohidmanager_hid_device_get_unique_id(IOHIDDeviceRef device)
{
/* osx seems to assign an unique id to each device when they are plugged in
* the id change if device is unplugged/plugged, but it's unique amongst the
* other device plugged */
return iohidmanager_hid_device_get_int_property(device,CFSTR(kIOHIDUniqueIDKey));
}
#endif


static void iohidmanager_hid_device_get_product_string(
IOHIDDeviceRef device, char *buf, size_t len)
Expand Down Expand Up @@ -591,20 +580,12 @@ static void iohidmanager_hid_device_add_autodetect(unsigned idx,
RARCH_LOG("Port %d: %s.\n", idx, device_name);
}

#if defined(__ppc__) || defined(__ppc64__)
static void iohidmanager_hid_device_add(IOHIDDeviceRef device,
iohidmanager_hid_t* hid)
#else
static void iohidmanager_hid_device_add_device(
IOHIDDeviceRef device, iohidmanager_hid_t* hid)
#endif

static void iohidmanager_hid_device_add_device(IOHIDDeviceRef device, iohidmanager_hid_t* hid)
{
int i;

/* get device unique id */
#if !(defined(__ppc__) || defined(__ppc64__))
uint32_t deviceUniqueId = iohidmanager_hid_device_get_unique_id(device);
#endif


static const uint32_t axis_use_ids[11] =
{
Expand All @@ -621,18 +602,7 @@ static void iohidmanager_hid_device_add_device(
kHIDUsage_Sim_Brake
};

#if !(defined(__ppc__) || defined(__ppc64__))
/* check if pad was already registered previously (by deterministic method)
* if so do not re-add the pad */
for (i=0; i<MAX_USERS; i++)
{
struct iohidmanager_hid_adapter *a = (struct iohidmanager_hid_adapter*)hid->slots[i].data;
if (!a)
continue;
if (a->uniqueId == deviceUniqueId)
return;
}
#endif


IOReturn ret;
uint16_t dev_vid, dev_pid;
Expand Down Expand Up @@ -673,9 +643,6 @@ static void iohidmanager_hid_device_add_device(

dev_vid = iohidmanager_hid_device_get_vendor_id (device);
dev_pid = iohidmanager_hid_device_get_product_id (device);
#if !(defined(__ppc__) || defined(__ppc64__))
adapter->uniqueId = deviceUniqueId;
#endif

adapter->slot = pad_connection_pad_init(hid->slots,
adapter->name, dev_vid, dev_pid, adapter,
Expand Down Expand Up @@ -936,14 +903,14 @@ static void iohidmanager_hid_device_add_device(
}
}

#if !(defined(__ppc__) || defined(__ppc64__))

static void iohidmanager_hid_device_add(void *data, IOReturn result,
void* sender, IOHIDDeviceRef device)
{
iohidmanager_hid_t *hid = (iohidmanager_hid_t*) hid_driver_get_data();
iohidmanager_hid_device_add_device(device, hid);
}
#endif


static void iohidmanager_hid_append_matching_dictionary(
CFMutableArrayRef array,
Expand Down Expand Up @@ -1059,20 +1026,17 @@ static int iohidmanager_hid_manager_set_device_matching(
hid_list_t * ptr = devList;
while (ptr != NULL)
{
#if defined(__ppc__) || defined(__ppc64__)
iohidmanager_hid_device_add(ptr->device, hid);
#else

iohidmanager_hid_device_add_device(ptr->device, hid);
#endif

//printf("%d\n",ptr->lid);

ptr = ptr->next;
free(devList);
devList = ptr;
}
free(device_array);

#if !(defined(__ppc__) || defined(__ppc64__))

/* register call back to dynamically add device plugged when retroarch is
* running
* those will be added after the one plugged when retroarch was launched,
Expand All @@ -1095,7 +1059,7 @@ static int iohidmanager_hid_manager_set_device_matching(
iohidmanager_hid_device_add, 0);

CFRelease(matcher);
#endif


return 0;
}
Expand Down

0 comments on commit 62f29bd

Please sign in to comment.