Class TGameController
Unit
Declaration
type TGameController = class(TObject)
Description
Properties of a given game controller (joystick, gamepad). Get instance of this by Controllers[Index].
Do not construct instances of this yourself, TGameControllers creates this automatically when necessary.
All the contents of this class are read-only for applications. Only the controller backends (that implement TGameController
logic using underlying system-specific APIs) can change it.
Hierarchy
- TObject
- TGameController
Overview
Fields
![]() |
Pressed: array [TGameControllerButton] of Boolean; |
![]() |
InternalPressedToReport: array [TGameControllerButton] of Boolean; |
Methods
![]() |
function AxisLeft: TVector2; |
![]() |
function AxisRight: TVector2; |
![]() |
function AxisLeftTrigger: Single; |
![]() |
function AxisRightTrigger: Single; |
![]() |
function ButtonCaption(const Button: TGameControllerButton): String; |
![]() |
function ButtonMeaning(const Button: TGameControllerButton): TGameControllerButtonMeaning; |
![]() |
destructor Destroy; override; |
Properties
![]() |
property Name: String read FName; |
![]() |
property Index: Integer read FIndex; |
Description
Fields
![]() |
Pressed: array [TGameControllerButton] of Boolean; |
Which buttons are now pressed. |
![]() |
InternalPressedToReport: array [TGameControllerButton] of Boolean; |
New state of buttons' pressed, to be reported by next TCastleContainer.Update, and it will be the new value of Pressed. |
Methods
![]() |
function AxisLeft: TVector2; |
Left analog stick position. Both coordinates are in range -1..1, where (0, 0) is the center of the stick. Note: It is not guaranteed that they fit within the circle of radius 1 (they usually don't, they go a bit outside the circle). But it is also not guaranteed that they can reach the edge of the square, e.g. position (-1,-1) may not be reachable, usually it is not reachable. So: Your application should not assume that user can make a stick position beyond the circle of radius 1, but it should accept such positions. See also
|
![]() |
function AxisRight: TVector2; |
Right analog stick position. See TGameController.AxisLeft for details of possible values. See also
|
![]() |
function AxisLeftTrigger: Single; |
Left trigger axis, in range 0..1. On some controllers, like Nintendo Switch, the triggers are "digital" so they can be only pressed or released. In such case, this axis will have only values 0.0 or 1.0. On other controllers, like Xbox controllers, the triggers are "analog", so they can be pressed with any amount of force. In such case, this axis will have any value from 0.0 to 1.0. Note: If you don't really want to treat trigger as "analog", you want to simply detect it as presses / released ("digital"), then detect on the application side when the trigger passes a certian "threshold". For example, when See also
|
![]() |
function AxisRightTrigger: Single; |
Right trigger axis, in range 0..1. See also
|
![]() |
function ButtonCaption(const Button: TGameControllerButton): String; |
Nice caption (label) of a given button. For buttons that have different names depending on the game controller, like "face buttons" (A, B, X, Y, square triangle circle cross), this caption depends on the game controller type. TODO: The current implementation assumes
|
![]() |
function ButtonMeaning(const Button: TGameControllerButton): TGameControllerButtonMeaning; |
Intended meaning of the given button. This may depend on the game controller type. TODO: The current implementation assumes
|
![]() |
destructor Destroy; override; |
This item has no description. |
Properties
![]() |
property Name: String read FName; |
Game controller name. Not necessarily unique, so be sure to display also game controller Index to the user in UI. |
![]() |
property Index: Integer read FIndex; |
Game controller |
Generated by PasDoc 0.16.0-snapshot.