mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Another fix for multiple controllers
This commit is contained in:
parent
47d1a6b8b6
commit
1798f9b338
2 changed files with 9 additions and 9 deletions
14
XBOXRECV.cpp
14
XBOXRECV.cpp
|
@ -346,15 +346,15 @@ void XBOXRECV::readReport(uint8_t controller) {
|
|||
if(ButtonState[controller] != OldButtonState[controller]) {
|
||||
ButtonClickState[controller] = (ButtonState[controller] >> 16) & ((~OldButtonState[controller]) >> 16); // Update click state variable, but don't include the two trigger buttons L2 and R2
|
||||
if(((uint8_t)OldButtonState[controller]) == 0 && ((uint8_t)ButtonState[controller]) != 0) // The L2 and R2 buttons are special as they are analog buttons
|
||||
R2Clicked = true;
|
||||
R2Clicked[controller] = true;
|
||||
if((uint8_t)(OldButtonState[controller] >> 8) == 0 && (uint8_t)(ButtonState[controller] >> 8) != 0)
|
||||
L2Clicked = true;
|
||||
L2Clicked[controller] = true;
|
||||
OldButtonState[controller] = ButtonState[controller];
|
||||
}
|
||||
}
|
||||
|
||||
void XBOXRECV::printReport(uint8_t controller, uint8_t nBytes) { //Uncomment "#define PRINTREPORT" to print the report send by the Xbox 360 Controller
|
||||
#if defined(DEBUG) || defined(PRINTREPORT)
|
||||
#if defined(PRINTREPORT)
|
||||
if (readBuf == NULL)
|
||||
return;
|
||||
Notify(PSTR("Controller "));
|
||||
|
@ -376,15 +376,15 @@ uint8_t XBOXRECV::getButtonPress(uint8_t controller, Button b) {
|
|||
}
|
||||
bool XBOXRECV::getButtonClick(uint8_t controller, Button b) {
|
||||
if(b == L2) {
|
||||
if(L2Clicked) {
|
||||
L2Clicked = false;
|
||||
if(L2Clicked[controller]) {
|
||||
L2Clicked[controller] = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else if(b== R2) {
|
||||
if(R2Clicked) {
|
||||
R2Clicked = false;
|
||||
if(R2Clicked[controller]) {
|
||||
R2Clicked[controller] = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -148,8 +148,8 @@ private:
|
|||
uint16_t ButtonClickState[4];
|
||||
int16_t hatValue[4][4];
|
||||
|
||||
bool L2Clicked; // These buttons are analog, so we use we use these bools to check if they where clicked or not
|
||||
bool R2Clicked;
|
||||
bool L2Clicked[4]; // These buttons are analog, so we use we use these bools to check if they where clicked or not
|
||||
bool R2Clicked[4];
|
||||
|
||||
uint8_t readBuf[EP_MAXPKTSIZE]; // General purpose buffer for input data
|
||||
uint8_t writeBuf[EP_MAXPKTSIZE]; // General purpose buffer for output data
|
||||
|
|
Loading…
Reference in a new issue