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 :booelan

Indicates whether the Gamepad object is connected (true) or not (false). Generally, this value should never be false as long as the Gamepad object exists.
Type:
  • booelan
Source:

(readonly) id :number

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:
  • number
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 :booelan

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

(readonly) stickLeftJustDown :booelan

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

(readonly) stickLeftJustLeft :booelan

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

(readonly) stickLeftJustRight :booelan

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

(readonly) stickLeftJustUp :booelan

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

(readonly) stickLeftLeft :booelan

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

(readonly) stickLeftRight :booelan

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

(readonly) stickLeftUp :booelan

If the left analog stick of the Gamepad object is facing up.
Type:
  • booelan
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 :booelan

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

(readonly) stickRightJustDown :booelan

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

(readonly) stickRightJustLeft :booelan

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

(readonly) stickRightJustRight :booelan

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

(readonly) stickRightJustUp :booelan

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

(readonly) stickRightLeft :booelan

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

(readonly) stickRightRight :booelan

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

(readonly) stickRightUp :booelan

If the right analog stick of the Gamepad object is facing up.
Type:
  • booelan
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 the gamepad vibration using the specified effect type.
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