mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 12:40:23 +00:00
commit
768be8b9c8
@ -24,22 +24,22 @@
|
||||
|
||||
#include "joypad_connection.h"
|
||||
|
||||
static bool joypad_is_end_of_list(joypad_connection_t *pad);
|
||||
|
||||
int pad_connection_find_vacant_pad(joypad_connection_t *joyconn)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned i;
|
||||
|
||||
if (!joyconn)
|
||||
return -1;
|
||||
if (!joyconn)
|
||||
return -1;
|
||||
|
||||
for (i = 0; i < MAX_USERS; i++)
|
||||
{
|
||||
joypad_connection_t *conn = &joyconn[i];
|
||||
for (i = 0; !joypad_is_end_of_list(&joyconn[i]); i++)
|
||||
{
|
||||
if(!joyconn[i].connected)
|
||||
return i;
|
||||
}
|
||||
|
||||
if (conn && !conn->connected)
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
return -1;
|
||||
}
|
||||
|
||||
static void set_end_of_list(joypad_connection_t *list, unsigned end)
|
||||
@ -62,6 +62,14 @@ static bool joypad_is_end_of_list(joypad_connection_t *pad) {
|
||||
joypad_connection_t *pad_connection_init(unsigned pads)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
if(pads > MAX_USERS)
|
||||
{
|
||||
RARCH_WARN("[joypad] invalid number of pads requested (%d), using default (%d)\n",
|
||||
pads, MAX_USERS);
|
||||
pads = MAX_USERS;
|
||||
}
|
||||
|
||||
joypad_connection_t *joyconn = (joypad_connection_t*)
|
||||
calloc(pads+1, sizeof(joypad_connection_t));
|
||||
|
||||
@ -226,13 +234,8 @@ void pad_connection_destroy(joypad_connection_t *joyconn)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < MAX_USERS; i ++)
|
||||
{
|
||||
if(joypad_is_end_of_list(&joyconn[i]))
|
||||
break;
|
||||
|
||||
for (i = 0; !joypad_is_end_of_list(&joyconn[i]); i ++)
|
||||
pad_connection_pad_deinit(&joyconn[i], i);
|
||||
}
|
||||
|
||||
free(joyconn);
|
||||
}
|
||||
|
@ -425,6 +425,7 @@ static void wiiu_hid_read_loop_callback(uint32_t handle, int32_t error,
|
||||
*/
|
||||
static void wiiu_hid_polling_thread_cleanup(OSThread *thread, void *stack) {
|
||||
int incomplete = 0;
|
||||
int retries = 0;
|
||||
wiiu_adapter_t *adapter;
|
||||
RARCH_LOG("Waiting for in-flight reads to finish.\n");
|
||||
do {
|
||||
@ -446,8 +447,11 @@ static void wiiu_hid_polling_thread_cleanup(OSThread *thread, void *stack) {
|
||||
}
|
||||
OSFastMutex_Unlock(&(adapters.lock));
|
||||
if(incomplete) {
|
||||
RARCH_LOG("%d unfinished adapters found, waiting 1ms\n", incomplete);
|
||||
usleep(1000);
|
||||
usleep(5000);
|
||||
}
|
||||
if(++retries >= 1000) {
|
||||
RARCH_WARN("[hid]: timed out waiting for in-flight read to finish.\n");
|
||||
incomplete = 0;
|
||||
}
|
||||
} while(incomplete);
|
||||
RARCH_LOG("All in-flight reads complete.\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user