Skip to content

Conversation

Doprez
Copy link
Contributor

@Doprez Doprez commented May 17, 2025

PR Details

Currently 8BitDo controllers dont have a registered layout so they will not work as GamePads. This adds the vendor Id and layout so that it will work outside of an XInput context.

Related Issue

No related issues, I found this by trying to use SDL on linux and the GamePad always being null.

Types of changes

  • Docs change / refactoring / dependency upgrade
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My change requires a change to the documentation.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have built and run the editor to try this change out.

@Doprez Doprez changed the title Adds the 8BitDo layout to for proper GamePad support. feat: Adds the 8BitDo layout to for proper GamePad support. May 17, 2025
@Kryptos-FR
Copy link
Member

Do you have a link to the vendor specs? If so can it be added as comment?

We might need to do fixes in the future so it's good to have a reference.

@Doprez
Copy link
Contributor Author

Doprez commented May 17, 2025

Unfortunately not a full spec sheet I only have the vendor Id and product Id from the mapping on my machine \\?\hid#vid_2dc8&pid_310a ... and using Device Hunt and there is the USB spec sheet for general USB debugging https://www.usb.org/sites/default/files/hut1_4.pdf

Although its important to note that this mapping is probably only useful for the SDL context since the mappings are coming from the JoyStick controller mappings so maybe I should check that this is also coming from the SDL input source?

@Eideren Eideren requested a review from Kryptos-FR May 24, 2025 14:44
Comment on lines +31 to +35
byte[] guidBytes = device.ProductId.ToByteArray();

ushort vendorId = BitConverter.ToUInt16(guidBytes, 4);

return vendorId == _vendorId;
Copy link
Member

Choose a reason for hiding this comment

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

Is there a way to do a non-alloc comparison? Maybe with a Span<byte> or a similar API.


namespace Stride.Input;

public class GamePadLayout8BitDo : GamePadLayout
Copy link
Member

Choose a reason for hiding this comment

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

If it is not meant to be derived, better seal the class.

@Eideren Eideren marked this pull request as draft August 27, 2025 15:39
@Eideren
Copy link
Collaborator

Eideren commented Aug 27, 2025

Moving this to draft, let us know when you're done working on this one :)

@Doprez
Copy link
Contributor Author

Doprez commented Aug 27, 2025

Makes sense, I think I may replace this with a more generic solution because of the "only useful for the SDL context since the mappings are coming from the JoyStick controller mappings" issue.

I did start using the HIDDevice lib from DevDecoder so that the controllers would work consistently between different windowing backends.

https://github.com/Doprez/Doprez.Stride.MoreInput/blob/main/src/GameControllerHIDDevice.cs

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.

3 participants