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

input: xpad - initialize 360 controllers #120

Closed
wants to merge 10 commits into from

Conversation

Oblomov
Copy link
Contributor

@Oblomov Oblomov commented Dec 3, 2018

Many knockoff brands emulating the XBOX 360 controller do not properly
send data unless configured correctly. Examples include the Gamesir G3w
and the Fantech GP11 Shooter.

Protocol inspection of communication with other operating systems
reveals a sequence of control messages that can be used to initialize
the controllers sufficiently to send proper data.

Proposed-by: Darvin Delgado [email protected]

dantob and others added 9 commits June 23, 2018 00:56
Signed-off-by: Daniel Tobias <[email protected]>
Signed-off-by: Jonathan <[email protected]>
Signed-off-by: Matt Sturgeon <[email protected]>
Suspending and resuming the system can sometimes cause the out
URB to get hung after a reset_resume. This causes LED setting
and force feedback to break on resume. To avoid this, just drop
the reset_resume callback so the USB core rebinds xpad to the
wireless pads on resume if a reset happened.

A nice side effect of this change is the LED ring on wireless
controllers is now set correctly on system resume.

Signed-off-by: Cameron Gutman <[email protected]>
Cc: [email protected]
"PDP Wired Controller for Xbox One - Stealth Series | Revenant Blue"
see paroj#102
@Oblomov
Copy link
Contributor Author

Oblomov commented Dec 3, 2018

This fixes #118 and should fix #119

@dnmodder
Copy link

dnmodder commented Dec 3, 2018

It works perfect, thank you very much for fixing it

Many knockoff brands emulating the XBOX 360 controller do not properly
send data unless configured correctly. Examples include the Gamesir G3w
and the Fantech GP11 Shooter.

Protocol inspection of communication with other operating systems
reveals a sequence of control messages that can be used to initialize
the controllers sufficiently to send proper data.

Proposed-by: Darvin Delgado <[email protected]>
@Oblomov
Copy link
Contributor Author

Oblomov commented Dec 4, 2018

Good to know!

I've pushed a new version, I had forgotten to free the control message return data in the “no error” path. Hopefully people with an actual XBOX 360 controller or some other knockoff brand can test it to verify that it doesn't break anything for them 8-)

@paroj
Copy link
Owner

paroj commented Dec 4, 2018

please move your init sequence to xpad_prepare_next_init_packet instead of your ad-hoc implementation. For this reuse the xboxone_init_packet structures (rename them to xpad_init_packet).

Your implementation blocks until all init packets were sent while waiting a magicnumber amount of time.
The xpad_prepare_next_init_packet approach overcomes both of these issues.

@Oblomov
Copy link
Contributor Author

Oblomov commented Dec 5, 2018

Hello @paroj, thanks for the hint, I'll rearrange the code per your suggestion.

Do I understand correctly that I have to manually encode the USB control request with the approach your propose?

@Oblomov
Copy link
Contributor Author

Oblomov commented Dec 5, 2018

Hm, no, that obviously doesn't work, so I'm guessing I'll have to duplicate what is currently done for the in and out interrupt URBs to add the management and use of a control URB instead … This is starting to get beyond my expertise …

@puleglot
Copy link

@Oblomov Your patch fixes initialization of Elecom JC-U4013S gamepad. Thanks!


status = usb_control_msg(xpad->udev,
usb_rcvctrlpipe(xpad->udev, 0),
0x1, 0xc1,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using constants defined in uapi/linux/usb/ch9.h instead of magic values (0x1, 0xc1, etc.)

0x1 = USB_REQ_CLEAR_FETAURE
0xc1 = USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE
0x100 = USB_DEVICE_REMOTE_WAKEUP

@puleglot
Copy link

@Oblomov Your patch fixes initialization of Elecom JC-U4013S gamepad. Thanks!

FTR: sending just the first packet (bmRequestType: 0xc1, bRequest: 1, wValue: 0x0100) fixes initialization of my controller. According to [1] it is a GET_CAPABILITIES request.

[1] https://xboxdevwiki.net/Xbox_Input_Devices#GET_CAPABILITIES

@MirceaKitsune
Copy link

I am affected by #119 with my Trust GXT 540 Yula controller I just bought: The device will not work in x-input mode unless I use a workaround python script, and unfortunately some games won't work at all on the d-input setting. Is there any news on this pull request please? Any chance we might see the patch in the Linux kernel this year? The last update on this seems to be from two years ago which is concerning.

@paroj
Copy link
Owner

paroj commented Aug 14, 2021

ok, lets put this to test. Picked manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.