Bug 205448
| Summary: | navigator.getGamepads() returns empty array in my WKWebView app | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Iain <iain> |
| Component: | WebCore Misc. | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED WORKSFORME | ||
| Severity: | Normal | CC: | ashley, beidson, webkit-bug-importer |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari 13 | ||
| Hardware: | iPhone / iPad | ||
| OS: | iOS 13 | ||
Iain
It's currently not possible to use the GamePad API within a hybrid application. Using the navigator.getGamePads() method in a WKWebview returns an empty array when a gamepad is attached, even after user interaction. Whereas Safari on the same device will return an array containing a Gamepad instance after user interaction.
I tried adding the Wireless Accessory Configuration capability to the application, but it had no effect. This was the only plausible sounding capability in the list.
Replication:
1. Connect gamepad to iOS device using bluetooth ( Dualshock 4 controllers are easy to setup )
2. Load http://luser.github.io/gamepadtest/
3. Press any button on the device ( required to "wakeup" the API )
Expected result:
Page displays controller status
Actual result:
Nothing happens
For a more minimal test you can call navigator.getGamePads() from the console and inspect the results.
Application was built in Xcode 11.3 (11C29) targeting iOS 12.0 and tested on iPad Pro ( ML0H2ZP/A ) on iPadOS 13.2.3 (17B111) with Sony DS4 ( CUH-ZCT1E ).
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Radar WebKit Bug Importer
<rdar://problem/58119044>
Brady Eidson
Gamepads work in Safari, and Safari is WKWebView based.
There's *plenty* of WKWebView specific support to make this work.
We need more specifics to find out why it's not working in your app.
Brady Eidson
OH sorry - Figured it out:
> Application was built in Xcode 11.3 (11C29) targeting iOS 12.0 and tested on iPad Pro ( ML0H2ZP/A ) on iPadOS 13.2.3 (17B111) with Sony DS4 ( CUH-ZCT1E ).
It's not expected the DS4 would work on iOS 12.
It's works on iOS 13+.