Class: Gamepad

(package) rune.input.Gamepad()

The Gamepad class represents a physical gamepad device and its current state. Note that the class can not be instantiated by itself, Gamepad objects are retrieved via an instance of the Gamepads class, which acts as a handler for all connected devices. Objects of the Gamepad class are used to read the state of a specific gamepad device, for example for player one, etc..

Constructor

(package) new Gamepad()

Creates a new Gamepad object.
Source:

Members

active :boolean

Whether the Gamepad object is active (true) or not (false). If false, the state of the Gamepad object will not be updated.
Type:
  • boolean
Source:

(readonly) buttons :Array

A list of the Gamepad object's buttons and their current state. Each button is indexed by their button ID.
Type:
  • Array
Source:

(readonly) connected :boolean

Indicates whether a physical device is connected to this Gamepad object. Returns false when no device state is available.
Type:
  • boolean
Source:

(readonly) id :string

An ID string containing information about the physical device that the Gamepad object represents. Note that this value is set by the manufacturer of the current physical device.
Type:
  • string
Source:

(readonly) index :number

An integer that is auto-incremented to be unique for each device currently connected to the system.
Type:
  • number
Source:

(readonly) stickLeft :rune.geom.Point

The direction of the left joystick of the input device. The direction is represented by a Point object that describes the x- and y-axis of the joystick.
Type:
Source:

(readonly) stickLeftDown :boolean

If the left analog stick of the Gamepad object is facing down.
Type:
  • boolean
Source:

(readonly) stickLeftJustDown :boolean

If the left analog stick of the Gamepad object was just facing down.
Type:
  • boolean
Source:

(readonly) stickLeftJustLeft :boolean

If the left analog stick of the Gamepad object was just facing left.
Type:
  • boolean
Source:

(readonly) stickLeftJustRight :boolean

If the left analog stick of the Gamepad object was just facing right.
Type:
  • boolean
Source:

(readonly) stickLeftJustUp :boolean

If the left analog stick of the Gamepad object was just facing up.
Type:
  • boolean
Source:

(readonly) stickLeftLeft :boolean

If the left analog stick of the Gamepad object is facing left.
Type:
  • boolean
Source:

(readonly) stickLeftRight :boolean

If the left analog stick of the Gamepad object is facing right.
Type:
  • boolean
Source:

(readonly) stickLeftUp :boolean

If the left analog stick of the Gamepad object is facing up.
Type:
  • boolean
Source:

(readonly) stickRight :rune.geom.Point

The direction of the right joystick of the input device. The direction is represented by a Point object that describes the x- and y-axis of the joystick.
Type:
Source:

(readonly) stickRightDown :boolean

If the right analog stick of the Gamepad object is facing down.
Type:
  • boolean
Source:

(readonly) stickRightJustDown :boolean

If the right analog stick of the Gamepad object was just facing down.
Type:
  • boolean
Source:

(readonly) stickRightJustLeft :boolean

If the right analog stick of the Gamepad object was just facing left.
Type:
  • boolean
Source:

(readonly) stickRightJustRight :boolean

If the right analog stick of the Gamepad object was just facing right.
Type:
  • boolean
Source:

(readonly) stickRightJustUp :boolean

If the right analog stick of the Gamepad object was just facing up.
Type:
  • boolean
Source:

(readonly) stickRightLeft :boolean

If the right analog stick of the Gamepad object is facing left.
Type:
  • boolean
Source:

(readonly) stickRightRight :boolean

If the right analog stick of the Gamepad object is facing right.
Type:
  • boolean
Source:

(readonly) stickRightUp :boolean

If the right analog stick of the Gamepad object is facing up.
Type:
  • boolean
Source:

threshold :number

The "dead zone" threshold of a joystick. All input data lower than this value is ignored.
Type:
  • number
Default Value:
  • 0.2
Source:

tolerance :number

Threshold for when input data from joysticks is to be counted as a boolean true value.
Type:
  • number
Default Value:
  • 0.5
Source:

Methods

justPressed(button) → {boolean}

Whether a specific button on the input device was just pressed. The button is identified based on its button ID.
Parameters:
Name Type Description
button number Button ID.
Source:
Returns:
Type
boolean

justReleased(button) → {boolean}

Whether a specific button on the input device was just released. The button is identified based on its button ID.
Parameters:
Name Type Description
button number Button ID.
Source:
Returns:
Type
boolean

pressed(button) → {boolean}

Whether a specific button on the input device is pressed. The button is identified based on its button ID.
Parameters:
Name Type Description
button number Button ID.
Source:
Returns:
Type
boolean

reset() → {undefined}

Resets the state of the Gamepad object.
Source:
Returns:
Type
undefined

vibrate(durationopt, delayopt, weakopt, strongopt, typeopt) → {undefined}

Triggers vibration using playEffect, falling back to legacy hapticActuators and pulse for dual-rumble. Unsupported devices and rejected effects are safe no-ops. A new call, reset or disconnect cancels pending fallback work.
Parameters:
Name Type Attributes Default Description
duration number <optional>
250 Duration in milliseconds. Zero or less stops vibration and cancels pending requests.
delay number <optional>
0 Delay before vibration starts, in milliseconds.
weak number <optional>
1.0 High-frequency motor intensity, clamped to 0.0–1.0.
strong number <optional>
1.0 Low-frequency motor intensity, clamped to 0.0–1.0.
type string <optional>
"dual-rumble" The vibration effect type.
Source:
Returns:
Type
undefined