MicrosoftEdge / WebView2Feedback

Feedback and discussions about Microsoft Edge WebView2
https://aka.ms/webview2
431 stars 51 forks source link

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

Open Sentry-Thibault opened 6 months ago

Sentry-Thibault commented 6 months ago

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: https://github.com/MicrosoftEdge/WebView2Feedback/issues/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

jennifer-jacobs commented 6 months ago

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 commented 6 months ago

Hi @jennifer-jacobs, Thanks for reply.

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

Sentry-Thibault commented 6 months ago

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 commented 6 months ago

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!

Sentry-Thibault commented 6 months ago

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 commented 6 months ago

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 commented 6 months ago

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

Sentry-Thibault commented 5 months ago

@jennifer-jacobs Up please

jennifer-jacobs commented 5 months ago

@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 commented 5 months ago

@jennifer-jacobs

bastecklein commented 5 months ago

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 commented 4 months ago

@jennifer-jacobs Up please

jennifer-jacobs commented 4 months ago

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

geocine commented 1 month ago

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