mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-15 14:59:37 +00:00
implement hid device search
This commit is contained in:
parent
ecd42f1aa8
commit
ae19eed00f
@ -6,7 +6,7 @@ DEBUG = 0
|
||||
GRIFFIN_BUILD = 0
|
||||
SALAMANDER_BUILD = 0
|
||||
WHOLE_ARCHIVE_LINK = 0
|
||||
WIIU_HID = 0
|
||||
WIIU_HID = 1
|
||||
WIIU_LOG_RPX = 0
|
||||
BUILD_DIR = objs/wiiu
|
||||
PC_DEVELOPMENT_IP_ADDRESS ?=
|
||||
@ -56,7 +56,11 @@ ifeq ($(WIIU_HID),1)
|
||||
input/connect/connect_nesusb.o \
|
||||
input/connect/connect_snesusb.o \
|
||||
input/connect/connect_wiiupro.o \
|
||||
input/connect/connect_wiiugca.o
|
||||
input/connect/connect_wiiugca.o \
|
||||
input/common/hid/hid_device_driver.o \
|
||||
input/common/hid/device_wiiu_gca.o \
|
||||
input/common/hid/device_ds3.o \
|
||||
input/common/hid/device_ds4.o
|
||||
endif
|
||||
|
||||
ifeq ($(SALAMANDER_BUILD),1)
|
||||
|
26
input/common/hid/device_ds3.c
Normal file
26
input/common/hid/device_ds3.c
Normal file
@ -0,0 +1,26 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "hid_device_driver.h"
|
||||
|
||||
static bool ds3_detect(uint16_t vendor_id, uint16_t product_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
hid_device_t ds3_hid_device = {
|
||||
ds3_detect
|
||||
};
|
26
input/common/hid/device_ds4.c
Normal file
26
input/common/hid/device_ds4.c
Normal file
@ -0,0 +1,26 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "hid_device_driver.h"
|
||||
|
||||
static bool ds4_detect(uint16_t vendor_id, uint16_t product_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
hid_device_t ds4_hid_device = {
|
||||
ds4_detect
|
||||
};
|
25
input/common/hid/device_wiiu_gca.c
Normal file
25
input/common/hid/device_wiiu_gca.c
Normal file
@ -0,0 +1,25 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "hid_device_driver.h"
|
||||
|
||||
static bool wiiu_gca_detect(uint16_t vendor_id, uint16_t product_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
hid_device_t wiiu_gca_hid_device = {
|
||||
wiiu_gca_detect
|
||||
};
|
36
input/common/hid/hid_device_driver.c
Normal file
36
input/common/hid/hid_device_driver.c
Normal file
@ -0,0 +1,36 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "hid_device_driver.h"
|
||||
|
||||
hid_device_t *hid_device_list[] = {
|
||||
&wiiu_gca_hid_device,
|
||||
&ds3_hid_device,
|
||||
&ds4_hid_device,
|
||||
NULL /* must be last entry in list */
|
||||
};
|
||||
|
||||
hid_device_t *hid_device_driver_lookup(uint16_t vendor_id, uint16_t product_id) {
|
||||
int i = 0;
|
||||
|
||||
for(i = 0; hid_device_list[i] != NULL; i++) {
|
||||
if(hid_device_list[i]->detect(vendor_id, product_id))
|
||||
return hid_device_list[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
32
input/common/hid/hid_device_driver.h
Normal file
32
input/common/hid/hid_device_driver.h
Normal file
@ -0,0 +1,32 @@
|
||||
/* RetroArch - A frontend for libretro.
|
||||
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
|
||||
* Copyright (C) 2011-2017 - Daniel De Matteis
|
||||
*
|
||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||
* of the GNU General Public License as published by the Free Software Found-
|
||||
* ation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||
* If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef HID_DEVICE_DRIVER__H
|
||||
#define HID_DEVICE_DRIVER__H
|
||||
|
||||
#include "../../input_driver.h"
|
||||
|
||||
typedef struct hid_device {
|
||||
bool (*detect)(uint16_t vid, uint16_t pid);
|
||||
} hid_device_t;
|
||||
|
||||
extern hid_device_t wiiu_gca_hid_device;
|
||||
extern hid_device_t ds3_hid_device;
|
||||
extern hid_device_t ds4_hid_device;
|
||||
|
||||
hid_device_t *hid_device_driver_lookup(uint16_t vendor_id, uint16_t product_id);
|
||||
|
||||
#endif /* HID_DEVICE_DRIVER__H */
|
@ -31,6 +31,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "../../input/input_driver.h"
|
||||
#include "../../input/common/hid/hid_device_driver.h"
|
||||
#include "../../input/connect/joypad_connection.h"
|
||||
#include "../../tasks/tasks_internal.h"
|
||||
#include "../../retroarch.h"
|
||||
@ -149,6 +150,7 @@ typedef struct wiiu_attach wiiu_attach_event;
|
||||
|
||||
struct wiiu_attach {
|
||||
wiiu_attach_event *next;
|
||||
hid_device_t *driver;
|
||||
uint32_t type;
|
||||
uint32_t handle;
|
||||
uint16_t vendor_id;
|
||||
|
@ -649,10 +649,18 @@ static void delete_adapter(wiiu_adapter_t *adapter)
|
||||
|
||||
static wiiu_attach_event *new_attach_event(HIDDevice *device)
|
||||
{
|
||||
hid_device_t *driver = hid_device_driver_lookup(device->vid, device->pid);
|
||||
if(!driver)
|
||||
{
|
||||
RARCH_ERR("[hid]: Failed to locate driver for device vid=%04x pid=%04x\n",
|
||||
device->vid, device->pid);
|
||||
return NULL;
|
||||
}
|
||||
wiiu_attach_event *event = alloc_zeroed(4, sizeof(wiiu_attach_event));
|
||||
if(!event)
|
||||
return NULL;
|
||||
|
||||
event->driver = driver;
|
||||
event->handle = device->handle;
|
||||
event->vendor_id = device->vid;
|
||||
event->product_id = device->pid;
|
||||
|
Loading…
Reference in New Issue
Block a user