diff --git a/SwitchProParser.h b/SwitchProParser.h index c600147a..c8336eb7 100644 --- a/SwitchProParser.h +++ b/SwitchProParser.h @@ -185,25 +185,43 @@ public: /** Set rumble off. */ void setRumbleOff() { - setRumbleOn(0, 0); + setRumble(false, false); } /** Toggle rumble. */ void setRumbleToggle() { - setRumbleOn(!switchProOutput.leftRumbleOn, !switchProOutput.rightRumbleOn); + setRumble(!switchProOutput.leftRumbleOn, !switchProOutput.rightRumbleOn); } /** - * Turn on rumble. - * @param leftRumbleOn Turn on left rumble motor. - * @param rightRumbleOn Turn on right rumble motor. + * Turn on/off rumble. + * @param leftRumbleOn Turn on/off left rumble motor. + * @param rightRumbleOn Turn on/off right rumble motor. */ - void setRumbleOn(bool leftRumbleOn, bool rightRumbleOn) { + void setRumble(bool leftRumbleOn, bool rightRumbleOn) { switchProOutput.leftRumbleOn = leftRumbleOn; switchProOutput.rightRumbleOn = rightRumbleOn; switchProOutput.ledReportChanged = true; // Set this, so the rumble effect gets changed immediately } + /** + * Turn on/off the left rumble. + * @param on Turn on/off left rumble motor. + */ + void setRumbleLeft(bool on) { + switchProOutput.leftRumbleOn = on; + switchProOutput.ledReportChanged = true; // Set this, so the rumble effect gets changed immediately + } + + /** + * Turn on/off the right rumble. + * @param on Turn on/off right rumble motor. + */ + void setRumbleRight(bool on) { + switchProOutput.rightRumbleOn = on; + switchProOutput.ledReportChanged = true; // Set this, so the rumble effect gets changed immediately + } + /** * Set LED value without using the ::LEDEnum. * This can also be used to flash the LEDs by setting the high 4-bits of the mask. diff --git a/examples/Bluetooth/SwitchPro/SwitchPro.ino b/examples/Bluetooth/SwitchPro/SwitchPro.ino index add2d002..75a0eb83 100644 --- a/examples/Bluetooth/SwitchPro/SwitchPro.ino +++ b/examples/Bluetooth/SwitchPro/SwitchPro.ino @@ -73,7 +73,7 @@ void loop() { Serial.print(F("\r\nCapture")); if (SwitchPro.getButtonClick(HOME)) { Serial.print(F("\r\nHome")); - SwitchPro.setLedHomeToggle(); // Toggle the home LED + SwitchPro.setLedHomeToggle(); } if (SwitchPro.getButtonClick(LEFT)) { @@ -102,29 +102,31 @@ void loop() { if (SwitchPro.getButtonClick(MINUS)) Serial.print(F("\r\nMinus")); - if (SwitchPro.getButtonClick(A)) { - SwitchPro.setRumbleOn(false, true); // Turn on the right rumble motor + if (SwitchPro.getButtonClick(A)) Serial.print(F("\r\nA")); - } - if (SwitchPro.getButtonClick(B)) { - SwitchPro.setRumbleOn(true, false); // Turn on the left rumble motor + if (SwitchPro.getButtonClick(B)) Serial.print(F("\r\nB")); - } if (SwitchPro.getButtonClick(X)) Serial.print(F("\r\nX")); - if (SwitchPro.getButtonClick(Y)) { - SwitchPro.setRumbleOn(false, false); + if (SwitchPro.getButtonClick(Y)) Serial.print(F("\r\nY")); - } - if (SwitchPro.getButtonClick(L)) + if (SwitchPro.getButtonClick(L)) { + SwitchPro.setRumbleLeft(false); Serial.print(F("\r\nL")); - if (SwitchPro.getButtonClick(R)) + } + if (SwitchPro.getButtonClick(R)) { + SwitchPro.setRumbleRight(false); Serial.print(F("\r\nR")); - if (SwitchPro.getButtonClick(ZL)) + } + if (SwitchPro.getButtonClick(ZL)) { + SwitchPro.setRumbleLeft(true); Serial.print(F("\r\nZL")); - if (SwitchPro.getButtonClick(ZR)) + } + if (SwitchPro.getButtonClick(ZR)) { + SwitchPro.setRumbleRight(true); Serial.print(F("\r\nZR")); + } if (SwitchPro.getButtonClick(L3)) Serial.print(F("\r\nL3")); if (SwitchPro.getButtonClick(R3))