New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xone: Wireless Adapter Support (WiFi) #14

Open
Queuecumber opened this Issue Oct 31, 2015 · 82 comments

Comments

@Queuecumber

Queuecumber commented Oct 31, 2015

I figured I'd open an issue for this, I have the wireless adapter "for windows 10", I haven't done much debugging with the xpad driver but I figured support for this is one of your goals. I can help debug this and/or provide any information you might need.

@Queuecumber Queuecumber changed the title from XBox One Wireless Controller Support to XBox One Wireless Adapter Support Oct 31, 2015

@wjbuys

This comment has been minimized.

wjbuys commented Nov 1, 2015

I also just got one, and would be willing to help with debugging.

In case it's useful, here's a Wireshark dump of the USB traffic when plugging in and removing the adapter.

@paroj

This comment has been minimized.

Owner

paroj commented Nov 1, 2015

@wjbuys did you dump running linux? If so dumping using windows 10 where the handshake actually succeeds would be more vaulable..

@wjbuys

This comment has been minimized.

wjbuys commented Nov 1, 2015

@paroj yep, that was on Linux. I don't have a Windows 10 box, will see if I can coax it out of a VM.

@wjbuys

This comment has been minimized.

wjbuys commented Nov 2, 2015

I've captured the exchange between the wireless adapter and a Windows 10 VM here. I couldn't actually get it to pair with a controller though.

@Queuecumber

This comment has been minimized.

Queuecumber commented Nov 3, 2015

@wjbuys that's weird, was it giving an error or something?

@wjbuys

This comment has been minimized.

wjbuys commented Nov 3, 2015

@Queuecumber nope, it just went something like:

  • Set up Virtualbox device filter to allow MS devices by vendor ID.
  • Plug in adapter. Adapter light is off. Adapter shows up as network adapter in Device Manager.
  • Switch on controller. Controller light blinks slowly.
  • Long-press adapter pair button. Adapter light blinks.
  • Long-press controller pair button. Controller light blinks rapidly, adapter light goes solid.
  • ~5 seconds pass, and controller light blinks slowly again (no connection).

This might be a Virtualbox issue (or just me, I can't Windows and I've never used the controller with an actual XBox), so getting a real dump would help a lot.

@steverweber

This comment has been minimized.

steverweber commented Dec 14, 2015

mac driver with xbox one support under active dev... might have some good code to share :)
360Controller/360Controller#151
360Controller/360Controller#160

@paroj paroj added the help wanted label Dec 19, 2015

@paroj paroj changed the title from XBox One Wireless Adapter Support to xone: Wireless Adapter Support Dec 19, 2015

@mooware

This comment has been minimized.

mooware commented Jan 20, 2016

So, is anyone working on this? I'd like to help, if I can.

I did a USB capture in Windows 10 with two controllers, but I have no idea how to interpret it:
https://dl.dropboxusercontent.com/u/267889/xone.pcap

@Almamu

This comment has been minimized.

Almamu commented Jan 22, 2016

I can help implementing this, I do have a Windows 10 box with an XBOX One Wireless adapter + a linux box in which I can test. I just need some more info to start reversing the protocol, does Wireshark detect the wireless dongle as a normal network adapter under Windows 10 (if so, can I just do a capture on it or do I need a special driver or something)?

@mooware

This comment has been minimized.

mooware commented Jan 22, 2016

I used usbpcap with Wireshark.

@drejjmit

This comment has been minimized.

drejjmit commented Jan 28, 2016

Almamu Yes. Under both W10 and W7 it's detected as a Network adapter.

@Almamu

This comment has been minimized.

Almamu commented Jan 29, 2016

@wjbuys Make sure that at least USB 2.0 support is enabled in the VM, I had the same problems until I activated it.

@tadly

This comment has been minimized.

tadly commented Feb 11, 2016

Trying to get that thing work with KVM (using libvirt) and USB passthrough to a win10 guest which (I'm assuming) is due to it not being properly recognized by the host (not sure on that though. I'm new to kvm)

What I'm trying to say is:
If there's anything I can help with, I'll do my best to do so.

What I've noticed so far:

  1. Adapter does show up on the windows guest as Network adapter
  2. When booting the guest, I get a device descriptor read/64, error -71

Pairing stick and controller does not work.
Same behaviour as for @wjbuys with virtualbox

@Queuecumber

This comment has been minimized.

Queuecumber commented Feb 11, 2016

I think at this point we really need someone who can understand the wireshark dumps. Thanks to the mac folks we actually have a couple of dumps floating around (I think). Not that more dumps wouldn't be extremely useful just that the big missing piece is someone who knows how to implement this. I tried to look at it myself but this isn't exactly my area of expertise

@Queuecumber

This comment has been minimized.

Queuecumber commented Feb 16, 2016

Another set of captures courtesy of the mac people

https://drive.google.com/file/d/0B3-WQPnZBRZhRmlNZjltU1pWTms/view

@tadly

This comment has been minimized.

tadly commented Feb 20, 2016

@Queuecumber ah crap, sorry...
wanted to share that thread for a while now and kept forgetting about it :/

http://controllermax.com/forums/showthread.php?t=151076&s=0794035b822a0fbaa8e480cb1f8c8676&p=1014946&viewfull=1#post1014946

That's all I know so far...

@rpcastagna

This comment has been minimized.

rpcastagna commented Feb 21, 2016

From looking at the dumps that have been uploaded, I don't think the protocol is too complicated. They're apparently using standard headers on the packets (at least Wireshark seems to recognize them) and the patterns seem relatively consistent. They're definitely not encrypted, and it wouldn't make sense from the engineer's perspective to make them encrypted.

I'm going to play around with these and see what I can do. It'd be really helpful if anyone could make a more extensive dump and annotate it: start recording, plug in without touching anything and see the traffic it produces just from that initial handshake, then systematically press each button once, waiting a second in between, then upload it along with the order that you hit all the buttons in.

For any other devs reading along, the dumps uploaded so far seem to have a pretty simple pattern:

  1. Adapter polls for device
  2. Controller says it's alive
  3. Adapter requests basic configuration information
  4. Controller says it's a usb 1.1 device that's not powered by the wire and supports remote wakeup
  5. Adapter requests more config information
  6. Controller identifies itself as a proprietary interface -- presumably Microsoft specific -- and lists 8 endpoints that probably map to the buttons
  7. Controller sends extra packet that's not standards compliant but is probably used as part of the configuration
  8. Adapter and controller handshake to confirm they understand each other
  9. Adapter and controller ping back and forth with each other very frequently, with the controller including status information that probably includes buttons currently pressed
@paroj

This comment has been minimized.

Owner

paroj commented Feb 21, 2016

please try to keep the discussion here focused on getting the controller to work using the adapter.
I have opened a new issue regarding WiFi protocol #25. Will clean up the comments here now.

@Queuecumber

This comment has been minimized.

Queuecumber commented Apr 17, 2016

Just to bring this to everyone's attention: 360Controller/360Controller#156 (comment)

One of the Mac guys has figured something out, nothing definitive yet though. When he releases his code I'll take a look at how he did it and see what happens

@stephen304

This comment has been minimized.

stephen304 commented Apr 30, 2016

Looks like he's been committing his code to his fork, if anybody here wants to start tinkering with it: https://github.com/haiduc32/360Controller/commits/master

@haiduc32

This comment has been minimized.

haiduc32 commented May 1, 2016

also please check my latest comment on the mac thread.

@haiduc32

This comment has been minimized.

haiduc32 commented Jul 9, 2016

@Developers - I managed to crack the most important parts of the protocol to the extent that now I have my xbox one controller sending all input commands through the wireless to my mac. you can find the class that is of interest: https://github.com/haiduc32/360Controller/blob/master/WirelessGamingReceiver/OneWirelessGamingReceiver.cpp
you can find all the commands in there. most of it is initializatioin, then pairing (or smth). some messages are in ProcessMessage as they are out of sync.
some limited information on the messages mostly from ProcessMessage can be found in here: https://docs.google.com/document/d/1AyrhC3gnVAmZyjlCGeJmPauCopRkLN56NyjHiuj8b14/edit?usp=sharing
if anyone is serious about working on that let me know if you need help on the protocol and we can setup a skype chat.

@cgutman

This comment has been minimized.

Contributor

cgutman commented Jul 17, 2016

@haiduc32 the Wireless adapter itself is simply a MediaTek MT7216US NIC. The proprietary part is Microsoft's protocol that runs across it (called Xbox GIP apparently). In Microsoft's stack, they seem to use a stock MediaTek provided NIC driver for the adapter itself and their own protocol driver that sits above it. Microsoft then puts a fairly standard HID stack on top of GIP. There are some quirks needed since the Xbox controllers don't send HID report descriptors (to my knowledge), so one would need to be provided by the OS.

I assume you're driving the whole thing from one driver (the NIC itself and GIP that runs atop it). Maybe it would make your life easier to split out the portion dedicated to the MediaTek NIC and implement the GIP driver separately? That may help even more if the new Bluetooth controller uses the same protocol.

I wrote some thoughts on the best way to structure this code in a thread here: http://thread.gmane.org/gmane.linux.kernel.input/50585

@mooware

This comment has been minimized.

mooware commented Sep 12, 2016

A quick note regarding the new Xbox One S controller with Bluetooth support: It already works with Linux (I'm using it with my Steam Link). I suppose this change was all it took: 1405c6a. I also had to update the controller firmware (which is done through the "Xbox Accessories" Windows 10 app; no idea if there's a way to do it without Windows).

@pikim

This comment has been minimized.

pikim commented Jan 22, 2017

But I tested the adapter again with the driver you linked to and it seems to be working quite ok (it was able to scan for WiFi networks, but I didn't get it running in AP mode).

In the meantime I stumbled upon another repository which could be interesting. Maybe the changes from here could be helpful? But I didn't try that version, yet.

What do you mean with IOs?

Anywhere in the MT7612U or A6210 drivers I read something about input and output pins that can be set or read. Under special circumstances it could lead to problems, for example when one output has to be set. Or when it must not be set to avoid hardware damage.

@pikim

This comment has been minimized.

pikim commented Jan 29, 2017

But I tested the adapter again with the driver you linked to and it seems to be working quite ok (it was able to scan for WiFi networks, but I didn't get it running in AP mode).

In the meantime I stumbled upon another repository which could be interesting. Maybe the changes from here could be helpful? But I didn't try that version, yet.

Of course my last statement was rubbish: the code doesn't run in AP mode, because they threw it out some months ago as they didn't need it.

Do you have an idea what was the problem with Ulli Krolls mt7612u? Did you try it recently or some time ago? I spent some hours to get it compiling, but I didn't get further, yet...

@braxion

This comment has been minimized.

braxion commented Mar 11, 2017

@pikim: any news or success at this issue?

@pikim

This comment has been minimized.

pikim commented Mar 13, 2017

@braxion
Unfortunately not. I didn't proceed with the xpad approach. I like devkids suggestion to use the adapter in a real wifi mode as it seems more promising. Unfortunately the drivers I tried so far don't really work at the moment. But as Ulli Krolls mt7612u is under permanent development, I hope it will be working soon. If not I'll try to proceed with xpad anyway.

@alaindesjardins

This comment has been minimized.

alaindesjardins commented Mar 23, 2017

I was going to buy a bluetooth version of the xbox one remote since the wireless adapter doesn't work but then I realized I wouldn't be able to use my Elite Controller since there is no version of that with bluetooth.

I hope you guys figure it out since I know I can't. I appreciate it :)

@FliesWithWind

This comment has been minimized.

FliesWithWind commented May 12, 2017

Hey guys,

Any news on the development? I'm planning to buy 2 bluetooth controlers and wireless adapter, since from what I've heard bluetooth won't handle two controllers. Really wish I could use it with my raspberry. I could try helping out a bit with the development.

@devkid

This comment has been minimized.

devkid commented May 12, 2017

No progress from my side so far. I'll have more time starting from July.

@finkler

This comment has been minimized.

finkler commented Jun 6, 2017

@FliesWithWind,
two Xbox bluetoothcontroller work good under Linux. I gave up on the wireless adapter as well, and bought the bluetooth version of the controllers. Just make sure you have the right adapter Class 1/EDR.

Repository owner deleted a comment from xtycoon Jun 20, 2017

Repository owner deleted a comment from tadly Jun 20, 2017

Repository owner deleted a comment from xtycoon Jun 20, 2017

Repository owner deleted a comment from braxion Jun 20, 2017

Repository owner deleted a comment from anfengdaydayup Jun 20, 2017

@yjbbrqw

This comment has been minimized.

yjbbrqw commented Jul 26, 2017

Can someone give a summary of work done since the issue was submitted? I'd like to help . (Althogh xone controller works fine via BT on my linux, but it's still annoying being unable to use my wireless adapter.

@Adubbz

This comment has been minimized.

Adubbz commented Jul 26, 2017

From what I can tell the actual implementation is still up in the air, so here's my summary of the information known so far. It's mainly just mashed together what people have said in a number of issues. Someone feel free to correct me if anything is missing.

The wireless adapter is a MediaTek MT7216US NIC, which is a WiFi adapter capable of using the 5.2 and 5.8 GHz bands (https://fccid.io/C3K1713, https://github.com/paroj/xpad/files/139111/TDS_XboxOneControllerPlusWDAforWindows_1510A.pdf).

Under Windows, there is a stock driver for the adapter itself (mt7612US.sys), a custom protocol driver (xboxgip.sys (Xbox Game Input Protocol)) utilising that, and a standard HID stack on top of GIP. It has been observed that WiFi packets were sent as long as the controller is connected to the dongle (i.e. power on and the X LED being on), and beacons are always sent. WiFi dumps for button presses and powering on/off the controller can be found at http://dl.devkid.net/uNqiOXi32H2Ul-_pEZtUHw/xbone-wireless.tgz. Images of the adapter board can be seen here 360Controller/360Controller#156 (comment)

There is firmware included for the adapter (FW_ACC_00U.bin) with a striking similarity to https://github.com/openwrt/mt76/tree/master/firmware (mt7662_firmware_e3_v1.9.bin), the open source driver for the MT76x2 family. This firmware presumably must be loaded every time during initialization as the device lacks rewritable memory to hold it when the power is lost.

There have been numerous captures of the USB traffic using tools such as USBPcap (http://desowin.org/usbpcap/index.html). Packets in these captures have a base packet header appended following the format specified here: http://desowin.org/usbpcap/captureformat.html. The basic pattern which can be observed from this is as follows:

  1. Adapter polls for device
  2. Controller says it's alive
  3. Adapter requests basic configuration information
  4. Controller says it's a usb 1.1 device that's not powered by the wire and supports remote wakeup
  5. Adapter requests more config information
  6. Controller identifies itself as a proprietary interface -- presumably Microsoft specific -- and lists 8 endpoints that probably map to the buttons
  7. Controller sends extra packet that's not standards compliant but is probably used as part of the configuration
  8. Adapter and controller handshake to confirm they understand each other
  9. Adapter and controller ping back and forth with each other very frequently, with the controller including status information that probably includes buttons currently pressed

There are two schools of thought surrounding how this should be implemented:

  1. Recreate the packets sent in the USB captures
  2. Find a wireless driver for the dongle itself, and implement the Xbox GIP protocol on top of that

haiduc32 has documented some features of the initialization and control USB packets here: https://docs.google.com/document/d/1AyrhC3gnVAmZyjlCGeJmPauCopRkLN56NyjHiuj8b14/ and managed to receive input commands from the controller via wireless on macOS: https://github.com/haiduc32/360Controller/blob/master/WirelessGamingReceiver/OneWirelessGamingReceiver.cpp

devkid has done some work investigating the WiFi protocol. Raw 802.11 MAC frames appear to be being sent over the USB connection, taking the form documented over at #25 (comment). devkid's additional notes can be found at https://gist.github.com/devkid/4b3bd50760504d1b93ea684cfd3ed895

Sources:
#14
#25
360Controller/360Controller#156

@pikim

This comment has been minimized.

pikim commented Jul 26, 2017

There are two schools of thought surrounding how this should be implemented:

  1. Recreate the packets sent in the USB captures
  2. Find a wireless driver for the dongle itself, and implement the Xbox GIP protocol on top of that

The point with solution 1 is that one also receives the detected WiFi networks all around and must be able to handle the changing names and so on. Could be possible, but it would be better to understand the communication.
Therefore solution 2 would be preferable but at the moment there's no working driver available for the MT7612U. Ulli Kroll is working on one and apparently there are plans to modify OpenWRTs mt76. While the first one crashes after a short time, modifying the second one for USB usage hasn't even begun.

There would be a third solution by using WiFi dongles that are known work under Linux, but I have neither such a dongle nor the knowledge to do this. But it could be learned, I think. So if anyone knows a 5GHz dongle that is well supported it would be great to know.

@tatsujb

This comment has been minimized.

tatsujb commented Sep 23, 2017

I have a Tl-wn823n I don't know if it would do the job or not.

@pikim

This comment has been minimized.

pikim commented Oct 21, 2017

In the meantime I sold my WLAN only controller and I plan to buy a Bluetooth version or a completely different controller. But that means that I won't work on this topic any more. Sorry guys!

@noabody

This comment has been minimized.

noabody commented Jan 4, 2018

Thanks to you and everyone that contributed to this, "the hard fight". Sometimes those fights aren't won but hopefully you took something valuable away from it.

@devkid

This comment has been minimized.

devkid commented Jan 11, 2018

@noabody As far as I'm aware of, the controller tries to connect to any valid "dongle wifi network" it sees. If the button on the dongle was pressed before, the dongle just accepts the connection.

@goldsteal

This comment has been minimized.

goldsteal commented Jun 10, 2018

Any update on this?

Not actually sure which one I have but given that "lsusb" only gives out "Bus 003 Device 020: ID 045e:02e6 Microsoft Corp." I assume it is the wireless LAN i.e. wifi version?

@tadly

This comment has been minimized.

tadly commented Jun 11, 2018

@goldsteal all versions are lan. The newer ones just additionally supports BT.
The receiver is for lan only (does not have BT. You have to "provide" that yourself.)
Just put your controller into pairing mode, whip out your phone and see if a it shows up in the list of available bluetooth devices. <- Easiest way of testing.

@goldsteal

This comment has been minimized.

goldsteal commented Jun 11, 2018

@tadly Will try that... Thanks.

@kylewlacy

This comment has been minimized.

kylewlacy commented Sep 17, 2018

For anyone else who's been following this issue, I opened bounty for the sister issue in 360Controller about the Wireless Adapter (360Controller/360Controller#156). I'm hoping that a bounty for that issue will lead to a solution for both projects. I left a comment about the bounty and a collection of resources about this issue over there: 360Controller/360Controller#156 (comment)

@Two-Tone

This comment has been minimized.

Two-Tone commented Sep 17, 2018

Holy hell, that's a huge bounty.

Question! Why use that repo's issue instead of this one?

@kylewlacy

This comment has been minimized.

kylewlacy commented Sep 17, 2018

@Two-Tone I actually use Linux day-to-day but I have used 360Controller before and I expect to use it in the future. I had to decide between opening the bounty for the 360Controller project or the xpad project. I ultimately decided on 360Controller mainly because it seems to be more popular (more stars, more contributors), so the impact of adding it to 360Controller will be bigger.

Of course, I'm really hopeful that someone will be able to add it quickly to this project once the patch has landed (I might even take a stab at porting it myself if it doesn't seem too difficult)

@Two-Tone

This comment has been minimized.

Two-Tone commented Sep 17, 2018

There may be more users and more contributors to that project, but you'd likely get noticed by many more developers overall since a large chunk of the Linux user base are developers due to how technical it can be, while a large chunk the user base on MacOS is not because it's not aimed at them.

@goldsteal

This comment has been minimized.

goldsteal commented Sep 20, 2018

I just added 5 bucks to the bounty. :D Just to show I still want this.

I am also pretty sure that when it's working in one project it will be easier to consider for the devs of xpad etc. to implement it since they can reuse some of the code - as long as the licenses allow it.

So maybe someone will take another crack at it. We shall wait and see. Also: a 1000$ seems like a high bounty for one guy with some spare money. Hope you can afford it mate. Don't be too stupid. Bankroll management is an important skill and all ;) That being said it's probably still more than deserved for anyone who can get it done considering how much full-time development this will probably need if you just price it at the going rate of a really good software engineer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment