felis / USB_Host_Shield_2.0

Revision 2.0 of USB Host Library for Arduino.
https://chome.nerpa.tech
1.8k stars 780 forks source link

Xbox One S controller Xbox button report problem #481

Open stuartsnow opened 5 years ago

stuartsnow commented 5 years ago

Hi, I believe I've found an issue with the Xbox One controller support. I have a fairly new genuine Xbox One controller and the XBOXONE library works mostly fine except for the Xbox button. If getButtonClick is used, it will return exactly one Xbox button click and no more. A reset of the microcontroller is required before the code will read another Xbox button click. If getButtonPress is used, after the Xbox button is pressed the first time, the code acts as if the Xbox button is being held down forever.

I started digging into the library code and enabled the PRINTREPORT debug statements. This revealed that once the Xbox button is pressed, the controller sends the 0x07 report (containing the Xbox button state) continuously as long as the controller is powered. Unplugging and replugging the controller makes it stop sending the report, but the getButton calls still don't work properly as the library never receives a report with the Xbox button state = 0. This at least explains why the getButtonClick and Press functions don't work.

The report looks like this: 07 30 01 02 01 5B and is sent about 3 times a second.

I then did some Googling and found this little nugget in the Linux source code:

/* the xbox button has its own special report */
    if (data[0] == 0X07) {
        /*
         * The Xbox One S controller requires these reports to be
         * acked otherwise it continues sending them forever and
         * won't report further mode button events.
         */
        if (data[1] == 0x30)
            xpadone_ack_mode_report(xpad, data[2]);

        input_report_key(dev, BTN_MODE, data[4] & 0x01);
        input_sync(dev);
        return;
    }

xpad.c, line 814

Could this be the reason?

jayxtt999 commented 5 years ago

hi,I am the same as you. Have you solved it?