HTML5 Gamepad API on Chrome

前端 未结 3 672
一生所求
一生所求 2021-02-15 15:15

I\'m using Chrome (Version 19.0.1084.46). I enabled the Gamepad API in chrome://flags. I plugged in some game pads, but navigator.webkitGamepads is always an array

3条回答
  •  感动是毒
    2021-02-15 15:38

    I was having trouble with this as well (on Ubuntu 10.04 with Chrome 21.0.1163.0 dev). I ran across this from a thread on chromium-discussions:

    Note that you need to press a face button on the gamepad before data will be available. This is due to fingerprinting concerns.

    I wrote a quick test page that seems to work if you hold a controller button down while refreshing the page. I'm using a Gamestop-branded Xbox 360 wired controller with the xboxdrv driver.

    Also, one other important thing to note - Chrome treats these Gamepad objects like snapshots of the controller state. So if you pass around the actual Gamepad object, you'll never get updated information. Chrome seems to only poll the controller when you call the navigator.webkitGamepads[x] getter (see line 23 in my test page).

提交回复
热议问题