Gamepad
- TypeScript
- C#
type GamepadPayload = {
leftX: number
leftY: number
rightX: number
rightY: number
leftTrigger: number
rightTrigger: number
up: boolean
down: boolean
left: boolean
right: boolean
leftThumbstick: boolean
rightThumbstick: boolean
leftShoulder: boolean
rightShoulder: boolean
north: boolean
south: boolean
east: boolean
west: boolean
home: boolean
utilLeft: boolean
utilRight: boolean
}
struct GamepadPayload
{
public double LeftX;
public double LeftY;
public double RightX;
public double RightY;
public double LeftTrigger;
public double RightTrigger;
public bool Up;
public bool Down;
public bool Left;
public bool Right;
public bool LeftThumbstick;
public bool RightThumbstick;
public bool LeftShoulder;
public bool RightShoulder;
public bool North;
public bool South;
public bool East;
public bool West;
public bool Home;
public bool UtilLeft;
public bool UtilRight;
}
This data is sent when the host moves a gamepad's thumbsticks, or presses a button or trigger.
Value
Any true
value indicates the button is pressed. Any false
value indicates the button is released.
All number
/double
values are in the range of 0
to 1
.
Fields
The leftX
and leftY
fields coresspond to the left thumbstick movement. The rightX
and rightY
fields coresspond to the right thumbstick movement.
The leftTrigger
and rightTrigger
fields coresspond to the amount of pressure applied to the left and right triggers.
The leftThumbstick
and rightThumbstick
fields coresspond to the press of the left and right thumbsticks.
The leftShoulder
and rightShoulder
fields coresspond to the left and right shoulder buttons.
The up
, down
, left
, and right
fields coresspond to the D-pad.
The north
, south
, east
, and west
fields coresspond to the face buttons.
The utilLeft
and utilRight
fields coresspond to the two buttons locate in the center area of the gamepad.
The home
field coressponds to the button at the center of the gamepad. On Xbox controllers, this is the Xbox button. On PlayStation controllers, this is the PS button. On Nintendo Switch controllers, this is the home button.