Constructor
new Gamepads(optionsopt)
Creates a new instance of the class.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> |
Gamepad settings. |
- Source:
Members
enable :boolean
Whether the gamepads subsystem should be enabled (true) or not (false).
When the subsystem is inactive, devices do not respond to input.
Type:
- boolean
- Source:
(readonly) numGamepads :number
Returns the number of connected gamepads. This value is always represented
by an integer between 0 and 4.
Type:
- number
- Source:
(readonly) stickLeftDown :boolean
Returns true if the direction of any of the connected gamepad's left analog
stick is facing down. For gamepads that do not have analog sticks, this value
is always false.
Type:
- boolean
- Source:
(readonly) stickLeftJustDown :boolean
Returns true if the direction of any of the connected gamepad's left analog
stick was just facing down. For gamepads that do not have analog sticks, this
value is always false.
Type:
- boolean
- Source:
(readonly) stickLeftJustLeft :boolean
Returns true if the direction of any of the connected gamepad's left analog
stick was just facing left. For gamepads that do not have analog sticks, this
value is always false.
Type:
- boolean
- Source:
(readonly) stickLeftJustRight :boolean
Returns true if the direction of any of the connected gamepad's left analog
stick was just facing right. For gamepads that do not have analog sticks, this
value is always false.
Type:
- boolean
- Source:
(readonly) stickLeftJustUp :boolean
Returns true if the direction of any of the connected gamepad's left analog
stick was just facing up. For gamepads that do not have analog sticks, this
value is always false.
Type:
- boolean
- Source:
(readonly) stickLeftLeft :boolean
Returns true if the direction of any of the connected gamepad's left analog
stick is facing left. For gamepads that do not have analog sticks, this value
is always false.
Type:
- boolean
- Source:
(readonly) stickLeftRight :boolean
Returns true if the direction of any of the connected gamepad's left analog
stick is facing right. For gamepads that do not have analog sticks, this
value is always false.
Type:
- boolean
- Source:
(readonly) stickLeftUp :boolean
Returns true if the direction of any of the connected gamepad's left analog
stick is facing up. For gamepads that do not have analog sticks, this value
is always false.
Type:
- boolean
- Source:
(readonly) stickRightDown :boolean
Returns true if the direction of any of the connected gamepad's right analog
stick is facing down. For gamepads that do not have analog sticks, this value
is always false.
Type:
- boolean
- Source:
(readonly) stickRightJustDown :boolean
Returns true if the direction of any of the connected gamepad's right analog
stick was just facing down. For gamepads that do not have analog sticks, this
value is always false.
Type:
- boolean
- Source:
(readonly) stickRightJustLeft :boolean
Returns true if the direction of any of the connected gamepad's right analog
stick was just facing left. For gamepads that do not have analog sticks, this
value is always false.
Type:
- boolean
- Source:
(readonly) stickRightJustRight :boolean
Returns true if the direction of any of the connected gamepad's right analog
stick was just facing right. For gamepads that do not have analog sticks,
this value is always false.
Type:
- boolean
- Source:
(readonly) stickRightJustUp :boolean
Returns true if the direction of any of the connected gamepad's right analog
stick was just facing up. For gamepads that do not have analog sticks, this
value is always false.
Type:
- boolean
- Source:
(readonly) stickRightLeft :boolean
Returns true if the direction of any of the connected gamepad's right analog
stick is facing left. For gamepads that do not have analog sticks, this value
is always false.
Type:
- boolean
- Source:
(readonly) stickRightRight :boolean
Returns true if the direction of any of the connected gamepad's right analog
stick is facing right. For gamepads that do not have analog sticks, this
value is always false.
Type:
- boolean
- Source:
(readonly) stickRightUP :boolean
Returns true if the direction of any of the connected gamepad's right analog
stick is facing up. For gamepads that do not have analog sticks, this value
is always false.
Type:
- boolean
- Source:
Methods
get(id) → {rune.input.Gamepad}
Request an instance of the Gamepad class. Each instance represents a
connected device. Because the subsystem can handle up to four devices, an
ID between 0 and 3 must be used. The method always returns a Gamepad object,
even if there is no connected physical device for the requested ID. A
Gamepad object that is not connected to a physical device can still be used
via code, but all input is always false for that Gamepad object.
Parameters:
Name | Type | Description |
---|---|---|
id |
number | ID of requested Gamepad object. |
- Source:
Throws:
-
If the requested ID is outside the range of possible IDs.
- Type
- RangeError
Returns:
- Type
- rune.input.Gamepad
justPressed(button) → {boolean}
Check if any of the connected devices just pressed a specific button that
is identified by its button ID.
Parameters:
Name | Type | Description |
---|---|---|
button |
number | button Button ID. |
- Source:
Returns:
- Type
- boolean
justReleased(button) → {boolean}
Check if any of the connected devices released a specific button that is
identified via their button ID.
Parameters:
Name | Type | Description |
---|---|---|
button |
number | button Button ID. |
- Source:
Returns:
- Type
- boolean
pressed(button) → {boolean}
Check if one of the connected devices presses a specific button which is
identified via its button ID.
Parameters:
Name | Type | Description |
---|---|---|
button |
number | Button ID. |
- Source:
Returns:
- Type
- boolean
reset() → {undefined}
Resets the input of all connected Gamepad objects.
- Source:
Returns:
- Type
- undefined
vibrate(durationopt, delayopt, weakopt, strongopt, typeopt) → {undefined}
Triggers vibration on all connected gamepads.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
duration |
number |
<optional> |
250 | The duration of the vibration in milliseconds. |
delay |
number |
<optional> |
0 | The delay before the vibration starts, in milliseconds. |
weak |
number |
<optional> |
1.0 | The intensity of the weak (low-frequency) vibration, ranging from 0.0 to 1.0. |
strong |
number |
<optional> |
1.0 | The intensity of the strong (high-frequency) vibration, ranging from 0.0 to 1.0. |
type |
string |
<optional> |
"dual-rumble" | The type of vibration effect to use (e.g., "dual-rumble"). |
- Source:
Returns:
- Type
- undefined