From 99e01d3a98d2ff637d875b953ea7d7163dd24056 Mon Sep 17 00:00:00 2001 From: David Madison Date: Thu, 1 Jul 2021 04:56:20 -0400 Subject: [PATCH] Transform Xbox old trigger enums This is required to get the "correct" output from the trigger and bumper enums, which for legacy reasons do not match up with the L1/L2 keys indices. --- XBOXOLD.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/XBOXOLD.cpp b/XBOXOLD.cpp index 1d38b694..a454d22a 100644 --- a/XBOXOLD.cpp +++ b/XBOXOLD.cpp @@ -293,6 +293,19 @@ void XBOXOLD::printReport(uint16_t length __attribute__((unused))) { //Uncomment } int8_t XBOXOLD::getAnalogIndex(ButtonEnum b) { + // For legacy reasons these mapping indices not match up, + // as the original code uses L1/R1 for the triggers and + // L2/R2 for the white/black buttons. To fix these new enums + // we have to transpose the keys before passing them through + // the button index function + switch (b) { + case(LT): b = L1; break; // normally L2 + case(RT): b = R1; break; // normally R2 + case(LB): b = WHITE; break; // normally L1 + case(RB): b = BLACK; break; // normally R1 + default: break; + } + // A, B, X, Y, BLACK, WHITE, L1, and R1 are analog buttons const int8_t index = ButtonIndex(b);