Skip to content

Commit 8f74d26

Browse files
authored
Fix registered Wiimotes unable to get active slot (#226)
1 parent ca84f9d commit 8f74d26

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

wiiuse/wpad.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,7 @@ static s8 __wpad_connreqCB(void *arg,struct bd_addr *pad_addr,u8 *cod,u8 link_ty
938938
{
939939
int i, j, level;
940940
int slot = WPAD_MAX_DEVICES;
941+
int confslot = CONF_PAD_MAX_ACTIVE;
941942
struct bd_addr bdaddr;
942943
u8 *name = NULL;
943944

@@ -947,10 +948,14 @@ static s8 __wpad_connreqCB(void *arg,struct bd_addr *pad_addr,u8 *cod,u8 link_ty
947948
// Only accept connection requests (i.e. "press any button") if not doing guest pairing
948949
if(BTE_GetPairMode() == PAIR_MODE_NORMAL) {
949950
if(!bd_addr_cmp(pad_addr,BD_ADDR_ANY)) {
950-
slot = GetActiveSlot(pad_addr);
951-
if (slot < CONF_PAD_MAX_ACTIVE) {
952-
name = (u8 *)__wpad_devs.active[slot].name;
953-
WIIUSE_DEBUG("Active pad '%s' found in slot %d", name, slot);
951+
confslot = GetActiveSlot(pad_addr);
952+
if (confslot < CONF_PAD_MAX_ACTIVE) {
953+
name = (u8 *)__wpad_devs.active[confslot].name;
954+
WIIUSE_DEBUG("Active pad '%s' found in slot %d", name, confslot);
955+
if (!(__wpads_used & (1<<confslot)))
956+
slot = confslot;
957+
else
958+
WIIUSE_DEBUG("Slot %d taken! Finding new slot", confslot);
954959
}
955960

956961
if(slot >= WPAD_MAX_DEVICES) {

0 commit comments

Comments
 (0)