Add name for hid device; implement detect

== DETAILS

- detect() methods in device_* files now check for VID/PID
  instead of just returning false
- add "name" field on hid device, mainly for logging purposes

== TESTING
Verified my WiiU GC adapter detected properly
This commit is contained in:
gblues 2018-02-07 22:28:25 -08:00
parent ae19eed00f
commit 41ce8853d7
5 changed files with 12 additions and 6 deletions

View File

@ -18,9 +18,10 @@
static bool ds3_detect(uint16_t vendor_id, uint16_t product_id)
{
return false;
return vendor_id == VID_SONY && product_id == PID_SONY_DS3;
}
hid_device_t ds3_hid_device = {
ds3_detect
ds3_detect,
"Sony DualShock 3"
};

View File

@ -18,9 +18,10 @@
static bool ds4_detect(uint16_t vendor_id, uint16_t product_id)
{
return false;
return vendor_id == VID_SONY && product_id == PID_SONY_DS4;
}
hid_device_t ds4_hid_device = {
ds4_detect
ds4_detect,
"Sony DualShock 4"
};

View File

@ -17,9 +17,10 @@
#include "hid_device_driver.h"
static bool wiiu_gca_detect(uint16_t vendor_id, uint16_t product_id) {
return false;
return vendor_id == VID_NINTENDO && product_id == PID_NINTENDO_GCA;
}
hid_device_t wiiu_gca_hid_device = {
wiiu_gca_detect
wiiu_gca_detect,
"Wii U Gamecube Adapter"
};

View File

@ -18,9 +18,11 @@
#define HID_DEVICE_DRIVER__H
#include "../../input_driver.h"
#include "../../connect/joypad_connection.h"
typedef struct hid_device {
bool (*detect)(uint16_t vid, uint16_t pid);
const char *name;
} hid_device_t;
extern hid_device_t wiiu_gca_hid_device;

View File

@ -656,6 +656,7 @@ static wiiu_attach_event *new_attach_event(HIDDevice *device)
device->vid, device->pid);
return NULL;
}
RARCH_LOG("[hid]: Found HID device driver: %s\n", driver->name);
wiiu_attach_event *event = alloc_zeroed(4, sizeof(wiiu_attach_event));
if(!event)
return NULL;