Skip to content
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

question: Xbox Elite Wireless Controller Series 2 support for paddles #427

Open
alan-barzilay opened this issue Jun 12, 2023 · 13 comments
Open
Labels
0 | type: enhancement New feature or request
Milestone

Comments

@alan-barzilay
Copy link

Hi! Love the project but I have a quick question that I would like to confirm before pulling the trigger on such an expensive controller haha

I understand that profiles and profile switching are still a bit iffy, but besides that is there any other feature missing for this controller? I really need the ability to remap LB and LT to the elite series 2 right hand paddles due to limited mobility in my left hand, my understanding is that xpadneo currently does not provide button remapping functionality but if it enables the use of the paddles I guess I could do the remapping inside of the game or through steam. Am I correct in my understanding? I never had an elite controller so I'm a bit loss about what functionalities could be missing or even exist haha

I read the docs but wasn' t sure if I was understanding it write. Also, if I buy this controller I would love to help further develop support for it :) (although I never got involved with coding for the kernel or drivers haha)

@kakra
Copy link
Collaborator

kakra commented Jun 12, 2023

Currently you cannot adjust this without hacking the source code. But the infrastructure is there. If you're somewhat into coding, you could hard-code a remapping yourself - it shouldn't be to difficult. We already can see and identify the paddles in the HID reports, and we do report them back to user-space in profile 0 mode.

Some more advanced, I'd like to reverse engineer how MS actually programs remappings into the controller via HID. I think I identified which HID reports do that but I didn't setup a packet capture yet.

Mapping LT to a paddle may be a bit more difficult because one is analog while the other is digital. But converting from a digital input to analog (as you probably want to do) should be easy because the value is either 0 or 1023. I'm currently working on doing it the other way around, too, for mouse emulation (converting analog to digital with some fuzzy logic).

So I'm all in for making this a perfect fit for your use-case.

@kakra kakra added the 0 | type: enhancement New feature or request label Jun 12, 2023
@kakra kakra added this to the v0.11 milestone Jun 12, 2023
@kakra
Copy link
Collaborator

kakra commented Jun 12, 2023

There's a proven working example in the source code how to suppress some HID events and synthesize others from it (for the Guide button and emulated profile switching).

It's actually this code you want to change:

if ((usage->type == EV_KEY) && (usage->code == BTN_PADDLES(0))) {
if (gamepad && xdata->profile == 0) {
/* report the paddles individually */
input_report_key(gamepad, BTN_PADDLES(0), value & 1 ? 1 : 0);
input_report_key(gamepad, BTN_PADDLES(1), value & 2 ? 1 : 0);
input_report_key(gamepad, BTN_PADDLES(2), value & 4 ? 1 : 0);
input_report_key(gamepad, BTN_PADDLES(3), value & 8 ? 1 : 0);
}
goto stop_processing;

Instead of reporting paddle 0,1,2,3 if a value bit is set, you may want to report the trigger axis or shoulder button instead.

You may actually need to suppress reporting the native trigger axis so it doesn't generate input events that mess up the result if you accidentally push on the trigger.

In profiles other than 0, the controller reports remappings from its internal programming which is mapping to A,B,X,Y by default (unless you changed that with the Windows Xbox Acc app).

@alan-barzilay
Copy link
Author

Makes sense! I didn' t think about the paddles being digital or analog, tbh I had no idea of which one they were haha

I'm sold on the idea, when I finally get the controller I will be back then :) Thank you for the detailed response!

@kakra

This comment was marked as off-topic.

@alan-barzilay

This comment was marked as off-topic.

@kakra

This comment was marked as off-topic.

@alan-barzilay

This comment was marked as off-topic.

@kakra

This comment was marked as off-topic.

@WillsterJohnson
Copy link
Contributor

WillsterJohnson commented Jun 16, 2023

If you have access to a Windows machine the Xbox Accessories app lets you write profiles, everything seems to work just fine for me (see above mention, #429).

Not ideal of course, say you decide you want a different mapping, well it's back to the Windows machine and reconfigure. But at least it's possible, and evidently bringing support for this to XPadNeo is being worked on.

@kakra
Copy link
Collaborator

kakra commented Jun 16, 2023

I'm planning to reverse engineer that protocol, so we can have a profile programming app in Linux, too.

@ahungry
Copy link

ahungry commented Dec 25, 2023

I just purchased an Xbox Series 2 Elite - Is there a way to make the back paddles report under jstest as events 11, 12, 13, 14 without modifying the source code/recompiling?

Then I could remap them to any key(s) I desire using something like antimicrox - currently they are returning as XABY (events 0 to 3).

I have not used Windows, so no HID remapping - I assume the XABY is the profile 0/default support noted on the readme.

@ahungry
Copy link

ahungry commented Dec 25, 2023

I'm going to try editing the source, but how do I compile this? Does install.sh actually compile? configure.sh did not produce a makefile for me, nor do I see a top level build file I'm familiar with (Makefile, or cmake stuff etc.)

diff --git a/hid-xpadneo/src/hid-xpadneo.c b/hid-xpadneo/src/hid-xpadneo.c
index 8219d03..b99981e 100644
--- a/hid-xpadneo/src/hid-xpadneo.c
+++ b/hid-xpadneo/src/hid-xpadneo.c
@@ -905,10 +905,10 @@ static int xpadneo_event(struct hid_device *hdev, struct hid_field *field,
        if ((usage->type == EV_KEY) && (usage->code == BTN_PADDLES(0))) {
                if (gamepad && xdata->profile == 0) {
                        /* report the paddles individually */
-                       input_report_key(gamepad, BTN_PADDLES(0), value & 1 ? 1 : 0);
-                       input_report_key(gamepad, BTN_PADDLES(1), value & 2 ? 1 : 0);
-                       input_report_key(gamepad, BTN_PADDLES(2), value & 4 ? 1 : 0);
-                       input_report_key(gamepad, BTN_PADDLES(3), value & 8 ? 1 : 0);
+                       input_report_key(gamepad, BTN_PADDLES(11), value & 1 ? 1 : 0);
+                       input_report_key(gamepad, BTN_PADDLES(12), value & 2 ? 1 : 0);
+                       input_report_key(gamepad, BTN_PADDLES(13), value & 4 ? 1 : 0);
+                       input_report_key(gamepad, BTN_PADDLES(14), value & 8 ? 1 : 0);
                }
                goto stop_processing;

Ah, I'm dumb, I see it exists in hid-xpadneo sub-directory 😄 (though my change seems to have no effect, time to read and grok more...)

Edit: Ok, clearly I should learn more about the controller itself - I see how to switch profiles there, and what I wanted was already present.

Thanks for an awesome project!

@kakra
Copy link
Collaborator

kakra commented Dec 26, 2023

@ahungry Yeah, profile 0 is hard-coded in the firmware to report the paddles as native paddles. If you switch to profile 1-3, it will use whatever was programmed into the controller, in case of factory defaults, that's reporting as ABXY for the paddles. While we can still see in the HID reports that a paddle was pressed, it will "press" ABXY at the same time, so for profile 1-3 I actually mask the paddle bits. We'll have to reconsider that after I figured out how programming the firmware works.

The BTN_PADDLES macro just shifts the button IDs into the trigger happy range. We will shift these a few offsets more soon to be compliant with SDL and in-kernel xpad.

Your patch actually applies to profile 0 only, and moves the buttons to TRIGGER_HAPPY+11 and above. Also, if you want to do that, you also need to ensure the keymap is updated, too, for setting the proper bits so user-space can figure out which bits are actually present.

Compiling can be done with make -C hid-xpadneo for systems having the kernel headers/sources installed. Otherwise, dkms uses the Makefile in hid-xpadneo/src.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0 | type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants