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

Xbox Controller is not working in Webview2 in UWP [WinUI2] #4366

Open
Sentry-Thibault opened this issue Feb 9, 2024 · 15 comments
Open

Xbox Controller is not working in Webview2 in UWP [WinUI2] #4366

Sentry-Thibault opened this issue Feb 9, 2024 · 15 comments
Assignees
Labels
bug Something isn't working tracked We are tracking this work internally.

Comments

@Sentry-Thibault
Copy link

Sentry-Thibault commented Feb 9, 2024

What happened?

I've created a simple UWP application with WinUI 2 according to the official documentation.
The webview is loading the URL https://gamepad-tester.com/

I connected a Gamepad (Xbox One Controller) to my computer.
The gamepad works fine in Google Chrome and Microsoft Edge (Chromium).

But the gamepad is not working in Webview2.

See also: #1318

Importance

Blocking. My app's basic functions are not working due to this issue.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

No response

SDK Version

No response

Framework

WinUI2/UWP

Operating System

Windows 10

OS Version

19045.3930

Repro steps

Create a simple WinUI2 UWP application and add a webview2 targeting the URL https://gamepad-tester.com/

Repros in Edge Browser

No

Regression

No, this never worked

Last working version (if regression)

No response

AB#48930763

@Sentry-Thibault Sentry-Thibault added the bug Something isn't working label Feb 9, 2024
@jennifer-jacobs jennifer-jacobs added the tracked We are tracking this work internally. label Feb 9, 2024
@jennifer-jacobs
Copy link

Hi @Sentry-Thibault, I was able to repro this. It's been added to our backlog!

I did find this bug (#3025) which may be related. I wonder if this is specifically a UWP issue, or if this works in a WinForms app. I know you need a UWP app for your scenario since you're building an app for Xbox.

If you open up a DevTools window like the user in that bug tried, does the behavior change?

@Sentry-Thibault
Copy link
Author

Hi @jennifer-jacobs, Thanks for reply.

It seems to not working with dev tools window focused in my case.

@Sentry-Thibault
Copy link
Author

Sentry-Thibault commented Feb 12, 2024

Hi,

If I add Xbox controller input detection UI in my UWP app (like : https://sandervandevelde.wordpress.com/2016/02/29/using-your-xbox-one-controller-in-a-uwp-app/)

It works.
It confirms that the problem is coming from WebView2.

@jennifer-jacobs
Copy link

Hi @Sentry-Thibault,
I looked more into this and only GameInput based providers work in UWP apps on Desktop and Xbox with WebView2. This is part of Gaming Services Runtime, which can be downloaded here. With this installed on your PC or Xbox this scenario should work. I believe your app could take a dependency on the Gaming Services Runtime package.

Some info on porting your app from other APIs to GameInput that might be helpful: https://learn.microsoft.com/en-us/gaming/gdk/_content/gc/input/porting/input-porting

Hopefully this works for you!

@jennifer-jacobs jennifer-jacobs removed the tracked We are tracking this work internally. label Feb 12, 2024
@Sentry-Thibault
Copy link
Author

Sentry-Thibault commented Feb 15, 2024

Hi @jennifer-jacobs,

Thanks for sharing this but I'm wondering how to integrate this.
All examples are using C++ and some information say that GameInput not need to be "integrate".

I'm in the fog right now ^^.

[EDIT]
Maybe it seems to be the same problem as previous link I had send to you : https://sandervandevelde.wordpress.com/2016/02/29/using-your-xbox-one-controller-in-a-uwp-app/. But this link allows me to use Gamepad in UWP app but not in the webview2 page.

Thanks

@jennifer-jacobs
Copy link

Hey @Sentry-Thibault,
Unfortunately I'm not able to test this right now to confirm, but to start I would try downloading the Gaming Services Runtime and installing it on your machine. Then try the same scenario again and see if it works.

I should be able to test this out locally next week if that doesn't work for you.

@Sentry-Thibault
Copy link
Author

@jennifer-jacobs It doesn't work for me unfortunaly.

@Sentry-Thibault
Copy link
Author

@jennifer-jacobs Up please

@jennifer-jacobs
Copy link

@Sentry-Thibault I just tried this on Win11 and it works on my machine. It's possible I have other tools installed however that are making this possible.

Just to confirm, you installed the gaming services package on your Win10 machine and then re-tried the scenario and it didn't work, correct?

How do you have your Xbox controller connected to your PC? Through bluetooth or through the Xbox wireless adapter?

@Sentry-Thibault
Copy link
Author

@jennifer-jacobs

  • Win10 + Gaming service package doesn't work.
  • Xbox controller wired (360 Xbox controller for windows)

@bastecklein
Copy link

For what it's worth, I have noticed that if you create a UWP/WebView2 application, Gamepad input just works when running the app on an actual Xbox, but does not work at all when running on desktop. If I remember right though, this same behavior happened with the original WebView, so I think it might be a UWP issue.

@Sentry-Thibault
Copy link
Author

@jennifer-jacobs Up please

@jennifer-jacobs jennifer-jacobs added the tracked We are tracking this work internally. label Apr 9, 2024
@jennifer-jacobs
Copy link

@Sentry-Thibault I was able to repro this and it's been added to our backlog!

@geocine
Copy link

geocine commented Jul 12, 2024

For what it's worth, I have noticed that if you create a UWP/WebView2 application, Gamepad input just works when running the app on an actual Xbox, but does not work at all when running on desktop. If I remember right though, this same behavior happened with the original WebView, so I think it might be a UWP issue.

I can confirm this , this is an existing issue too on our old wwahost apps on Windows 11 . Works on both Windows 10 and Xbox

We are planning to move away from wwahost . If this issue persist on WebView2 then its not worth the move. We are trying to reuse as much the current code that we have for the UI

@chrisgregan
Copy link

Hi, I am having the same issue using WebView2 embedded in a WinUI 3 application running on Windows 11. When I navigate to https://gamepad-tester.com/, it only registers input when I press the Xbox button on the controller - so there is some communication happening. No other button or stick input works at all however.

@jennifer-jacobs You mentioned that you've been able to repro the issue and it's been added to the backlog. Is there an ETA for addressing it or a workaround I could try in the mean time?

It's disappointing not to be able to support gamepad input as it severely limits the options for gaming with WebView2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests

5 participants