From 5b4b766459426ee370ed64d08744f7e7a46be31a Mon Sep 17 00:00:00 2001 From: Nathan Strong Date: Sat, 16 Oct 2021 23:56:15 -0700 Subject: [PATCH] Fix wiimotes regression == DETAILS - only call disconnect when we're actually disconnecting a remote (e.g. read errors or remote goes to sleep). - clean up some compile warnings introduced by others (mainly unused variables) --- input/drivers_joypad/wiiu/kpad_driver.c | 20 +++++++++++++++----- retroarch.c | 17 +++++++---------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/input/drivers_joypad/wiiu/kpad_driver.c b/input/drivers_joypad/wiiu/kpad_driver.c index 96aca4a233..aa3efeeeef 100644 --- a/input/drivers_joypad/wiiu/kpad_driver.c +++ b/input/drivers_joypad/wiiu/kpad_driver.c @@ -149,8 +149,15 @@ static void kpad_register(unsigned channel, uint8_t device_type) { int slot; - kpad_deregister(channel); - slot = get_slot_for_channel(channel); + if(device_type == WIIMOTE_TYPE_NONE) { + kpad_deregister(channel); + return; + } + + slot = joypad_state.kpad.channel_slot_map[channel]; + if(slot < 0) { + slot = get_slot_for_channel(channel); + } if (slot < 0) { @@ -158,8 +165,10 @@ static void kpad_register(unsigned channel, uint8_t device_type) return; } - joypad_state.kpad.wiimotes[channel].type = device_type; - joypad_state.pads[slot].input_driver = &kpad_driver; + joypad_state.kpad.wiimotes[channel].type = device_type; + joypad_state.kpad.channel_slot_map[channel] = slot; + joypad_state.pads[slot].input_driver = &kpad_driver; + joypad_state.pads[slot].connected = true; input_pad_connect(slot, &kpad_driver); } } @@ -232,8 +241,9 @@ static void kpad_poll(void) if (result == 0) { joypad_state.kpad.poll_failures[channel]++; - if (joypad_state.kpad.poll_failures[channel] > 5) + if (joypad_state.kpad.poll_failures[channel] > 5) { kpad_deregister(channel); + } continue; } joypad_state.kpad.poll_failures[channel] = 0; diff --git a/retroarch.c b/retroarch.c index b8b1c67cb7..f072e28330 100644 --- a/retroarch.c +++ b/retroarch.c @@ -262,8 +262,8 @@ #define RUNLOOP_MSG_QUEUE_LOCK(runloop_st) slock_lock((runloop_st)->msg_queue_lock) #define RUNLOOP_MSG_QUEUE_UNLOCK(runloop_st) slock_unlock((runloop_st)->msg_queue_lock) #else -#define RUNLOOP_MSG_QUEUE_LOCK(runloop_st) -#define RUNLOOP_MSG_QUEUE_UNLOCK(runloop_st) +#define RUNLOOP_MSG_QUEUE_LOCK(runloop_st) (void)(runloop_st) +#define RUNLOOP_MSG_QUEUE_UNLOCK(runloop_st) (void)(runloop_st) #endif /* Custom forward declarations */ @@ -5793,14 +5793,13 @@ static bool command_event_disk_control_append_image( rarch_system_info_t *sys_info, const char *path) { - runloop_state_t *runloop_st = &runloop_state; input_driver_state_t *input_st = input_state_get_ptr(); if ( !sys_info || !disk_control_append_image(&sys_info->disk_control, path)) return false; #ifdef HAVE_THREADS - if (runloop_st->use_sram) + if (runloop_state.use_sram) autosave_deinit(); #endif @@ -16924,8 +16923,6 @@ static void do_runahead( #else const bool have_dynamic = false; #endif - runloop_state_t - *runloop_st = &runloop_state; video_driver_state_t *video_st = video_state_get_ptr(); uint64_t frame_count = video_st->frame_count; @@ -17018,7 +17015,7 @@ static void do_runahead( if ( runloop_st->input_is_dirty || p_rarch->runahead_force_input_dirty) { - runloop_st->input_is_dirty = false; + runloop_state.input_is_dirty = false; if (!runahead_save_state(p_rarch)) { @@ -19053,12 +19050,12 @@ static void retroarch_fail(struct rarch_state *p_rarch, bool retroarch_main_quit(void) { - struct rarch_state *p_rarch = &rarch_st; runloop_state_t *runloop_st = &runloop_state; video_driver_state_t*video_st = video_state_get_ptr(); settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); #ifdef HAVE_DISCORD + struct rarch_state *p_rarch = &rarch_st; discord_state_t *discord_st = &p_rarch->discord_st; if (discord_is_inited) { @@ -21229,9 +21226,9 @@ bool core_unset_netplay_callbacks(void) bool core_set_cheat(retro_ctx_cheat_info_t *info) { - struct rarch_state *p_rarch = &rarch_st; runloop_state_t *runloop_st = &runloop_state; #if defined(HAVE_RUNAHEAD) && (defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)) + struct rarch_state *p_rarch = &rarch_st; settings_t *settings = config_get_ptr(); bool run_ahead_enabled = false; unsigned run_ahead_frames = 0; @@ -21267,9 +21264,9 @@ bool core_set_cheat(retro_ctx_cheat_info_t *info) bool core_reset_cheat(void) { - struct rarch_state *p_rarch = &rarch_st; runloop_state_t *runloop_st = &runloop_state; #if defined(HAVE_RUNAHEAD) && (defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)) + struct rarch_state *p_rarch = &rarch_st; settings_t *settings = config_get_ptr(); bool run_ahead_enabled = false; unsigned run_ahead_frames = 0;