Does MiSTer support the Xbox One Wireless Adapter? (re: xow user mode driver)

Discussion of keyboards, gamepads, joysticks and other input related peripherals.
sofakng
Posts: 138
Joined: Fri Jun 19, 2020 12:52 am
Been thanked: 23 times

Does MiSTer support the Xbox One Wireless Adapter? (re: xow user mode driver)

Unread post by sofakng »

Does MiSTer support the Xbox One Wireless Adapter?

It looks like there is a user-mode driver available called xow that works with libusb and uinput.

I'm aware that newer Xbox One controllers support bluetooth, but porkchop's mister controller latency spreadsheets shows the Xbox One having 15ms of latency with bluetooth. Microsoft claims it should be under 8ms when using their wireless adapter. (their wireless adapter communicates at 5 GHz and uses a proprietary protocol).
sofakng
Posts: 138
Joined: Fri Jun 19, 2020 12:52 am
Been thanked: 23 times

Re: Does MiSTer support the Xbox One Wireless Adapter? (re: xow user mode driver)

Unread post by sofakng »

I've made some progress getting this to work, but unfortunately it's segmentation faulting.

xow requires the mt76x2u driver to not load when the X-Box Wireless Adapter is inserted. I couldn't find a method to do this (ie. modprobe.conf) so I re-compiled the kernel without mt76x2u support.

Afterwards I cross-compiled xow (latest version from github) and it runs, but when it attempts to upload the mt76x2u firmware using libusb, it segmentation faults:

Code: Select all

(gdb) run
Starting program: /root/xow
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/libthread_db.so.1".
2020-10-11 02:39:26 INFO  - xow v0.5-16-ga3d2b01 ©Severin v. W.
[New Thread 0xb6cb0430 (LWP 1579)]
2020-10-11 02:39:26 INFO  - Waiting for device...
2020-10-11 02:39:29 DEBUG - Opening device...

Thread 1 "xow" received signal SIGSEGV, Segmentation fault.
0xb6f98ab4 in ?? () from /lib/libusb-1.0.so.0
(gdb) bt
#0  0xb6f98ab4 in ?? () from /lib/libusb-1.0.so.0
#1  0xb6f97c64 in libusb_handle_events_timeout_completed () from /lib/libusb-1.0.so.0
#2  0xb6f98de4 in libusb_bulk_transfer () from /lib/libusb-1.0.so.0
#3  0x0040a93e in UsbDevice::bulkWrite (this=0x438e90, endpoint=endpoint@entry=4 '\004', data=...)
    at dongle/usb.cpp:141
#4  0x004042e0 in Mt76::loadFirmwarePart (this=this@entry=0xbefff9c8, offset=offset@entry=524288, start=...,
    start@entry=..., end=..., end@entry=...) at dongle/mt76.cpp:1529
#5  0x0040470a in Mt76::loadFirmware (this=this@entry=0xbefff9c8) at dongle/mt76.cpp:1464
#6  0x00407578 in Mt76::Mt76 (this=0xbefff9c8, usbDevice=...) at dongle/mt76.cpp:819
#7  0x0040996a in Dongle::Dongle (this=0xbefff9c8, usbDevice=...) at dongle/dongle.cpp:24
#8  0x004033a6 in main () at xow.cpp:88
I'm in a bit over my head at this point but is it possible for anybody to take a look at this? Does anything in there indicate something I can look at or investigate?
MostroW
Posts: 325
Joined: Tue Aug 18, 2020 3:32 pm
Has thanked: 141 times
Been thanked: 43 times

Re: Does MiSTer support the Xbox One Wireless Adapter? (re: xow user mode driver)

Unread post by MostroW »

XOW prerequisites state you need kernel 4.5+ while MiSTer is running on 4.19, maybe that is causing your issues?
sofakng
Posts: 138
Joined: Fri Jun 19, 2020 12:52 am
Been thanked: 23 times

Re: Does MiSTer support the Xbox One Wireless Adapter? (re: xow user mode driver)

Unread post by sofakng »

Unless I'm mistaken, 4.19 is much newer (October 2018) than 4.5 (March 2016).

I'm not sure what the number/version system is called, but I think the major version is '4' and the minor version is '19' and '5' (therefore '19' is larger and newer). Please correct me if I'm wrong.
MostroW
Posts: 325
Joined: Tue Aug 18, 2020 3:32 pm
Has thanked: 141 times
Been thanked: 43 times

Re: Does MiSTer support the Xbox One Wireless Adapter? (re: xow user mode driver)

Unread post by MostroW »

you're totally right and i probably had a brain malfunction and i've read an entirely different number hence where i was under the presumption that the driver needed a higher version kernel.
sofakng
Posts: 138
Joined: Fri Jun 19, 2020 12:52 am
Been thanked: 23 times

Re: Does MiSTer support the Xbox One Wireless Adapter? (re: xow user mode driver)

Unread post by sofakng »

Does anybody know the exact version of libusb included with MiSTer?

I've recompiled libusb-1.0.23 (without udev support, I think) and it worked perfectly with MiSTer. I was even able to pair a controller and navigate the menu with the controller, etc.
MostroW
Posts: 325
Joined: Tue Aug 18, 2020 3:32 pm
Has thanked: 141 times
Been thanked: 43 times

Re: Does MiSTer support the Xbox One Wireless Adapter? (re: xow user mode driver)

Unread post by MostroW »

i've taken a look on my MiSTer and this is what i found in the /usr/lib

libusb-1.0.so.0
libusb-0.1.so.4
libusb-1.0.so.0.1.0
libusb-0.1.so.4.4.4
libusb-1.0.so
libusb.so

Is there any other way to query a more specific version from the libraries as 3 of them seem to be v1 but no build version present in the filename.
sofakng
Posts: 138
Joined: Fri Jun 19, 2020 12:52 am
Been thanked: 23 times

Re: Does MiSTer support the Xbox One Wireless Adapter? (re: xow user mode driver)

Unread post by sofakng »

Thanks MostroW. I've seen those files as well but I don't think you find the actual version number from them.

However, I posted an issue on github and sorgelig responded saying it's v1.0.20.
MostroW
Posts: 325
Joined: Tue Aug 18, 2020 3:32 pm
Has thanked: 141 times
Been thanked: 43 times

Re: Does MiSTer support the Xbox One Wireless Adapter? (re: xow user mode driver)

Unread post by MostroW »

alright trying to be of help but i also saw my post was meaningless in the end and didn't really contribute to what was asked.
thanks for the kind reply though. :D

i really hope you can get the adapter going, i'm using the old big black rectangular one so i could test should you ever need that!
sofakng
Posts: 138
Joined: Fri Jun 19, 2020 12:52 am
Been thanked: 23 times

Re: Does MiSTer support the Xbox One Wireless Adapter? (re: xow user mode driver)

Unread post by sofakng »

No problem, thanks again!

Here are my latency testing results using the 'xow' driver and the wireless adapter:

Code: Select all

Samples: 6047
Average: 6.0506 ms
Max:     17.588 ms
Min:     1.912 ms
Std Dev: 2.387 ms
It definitely has lower latency than using Bluetooth. Just to confirm, I also tested the controller using Bluetooth but I got different results at different times on the day. I think my area has lots of 2.4 GHz interference which I believe explains the results:

Code: Select all

Samples: 3288
Average: 16.2453 ms
Max:     57.012 ms
Min:     10.292 ms
Std Dev: 3.625 ms

Code: Select all

Samples: 1799
Average: 9.2372 ms
Max:     29.300 ms
Min:     3.264 ms
Std Dev: 2.647 ms
Huge thanks to misteraddons for his latency testing core and testing information!
movisman
Posts: 34
Joined: Mon Aug 24, 2020 4:58 pm
Has thanked: 1 time
Been thanked: 2 times

Re: Does MiSTer support the Xbox One Wireless Adapter? (re: xow user mode driver)

Unread post by movisman »

Hi there,

I created a thread about this a couple of months back:
viewtopic.php?f=32&t=1039

I have two Xbox One controllers plus the wireless dongle, and have been using the 'xow' driver with my RetroPie setup flawlessly. It works really well and also has no problem with both controllers connected simultaneously. They pair instantly as soon as you turn them on, they turn off automatically after a period of inactivity, range is good - I just have no issues.

I don't have a MiSTer yet, but am thinking of going 'all in' and treating myself at some stage soon. However I was curious if I could use my Xbox One controllers with MiSTer without having to resort to Bluetooth - which would likely increase latency. In my experience it just isn't as reliable as the dongle either.

If there was a way of getting the 'xow' driver working with MiSTer - that would be fantastic.
sofakng
Posts: 138
Joined: Fri Jun 19, 2020 12:52 am
Been thanked: 23 times

Re: Does MiSTer support the Xbox One Wireless Adapter? (re: xow user mode driver)

Unread post by sofakng »

Hey ... I did see your thread and I'm glad to see others interested in wireless adapter support.

I've run a few more tests and bluetooth is very inconsistent with the Xbox One controller. I can run 5000+ samples and the average latency will stay at 16ms. However, if I reconnect the controller or reboot MiSTer and run another 5000+ samples it will stay at 9ms.

However, BlueZ reports the same link quality ('hcitool lq') under both conditions. (it ranges between 240 - 255, where 255 is the maximum/best quality connection)

It's interesting that with my testing (several tests over different days, different times of the day, and moving the CSR8510 receiver to different locations), that the latency is ALWAYS either 9ms or 16ms. I'm not sure what causes the controller to use the lower latency setting.

Regardless, I'll need help from somebody more familiar with MiSTer and the Linux system to help submit a pull request for the xow driver.

Here are a few steps needed:

1) The mt76 kernel driver needs to be disabled for the Xbox USB adapter. This can be done using modprobe.conf but I don't think MiSTer uses kernel modules. (and I don't know enough about Linux to fully understand)

I was able to get the adapter working by recompiling the kernel and completely removing the mt76 driver.

2) The xow user-mode driver doesn't appear to be compatible with the included libusb library. This is easy to solve though by including a seperate libusb version with xow or having sorgelig upgrade the libusb included in MiSTer.

3) Xow doesn't require any kernel modifications, but it does require the 'xow' process (service/daemon) to run all the time. This probably isn't a good idea to enable under a default install but we can include a script to enable/disable the service.

Right now the biggest issue is #1 because I'm not familiar enough with Linux to implement the modules.conf under the MiSTer linux system.
movisman
Posts: 34
Joined: Mon Aug 24, 2020 4:58 pm
Has thanked: 1 time
Been thanked: 2 times

Re: Does MiSTer support the Xbox One Wireless Adapter? (re: xow user mode driver)

Unread post by movisman »

Hey there,

Thanks for the information - all really interesting stuff this. Some very useful findings there!

If someone who is more familiar with Linux is also interested in adding support, it sounds like it could definitely be possible to get things working. I wonder who (maybe on this forum) might be able to help you out to get this working, or to answer some of your points about kernel modules, etc.

It would be really great if MiSTer had wireless adapter dongle support for the Xbox One controller using the xow driver. It doesn't have to be default (because of the service/daemon thing), but could easily enabled/disabled via a script or .ini like you suggest. The xow driver just works really well for me in RetroPie - it was easy to install, it works reliably and is (for me at least) definitely better than Bluetooth overall. Not only for latency, but for connection reliability, pairing, sleep, etc. Not that Bluetooth is bad, but the dongle is definitely preferable and more stable in my environment. This is in RetroPie of course, so not necessarily a relevant comparison to how things might work in MiSTer, but I imagine the experience would be similar. Using the dongle solves practically all of my gripes with Bluetooth.

If I eventually get myself set up with MiSTer, I would be more than happy to help with testing if it ever gets to that point - however although I have some understanding of Linux (mainly from a lot of fiddling with the RetroPie environment) I probably don't have enough be able to help with the implementation part.
sofakng
Posts: 138
Joined: Fri Jun 19, 2020 12:52 am
Been thanked: 23 times

Re: Does MiSTer support the Xbox One Wireless Adapter? (re: xow user mode driver)

Unread post by sofakng »

I've found the compatibility issue between xow and libusb-1.0.20 and I've submitted a pull request to have it fixed.

This means we will not have to include a separate version of libusb to support xow with MiSTer.
movisman
Posts: 34
Joined: Mon Aug 24, 2020 4:58 pm
Has thanked: 1 time
Been thanked: 2 times

Re: Does MiSTer support the Xbox One Wireless Adapter? (re: xow user mode driver)

Unread post by movisman »

That's great! I saw your pull request has also been merged into master, so that's promising stuff and fixes one of the issues.
Post Reply