(Apple HID) Get vendor ID/product ID too
This commit is contained in:
parent
d7fe629afa
commit
a0f24d0bb2
|
@ -73,6 +73,7 @@ int32_t apple_joypad_connect(const char* name, void *data)
|
||||||
} pad_map[] =
|
} pad_map[] =
|
||||||
{
|
{
|
||||||
{ "Nintendo RVL-CNT-01", &apple_pad_wii },
|
{ "Nintendo RVL-CNT-01", &apple_pad_wii },
|
||||||
|
{ "Nintendo RVL-CNT-01-UC", &apple_pad_wii },
|
||||||
{ "PLAYSTATION(R)3 Controller", &apple_pad_ps3 },
|
{ "PLAYSTATION(R)3 Controller", &apple_pad_ps3 },
|
||||||
{ 0, 0}
|
{ 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 apple_joypad_connect_gcapi(void)
|
||||||
{
|
{
|
||||||
int32_t slot;
|
int32_t slot = find_empty_slot();
|
||||||
slot = find_empty_slot();
|
|
||||||
|
|
||||||
if (slot >= 0 && slot < MAX_PLAYERS)
|
if (slot >= 0 && slot < MAX_PLAYERS)
|
||||||
{
|
{
|
||||||
joypad_slot_t *s = (joypad_slot_t*)&slots[slot];
|
joypad_slot_t *s = (joypad_slot_t*)&slots[slot];
|
||||||
|
|
||||||
s->used = true;
|
s->used = true;
|
||||||
s->is_gcapi = 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)
|
if (slot < MAX_PLAYERS && slots[slot].used)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
struct apple_pad_connection
|
struct apple_pad_connection
|
||||||
{
|
{
|
||||||
|
int v_id;
|
||||||
|
int p_id;
|
||||||
uint32_t slot;
|
uint32_t slot;
|
||||||
IOHIDDeviceRef device_handle;
|
IOHIDDeviceRef device_handle;
|
||||||
uint8_t data[2048];
|
uint8_t data[2048];
|
||||||
|
@ -128,6 +130,7 @@ static void hid_manager_device_attached(void* context, IOReturn result,
|
||||||
{
|
{
|
||||||
char device_name[PATH_MAX];
|
char device_name[PATH_MAX];
|
||||||
CFStringRef device_name_ref;
|
CFStringRef device_name_ref;
|
||||||
|
CFNumberRef vendorID, productID;
|
||||||
struct apple_pad_connection* connection = (struct apple_pad_connection*)
|
struct apple_pad_connection* connection = (struct apple_pad_connection*)
|
||||||
calloc(1, sizeof(*connection));
|
calloc(1, sizeof(*connection));
|
||||||
|
|
||||||
|
@ -141,9 +144,17 @@ static void hid_manager_device_attached(void* context, IOReturn result,
|
||||||
kCFRunLoopCommonModes);
|
kCFRunLoopCommonModes);
|
||||||
IOHIDDeviceRegisterRemovalCallback(device, hid_device_removed, connection);
|
IOHIDDeviceRegisterRemovalCallback(device, hid_device_removed, connection);
|
||||||
|
|
||||||
|
#ifndef IOS
|
||||||
device_name_ref = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductKey));
|
device_name_ref = IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductKey));
|
||||||
CFStringGetCString(device_name_ref, device_name,
|
CFStringGetCString(device_name_ref, device_name,
|
||||||
sizeof(device_name), kCFStringEncodingUTF8);
|
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);
|
connection->slot = apple_joypad_connect(device_name, connection);
|
||||||
|
|
||||||
|
@ -218,14 +229,14 @@ static bool hid_init_manager(void)
|
||||||
|
|
||||||
static int hid_exit(void)
|
static int hid_exit(void)
|
||||||
{
|
{
|
||||||
if (g_hid_manager)
|
if (!g_hid_manager)
|
||||||
{
|
return -1;
|
||||||
|
|
||||||
IOHIDManagerClose(g_hid_manager, kIOHIDOptionsTypeNone);
|
IOHIDManagerClose(g_hid_manager, kIOHIDOptionsTypeNone);
|
||||||
IOHIDManagerUnscheduleFromRunLoop(g_hid_manager,
|
IOHIDManagerUnscheduleFromRunLoop(g_hid_manager,
|
||||||
CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
|
CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
|
||||||
|
|
||||||
CFRelease(g_hid_manager);
|
CFRelease(g_hid_manager);
|
||||||
}
|
|
||||||
|
|
||||||
g_hid_manager = NULL;
|
g_hid_manager = NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue