diff --git a/input/apple_joypad.c b/input/apple_joypad.c index 6da03bc4be..a90974ae8c 100644 --- a/input/apple_joypad.c +++ b/input/apple_joypad.c @@ -73,6 +73,7 @@ int32_t apple_joypad_connect(const char* name, void *data) } pad_map[] = { { "Nintendo RVL-CNT-01", &apple_pad_wii }, + { "Nintendo RVL-CNT-01-UC", &apple_pad_wii }, { "PLAYSTATION(R)3 Controller", &apple_pad_ps3 }, { 0, 0} }; @@ -90,12 +91,12 @@ int32_t apple_joypad_connect(const char* name, void *data) int32_t apple_joypad_connect_gcapi(void) { - int32_t slot; - slot = find_empty_slot(); + int32_t slot = find_empty_slot(); if (slot >= 0 && slot < MAX_PLAYERS) { joypad_slot_t *s = (joypad_slot_t*)&slots[slot]; + s->used = true; s->is_gcapi = true; } @@ -116,7 +117,8 @@ void apple_joypad_disconnect(uint32_t slot) } } -void apple_joypad_packet(uint32_t slot, uint8_t* data, uint32_t length) +void apple_joypad_packet(uint32_t slot, + uint8_t* data, uint32_t length) { if (slot < MAX_PLAYERS && slots[slot].used) { diff --git a/input/hid/apple_input_hid.c b/input/hid/apple_input_hid.c index bf0d0559f9..a1bfe8df60 100644 --- a/input/hid/apple_input_hid.c +++ b/input/hid/apple_input_hid.c @@ -20,6 +20,8 @@ struct apple_pad_connection { + int v_id; + int p_id; uint32_t slot; IOHIDDeviceRef device_handle; uint8_t data[2048]; @@ -128,6 +130,7 @@ static void hid_manager_device_attached(void* context, IOReturn result, { char device_name[PATH_MAX]; CFStringRef device_name_ref; + CFNumberRef vendorID, productID; struct apple_pad_connection* connection = (struct apple_pad_connection*) calloc(1, sizeof(*connection)); @@ -141,9 +144,17 @@ static void hid_manager_device_attached(void* context, IOReturn result, kCFRunLoopCommonModes); IOHIDDeviceRegisterRemovalCallback(device, hid_device_removed, connection); +#ifndef IOS device_name_ref = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductKey)); CFStringGetCString(device_name_ref, device_name, sizeof(device_name), kCFStringEncodingUTF8); +#endif + + vendorID = (CFNumberRef)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDVendorIDKey)); + CFNumberGetValue(vendorID, kCFNumberIntType, &connection->v_id); + + productID = (CFNumberRef)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductIDKey)); + CFNumberGetValue(productID, kCFNumberIntType, &connection->p_id); connection->slot = apple_joypad_connect(device_name, connection); @@ -218,14 +229,14 @@ static bool hid_init_manager(void) static int hid_exit(void) { - if (g_hid_manager) - { - IOHIDManagerClose(g_hid_manager, kIOHIDOptionsTypeNone); - IOHIDManagerUnscheduleFromRunLoop(g_hid_manager, - CFRunLoopGetCurrent(), kCFRunLoopCommonModes); + if (!g_hid_manager) + return -1; - CFRelease(g_hid_manager); - } + IOHIDManagerClose(g_hid_manager, kIOHIDOptionsTypeNone); + IOHIDManagerUnscheduleFromRunLoop(g_hid_manager, + CFRunLoopGetCurrent(), kCFRunLoopCommonModes); + + CFRelease(g_hid_manager); g_hid_manager = NULL;