Class Gamepad
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The Gamepad interface of the Gamepad API defines an individual gamepad or other controller, allowing access to information such as button presses, axis positions, and id.
[Value("Gamepad")]
public class Gamepad
- Inheritance
-
Gamepad
- Inherited Members
Remarks
A Gamepad object can be returned in one of two ways: via the gamepad property of the Window.Gamepadconnected and Window.Gamepaddisconnected events, or by grabbing any position in the array returned by the GetGamepads() method.
NOTE
The support of gamepad features varies across different combinations of platforms and controllers. Even if the controller supports a certain feature (for example, haptic feedback), the platform may not support it for that controller.
Constructors
Gamepad()
public Gamepad()
Properties
Axes
The Gamepad.axes property of the Gamepad
interface returns an array representing the controls with axes present on the device
(e.g., analog thumb sticks).
[Value("axes")]
public Number[] Axes { get; }
Property Value
- Number[]
An array of numbers.
Remarks
Each entry in the array is a floating point value in the range -1.0 – 1.0, representing
the axis position from the lowest value (-1.0) to the highest value (1.0).
Buttons
The buttons property of the Gamepad interface returns an array of GamepadButton objects representing the buttons present on the device.
[Value("buttons")]
public GamepadButton[] Buttons { get; }
Property Value
- GamepadButton[]
An array of GamepadButton objects.
Remarks
Each entry in the array is 0 if the button is not pressed, and non-zero (typically 1.0) if the button is pressed.
Connected
The Gamepad.connected property of the
Gamepad interface returns a boolean indicating whether the gamepad is
still connected to the system.
[Value("connected")]
public bool Connected { get; }
Property Value
- bool
A boolean.
Remarks
If the gamepad is connected, the value is true; if not, it isfalse.
Hand
NOTE
Experimentalhand read-only property of the Gamepad interface returns an enum defining what hand the controller is being held in, or is most likely to be held in.
[Value("hand")]
public GamepadHand Hand { get; }
Property Value
- GamepadHand
A
GamepadHandenum; possible values are:
Remarks
HapticActuators
NOTE
ExperimentalhapticActuators read-only property of the Gamepad interface returns an array containing GamepadHapticActuator objects, each of which represents haptic feedback hardware available on the controller.
[Value("hapticActuators")]
public GamepadHapticActuator[] HapticActuators { get; }
Property Value
- GamepadHapticActuator[]
An array containing GamepadHapticActuator objects.
Remarks
Id
The Gamepad.id property of the Gamepad
interface returns a string containing some information about the controller.
[Value("id")]
public string Id { get; }
Property Value
- string
A string primitive.
Remarks
The exact syntax is not strictly specified, but in Firefox it will contain three pieces
of information separated by dashes (-):
For example, a PS2 controller returned 810-3-USB Gamepad.
This information is intended to allow you to find a mapping for the controls on the
device as well as display useful feedback to the user.
Index
The Gamepad.index property of the Gamepad
interface returns an integer that is auto-incremented to be unique for each device
currently connected to the system.
[Value("index")]
public long Index { get; }
Property Value
Remarks
This can be used to distinguish multiple controllers; a gamepad that is disconnected
and reconnected will retain the same index.
Mapping
The Gamepad.mapping property of the
Gamepad interface returns a string indicating whether the browser has
remapped the controls on the device to a known layout.
[Value("mapping")]
public GamepadMappingType Mapping { get; }
Property Value
Remarks
Pose
NOTE
Experimentalpose read-only property of the Gamepad interface returns a GamepadPose object representing the pose information associated with a WebVR controller (e.g., its position and orientation in 3D space).
[Value("pose")]
public GamepadPose? Pose { get; }
Property Value
- GamepadPose
A GamepadPose object.
Remarks
Timestamp
The Gamepad.timestamp property of the
Gamepad interface returns a Number
representing the last time the data for this gamepad was updated.
[Value("timestamp")]
public Number Timestamp { get; }
Property Value
Remarks
The idea behind this is to allow developers to determine if the axes andbutton data have been updated from the hardware. The value must be
relative to the navigationStart attribute of the
PerformanceTiming interface. Values are monotonically
increasing, meaning that they can be compared to determine the ordering of updates, as
newer values will always be greater than or equal to older values.
NOTE
This property is not currently supported anywhere.
TouchEvents
[Value("touchEvents")]
public GamepadTouch[]? TouchEvents { get; }
Property Value
VibrationActuator
The vibrationActuator read-only property of the Gamepad interface returns a GamepadHapticActuator object, which represents haptic feedback hardware available on the controller.
[Value("vibrationActuator")]
public GamepadHapticActuator VibrationActuator { get; }
Property Value
- GamepadHapticActuator
A GamepadHapticActuator object.
Remarks
NOTE
Support for this property may vary across different combinations of platforms and controllers. Even if the controller supports haptic feedback, the platform may not support it.