Skip to content

Commit e61889f

Browse files
committed
Added gamepads to Device feature test
1 parent f98bbc1 commit e61889f

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

v3/src/device/Input.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,30 @@ var Input = {
1010
mspointer: false,
1111

1212
// @property {?string} wheelType - The newest type of Wheel/Scroll event supported: 'wheel', 'mousewheel', 'DOMMouseScroll'
13-
wheelEvent: null
13+
wheelEvent: null,
14+
15+
// @property {boolean} gamepads - Is navigator.getGamepads available?
16+
gamepads: false
1417

1518
};
1619

1720
function init ()
1821
{
19-
if ('ontouchstart' in document.documentElement || (window.navigator.maxTouchPoints && window.navigator.maxTouchPoints >= 1))
22+
if ('ontouchstart' in document.documentElement || (navigator.maxTouchPoints && navigator.maxTouchPoints >= 1))
2023
{
2124
Input.touch = true;
2225
}
2326

24-
if (window.navigator.msPointerEnabled || window.navigator.pointerEnabled)
27+
if (navigator.msPointerEnabled || navigator.pointerEnabled)
2528
{
2629
Input.mspointer = true;
2730
}
2831

32+
if (navigator.getGamepads)
33+
{
34+
Input.gamepads = true;
35+
}
36+
2937
if (!OS.cocoonJS)
3038
{
3139
// See https://developer.mozilla.org/en-US/docs/Web/Events/wheel

v3/src/input/gamepad/GamepadManager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var GamepadManager = new Class({
3434
{
3535
var config = this.manager.config;
3636

37-
this.enabled = config.inputGamepad;
37+
this.enabled = config.inputGamepad && this.manager.game.device.Input.gamepads;
3838

3939
this.target = window;
4040

0 commit comments

Comments
 (0)