This is a function that will be called with each update to get new Gamepad data.
Typically this should be something like: new Gamepads(() => navigator.getGamepads());
This event fires when the finish()
method has been called.
Returns true if the finish()
method has been called.
Provides a way of identifying keyboards so they can be easily retrieved later
Returns the name of this type. This can be used rather than instanceof which is sometimes unreliable.
This method is intended to be called by a clock to provide regular updates. It should not be called by consumers of the library.
The method first of all attempts to match up any unmatched gamepad objects with incoming gamepad data. It then loops through each matched gamepad and updates the object's data with what's coming from the matched up gamepad data.
How many milliseconds have passed since the last update cycle.
Provides a way for setting the ref through a chained function call. For example:
clock.addChild(new Gamepads(() => navigator.getGamepads()).withRef('gamepads'));
The calling object.
The ref to set on the object.
Generated using TypeDoc
The Gamepads class provides an easy way for keeping shimi Gamepad objects synced up to Gamepad objects from the Gamepad Web API.
When a gamepad gets added to a Gamepads instance, it is added as unmatched. With each update cycle, Gamepads will attempt to pair up any unmatched gamepad objects with incoming gamepad data. Once a match is established, the gamepad object will get updated with new gamepad data each cycle, allowing for the state of each button to be easily tracked.