Provides support for reading state-based game controllers.
Use the Controller class to read the state of game controllers that are recognised by the operating system.
Unlike analog devices that stream input commands (e.g. mice), gamepad controllers maintain a state that can be read at any time. The controller state is normally read at least once per frame, which can be achieved in the main inner loop, or in a separate timer.
Controller input management is governed by the Display class. The GRAB_CONTROLLERS
flag must be defined in the active Display's Flags field in order to ensure that controller input can be received. Failure to do so may mean that the Controller object appears to work but does not receive input.
The Controller class consists of the following fields:
Access | Name | Type | Comment | ||
---|---|---|---|---|---|
Buttons | CON | JET button values expressed as bit-fields. | |||
| |||||
LeftStickX | DOUBLE | Left analog stick value for X axis, between -1.0 and 1.0. | |||
LeftStickY | DOUBLE | Left analog stick value for Y axis, between -1.0 and 1.0. | |||
LeftTrigger | DOUBLE | Left trigger value between 0.0 and 1.0. | |||
Port | INT | The port number assigned to the controller. | |||
Set the port number to choose the controller that will be queried for state changes. The default of zero is assigned to the primary controller. The port number can be changed at any time, so multiple controllers can be queried through one interface at the cost of overwriting the previous state. Check TotalPorts if your program supports more than one controller. | |||||
RightStickX | DOUBLE | Right analog stick value for X axis, between -1.0 and 1.0. | |||
RightStickY | DOUBLE | Right analog stick value for Y axis, between -1.0 and 1.0. | |||
RightTrigger | DOUBLE | Right trigger value between 0.0 and 1.0. | |||
TotalPorts | INT | Reports the total number of controllers connected to the system. |
The following actions are currently supported:
Query | Get the current controller state. |
---|