mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 12:32:52 +00:00
More progress on the HID driver
== DETAILS I think I've about got the thread startup/teardown code worked out. Logically, anyway, if not accurately. The challenge has been figuring out how best to integrate the features of HID2VPAD. I found `input/connect/joypad_connection.c` and this seems like the logical place for: - Special-case driver for the Switch Pro controller - Any other special cases HIDTOVPAD supports that core RetroArch doesn't - Parsing of HIDTOVPAD config file to add custom button mapping == TESTING Compiles. Haven't tested with a real Wii U. Probably doesn't work though. I very likely have the threading bit wrong.
This commit is contained in:
parent
c3736adb77
commit
5c5e5be649
@ -32,19 +32,6 @@
|
|||||||
#define DEVICE_UNUSED 0
|
#define DEVICE_UNUSED 0
|
||||||
#define DEVICE_USED 1
|
#define DEVICE_USED 1
|
||||||
|
|
||||||
typedef struct wiiu_hid
|
|
||||||
{
|
|
||||||
HIDClient *client;
|
|
||||||
OSThread *polling_thread;
|
|
||||||
// memory accounting; keep a pointer to the stack buffer so we can clean up later.
|
|
||||||
void *polling_thread_stack;
|
|
||||||
volatile bool polling_thread_quit;
|
|
||||||
} wiiu_hid_t;
|
|
||||||
>>>>>>> Start implementing HID polling thread
|
|
||||||
|
|
||||||
#define DEVICE_UNUSED 0
|
|
||||||
#define DEVICE_USED 1
|
|
||||||
|
|
||||||
typedef struct wiiu_hid_user wiiu_hid_user_t;
|
typedef struct wiiu_hid_user wiiu_hid_user_t;
|
||||||
|
|
||||||
struct wiiu_hid_user
|
struct wiiu_hid_user
|
||||||
@ -64,7 +51,34 @@ typedef struct wiiu_hid
|
|||||||
// setting this to true tells the polling thread to quit
|
// setting this to true tells the polling thread to quit
|
||||||
volatile bool polling_thread_quit;
|
volatile bool polling_thread_quit;
|
||||||
} wiiu_hid_t;
|
} wiiu_hid_t;
|
||||||
|
>>>>>>> Start implementing HID polling thread
|
||||||
|
|
||||||
|
#define DEVICE_UNUSED 0
|
||||||
|
#define DEVICE_USED 1
|
||||||
|
|
||||||
|
typedef struct wiiu_hid_user wiiu_hid_user_t;
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
struct wiiu_hid_user
|
||||||
|
{
|
||||||
|
wiiu_hid_user_t *next;
|
||||||
|
uint8_t *buffer;
|
||||||
|
uint32_t transfersize;
|
||||||
|
uint32_t handle;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct wiiu_hid
|
||||||
|
{
|
||||||
|
HIDClient *client;
|
||||||
|
OSThread *polling_thread;
|
||||||
|
// memory accounting; keep a pointer to the stack buffer so we can clean up later.
|
||||||
|
void *polling_thread_stack;
|
||||||
|
// setting this to true tells the polling thread to quit
|
||||||
|
volatile bool polling_thread_quit;
|
||||||
|
} wiiu_hid_t;
|
||||||
|
|
||||||
|
=======
|
||||||
|
>>>>>>> More progress on the HID driver
|
||||||
/*
|
/*
|
||||||
* The attach/detach callback has no access to the wiiu_hid_t object. Therefore, we need a
|
* The attach/detach callback has no access to the wiiu_hid_t object. Therefore, we need a
|
||||||
* global place to handle device data.
|
* global place to handle device data.
|
||||||
@ -92,6 +106,8 @@ static void enqueue_device(void);
|
|||||||
=======
|
=======
|
||||||
>>>>>>> Start implementing HID polling thread
|
>>>>>>> Start implementing HID polling thread
|
||||||
|
|
||||||
|
static void enqueue_device(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HID driver entrypoints registered with hid_driver_t
|
* HID driver entrypoints registered with hid_driver_t
|
||||||
*/
|
*/
|
||||||
@ -186,6 +202,9 @@ static void wiiu_hid_free(void *data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
>>>>>>> More progress on the HID driver
|
||||||
static void free_pad_list(void) {
|
static void free_pad_list(void) {
|
||||||
wiiu_hid_user_t *top;
|
wiiu_hid_user_t *top;
|
||||||
|
|
||||||
@ -196,8 +215,11 @@ static void free_pad_list(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
=======
|
=======
|
||||||
>>>>>>> Start implementing HID polling thread
|
>>>>>>> Start implementing HID polling thread
|
||||||
|
=======
|
||||||
|
>>>>>>> More progress on the HID driver
|
||||||
/**
|
/**
|
||||||
* This is a no-op because polling is done with a worker thread.
|
* This is a no-op because polling is done with a worker thread.
|
||||||
*/
|
*/
|
||||||
@ -221,14 +243,20 @@ static void start_polling_thread(wiiu_hid_t *hid) {
|
|||||||
void *stack = memalign(32, stack_size);
|
void *stack = memalign(32, stack_size);
|
||||||
|
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
>>>>>>> More progress on the HID driver
|
||||||
if(pad_list_mutex == NULL) {
|
if(pad_list_mutex == NULL) {
|
||||||
pad_list_mutex = new_fastmutex("pad_list");
|
pad_list_mutex = new_fastmutex("pad_list");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!thread || !stack || !pad_list_mutex)
|
if(!thread || !stack || !pad_list_mutex)
|
||||||
|
<<<<<<< HEAD
|
||||||
=======
|
=======
|
||||||
if(!thread || !stack)
|
if(!thread || !stack)
|
||||||
>>>>>>> Start implementing HID polling thread
|
>>>>>>> Start implementing HID polling thread
|
||||||
|
=======
|
||||||
|
>>>>>>> More progress on the HID driver
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
if(!OSCreateThread(thread, wiiu_hid_polling_thread, 1, (char *)hid, stack, stack_size, priority, attributes))
|
if(!OSCreateThread(thread, wiiu_hid_polling_thread, 1, (char *)hid, stack, stack_size, priority, attributes))
|
||||||
@ -239,11 +267,16 @@ static void start_polling_thread(wiiu_hid_t *hid) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
|
<<<<<<< HEAD
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
if(pad_list_mutex)
|
if(pad_list_mutex)
|
||||||
delete_fastmutex(pad_list_mutex);
|
delete_fastmutex(pad_list_mutex);
|
||||||
=======
|
=======
|
||||||
>>>>>>> Start implementing HID polling thread
|
>>>>>>> Start implementing HID polling thread
|
||||||
|
=======
|
||||||
|
if(pad_list_mutex)
|
||||||
|
delete_fastmutex(pad_list_mutex);
|
||||||
|
>>>>>>> More progress on the HID driver
|
||||||
if(stack)
|
if(stack)
|
||||||
free(stack);
|
free(stack);
|
||||||
if(thread)
|
if(thread)
|
||||||
@ -264,13 +297,19 @@ static void stop_polling_thread(wiiu_hid_t *hid) {
|
|||||||
free(hid->polling_thread);
|
free(hid->polling_thread);
|
||||||
free(hid->polling_thread_stack);
|
free(hid->polling_thread_stack);
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
>>>>>>> More progress on the HID driver
|
||||||
|
|
||||||
// with the thread stopped, we don't need the mutex.
|
// with the thread stopped, we don't need the mutex.
|
||||||
delete_fastmutex(pad_list_mutex);
|
delete_fastmutex(pad_list_mutex);
|
||||||
pad_list_mutex = NULL;
|
pad_list_mutex = NULL;
|
||||||
free_pad_list();
|
free_pad_list();
|
||||||
|
<<<<<<< HEAD
|
||||||
=======
|
=======
|
||||||
>>>>>>> Start implementing HID polling thread
|
>>>>>>> Start implementing HID polling thread
|
||||||
|
=======
|
||||||
|
>>>>>>> More progress on the HID driver
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -293,6 +332,9 @@ static void wiiu_hid_do_poll(wiiu_hid_t *hid) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
<<<<<<< HEAD
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
>>>>>>> More progress on the HID driver
|
||||||
int32_t wiiu_attach_device(HIDClient *client, HIDDevice *device) {
|
int32_t wiiu_attach_device(HIDClient *client, HIDDevice *device) {
|
||||||
wiiu_hid_user_t *adapter = new_wiiu_hid_user_t();
|
wiiu_hid_user_t *adapter = new_wiiu_hid_user_t();
|
||||||
|
|
||||||
@ -310,8 +352,11 @@ int32_t wiiu_detach_device(HIDClient *client, HIDDevice *device) {
|
|||||||
return DEVICE_UNUSED;
|
return DEVICE_UNUSED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
=======
|
=======
|
||||||
>>>>>>> Start implementing HID polling thread
|
>>>>>>> Start implementing HID polling thread
|
||||||
|
=======
|
||||||
|
>>>>>>> More progress on the HID driver
|
||||||
/**
|
/**
|
||||||
* Callbacks
|
* Callbacks
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user