Add VID/PID detection for joypad connection

This commit is contained in:
twinaphex 2015-04-03 23:30:39 +02:00
parent ffffe3c1e7
commit 5e83eefd81
5 changed files with 15 additions and 10 deletions

View File

@ -533,7 +533,7 @@ void btpad_packet_handler(uint8_t packet_type,
RARCH_LOG("[BTpad]: Got %.200s.\n", (char*)&packet[9]);
connection->slot = pad_connection_pad_init(&slots[connection->slot],
(char*)packet + 9, connection, &btpad_connection_send_control);
(char*)packet + 9, 0, 0, connection, &btpad_connection_send_control);
connection->state = BTPAD_CONNECTED;
}
break;

View File

@ -58,7 +58,8 @@ void *pad_connection_init(unsigned pads)
}
int32_t pad_connection_pad_init(joypad_connection_t *joyconn,
const char* name, void *data, send_control_t ptr)
const char* name, uint16_t vid, uint16_t pid,
void *data, send_control_t ptr)
{
int pad = pad_connection_find_vacant_pad(joyconn);
@ -69,15 +70,17 @@ int32_t pad_connection_pad_init(joypad_connection_t *joyconn,
static const struct
{
const char* name;
uint16_t vid;
uint16_t pid;
pad_connection_interface_t *iface;
} pad_map[] =
{
{ "Nintendo RVL-CNT-01", &pad_connection_wii },
{ "Nintendo RVL-CNT-01", 1406, 816, &pad_connection_wii },
#if 0
{ "Nintendo RVL-CNT-01-UC", &pad_connection_wii_u },
{ "Nintendo RVL-CNT-01-UC", 0, 0, &pad_connection_wii_u },
#endif
{ "Wireless Controller", &pad_connection_ps4 },
{ "PLAYSTATION(R)3 Controller", &pad_connection_ps3 },
{ "Wireless Controller", 1356, 1476, &pad_connection_ps4 },
{ "PLAYSTATION(R)3 Controller", 1356, 616, &pad_connection_ps3 },
{ 0, 0}
};
@ -85,7 +88,8 @@ int32_t pad_connection_pad_init(joypad_connection_t *joyconn,
{
for (i = 0; name && pad_map[i].name; i++)
{
if (!strstr(name, pad_map[i].name))
if ( (!strstr(name, pad_map[i].name))
|| (pad_map[i].vid == vid && pad_map[i].pid == pid))
continue;
s->iface = pad_map[i].iface;

View File

@ -48,7 +48,8 @@ typedef struct joypad_connection
} joypad_connection_t;
int32_t pad_connection_pad_init(joypad_connection_t *joyconn,
const char* name, void *data, send_control_t ptr);
const char* name, uint16_t vid, uint16_t pid,
void *data, send_control_t ptr);
int32_t apple_joypad_connect_gcapi(joypad_connection_t *joyconn);

View File

@ -318,7 +318,7 @@ static void apple_hid_device_add(void *data, IOReturn result,
dev_pid = apple_hid_device_get_product_id (device);
adapter->slot = pad_connection_pad_init(hid->slots,
adapter->name, adapter, &apple_hid_device_send_control);
adapter->name, dev_vid, dev_pid, adapter, &apple_hid_device_send_control);
if (pad_connection_has_interface(hid->slots, adapter->slot))
IOHIDDeviceRegisterInputReportCallback(device,

View File

@ -188,7 +188,7 @@ static int add_adapter(void *data, struct libusb_device *dev)
device_name = (const char*)adapter->name;
adapter->slot = pad_connection_pad_init(hid->slots,
device_name, adapter, &libusb_hid_device_send_control);
device_name, desc.idVendor, desc.idProduct, adapter, &libusb_hid_device_send_control);
libusb_get_description(adapter->device, &adapter->interface_number);