Skip to content

Commit 8090843

Browse files
committed
WiiClassicController example: loop reconnection
Strictly speaking there's no reason to call 'update' if the controller isn't connected. Better to loop that and make it more obvious what's going on.
1 parent 9a29ba9 commit 8090843

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

examples/WiiClassicController/WiiClassicController.ino

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,15 @@ void loop() {
7878

7979
// XInput.setButton(BUTTON_L3, classic.buttonZL()); // The Classic Controller doesn't have L3 and R3
8080
// XInput.setButton(BUTTON_R3, classic.buttonZR()); // but you can uncomment these to check that they work
81+
82+
XInput.send();
8183
}
8284
else { // Data is bad :(
83-
XInput.releaseAll(); // clear set inputs
84-
classic.connect(); // attempt to reconnect
85-
delay(1000);
86-
}
85+
XInput.releaseAll(); // clear set inputs...
86+
XInput.send(); // ...and send that update
8787

88-
XInput.send();
88+
while (!classic.connect()) { // attempt to reconnect
89+
delay(1000);
90+
}
91+
}
8992
}

0 commit comments

Comments
 (0)