From 2120adf2830b5a0d6a6c3d15599d9189b6c121ef Mon Sep 17 00:00:00 2001 From: David Madison Date: Sat, 27 Mar 2021 08:35:55 -0400 Subject: [PATCH] Refactor button index function names It's not really fair to refer to the main index function as "legacy" if it's actively being used. All controller-specific 'get' filtering functions are now appended with the name of the controller rather than having it in the middle. --- PS3BT.cpp | 6 +++--- PS3Enums.h | 4 ++-- PS3USB.cpp | 6 +++--- PS4Parser.cpp | 14 +++++++------- PS4Parser.h | 2 +- PS5Parser.cpp | 14 +++++++------- PS5Parser.h | 2 +- PSBuzz.cpp | 8 ++++---- PSBuzz.h | 3 ++- Wii.cpp | 16 ++++++++-------- Wii.h | 4 ++-- XBOXONE.cpp | 18 +++++++++--------- XBOXONESParser.cpp | 20 ++++++++++---------- XBOXONESParser.h | 2 +- XBOXRECV.cpp | 12 ++++++------ XBOXUSB.cpp | 12 ++++++------ controllerEnums.h | 2 +- xboxEnums.h | 4 ++-- 18 files changed, 75 insertions(+), 74 deletions(-) diff --git a/PS3BT.cpp b/PS3BT.cpp index 3326f1f6..8c181f45 100644 --- a/PS3BT.cpp +++ b/PS3BT.cpp @@ -47,12 +47,12 @@ BluetoothService(p) // Pointer to USB class instance - mandatory } bool PS3BT::getButtonPress(ButtonEnum b) { - const int8_t index = getPS3ButtonIndex(b); if (index < 0) return 0; + const int8_t index = getButtonIndexPS3(b); if (index < 0) return 0; return (ButtonState & pgm_read_dword(&PS3_BUTTONS[index])); } bool PS3BT::getButtonClick(ButtonEnum b) { - const int8_t index = getPS3ButtonIndex(b); if (index < 0) return 0; + const int8_t index = getButtonIndexPS3(b); if (index < 0) return 0; uint32_t button = pgm_read_dword(&PS3_BUTTONS[index]); bool click = (ButtonClickState & button); ButtonClickState &= ~button; // Clear "click" event @@ -60,7 +60,7 @@ bool PS3BT::getButtonClick(ButtonEnum b) { } uint8_t PS3BT::getAnalogButton(ButtonEnum a) { - const int8_t index = getPS3ButtonIndex(a); if (index < 0) return 0; + const int8_t index = getButtonIndexPS3(a); if (index < 0) return 0; return (uint8_t)(l2capinbuf[pgm_read_byte(&PS3_ANALOG_BUTTONS[index])]); } diff --git a/PS3Enums.h b/PS3Enums.h index 2c0116e4..ababecec 100644 --- a/PS3Enums.h +++ b/PS3Enums.h @@ -138,8 +138,8 @@ enum StatusEnum { Bluetooth = (40 << 8) | 0x16, // Operating by Bluetooth and rumble is turned off }; -inline int8_t getPS3ButtonIndex(ButtonEnum b) { - const int8_t index = legacyButtonValues(b); +inline int8_t getButtonIndexPS3(ButtonEnum b) { + const int8_t index = ButtonIndex(b); if ((uint8_t) index >= (sizeof(PS3_BUTTONS) / sizeof(PS3_BUTTONS[0]))) return -1; return index; } diff --git a/PS3USB.cpp b/PS3USB.cpp index 4aba0e54..0b0438b4 100644 --- a/PS3USB.cpp +++ b/PS3USB.cpp @@ -314,12 +314,12 @@ void PS3USB::printReport() { // Uncomment "#define PRINTREPORT" to print the rep } bool PS3USB::getButtonPress(ButtonEnum b) { - const int8_t index = getPS3ButtonIndex(b); if (index < 0) return 0; + const int8_t index = getButtonIndexPS3(b); if (index < 0) return 0; return (ButtonState & pgm_read_dword(&PS3_BUTTONS[index])); } bool PS3USB::getButtonClick(ButtonEnum b) { - const int8_t index = getPS3ButtonIndex(b); if (index < 0) return 0; + const int8_t index = getButtonIndexPS3(b); if (index < 0) return 0; uint32_t button = pgm_read_dword(&PS3_BUTTONS[index]); bool click = (ButtonClickState & button); ButtonClickState &= ~button; // Clear "click" event @@ -327,7 +327,7 @@ bool PS3USB::getButtonClick(ButtonEnum b) { } uint8_t PS3USB::getAnalogButton(ButtonEnum a) { - const int8_t index = getPS3ButtonIndex(a); if (index < 0) return 0; + const int8_t index = getButtonIndexPS3(a); if (index < 0) return 0; return (uint8_t)(readBuf[(pgm_read_byte(&PS3_ANALOG_BUTTONS[index])) - 9]); } diff --git a/PS4Parser.cpp b/PS4Parser.cpp index aee04d2c..e27974bb 100644 --- a/PS4Parser.cpp +++ b/PS4Parser.cpp @@ -32,8 +32,8 @@ enum DPADEnum { // To enable serial debugging see "settings.h" //#define PRINTREPORT // Uncomment to print the report send by the PS4 Controller -int8_t PS4Parser::getButtonIndex(ButtonEnum b) { - const int8_t index = legacyButtonValues(b); +int8_t PS4Parser::getButtonIndexPS4(ButtonEnum b) { + const int8_t index = ButtonIndex(b); if ((uint8_t) index >= (sizeof(PS4_BUTTONS) / sizeof(PS4_BUTTONS[0]))) return -1; return index; } @@ -54,7 +54,7 @@ bool PS4Parser::checkDpad(ButtonEnum b) { } bool PS4Parser::getButtonPress(ButtonEnum b) { - const int8_t index = getButtonIndex(b); if (index < 0) return 0; + const int8_t index = getButtonIndexPS4(b); if (index < 0) return 0; if (index <= LEFT) // Dpad return checkDpad(b); else @@ -62,7 +62,7 @@ bool PS4Parser::getButtonPress(ButtonEnum b) { } bool PS4Parser::getButtonClick(ButtonEnum b) { - const int8_t index = getButtonIndex(b); if (index < 0) return 0; + const int8_t index = getButtonIndexPS4(b); if (index < 0) return 0; uint32_t mask = 1UL << pgm_read_byte(&PS4_BUTTONS[index]); bool click = buttonClickState.val & mask; buttonClickState.val &= ~mask; // Clear "click" event @@ -70,10 +70,10 @@ bool PS4Parser::getButtonClick(ButtonEnum b) { } uint8_t PS4Parser::getAnalogButton(ButtonEnum b) { - const int8_t index = getButtonIndex(b); if (index < 0) return 0; - if (index == legacyButtonValues(L2)) // These are the only analog buttons on the controller + const int8_t index = getButtonIndexPS4(b); if (index < 0) return 0; + if (index == ButtonIndex(L2)) // These are the only analog buttons on the controller return ps4Data.trigger[0]; - else if (index == legacyButtonValues(R2)) + else if (index == ButtonIndex(R2)) return ps4Data.trigger[1]; return 0; } diff --git a/PS4Parser.h b/PS4Parser.h index 4d6088ba..c0d27321 100644 --- a/PS4Parser.h +++ b/PS4Parser.h @@ -362,7 +362,7 @@ protected: virtual void sendOutputReport(PS4Output *output) = 0; private: - static int8_t getButtonIndex(ButtonEnum b); + static int8_t getButtonIndexPS4(ButtonEnum b); bool checkDpad(ButtonEnum b); // Used to check PS4 DPAD buttons PS4Data ps4Data; diff --git a/PS5Parser.cpp b/PS5Parser.cpp index 8d53997c..019c80e1 100644 --- a/PS5Parser.cpp +++ b/PS5Parser.cpp @@ -36,8 +36,8 @@ enum DPADEnum { // To enable serial debugging see "settings.h" //#define PRINTREPORT // Uncomment to print the report send by the PS5 Controller -int8_t PS5Parser::getButtonIndex(ButtonEnum b) { - const int8_t index = legacyButtonValues(b); +int8_t PS5Parser::getButtonIndexPS5(ButtonEnum b) { + const int8_t index = ButtonIndex(b); if ((uint8_t) index >= (sizeof(PS5_BUTTONS) / sizeof(PS5_BUTTONS[0]))) return -1; return index; } @@ -58,7 +58,7 @@ bool PS5Parser::checkDpad(ButtonEnum b) { } bool PS5Parser::getButtonPress(ButtonEnum b) { - const int8_t index = getButtonIndex(b); if (index < 0) return 0; + const int8_t index = getButtonIndexPS5(b); if (index < 0) return 0; if (index <= LEFT) // Dpad return checkDpad(b); else @@ -66,7 +66,7 @@ bool PS5Parser::getButtonPress(ButtonEnum b) { } bool PS5Parser::getButtonClick(ButtonEnum b) { - const int8_t index = getButtonIndex(b); if (index < 0) return 0; + const int8_t index = getButtonIndexPS5(b); if (index < 0) return 0; uint32_t mask = 1UL << pgm_read_byte(&PS5_BUTTONS[index]); bool click = buttonClickState.val & mask; buttonClickState.val &= ~mask; // Clear "click" event @@ -74,10 +74,10 @@ bool PS5Parser::getButtonClick(ButtonEnum b) { } uint8_t PS5Parser::getAnalogButton(ButtonEnum b) { - const int8_t index = getButtonIndex(b); if (index < 0) return 0; - if (index == legacyButtonValues(L2)) // These are the only analog buttons on the controller + const int8_t index = getButtonIndexPS5(b); if (index < 0) return 0; + if (index == ButtonIndex(L2)) // These are the only analog buttons on the controller return ps5Data.trigger[0]; - else if (index == legacyButtonValues(R2)) + else if (index == ButtonIndex(R2)) return ps5Data.trigger[1]; return 0; } diff --git a/PS5Parser.h b/PS5Parser.h index 7c0c29c9..dc2ddcac 100644 --- a/PS5Parser.h +++ b/PS5Parser.h @@ -403,7 +403,7 @@ protected: private: - static int8_t getButtonIndex(ButtonEnum b); + static int8_t getButtonIndexPS5(ButtonEnum b); bool checkDpad(ButtonEnum b); // Used to check PS5 DPAD buttons PS5Data ps5Data; diff --git a/PSBuzz.cpp b/PSBuzz.cpp index c542c499..5683aa0c 100644 --- a/PSBuzz.cpp +++ b/PSBuzz.cpp @@ -49,19 +49,19 @@ uint8_t PSBuzz::OnInitSuccessful() { return 0; }; -int8_t PSBuzz::getButtonIndex(ButtonEnum b) { - const int8_t index = legacyButtonValues(b); +int8_t PSBuzz::getButtonIndexBuzz(ButtonEnum b) { + const int8_t index = ButtonIndex(b); if (index > 4) return -1; // 5 buttons, 0-4 inclusive return index; } bool PSBuzz::getButtonPress(ButtonEnum b, uint8_t controller) { - const int8_t index = getButtonIndex(b); if (index < 0) return 0; + const int8_t index = getButtonIndexBuzz(b); if (index < 0) return 0; return psbuzzButtons.val & (1UL << (index + 5 * controller)); // Each controller uses 5 bits, so the value is shifted 5 for each controller }; bool PSBuzz::getButtonClick(ButtonEnum b, uint8_t controller) { - const int8_t index = getButtonIndex(b); if (index < 0) return 0; + const int8_t index = getButtonIndexBuzz(b); if (index < 0) return 0; uint32_t mask = (1UL << (index + 5 * controller)); // Each controller uses 5 bits, so the value is shifted 5 for each controller bool click = buttonClickState.val & mask; buttonClickState.val &= ~mask; // Clear "click" event diff --git a/PSBuzz.h b/PSBuzz.h index 8f891c35..b092af3b 100644 --- a/PSBuzz.h +++ b/PSBuzz.h @@ -175,9 +175,10 @@ protected: /**@}*/ private: + static int8_t getButtonIndexBuzz(ButtonEnum b); + void (*pFuncOnInit)(void); // Pointer to function called in onInit() - static int8_t getButtonIndex(ButtonEnum b); void PSBuzz_Command(uint8_t *data, uint16_t nbytes); PSBUZZButtons psbuzzButtons, oldButtonState, buttonClickState; diff --git a/Wii.cpp b/Wii.cpp index 6073f250..f2fa5a96 100644 --- a/Wii.cpp +++ b/Wii.cpp @@ -1094,25 +1094,25 @@ void WII::readWiiBalanceBoardCalibration() { /* WII Commands */ /************************************************************/ -int8_t WII::getButtonIndex(ButtonEnum b) { - const int8_t index = legacyButtonValues(b); +int8_t WII::getButtonIndexWii(ButtonEnum b) { + const int8_t index = ButtonIndex(b); if ((uint8_t) index >= (sizeof(WII_BUTTONS) / sizeof(WII_BUTTONS[0]))) return -1; return index; } -int8_t WII::getButtonIndexPro(ButtonEnum b) { - const int8_t index = legacyButtonValues(b); +int8_t WII::getButtonIndexWiiPro(ButtonEnum b) { + const int8_t index = ButtonIndex(b); if ((uint8_t) index >= (sizeof(WII_PROCONTROLLER_BUTTONS) / sizeof(WII_PROCONTROLLER_BUTTONS[0]))) return -1; return index; } bool WII::getButtonPress(ButtonEnum b) { // Return true when a button is pressed if (wiiUProControllerConnected) { - const int8_t index = getButtonIndexPro(b); if (index < 0) return 0; + const int8_t index = getButtonIndexWiiPro(b); if (index < 0) return 0; return (ButtonState & pgm_read_dword(&WII_PROCONTROLLER_BUTTONS[index])); } else { - const int8_t index = getButtonIndex(b); if (index < 0) return 0; + const int8_t index = getButtonIndexWii(b); if (index < 0) return 0; return (ButtonState & pgm_read_dword(&WII_BUTTONS[index])); } } @@ -1120,11 +1120,11 @@ bool WII::getButtonPress(ButtonEnum b) { // Return true when a button is pressed bool WII::getButtonClick(ButtonEnum b) { // Only return true when a button is clicked uint32_t button; if (wiiUProControllerConnected) { - const int8_t index = getButtonIndexPro(b); if (index < 0) return 0; + const int8_t index = getButtonIndexWiiPro(b); if (index < 0) return 0; button = pgm_read_dword(&WII_PROCONTROLLER_BUTTONS[index]); } else { - const int8_t index = getButtonIndex(b); if (index < 0) return 0; + const int8_t index = getButtonIndexWii(b); if (index < 0) return 0; button = pgm_read_dword(&WII_BUTTONS[index]); } bool click = (ButtonClickState & button); diff --git a/Wii.h b/Wii.h index d70b2510..7d65afcf 100644 --- a/Wii.h +++ b/Wii.h @@ -431,8 +431,8 @@ protected: /**@}*/ private: - static int8_t getButtonIndex(ButtonEnum b); - static int8_t getButtonIndexPro(ButtonEnum b); + static int8_t getButtonIndexWii(ButtonEnum b); + static int8_t getButtonIndexWiiPro(ButtonEnum b); void L2CAP_task(); // L2CAP state machine diff --git a/XBOXONE.cpp b/XBOXONE.cpp index 7345c734..d2e7aabd 100644 --- a/XBOXONE.cpp +++ b/XBOXONE.cpp @@ -331,9 +331,9 @@ void XBOXONE::readReport() { if(readBuf[0] == 0x07) { // The XBOX button has a separate message if(readBuf[4] == 1) - ButtonState |= pgm_read_word(&XBOX_BUTTONS[legacyButtonValues(XBOX)]); + ButtonState |= pgm_read_word(&XBOX_BUTTONS[ButtonIndex(XBOX)]); else - ButtonState &= ~pgm_read_word(&XBOX_BUTTONS[legacyButtonValues(XBOX)]); + ButtonState &= ~pgm_read_word(&XBOX_BUTTONS[ButtonIndex(XBOX)]); if(ButtonState != OldButtonState) { ButtonClickState = ButtonState & ~OldButtonState; // Update click state variable @@ -348,7 +348,7 @@ void XBOXONE::readReport() { return; } - uint16_t xbox = ButtonState & pgm_read_word(&XBOX_BUTTONS[legacyButtonValues(XBOX)]); // Since the XBOX button is separate, save it and add it back in + uint16_t xbox = ButtonState & pgm_read_word(&XBOX_BUTTONS[ButtonIndex(XBOX)]); // Since the XBOX button is separate, save it and add it back in // xbox button from before, dpad, abxy, start/back, sync, stick click, shoulder buttons ButtonState = xbox | (((uint16_t)readBuf[5] & 0xF) << 8) | (readBuf[4] & 0xF0) | (((uint16_t)readBuf[4] & 0x0C) << 10) | ((readBuf[4] & 0x01) << 3) | (((uint16_t)readBuf[5] & 0xC0) << 8) | ((readBuf[5] & 0x30) >> 4); @@ -378,23 +378,23 @@ void XBOXONE::readReport() { } uint16_t XBOXONE::getButtonPress(ButtonEnum b) { - const int8_t index = getXboxButtonIndex(b); if (index < 0) return 0; - if(index == legacyButtonValues(L2)) // These are analog buttons + const int8_t index = getButtonIndexXbox(b); if (index < 0) return 0; + if(index == ButtonIndex(L2)) // These are analog buttons return triggerValue[0]; - else if(index == legacyButtonValues(R2)) + else if(index == ButtonIndex(R2)) return triggerValue[1]; return (bool)(ButtonState & ((uint16_t)pgm_read_word(&XBOX_BUTTONS[index]))); } bool XBOXONE::getButtonClick(ButtonEnum b) { - const int8_t index = getXboxButtonIndex(b); if (index < 0) return 0; - if(index == legacyButtonValues(L2)) { + const int8_t index = getButtonIndexXbox(b); if (index < 0) return 0; + if(index == ButtonIndex(L2)) { if(L2Clicked) { L2Clicked = false; return true; } return false; - } else if(index == legacyButtonValues(R2)) { + } else if(index == ButtonIndex(R2)) { if(R2Clicked) { R2Clicked = false; return true; diff --git a/XBOXONESParser.cpp b/XBOXONESParser.cpp index b92bbeb7..4ce12d99 100644 --- a/XBOXONESParser.cpp +++ b/XBOXONESParser.cpp @@ -54,8 +54,8 @@ enum DPADEnum { DPAD_LEFT_UP = 0x8, }; -int8_t XBOXONESParser::getButtonIndex(ButtonEnum b) { - const int8_t index = legacyButtonValues(b); +int8_t XBOXONESParser::getButtonIndexXboxOneS(ButtonEnum b) { + const int8_t index = ButtonIndex(b); if ((uint8_t) index >= (sizeof(XBOX_ONE_S_BUTTONS) / sizeof(XBOX_ONE_S_BUTTONS[0]))) return -1; return index; } @@ -76,33 +76,33 @@ bool XBOXONESParser::checkDpad(ButtonEnum b) { } uint16_t XBOXONESParser::getButtonPress(ButtonEnum b) { - const int8_t index = getButtonIndex(b); if (index < 0) return 0; - if (index == legacyButtonValues(L2)) + const int8_t index = getButtonIndexXboxOneS(b); if (index < 0) return 0; + if (index == ButtonIndex(L2)) return xboxOneSData.trigger[0]; - else if (index == legacyButtonValues(R2)) + else if (index == ButtonIndex(R2)) return xboxOneSData.trigger[1]; else if (index <= LEFT) // Dpad return checkDpad(b); - else if (index == legacyButtonValues(XBOX)) + else if (index == ButtonIndex(XBOX)) return xboxButtonState; return xboxOneSData.btn.val & (1UL << pgm_read_byte(&XBOX_ONE_S_BUTTONS[index])); } bool XBOXONESParser::getButtonClick(ButtonEnum b) { - const int8_t index = getButtonIndex(b); if (index < 0) return 0; - if(index == legacyButtonValues(L2)) { + const int8_t index = getButtonIndexXboxOneS(b); if (index < 0) return 0; + if(index == ButtonIndex(L2)) { if(L2Clicked) { L2Clicked = false; return true; } return false; - } else if(index == legacyButtonValues(R2)) { + } else if(index == ButtonIndex(R2)) { if(R2Clicked) { R2Clicked = false; return true; } return false; - } else if (index == legacyButtonValues(XBOX)) { + } else if (index == ButtonIndex(XBOX)) { bool click = xboxbuttonClickState; xboxbuttonClickState = 0; // Clear "click" event return click; diff --git a/XBOXONESParser.h b/XBOXONESParser.h index 531bb3eb..c9dbb51a 100644 --- a/XBOXONESParser.h +++ b/XBOXONESParser.h @@ -111,7 +111,7 @@ protected: virtual void sendOutputReport(uint8_t *data, uint8_t nbytes) = 0; private: - static int8_t getButtonIndex(ButtonEnum b); + static int8_t getButtonIndexXboxOneS(ButtonEnum b); bool checkDpad(ButtonEnum b); // Used to check Xbox One S DPAD buttons diff --git a/XBOXRECV.cpp b/XBOXRECV.cpp index 1a7ac318..0ba3b6b0 100644 --- a/XBOXRECV.cpp +++ b/XBOXRECV.cpp @@ -408,23 +408,23 @@ void XBOXRECV::printReport(uint8_t controller __attribute__((unused)), uint8_t n } uint8_t XBOXRECV::getButtonPress(ButtonEnum b, uint8_t controller) { - const int8_t index = getXboxButtonIndex(b); if (index < 0) return 0; - if(index == legacyButtonValues(L2)) // These are analog buttons + const int8_t index = getButtonIndexXbox(b); if (index < 0) return 0; + if(index == ButtonIndex(L2)) // These are analog buttons return (uint8_t)(ButtonState[controller] >> 8); - else if(index == legacyButtonValues(R2)) + else if(index == ButtonIndex(R2)) return (uint8_t)ButtonState[controller]; return (bool)(ButtonState[controller] & ((uint32_t)pgm_read_word(&XBOX_BUTTONS[index]) << 16)); } bool XBOXRECV::getButtonClick(ButtonEnum b, uint8_t controller) { - const int8_t index = getXboxButtonIndex(b); if (index < 0) return 0; - if(index == legacyButtonValues(L2)) { + const int8_t index = getButtonIndexXbox(b); if (index < 0) return 0; + if(index == ButtonIndex(L2)) { if(L2Clicked[controller]) { L2Clicked[controller] = false; return true; } return false; - } else if(index == legacyButtonValues(R2)) { + } else if(index == ButtonIndex(R2)) { if(R2Clicked[controller]) { R2Clicked[controller] = false; return true; diff --git a/XBOXUSB.cpp b/XBOXUSB.cpp index 6b44299e..0ce0997f 100644 --- a/XBOXUSB.cpp +++ b/XBOXUSB.cpp @@ -281,23 +281,23 @@ void XBOXUSB::printReport() { //Uncomment "#define PRINTREPORT" to print the rep } uint8_t XBOXUSB::getButtonPress(ButtonEnum b) { - const int8_t index = getXboxButtonIndex(b); if (index < 0) return 0; - if(index == legacyButtonValues(L2)) // These are analog buttons + const int8_t index = getButtonIndexXbox(b); if (index < 0) return 0; + if(index == ButtonIndex(L2)) // These are analog buttons return (uint8_t)(ButtonState >> 8); - else if(index == legacyButtonValues(R2)) + else if(index == ButtonIndex(R2)) return (uint8_t)ButtonState; return (bool)(ButtonState & ((uint32_t)pgm_read_word(&XBOX_BUTTONS[index]) << 16)); } bool XBOXUSB::getButtonClick(ButtonEnum b) { - const int8_t index = getXboxButtonIndex(b); if (index < 0) return 0; - if(index == legacyButtonValues(L2)) { + const int8_t index = getButtonIndexXbox(b); if (index < 0) return 0; + if(index == ButtonIndex(L2)) { if(L2Clicked) { L2Clicked = false; return true; } return false; - } else if(index == legacyButtonValues(R2)) { + } else if(index == ButtonIndex(R2)) { if(R2Clicked) { R2Clicked = false; return true; diff --git a/controllerEnums.h b/controllerEnums.h index bfffb83d..60181823 100644 --- a/controllerEnums.h +++ b/controllerEnums.h @@ -183,7 +183,7 @@ enum ButtonEnum { /**@}*/ }; -inline constexpr int8_t legacyButtonValues(ButtonEnum key) { +inline constexpr int8_t ButtonIndex(ButtonEnum key) { // using a chained ternary in place of a switch for constexpr on older compilers return (key == UP || key == RED) ? 0 : diff --git a/xboxEnums.h b/xboxEnums.h index 037be594..d3d3f907 100644 --- a/xboxEnums.h +++ b/xboxEnums.h @@ -62,8 +62,8 @@ const uint16_t XBOX_BUTTONS[] PROGMEM = { 0x0008, // SYNC }; -inline int8_t getXboxButtonIndex(ButtonEnum b) { - const int8_t index = legacyButtonValues(b); +inline int8_t getButtonIndexXbox(ButtonEnum b) { + const int8_t index = ButtonIndex(b); if ((uint8_t) index >= (sizeof(XBOX_BUTTONS) / sizeof(XBOX_BUTTONS[0]))) return -1; return index; }