felis / USB_Host_Shield_2.0

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

Xbox One S controller does not pair #627

Open gerahamm opened 3 years ago

gerahamm commented 3 years ago

Environment

The Usb Host Shield has been tested with a wired Xbox 360 controller and the available example code. Works perfectly.

While using the example code for the Xbox One S Controller (link) with any of the given BT dongles I just receive the following output:

Xbox One S Bluetooth Library Started
BTD ConfigureDevice
BTD Init
Addr: 01
Endpoint descriptor:
Length:         07
Type:           05
Address:        81
Attributes:     03
MaxPktSize:     0010
Poll Intrv:     01
Endpoint descriptor:
Length:         07
Type:           05
Address:        02
Attributes:     02
MaxPktSize:     0040
Poll Intrv:     01
Endpoint descriptor:
Length:         07
Type:           05
Address:        82
Attributes:     02
MaxPktSize:     0040
Poll Intrv:     01
Bluetooth Dongle Initialized
Connection established
Connection established
Connection established
Connection established
Connection established
Connection established
Connection established
Connection established
HCI Reset complete
Unmanaged HCI Event: 24, data: 03 04 08 00 00 00 00 00 00 00 00 00 
Write class of device
Ignore HCI Event: 09
Local Bluetooth Address: 00:1A:7D:DA:71:13
HCI version: 09
Class of device: 0A 09 08
Page number: 00
Maximum page number: 00
Extended LMP features: BF 3E 4D FA DB 3D 7B C7
Dongle supports secure simple pairing (controller support)
Unmanaged HCI Event: 56, data: 01 01 10 00 00 00 BF 3E 4D FA DB 3D
...
Unmanaged HCI Event: 56, data: 01 01 10 00 00 00 BF 3E 4D FA DB 3D

Other BT dongle has different address.

Tried the following:

  1. Removing the BT dongle after the above output and connecting the controller via USB produces a lot of unreadable output (strange symbols)
  2. External power supply for more power
  3. USB hub

Unfortunately without any success.

MasterJubei commented 3 years ago

I had a lot of problems with the knockoff mini usb host shield, mine looks just like that. I bought two of them, they experience a lot of intermittent problems. They kept freezing my board. The full sized usb host shields all over amazon work just fine though. There is also the chance it is your bluetooth dongle https://www.amazon.com/gp/product/B07TLD8CNQ/ref=ppx_yo_dt_b_search_asin_image?ie=UTF8&psc=1 I use this and it works well.

With that said, even if you do get it working, the xbox one s controller is fairly broken in its current state, I would recommend using a PS4 controller since I know that works just fine.

With the Xbox One S controller you have to re-pair every time unless you use the patch I have in a PR request. I found a lot of the buttons are not mapped correctly, at least on my revision of the controller. The data in XBOXSBT.xboxOneSData.btn is mapped incorrectly. I am trying to fix that, although I have a feeling the data might be different depending on controller locale/revision since mine is very different than the stock code. e.g. for my controller, A,B buttons work, but the left stick/right stick buttons are mapped to the wrong values, same for start, menu, and x,y.

HisashiKato commented 3 years ago

Packets sent via Bluetooth from the Xbox One S controller (MODEL 1708) have changed as follows with the firmware update (4.8.1923.0). https://github.com/atar-axis/xpadneo/blob/master/docs/descriptors/xb1s_linux.md

HisashiKato commented 3 years ago

I made a structure like this for my library. https://github.com/HisashiKato/USB_Host_Shield_Library_2.0_BTXBOX/blob/master/src/XB1SBTParser.h#L89-L126

MasterJubei commented 3 years ago

I made a structure like this for my library. https://github.com/HisashiKato/USB_Host_Shield_Library_2.0_BTXBOX/blob/master/src/XB1SBTParser.h#L89-L126

Ah great, thanks. I was going in blind and without reading the context of the structures, and well the results were looking very strange, although it seemed to still work. Yours is obviously the one to go with of course. I will say I prefer the way you have done the parsing much more over the project's code. It is much easier to follow.


        struct {
                uint8_t dpad : 4;
                uint8_t reserved : 4;

                uint8_t a : 1;
                uint8_t b : 1;
                uint8_t U1 : 1;
                uint8_t x : 1;

                uint8_t y : 1;
                uint8_t U2 : 1;
                uint8_t LB : 1;
                uint8_t RB : 1;
                //uint8_t menu : 1;

                uint8_t U3 : 1;
                uint8_t U4 : 1;
                uint8_t U5 : 1;
                uint8_t menu : 1; //start button
                uint8_t XBOX : 1;
                uint8_t LSB : 1; //LSB
                uint8_t RSB : 1; //RSB
                uint8_t U6 : 1;
                uint8_t SHARE : 1;
                //uint8_t reserved2 : 6;
        } __attribute__((packed));
        uint32_t val : 25;
} __attribute__((packed));```
HisashiKato commented 3 years ago

With the new firmware, the button data packet has increased by 1 byte, and the contents of the entire button data have changed. (This change is only for packets sent from Bluetooth, not for packets sent via USB wire.)

MasterJubei commented 3 years ago

@gerahamm I have not used an Arduino nano, so I have not looked at the details of how that is wired. But for my setup I had to cut the 5v line on the usb host mini shield. It is default bridged to VCC which is 3.3V. Cut on the indicated green line.

image

gerahamm commented 3 years ago

Thanks for your replies.

@MasterJubei I did cut the 5v line from the beginning. As stated I'm able to use my wired Xbox 360 controller with it. The BT dongle is even recongnized (see log), but I cannot pair my Xbox One S controller with it.

BTW the output with the BT dongle 1 is:

Xbox One S Bluetooth Library Started
BTD ConfigureDevice
BTD Init
Addr: 01
Endpoint descriptor:
Length:         07
Type:           05
Address:        81
Attributes:     03
MaxPktSize:     0010
Poll Intrv:     01
Endpoint descriptor:
Length:         07
Type:           05
Address:        02
Attributes:     02
MaxPktSize:     0040
Poll Intrv:     00
Endpoint descriptor:
Length:         07
Type:           05
Address:        82
Attributes:     02
MaxPktSize:     0040
Poll Intrv:     00
Bluetooth Dongle Initialized
Connection established
Connection established
Connection established
Connection established
Connection established
Connection established
Connection established
HCI Reset complete
Unmanaged HCI Event: 24, data: 03 04 08 00 00 00 00 00 00 00 00 00
Write class of device
Local Bluetooth Address: 00:E0:4C:23:99:87
HCI version: 0A
Class of device: 5D 0A 00
Page number: 00
Maximum page number: 02
Extended LMP features: FF FF FF FE DB FD 7B 87
Dongle supports secure simple pairing (controller support)
Unmanaged HCI Event: 56, data: 01 01 10 00 00 02 FF FF FF FE DB FD 
Simple pairing was enabled
Set event mask completed
Please enable discovery of your device

I just tried the Wii example with my available Wiimote and this is also not working. Unfortunately I cannot use the extended debugging, because the Atmega 328p does not have sufficient ROM/RAM.

gerahamm commented 3 years ago

@MasterJubei There cannot be a reconnection if the initial pairing does not work at all :)