mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
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.
This commit is contained in:
parent
6e63210c2a
commit
99e01d3a98
1 changed files with 13 additions and 0 deletions
13
XBOXOLD.cpp
13
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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue