Change Xbox LT/LB/RT/RB references in examples

This commit is contained in:
David Madison 2021-07-01 05:08:07 -04:00
parent 680ddcfc9d
commit 135608c0ce
5 changed files with 62 additions and 62 deletions

View file

@ -97,13 +97,13 @@ void loop() {
Serial.print(F("Y: "));
Serial.println(Xbox.getButtonPress(Y));
}
if (Xbox.getButtonPress(L1)) {
Serial.print(F("L1: "));
Serial.println(Xbox.getButtonPress(L1));
if (Xbox.getButtonPress(LT)) {
Serial.print(F("LT: "));
Serial.println(Xbox.getButtonPress(LT));
}
if (Xbox.getButtonPress(R1)) {
Serial.print(F("R1: "));
Serial.println(Xbox.getButtonPress(R1));
if (Xbox.getButtonPress(RT)) {
Serial.print(F("RT: "));
Serial.println(Xbox.getButtonPress(RT));
}
}
delay(1);

View file

@ -49,15 +49,15 @@ void loop() {
Serial.println();
}
if (Xbox.getButtonPress(L2) > 0 || Xbox.getButtonPress(R2) > 0) {
if (Xbox.getButtonPress(L2) > 0) {
Serial.print(F("L2: "));
Serial.print(Xbox.getButtonPress(L2));
if (Xbox.getButtonPress(LT) > 0 || Xbox.getButtonPress(RT) > 0) {
if (Xbox.getButtonPress(LT) > 0) {
Serial.print(F("LT: "));
Serial.print(Xbox.getButtonPress(LT));
Serial.print("\t");
}
if (Xbox.getButtonPress(R2) > 0) {
Serial.print(F("R2: "));
Serial.print(Xbox.getButtonPress(R2));
if (Xbox.getButtonPress(RT) > 0) {
Serial.print(F("RT: "));
Serial.print(Xbox.getButtonPress(RT));
Serial.print("\t");
}
Serial.println();
@ -94,14 +94,14 @@ void loop() {
if (Xbox.getButtonClick(SYNC))
Serial.println(F("Sync"));
if (Xbox.getButtonClick(L1))
Serial.println(F("L1"));
if (Xbox.getButtonClick(R1))
Serial.println(F("R1"));
if (Xbox.getButtonClick(L2))
Serial.println(F("L2"));
if (Xbox.getButtonClick(R2))
Serial.println(F("R2"));
if (Xbox.getButtonClick(LB))
Serial.println(F("LB"));
if (Xbox.getButtonClick(RB))
Serial.println(F("RB"));
if (Xbox.getButtonClick(LT))
Serial.println(F("LT"));
if (Xbox.getButtonClick(RT))
Serial.println(F("RT"));
if (Xbox.getButtonClick(L3))
Serial.println(F("L3"));
if (Xbox.getButtonClick(R3))

View file

@ -63,27 +63,27 @@ void loop() {
Serial.println();
}
if (Xbox.getButtonPress(L2) > 0 || Xbox.getButtonPress(R2) > 0) {
if (Xbox.getButtonPress(L2) > 0) {
Serial.print(F("L2: "));
Serial.print(Xbox.getButtonPress(L2));
if (Xbox.getButtonPress(LT) > 0 || Xbox.getButtonPress(RT) > 0) {
if (Xbox.getButtonPress(LT) > 0) {
Serial.print(F("LT: "));
Serial.print(Xbox.getButtonPress(LT));
Serial.print("\t");
}
if (Xbox.getButtonPress(R2) > 0) {
Serial.print(F("R2: "));
Serial.print(Xbox.getButtonPress(R2));
if (Xbox.getButtonPress(RT) > 0) {
Serial.print(F("RT: "));
Serial.print(Xbox.getButtonPress(RT));
Serial.print("\t");
}
Serial.println();
}
// Set rumble effect
static uint16_t oldL2Value, oldR2Value;
if (Xbox.getButtonPress(L2) != oldL2Value || Xbox.getButtonPress(R2) != oldR2Value) {
oldL2Value = Xbox.getButtonPress(L2);
oldR2Value = Xbox.getButtonPress(R2);
uint8_t leftRumble = map(oldL2Value, 0, 1023, 0, 255); // Map the trigger values into a byte
uint8_t rightRumble = map(oldR2Value, 0, 1023, 0, 255);
static uint16_t oldLTValue, oldRTValue;
if (Xbox.getButtonPress(LT) != oldLTValue || Xbox.getButtonPress(RT) != oldRTValue) {
oldLTValue = Xbox.getButtonPress(LT);
oldRTValue = Xbox.getButtonPress(RT);
uint8_t leftRumble = map(oldLTValue, 0, 1023, 0, 255); // Map the trigger values into a byte
uint8_t rightRumble = map(oldRTValue, 0, 1023, 0, 255);
if (leftRumble > 0 || rightRumble > 0)
Xbox.setRumbleOn(leftRumble, rightRumble, leftRumble, rightRumble);
else
@ -108,14 +108,14 @@ void loop() {
Xbox.disconnect();
}
if (Xbox.getButtonClick(L1))
Serial.println(F("L1"));
if (Xbox.getButtonClick(R1))
Serial.println(F("R1"));
if (Xbox.getButtonClick(L2))
Serial.println(F("L2"));
if (Xbox.getButtonClick(R2))
Serial.println(F("R2"));
if (Xbox.getButtonClick(LB))
Serial.println(F("LB"));
if (Xbox.getButtonClick(RB))
Serial.println(F("RB"));
if (Xbox.getButtonClick(LT))
Serial.println(F("LT"));
if (Xbox.getButtonClick(RT))
Serial.println(F("RT"));
if (Xbox.getButtonClick(L3))
Serial.println(F("L3"));
if (Xbox.getButtonClick(R3))

View file

@ -32,12 +32,12 @@ void loop() {
if (Xbox.XboxReceiverConnected) {
for (uint8_t i = 0; i < 4; i++) {
if (Xbox.Xbox360Connected[i]) {
if (Xbox.getButtonPress(L2, i) || Xbox.getButtonPress(R2, i)) {
Serial.print("L2: ");
Serial.print(Xbox.getButtonPress(L2, i));
Serial.print("\tR2: ");
Serial.println(Xbox.getButtonPress(R2, i));
Xbox.setRumbleOn(Xbox.getButtonPress(L2, i), Xbox.getButtonPress(R2, i), i);
if (Xbox.getButtonPress(LT, i) || Xbox.getButtonPress(RT, i)) {
Serial.print("LT: ");
Serial.print(Xbox.getButtonPress(LT, i));
Serial.print("\tRT: ");
Serial.println(Xbox.getButtonPress(RT, i));
Xbox.setRumbleOn(Xbox.getButtonPress(LT, i), Xbox.getButtonPress(RT, i), i);
}
if (Xbox.getAnalogHat(LeftHatX, i) > 7500 || Xbox.getAnalogHat(LeftHatX, i) < -7500 || Xbox.getAnalogHat(LeftHatY, i) > 7500 || Xbox.getAnalogHat(LeftHatY, i) < -7500 || Xbox.getAnalogHat(RightHatX, i) > 7500 || Xbox.getAnalogHat(RightHatX, i) < -7500 || Xbox.getAnalogHat(RightHatY, i) > 7500 || Xbox.getAnalogHat(RightHatY, i) < -7500) {
@ -93,10 +93,10 @@ void loop() {
if (Xbox.getButtonClick(R3, i))
Serial.println(F("R3"));
if (Xbox.getButtonClick(L1, i))
Serial.println(F("L1"));
if (Xbox.getButtonClick(R1, i))
Serial.println(F("R1"));
if (Xbox.getButtonClick(LB, i))
Serial.println(F("LB"));
if (Xbox.getButtonClick(RB, i))
Serial.println(F("RB"));
if (Xbox.getButtonClick(XBOX, i)) {
Xbox.setLedMode(ROTATING, i);
Serial.print(F("Xbox (Battery: "));

View file

@ -29,12 +29,12 @@ void setup() {
void loop() {
Usb.Task();
if (Xbox.Xbox360Connected) {
if (Xbox.getButtonPress(L2) || Xbox.getButtonPress(R2)) {
Serial.print("L2: ");
Serial.print(Xbox.getButtonPress(L2));
Serial.print("\tR2: ");
Serial.println(Xbox.getButtonPress(R2));
Xbox.setRumbleOn(Xbox.getButtonPress(L2), Xbox.getButtonPress(R2));
if (Xbox.getButtonPress(LT) || Xbox.getButtonPress(RT)) {
Serial.print("LT: ");
Serial.print(Xbox.getButtonPress(LT));
Serial.print("\tRT: ");
Serial.println(Xbox.getButtonPress(RT));
Xbox.setRumbleOn(Xbox.getButtonPress(LT), Xbox.getButtonPress(RT));
} else
Xbox.setRumbleOn(0, 0);
@ -91,10 +91,10 @@ void loop() {
if (Xbox.getButtonClick(R3))
Serial.println(F("R3"));
if (Xbox.getButtonClick(L1))
Serial.println(F("L1"));
if (Xbox.getButtonClick(R1))
Serial.println(F("R1"));
if (Xbox.getButtonClick(LB))
Serial.println(F("LB"));
if (Xbox.getButtonClick(RB))
Serial.println(F("RB"));
if (Xbox.getButtonClick(XBOX)) {
Xbox.setLedMode(ROTATING);
Serial.println(F("Xbox"));