atar-axis / xpadneo

Advanced Linux Driver for Xbox One Wireless Controller (shipped with Xbox One S)
https://atar-axis.github.io/xpadneo/
GNU General Public License v3.0
1.87k stars 110 forks source link

[Xbox Elite S2] Mappings configured in Xbox Accessories on Windows *DO* work on Linux (Pop!_OS 22.04) #429

Closed WillsterJohnson closed 1 year ago

WillsterJohnson commented 1 year ago

Regarding: https://github.com/atar-axis/xpadneo/blob/cf97733f4f3d372ee80247fe7532de7b15123bc4/docs/README.md?plain=1#L193

Related issues (non-exhaustive list):

Version of xpadneo

v0.9-142-gcf97733 (https://github.com/atar-axis/xpadneo/commit/cf97733f4f3d372ee80247fe7532de7b15123bc4)

System Info

(happy to provide more on request, will update this section also)

$: uname -r
6.0.2-76060002-generic

$: dkms --version
dkms-2.8.7

$: apt-cache policy linux-headers-`uname -r`
linux-headers-6.0.2-76060002-generic:
  Installed: 6.0.2-76060002.202210150739~1666289067~22.04~fe0ce53
  Candidate: 6.0.2-76060002.202210150739~1666289067~22.04~fe0ce53
  Version table:
 *** 6.0.2-76060002.202210150739~1666289067~22.04~fe0ce53 100
        100 /var/lib/dpkg/status

$: bluetoothctl --version
bluetoothctl: 5.64

Controller Model

Connection mode

Setup

Test

Profiles

Unless otherwise stated;

Slot 1 (ABXY)

Joystick Curves

  • Left: Delayed, 50% exaggeration
  • Right: Delayed, 50% exaggeration

Trigger Actuation

  • Left: 0%-100%
  • Right: 0%-100%

Normal Mappings

  • P1 > B
  • P2 > Y
  • P3 > A
  • P4 > X

Shift Mappings

Shift keys: N/A

Slot 2 (ABLBRB)

Joystick Curves

  • Left: Delayed, 50% exaggeration
  • Right: Delayed, 50% exaggeration

Trigger Actuation

  • Left: 0%-100%
  • Right: 0%-100%

Normal Mappings

  • P1 > B
  • P2 > RB (right shoulder)
  • P3 > A
  • P4 > LB (left shoulder)

Shift Mappings

Shift keys: N/A

Slot 3 (Shifted)

Joystick Curves

  • Left: Delayed, 50% exaggeration
  • Right: Delayed, 50% exaggeration

Trigger Actuation

  • Left: 0%-100%
  • Right: 0%-100%

Normal Mappings

  • P1 > B
  • P3 > A

Shift Mappings

Shift keys: P1, P3

  • P1 > A
  • P3 > B
  • A > DpadD
  • B > DpadR
  • X > DpadL
  • Y > DpadU
  • DpadU > Y
  • DpadR > B
  • DpadD > A
  • DpadL > X
  • LT > RT
  • RT > LT
  • LB > RB
  • RB > LB
  • LSB > RSB
  • RSB > LSB
  • Sticks swap X-axis

Results

Every single button on the controller does exactly what was configured in Xbox Accessories, including paddle mapping and shift layer.

/docs/README.md

-- The other three profiles behave the same way currently, and there is no support for configuring them. This may be
-  different if profiles have been configured in Windows already, that is still untested.
+- The other three profiles behave the same way currently, and there is no support for configuring them. configurations
+  set in Windows with the Xbox Accessories app will work as expected. Tested distros: 
+  - Pop!_OS 22.04 (Ubuntu flavor)

Further Info

Some issues are present when using the Xbox Elite Series 2 on Linux with XPadNeo. If I've found a workaround, I've added it as an item in a sublist below.

Steam controller input test UI over bluetooth Steam controller input test UI over USB

Steam controller input test UI shown above. Left: Bluetooth, Right: USB

To the maintainers & contributors of XPadNeo, if you need someone to test something (XPadNeo development related) on an Xbox Elite S2, don't hesitate to contact me. Either @ me on GitHub, or see my GitHub profile for more ways to get in touch. I'm dreadful at C, and useless with Kernel modules, so unfortunately "owning an Elite S2" is the only way I can contribute.

Your Controller Is Pink?

You read well - yes!

My Xbox Elite S2 controller - Pink body, silver joystick bases, light blue buttons

I called it "BubblegumButtons" but unfortunately Linux doesn't use it's name, see issues in "Further Info" above.

kakra commented 1 year ago

I don't think we can get the name of the controller via Bluetooth: There's no report defined in the HID descriptor which would allow that. There seem to be reports defined which I'm guessing can (a) set the RGB value and brightness of the Guide LED, and there's a report defined which can send arbitrary data which I believe is for programming the profiles. But I found out in the last few days that the current firmware version no longer seems to have those reports, I need to reevaluate that.

In USB mode (wired or wireless via dongle), the protocol uses GIP. I've started an early version of a protocol decoder for Wireshark here: https://github.com/xpadneo/gip-dissector. The controller uses SSL handshakes to encrypt some data, so it will be hard to figure out what's going on. But I'm pretty sure there are ways to read the custom name, write RGB (already known how to do that), set profiles (TBD). HID and GIP are quite similar, so if they both have reports for the same purpose, data is sent and received in an almost similar format byte by byte, just the report IDs differ.

Regarding the mappings: Yes, I expected that profiles programmed in Windows will map completely fine in Linux - there's just no way of programming it in Linux.

Regarding the model: Yes, we mimic an original Xbox360 USB controller at the device interface layer of Linux. This has historic reasons: Before SDL2 became de-facto standard in games, games expected the joystick interface to have specific buttons at specific positions, similar for evdev interface. Upcoming SDL2 will have full support for xpadneo mappings including the paddles and special buttons. When it becomes widely deployed, Proton games and Steam Input will automatically work properly finally because older games can load newer SDL2 libs via a dynamic loader and compatibility layer.

So yes, we should probably amend the documentation to explicitly mention that profiles programmed in Windows will work. Feel free to open a pull request for that. No need to mention tested distributions, it finally boils down to SDL2 to detect that properly.

If using a VM with USB passthrough, the following problem occurs: The Xbox Acc app may put the controller into bootloader mode, and then it gets a different USB ID, thus disconnects from the guest. If you use the USB dongle and its wireless connection, you'll bypass that problem and it works.

WillsterJohnson commented 1 year ago

I don't think we can get the name of the controller via Bluetooth

Just had a look, even on Windows (hardware, not VM) it has a generic name over Bluetooth. If it's transmitting it's name, Windows & Xbox Accessories don't seem to be using it.

I'm not concerned about the model UI. Oddly enough it shows up as what appears to be the correct model in the Steam Input UI, seems like Steam can't decide what an Xbox controller looks like.

If using a VM with USB passthrough, the following problem occurs: The Xbox Acc app may put the controller into bootloader mode, and then it gets a different USB ID, thus disconnects from the guest. If you use the USB dongle and its wireless connection, you'll bypass that problem and it works.

That sounds about right, if I had no USB filter or if I used one with default settings, it would connect then immediately disconnect. If I removed some of the filter fields, I'd get a connect/disconnect loop that near enough brought the VM to a standstill. I don't have the dongle unfortunately, but it's good to know that option is available.

I'll sort out that PR shortly.