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

Public Name: String;
Public Pressed: array [TGameControllerButton] of Boolean;
Public InternalPressedToReport: array [TGameControllerButton] of Boolean;

Methods

Public function AxisLeft: TVector2;
Public function AxisRight: TVector2;
Public function AxisLeftTrigger: Single;
Public function AxisRightTrigger: Single;
Public function ButtonCaption(const Button: TGameControllerButton): String;
Public function ButtonMeaning(const Button: TGameControllerButton): TGameControllerButtonMeaning;
Public destructor Destroy; override;

Description

Fields

Public Name: String;

Game controller name. Not necessarily unique, so be sure to display also game controller index to the user in UI.

Public Pressed: array [TGameControllerButton] of Boolean;

Which buttons are now pressed.

Public 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

Public 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.

Public function AxisRight: TVector2;

Right analog stick position. See TGameController.AxisLeft for details of possible values.

Public function AxisLeftTrigger: Single;

Left trigger axis, in range 0..1.

Public function AxisRightTrigger: Single;

Right trigger axis, in range 0..1.

Public 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

  • XBox controller on all platforms except Nintendo Switch,

  • or Nintendo Switch controllers on Nintendo Switch.

Public 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

  • XBox controller on all platforms except Nintendo Switch,

  • or Nintendo Switch controllers on Nintendo Switch.

Public destructor Destroy; override;

This item has no description.


Generated by PasDoc 0.16.0-snapshot.