mirror of
https://github.com/limyz/573controller
synced 2024-11-27 17:00:58 +01:00
Optimize code slightly
This commit is contained in:
parent
9849b5c7f2
commit
4f9a699823
@ -94,23 +94,7 @@ void loop() {
|
||||
for (int index = 0; index < 5; index++) {
|
||||
int currentButtonState = !digitalRead(index + pinToButtonMap);
|
||||
if (currentButtonState != lastButtonState[index]) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
Joystick.setButton(0, currentButtonState);
|
||||
break;
|
||||
case 1:
|
||||
Joystick.setButton(1, currentButtonState);
|
||||
break;
|
||||
case 2:
|
||||
Joystick.setButton(2, currentButtonState);
|
||||
break;
|
||||
case 3:
|
||||
Joystick.setButton(3, currentButtonState);
|
||||
break;
|
||||
case 4:
|
||||
Joystick.setButton(4, currentButtonState);
|
||||
break;
|
||||
}
|
||||
Joystick.setButton(index, currentButtonState);
|
||||
lastButtonState[index] = currentButtonState;
|
||||
}
|
||||
}
|
||||
|
@ -84,23 +84,7 @@ void loop() {
|
||||
for (int index = 0; index < 5; index++) {
|
||||
int currentButtonState = !digitalRead(index + pinToButtonMap);
|
||||
if (currentButtonState != lastButtonState[index]) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
Joystick.setButton(0, currentButtonState);
|
||||
break;
|
||||
case 1:
|
||||
Joystick.setButton(1, currentButtonState);
|
||||
break;
|
||||
case 2:
|
||||
Joystick.setButton(2, currentButtonState);
|
||||
break;
|
||||
case 3:
|
||||
Joystick.setButton(3, currentButtonState);
|
||||
break;
|
||||
case 4:
|
||||
Joystick.setButton(4, currentButtonState);
|
||||
break;
|
||||
}
|
||||
Joystick.setButton(index, currentButtonState);
|
||||
lastButtonState[index] = currentButtonState;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user