mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 05:03:37 +00:00
The GamepadPlugin
will now call refreshPads
as part of its start process. This allows you to use Gamepads across multiple Scenes, without having to wait for a connected event from each one of them. If you've already had a connected event in a previous Scene, you can now just read the pads directly via this.input.gamepad.pad1
and similar. Fix #4890
This commit is contained in:
parent
a54a3a3e96
commit
5ecdc3b4a2
1 changed files with 11 additions and 3 deletions
|
@ -40,6 +40,9 @@ var InputEvents = require('../events');
|
|||
* to the gamepads you can poll its buttons and axis sticks. See the properties and methods available on
|
||||
* the `Gamepad` class for more details.
|
||||
*
|
||||
* As of September 2020 Chrome, and likely other browsers, will soon start to require that games requesting
|
||||
* access to the Gamepad API are running under SSL. They will actively block API access if they are not.
|
||||
*
|
||||
* For more information about Gamepad support in browsers see the following resources:
|
||||
*
|
||||
* https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API
|
||||
|
@ -221,6 +224,8 @@ var GamepadPlugin = new Class({
|
|||
if (this.enabled)
|
||||
{
|
||||
this.startListeners();
|
||||
|
||||
this.refreshPads();
|
||||
}
|
||||
|
||||
this.sceneInputPlugin.pluginEvents.once(InputEvents.SHUTDOWN, this.shutdown, this);
|
||||
|
@ -292,6 +297,11 @@ var GamepadPlugin = new Class({
|
|||
this.target.removeEventListener('gamepaddisconnected', this.onGamepadHandler);
|
||||
|
||||
this.sceneInputPlugin.pluginEvents.off(InputEvents.UPDATE, this.update);
|
||||
|
||||
for (var i = 0; i < this.gamepads.length; i++)
|
||||
{
|
||||
this.gamepads[i].removeAllListeners();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -304,7 +314,7 @@ var GamepadPlugin = new Class({
|
|||
{
|
||||
for (var i = 0; i < this.gamepads.length; i++)
|
||||
{
|
||||
this.gamepads.connected = false;
|
||||
this.gamepads[i].pad.connected = false;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -489,8 +499,6 @@ var GamepadPlugin = new Class({
|
|||
{
|
||||
this.stopListeners();
|
||||
|
||||
this.disconnectAll();
|
||||
|
||||
this.removeAllListeners();
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue