gdk: GameInput Joystick backend
The recommended gamepad API to use on GDK is GameInput, although Microsoft do provide a wrapper XInputOnGameInput, it's still a wrapper, SDL should be able to handle GameInput natively.
Description
This is an implementation of the joystick backend through native GameInput,
currently it only supports Gamepad-like or Controller-like devices.
If the device's family is reported as Xbox360 or XboxOne then it mimics the xinputjoystick backend and provides a built-in mapping, allowing it to act as a drop-in replacement for xinputjoystick most of the time.
I'm free to any suggestions because currently this backend is a bit messy and I'd like to improve it.
The GameInput docs are public, no partner access is required: https://learn.microsoft.com/en-us/gaming/gdk/_content/gc/input/overviews/input-overview
Existing Issue(s)
Fixed the PR for SDL3.
Can you squash for review? Thanks!
I'm currently thinking about whether to implement GameInput mouse, keyboard & touch support as well. Are there any GDKX developers that want this stuff in SDL for GDK and can test that?
We're going to need GameInput for our upcoming game, so if this could make it into the 2.30.0 release it would be much appreciated! 🙏
We're about to ship 2.30, and this hasn't had any cleanup or testing, but we can add this to the 2.32 milestone.
@nkrapivin, can you please squash this PR for review, and resolve conflicts?
Hi @RustyMoyher ,
I'm very sorry about that. I have some errands here and there, what parts of GameInput do you want implemented?
Right now I only have the GameController backend which should work fine, the keyboard & mouse backends are not implemented however, and you're supposed to use the UI TextInput code (which was merged a long time ago) on Xbox anyway.
- Nikita Krapivin, Valkyrie Initiative LLP.
Hi @nkrapivin
No worries! We only need the GameController backend.
Okie! Then I'll finish up the GameController backend, expect weird and quirky force pushes today-tomorrow...
When you're done, please squash the changes for review. You can do that by running git rebase -i origin and then choosing f for all commits except the first one.
There's a current problem with the backend is that I don't know how to implement the mappings (like SDL-switch has a hardcoded mapping string). I tried to simulate the "new" XInput backend as much as possible so it should be similar, but I don't know how to make such a string.
Does the implementation need to be C++? Normally we've left everything C unless it specifically needs to be C++ for platform reasons.
Does the implementation need to be C++? Normally we've left everything C unless it specifically needs to be C++ for platform reasons.
Most GDK headers require at least C++11, technically GameInput doesn't have that check but GDK does imply C++. (For example XUser and it's device association API does require C++11, and a game will probably use this to associate players <-> gamepads, which is why devicePath is set to the APP_LOCAL_DEVICE_ID)
I'll go ahead and merge this and we can address the feedback from @chrism-MSFT via followup commits.
Thanks!
This has been merged and I've updated it with the feedback from @chrism-MSFT.