Skip to content

Commit 24c137d

Browse files
authored
wiimote: Clear used wiimotes on shutdown (#228)
* Properly clear used/active Wiimote bitmask * Ensure slot can always be taken by proper owner
1 parent 8f74d26 commit 24c137d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

wiiuse/wpad.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,9 +950,10 @@ static s8 __wpad_connreqCB(void *arg,struct bd_addr *pad_addr,u8 *cod,u8 link_ty
950950
if(!bd_addr_cmp(pad_addr,BD_ADDR_ANY)) {
951951
confslot = GetActiveSlot(pad_addr);
952952
if (confslot < CONF_PAD_MAX_ACTIVE) {
953+
BD_ADDR_FROM_BYTES(&bdaddr,__wpad_devs.active[confslot].bdaddr);
953954
name = (u8 *)__wpad_devs.active[confslot].name;
954955
WIIUSE_DEBUG("Active pad '%s' found in slot %d", name, confslot);
955-
if (!(__wpads_used & (1<<confslot)))
956+
if (!(__wpads_used & (1<<confslot)) || bd_addr_cmp(pad_addr,&bdaddr))
956957
slot = confslot;
957958
else
958959
WIIUSE_DEBUG("Slot %d taken! Finding new slot", confslot);
@@ -1738,6 +1739,9 @@ s32 WPAD_Shutdown(void)
17381739
__wpads_listen[i].sock = NULL;
17391740
}
17401741

1742+
__wpads_active = 0;
1743+
__wpads_used = 0;
1744+
17411745
__wiiuse_sensorbar_enable(0);
17421746
_CPU_ISR_Restore(level);
17431747

0 commit comments

Comments
 (0)