Skip to content

Commit

Permalink
Use the current Gamepad API
Browse files Browse the repository at this point in the history
`webkitGetGamepads` is deprecated in recent browser versions. Provide use of the current API if available.
  • Loading branch information
Systemcluster committed Sep 13, 2014
1 parent 178be05 commit 176a0a7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/input/input_gamepads.js
Expand Up @@ -4,7 +4,7 @@ pc.extend(pc.input, function () {
* @class Input handler for accessing GamePad input
*/
var GamePads = function () {
this.gamepadsSupported = !!navigator.webkitGetGamepads;
this.gamepadsSupported = !!navigator.getGamepads || !!navigator.webkitGetGamepads;

this.current = [];
this.previous = [];
Expand Down Expand Up @@ -125,7 +125,7 @@ pc.extend(pc.input, function () {
poll: function () {
var pads = [];
if (this.gamepadsSupported) {
var padDevices = navigator.webkitGetGamepads();
var padDevices = navigator.getGamepads ? navigator.getGamepads() : navigator.webkitGetGamepads();
var i, len = padDevices.length;
for (i = 0; i < len; i++) {
if (padDevices[i]) {
Expand Down

0 comments on commit 176a0a7

Please sign in to comment.