-
Notifications
You must be signed in to change notification settings - Fork 692
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: Gamepad support in WinUI 3 #6891
Comments
@codendone Is there any info on this question? |
Gamepads work with WinUI |
@castorix Thanks for the response 👍 I should have been clearer in my original question, sorry about that. UWP has out of the box support to navigate and interact with the UI with gamepads, whereas WinUI3 in WinAppSDK doesn't seem to have this yet (or at least I wasn't able to get it working). I'm wondering if anyone has any insight into the current state of this, or if there are any plans for it if this is indeed the case. This is the sort of support I'm looking for: https://docs.microsoft.com/en-us/windows/apps/design/input/gamepad-and-remote-interactions. I did end up testing Windows.Gaming.Input, and this seems to work entirely as expected. So as an alternative I'd imagine I can either map gamepad inputs to keyboard inputs, or use FocusManager to emulate the above support. I'll keep this issue updated as I find time to continue investigating, though insight from anyone who's had experience with this would certainly be appreciated. |
For now, what I've done is use InputInjector to map gamepad inputs to keyboard inputs, and enable navigation using keyboard navigation strategies (e.g. XYFocusKeyboardNavigation). As far as I can tell, this is the simplest way of achieving UWP's out of the box gamepad navigation without implementing custom focus management logic. This should also support focus navigation strategies. From the sounds of it, UWP does the reverse and maps keyboard input to gamepad inputs 🤔 So if anyone knows of a more direct way to do this, I'd love to hear it. |
The moment I posted this I realized it's likely that the more direct way that I'm looking for would be to just inject gamepad inputs, if WinAppSDK is also doing this mapping. InjectGamepadInput didn't work out, this is just treated as another controller. As it turns out, Window.System.VirtualKey also has gamepad inputs as virtual keys. Injecting these as keyboard input results in the exact out of the box UI navigation that UWP has, even with XYFocusKeyboardNavigation disabled. I'm happy to move forward with this solution for now, unless anyone has any suggestions. I'll close the issue in a few days otherwise. |
So just so I'm clear this 10 month old article is total BS, right? None of this actually works, nor has it ever worked in WinUI 3. I have an Xbox One controller and there's no gamepad support whatsoever. KeyDown/KeyUp doesn't register events for VirtualKey.Gamepad*, no XYNavigation, no FocusEngage, no Mouse Mode, nothing. All of these except Mouse Mode works in a UWP project using the same hardware. |
So you're saying that a Control's XYNavigation and FocusEngage responds to keyboard injection of a gamepad VirtualKeys? How do you trigger the injection with an actual gamepad though? Using Win32 API? |
It worked with WinUI3 in UWP (before the switch to WinAppSDK). I think this article is still valuable despite it not functioning in WinUI3 in WinAppSDK by default, since it shows the keyboard to gamepad mappings and gets across the general philosophy well.
Yep, seems that way 👍
I'm personally using Windows.Gaming.Input to map gamepad state to keyboard inputs via InputInjector.InjectKeyboardInput. One thing to note about this library is Gamepad.Gamepads() will be empty on app launch (this is the case for UWP as well). You need to listen to the Gamepad.GamepadAdded event instead. |
Going to close this issue since a workaround has been identified. |
Is there any info on gamepad support in Windows App SDK for WinUI 3? Is it possible that it'd make it into WinAppSDK 1.1 or 1.2? I haven't seen mention of it in the WinAppSDK roadmap, WinUI 3 roadmap, or in any of the community calls.
The latest info I could find was that it isn't supported in WinUI 3 GA.
Edit: Clarified the question here.
The text was updated successfully, but these errors were encountered: