Download Now

    Reference TJoystick

    Declared in Codebot.Hardware.pas on line 525

    TJoystick is a device with any number of axes, buttons, hats and trackballs. Reading a part which does not exist returns its resting value.
      TJoystick = class
      public
        { Create takes ownership of a joystick opened by SDL, and of its game
          controller if it is a gamepad }
        constructor Create(Joystick, Controller: Pointer);
        destructor Destroy; override;
        { The name of the joystick }
        property Name: string read FName;
        { Attached is False once the joystick is disconnected }
        property Attached: Boolean read GetAttached;
        { IsGamepad is True if the joystick has the named buttons and axes }
        property IsGamepad: Boolean read GetIsGamepad;
        { A named button is True while it is held down, and is always False if the
          joystick is not a gamepad }
        property GamepadButtons[Button: TGamepadButton]: Boolean read GetGamepadButton;
        { A named axis is always 0 if the joystick is not a gamepad }
        property GamepadAxes[Axis: TGamepadAxis]: Single read GetGamepadAxis;
        property AxisCount: Integer read GetAxisCount;
        { An axis ranges from -1 to 1 and rests at 0, other than a trigger which
          rests at -1 on many gamepads. Typically axes 0 and 1 are x and y of the
          first stick, and y is 1 when the stick is pulled down. The layout differs
          by joystick. }
        property Axes[Index: Integer]: Single read GetAxis;
        property ButtonCount: Integer read GetButtonCount;
        { A button is True while it is held down }
        property Buttons[Index: Integer]: Boolean read GetButton;
        { The number of hats, and the position of each }
        property HatCount: Integer read GetHatCount;
        property Hats[Index: Integer]: TJoystickHat read GetHat;
        { The number of trackballs, and the movement of each }
        property TrackballCount: Integer read GetTrackballCount;
        property Trackballs[Index: Integer]: TJoystickTrackball read GetTrackball;
      end;

    See also