mirror of
https://github.com/felis/USB_Host_Shield_2.0.git
synced 2024-03-22 11:31:26 +01:00
Merge pull request #298 from felis/XBOXONE_fix
Newer Xbox One controllers requires a longer initialisation command
This commit is contained in:
commit
fb47645ea7
2 changed files with 37 additions and 5 deletions
10
XBOXONE.cpp
10
XBOXONE.cpp
|
@ -179,7 +179,10 @@ uint8_t XBOXONE::Init(uint8_t parent, uint8_t port, bool lowspeed) {
|
||||||
// initialize the controller for input
|
// initialize the controller for input
|
||||||
writeBuf[0] = 0x05;
|
writeBuf[0] = 0x05;
|
||||||
writeBuf[1] = 0x20;
|
writeBuf[1] = 0x20;
|
||||||
rcode = XboxCommand(writeBuf, 2);
|
writeBuf[2] = 0x00;
|
||||||
|
writeBuf[3] = 0x01;
|
||||||
|
writeBuf[4] = 0x00;
|
||||||
|
rcode = XboxCommand(writeBuf, 5);
|
||||||
if (rcode)
|
if (rcode)
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
|
||||||
|
@ -263,6 +266,11 @@ void XBOXONE::readReport() {
|
||||||
ButtonState |= pgm_read_word(&XBOX_BUTTONS[XBOX]);
|
ButtonState |= pgm_read_word(&XBOX_BUTTONS[XBOX]);
|
||||||
else
|
else
|
||||||
ButtonState &= ~pgm_read_word(&XBOX_BUTTONS[XBOX]);
|
ButtonState &= ~pgm_read_word(&XBOX_BUTTONS[XBOX]);
|
||||||
|
|
||||||
|
if(ButtonState != OldButtonState) {
|
||||||
|
ButtonClickState = ButtonState & ~OldButtonState; // Update click state variable
|
||||||
|
OldButtonState = ButtonState;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(readBuf[0] != 0x20) { // Check if it's the correct report, otherwise return - the controller also sends different status reports
|
if(readBuf[0] != 0x20) { // Check if it's the correct report, otherwise return - the controller also sends different status reports
|
||||||
#ifdef EXTRADEBUG
|
#ifdef EXTRADEBUG
|
||||||
|
|
32
XBOXONE.h
32
XBOXONE.h
|
@ -34,9 +34,30 @@
|
||||||
#define XBOX_OUTPUT_PIPE 1
|
#define XBOX_OUTPUT_PIPE 1
|
||||||
#define XBOX_INPUT_PIPE 2
|
#define XBOX_INPUT_PIPE 2
|
||||||
|
|
||||||
// PID and VID of the different devices
|
// PID and VID of the different devices - see: https://github.com/torvalds/linux/blob/master/drivers/input/joystick/xpad.c
|
||||||
#define XBOX_VID 0x045E // Microsoft Corporation
|
|
||||||
#define XBOX_ONE_PID 0x02D1 // Microsoft One Wired controller
|
// Official controllers
|
||||||
|
#define XBOX_VID1 0x045E // Microsoft Corporation
|
||||||
|
#define XBOX_ONE_PID1 0x02D1 // Microsoft X-Box One pad
|
||||||
|
#define XBOX_ONE_PID2 0x02DD // Microsoft X-Box One pad (Firmware 2015)
|
||||||
|
#define XBOX_ONE_PID3 0x02E3 // Microsoft X-Box One Elite pad
|
||||||
|
#define XBOX_ONE_PID4 0x02EA // Microsoft X-Box One S pad
|
||||||
|
|
||||||
|
// Unofficial controllers
|
||||||
|
#define XBOX_VID2 0x0738 // Mad Catz
|
||||||
|
#define XBOX_VID3 0x0E6F // Afterglow
|
||||||
|
#define XBOX_VID4 0x0F0D // HORIPAD ONE
|
||||||
|
#define XBOX_VID5 0x1532 // Razer
|
||||||
|
#define XBOX_VID6 0x24C6 // PowerA
|
||||||
|
|
||||||
|
#define XBOX_ONE_PID5 0x4A01 // Mad Catz FightStick TE 2 - might have different mapping for triggers?
|
||||||
|
#define XBOX_ONE_PID6 0x0139 // Afterglow Prismatic Wired Controller
|
||||||
|
#define XBOX_ONE_PID7 0x0146 // Rock Candy Wired Controller for Xbox One
|
||||||
|
#define XBOX_ONE_PID8 0x0067 // HORIPAD ONE
|
||||||
|
#define XBOX_ONE_PID9 0x0A03 // Razer Wildcat
|
||||||
|
#define XBOX_ONE_PID10 0x541A // PowerA Xbox One Mini Wired Controller
|
||||||
|
#define XBOX_ONE_PID11 0x542A // Xbox ONE spectra
|
||||||
|
#define XBOX_ONE_PID12 0x543A // PowerA Xbox One wired controller
|
||||||
|
|
||||||
#define XBOX_REPORT_BUFFER_SIZE 14 // Size of the input report buffer
|
#define XBOX_REPORT_BUFFER_SIZE 14 // Size of the input report buffer
|
||||||
|
|
||||||
|
@ -94,7 +115,10 @@ public:
|
||||||
* @return Returns true if the device's VID and PID matches this driver.
|
* @return Returns true if the device's VID and PID matches this driver.
|
||||||
*/
|
*/
|
||||||
virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) {
|
virtual bool VIDPIDOK(uint16_t vid, uint16_t pid) {
|
||||||
return (vid == XBOX_VID && pid == XBOX_ONE_PID);
|
return ((vid == XBOX_VID1 || vid == XBOX_VID2 || vid == XBOX_VID3 || vid == XBOX_VID4 || vid == XBOX_VID5 || vid == XBOX_VID6) &&
|
||||||
|
(pid == XBOX_ONE_PID1 || pid == XBOX_ONE_PID2 || pid == XBOX_ONE_PID3 || pid == XBOX_ONE_PID4 ||
|
||||||
|
pid == XBOX_ONE_PID5 || pid == XBOX_ONE_PID6 || pid == XBOX_ONE_PID7 || pid == XBOX_ONE_PID8 ||
|
||||||
|
pid == XBOX_ONE_PID9 || pid == XBOX_ONE_PID10 || pid == XBOX_ONE_PID11 || pid == XBOX_ONE_PID12));
|
||||||
};
|
};
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue