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.print(F("Y: "));
Serial.println(Xbox.getButtonPress(Y)); Serial.println(Xbox.getButtonPress(Y));
} }
if (Xbox.getButtonPress(L1)) { if (Xbox.getButtonPress(LT)) {
Serial.print(F("L1: ")); Serial.print(F("LT: "));
Serial.println(Xbox.getButtonPress(L1)); Serial.println(Xbox.getButtonPress(LT));
} }
if (Xbox.getButtonPress(R1)) { if (Xbox.getButtonPress(RT)) {
Serial.print(F("R1: ")); Serial.print(F("RT: "));
Serial.println(Xbox.getButtonPress(R1)); Serial.println(Xbox.getButtonPress(RT));
} }
} }
delay(1); delay(1);

View file

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

View file

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

View file

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

View file

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