Skip to content

Commit

Permalink
Added PID 0x02A9
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryzee119 committed Sep 21, 2019
1 parent 8ecbaf9 commit 426220b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ class XBOXONE : public USBDeviceConfig, public UsbConfigXtracter {
/** True if a Xbox ONE controller is connected. */
bool XboxOneConnected;
uint16_t PID, VID;

void enableInput();


protected:
/** Pointer to USB class instance. */
Expand Down Expand Up @@ -230,6 +230,7 @@ class XBOXONE : public USBDeviceConfig, public UsbConfigXtracter {
int16_t hatValue[4];
uint16_t triggerValue[2];
uint16_t triggerValueOld[2];
uint32_t enableInputTimer; //Timing for checkStatus() signals

bool L2Clicked; // These buttons are analog, so we use we use these bools to check if they where clicked or not
bool R2Clicked;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#define XBOX_WIRELESS_RECEIVER_PID 0x0719 // Microsoft Wireless Gaming Receiver
#define XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID 0x0291 // Third party Wireless Gaming Receiver
#define XBOX_WIRELESS_RECEIVER_THIRD_PARTY1_PID 0x02AA // Another Third party Wireless Gaming Receiver

#define XBOX_WIRELESS_RECEIVER_THIRD_PARTY2_PID 0x02A9 // Another Third party Wireless Gaming Receiver

#define XBOX_MAX_ENDPOINTS 17

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,11 @@ uint8_t XBOXONE::Poll() {
if(!bPollEnable)
return 0;

if(millis()-enableInputTimer>100){
enableInput();
enableInputTimer=millis();
}

if((int32_t)((uint32_t)millis() - qNextPollTime) >= 0L) { // Do not poll if shorter than polling interval
qNextPollTime = (uint32_t)millis() + pollInterval; // Set new poll time
uint16_t length = (uint16_t)epInfo[ XBOX_ONE_INPUT_PIPE ].maxPktSize; // Read the maximum packet size from the endpoint
Expand Down Expand Up @@ -404,18 +409,20 @@ int16_t XBOXONE::getAnalogHat(AnalogHatEnum a) {

/* Xbox Controller commands */
uint8_t XBOXONE::XboxCommand(uint8_t* data, uint16_t nbytes) {
static uint32_t outputCommandTimer=0;
data[2] = cmdCounter++; // Increment the output command counter
while(millis()-outputCommandTimer<1);
uint8_t rcode = pUsb->outTransfer(bAddress, epInfo[ XBOX_ONE_OUTPUT_PIPE ].epAddr, nbytes, data);
#ifdef DEBUG_USB_HOST
Notify(PSTR("\r\nXboxCommand, Return: "), 0x80);
D_PrintHex<uint8_t > (rcode, 0x80);
#endif
outputCommandTimer=millis();
return rcode;
}

// The Xbox One packets are described at: https://github.com/quantus/xbox-one-controller-protocol
void XBOXONE::onInit() {
enableInput();
enableInput();
enableInput();

if(pFuncOnInit)
pFuncOnInit(); // Call the user function
}
Expand Down Expand Up @@ -468,7 +475,7 @@ void XBOXONE::enableInput(){
uint8_t writeBuf[5];
writeBuf[0] = 0x05;
writeBuf[1] = 0x20;
// Byte 2 is set in "XboxCommand"
writeBuf[2] = 0x00;
writeBuf[3] = 0x01;
writeBuf[4] = 0x00;
XboxCommand(writeBuf, 5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ uint8_t XBOXRECV::ConfigureDevice(uint8_t parent, uint8_t port, bool lowspeed) {
PID = udd->idProduct;

if((VID != XBOX_VID && VID != MADCATZ_VID && VID != JOYTECH_VID) ||
(PID != XBOX_WIRELESS_RECEIVER_PID && PID != XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID && PID != XBOX_WIRELESS_RECEIVER_THIRD_PARTY1_PID)) {
(PID != XBOX_WIRELESS_RECEIVER_PID &&
PID != XBOX_WIRELESS_RECEIVER_THIRD_PARTY_PID &&
PID != XBOX_WIRELESS_RECEIVER_THIRD_PARTY1_PID &&
PID != XBOX_WIRELESS_RECEIVER_THIRD_PARTY2_PID)) {
goto FailUnknownDevice;
}

Expand Down

0 comments on commit 426220b

Please sign in to comment.