WebView2Feedback icon indicating copy to clipboard operation
WebView2Feedback copied to clipboard

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

Open Sentry-Thibault opened this issue 1 year ago • 17 comments

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

Sentry-Thibault avatar Feb 09 '24 15:02 Sentry-Thibault

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?

jennifer-nejad avatar Feb 09 '24 22:02 jennifer-nejad

Hi @jennifer-jacobs, Thanks for reply.

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

Sentry-Thibault avatar Feb 12 '24 08:02 Sentry-Thibault

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.

Sentry-Thibault avatar Feb 12 '24 11:02 Sentry-Thibault

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-nejad avatar Feb 12 '24 18:02 jennifer-nejad

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

Sentry-Thibault avatar Feb 15 '24 09:02 Sentry-Thibault

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.

jennifer-nejad avatar Feb 16 '24 18:02 jennifer-nejad

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

Sentry-Thibault avatar Feb 18 '24 18:02 Sentry-Thibault

@jennifer-jacobs Up please

Sentry-Thibault avatar Mar 01 '24 08:03 Sentry-Thibault

@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?

jennifer-nejad avatar Mar 06 '24 01:03 jennifer-nejad

@jennifer-jacobs

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

Sentry-Thibault avatar Mar 07 '24 09:03 Sentry-Thibault

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.

bastecklein avatar Mar 09 '24 14:03 bastecklein

@jennifer-jacobs Up please

Sentry-Thibault avatar Mar 25 '24 14:03 Sentry-Thibault

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

jennifer-nejad avatar Apr 09 '24 23:04 jennifer-nejad

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

  • https://stackoverflow.com/questions/70975642/webview-not-receiving-input-from-xbox-controller-on-windows-11
  • https://stackoverflow.com/questions/69115995/how-to-detect-xbox-controller-key-press-events-in-windows-11-in-winjs-uwp-app

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

geocine avatar Jul 12 '24 03:07 geocine

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.

chrisgregan avatar Oct 08 '24 12:10 chrisgregan

The issue still not fixed. I am trying to implement UWP app with WebView2 and I need to control the web page with gamepad.

AlexRUiLs avatar Feb 19 '25 20:02 AlexRUiLs

@jennifer-jacobs Same issue in Maui WebView2 and Maui Blazor. Only the Xbox-Button works or every Button works if the Dev-Tools are focused. This breaks development for windows completely. Gaming Services are installed in Windows 11 (27.99.7001.0). Are there any workarounds or any updates when it's planned to fix?

MarkusRodler avatar Apr 11 '25 18:04 MarkusRodler

We're seeing similar behavior in .NET MAUI 8 using the WebView control. I can provide an additional repro if needed, but once we discovered the issue we did the following as a sanity check:

  1. Created an empty .NET MAUI project
  2. Updated MainPage.xaml to only include a WebView with Source="https://hardwaretester.com/gamepad"
  3. Ran the app

Similarly to what others have mentioned, the WebView totally ignores gamepad input unless the dev tools window is opened and focused. We tested under the following conditions:

  • Wired PowerA brand Xbox controller
  • Both Windows 10 and Windows 11
  • Gaming Services Runtime installed
  • With and without a direct project dependency on the Microsoft.GameInput NuGet package

knotekbr avatar Aug 05 '25 14:08 knotekbr