Gorilla.Controller.Input.Types Unit Reference

Type definitions for input handling system.

Unit: Gorilla.Controller.Input.Types

Type Definitions

TGorillaInputDeviceType

type
  TGorillaInputDeviceType = (Keyboard, Mouse, GamePad);

Enumeration of supported input device types.

Values:

  • Keyboard - Physical keyboard
  • Mouse - Mouse or pointing device
  • GamePad - Game controller (XInput, SDL2, etc.)

TGorillaInputDeviceTypes

type
  TGorillaInputDeviceTypes = set of TGorillaInputDeviceType;

Set of input device types for enabling multiple devices.

Usage:

GorillaInputController1.Supported := [Keyboard, Mouse];

TGorillaInputMode

type
  TGorillaInputMode = (Activated, Deactivated);

Input activation state.

Values:

  • Activated - Input pressed/activated
  • Deactivated - Input released/deactivated

TGorillaMouseState

type
  TGorillaMouseState = (
    LButtonDown, LButtonUp,
    RButtonDown, RButtonUp,
    MButtonDown, MButtonUp,
    X1ButtonDown, X1ButtonUp,
    X2ButtonDown, X2ButtonUp,
    LButtonDblClick, RButtonDblClick,
    MButtonDblClick, X1ButtonDblClick, X2ButtonDblClick,
    MouseMove, MouseWheel
  );

Mouse event states.

Button States:

  • LButtonDown / LButtonUp - Left button
  • RButtonDown / RButtonUp - Right button
  • MButtonDown / MButtonUp - Middle button (wheel click)
  • X1ButtonDown / X1ButtonUp - Extra button 1
  • X2ButtonDown / X2ButtonUp - Extra button 2

Double-Click States:

  • LButtonDblClick - Left button double-click
  • RButtonDblClick - Right button double-click
  • MButtonDblClick - Middle button double-click
  • X1ButtonDblClick - Extra button 1 double-click
  • X2ButtonDblClick - Extra button 2 double-click

Movement States:

  • MouseMove - Mouse position changed
  • MouseWheel - Mouse wheel scrolled

TGorillaMouseStates

type
  TGorillaMouseStates = set of TGorillaMouseState;

Set of mouse states for event callbacks.

TGorillaInputCode

type
  TGorillaInputCode = NativeInt;

Generic input code type for keyboard keys, mouse buttons, and gamepad buttons.

See: Gorilla.Controller.Input.Consts for available codes.

TGorillaCharacterControllerHotKey

type
  TGorillaCharacterControllerHotKey = (
    UnknownHotKey,

    // Keyboard Movement
    KeyboardMoveForward, KeyboardMoveBackward,
    KeyboardMoveLeft, KeyboardMoveRight,

    // Keyboard Extended Movement
    KeyboardJump, KeyboardCrouch, KeyboardCrawl,
    KeyboardBoost, KeyboardAim,

    // Keyboard Actions
    KeyboardCustomAction1, KeyboardCustomAction2,
    KeyboardCustomAction3, KeyboardCustomAction4,

    // Keyboard Game Control
    KeyboardStart, KeyboardMode, KeyboardBack,

    // Keyboard Menu
    KeyboardMenuUp, KeyboardMenuDown,
    KeyboardMenuLeft, KeyboardMenuRight,

    // Mouse Actions
    MouseDragMove, MouseLeftButton,
    MouseMiddleButton, MouseRightButton,

    // GamePad Movement
    GamePadMove, GamePadMoveForward,
    GamePadMoveBackward, GamePadMoveLeft, GamePadMoveRight,

    // GamePad Extended Movement
    GamePadJump, GamePadCrouch, GamePadCrawl,
    GamePadBoost, GamePadAim,

    // GamePad Actions
    GamePadButtonA, GamePadButtonB,
    GamePadButtonX, GamePadButtonY,

    // GamePad Game Control
    GamePadStart, GamePadMode, GamePadBack,

    // GamePad Menu
    GamePadMenuUp, GamePadMenuDown,
    GamePadMenuLeft, GamePadMenuRight
  );

Predefined HotKey enumeration for character controllers.

Usage: Used internally by TGorillaCharacterController for standard FPS/TPS controls.

See: Character Controller documentation for usage examples.

TGorillaCharacterControllerState

type
  TGorillaCharacterControllerState = (
    fpIdle, fpMoving, fpRotating, fpRotateMoving,
    fpBoost, fpCrouching, fpCrawling, fpJumping,
    fpAiming, fpPushing, fpPulling,
    fpCustomAction, fpClick,
    fpStart, fpMode, fpBack,
    fpNavigation
  );

Character controller state enumeration.

Base States:

  • fpIdle - Character standing still
  • fpMoving - Character moving
  • fpRotating - Character rotating in place
  • fpRotateMoving - Character moving and rotating

Action States:

  • fpBoost - Sprinting/boosting
  • fpCrouching - Crouched
  • fpCrawling - Crawling/prone
  • fpJumping - Jumping
  • fpAiming - Aiming weapon
  • fpPushing - Pushing object
  • fpPulling - Pulling object
  • fpCustomAction - Custom action active
  • fpClick - Mouse click

UI States:

  • fpStart - Start button pressed
  • fpMode - Mode button pressed
  • fpBack - Back button pressed
  • fpNavigation - Menu navigation

TGorillaCharacterControllerStates

type
  TGorillaCharacterControllerStates = Set of TGorillaCharacterControllerState;

Set of character controller states. Multiple states can be active simultaneously.

Example:

if [fpMoving, fpBoost] <= Player.States then
  // Player is sprinting

TGorillaGamePadDeviceType

type
  TGorillaGamePadDeviceType = (
    Default,
    Wheel,
    ArcadeStick,
    FlightStick,
    DancePad
  );

GamePad device classification.

Values:

  • Default - Standard gamepad (Xbox, PlayStation style)
  • Wheel - Racing wheel
  • ArcadeStick - Arcade fight stick
  • FlightStick - Flight joystick
  • DancePad - Dance pad controller

TGorillaGamePadButton

type
  TGorillaGamePadButton = (
    None,

    // D-Pad
    DPadUp, DPadDown, DPadLeft, DPadRight,

    // System
    StartButton, ModeButton, BackButton,

    // Thumbsticks (press)
    LeftThumbStick, RightThumbStick,

    // Shoulders
    LeftShoulder, RightShoulder,

    // Face Buttons
    ButtonA, ButtonB, ButtonX, ButtonY
  );

GamePad button enumeration.

D-Pad:

  • DPadUp / DPadDown / DPadLeft / DPadRight - Directional pad

System Buttons:

  • StartButton - Start/Menu button
  • ModeButton - Xbox/Guide/Home button
  • BackButton - Back/View/Select button

Thumbsticks:

  • LeftThumbStick - L3 (left stick press)
  • RightThumbStick - R3 (right stick press)

Shoulders:

  • LeftShoulder - LB (left bumper)
  • RightShoulder - RB (right bumper)

Face Buttons:

  • ButtonA - A (Xbox) / Cross (PlayStation)
  • ButtonB - B (Xbox) / Circle (PlayStation)
  • ButtonX - X (Xbox) / Square (PlayStation)
  • ButtonY - Y (Xbox) / Triangle (PlayStation)

TGorillaGamePadButtons

type
  TGorillaGamePadButtons = set of TGorillaGamePadButton;

Set of gamepad buttons.

Usage:

if TGorillaGamePadButton.ButtonA in AButtons then
  Player.Jump();

TGorillaGamePadButtonsArray

type
  TGorillaGamePadButtonsArray = TArray<TGorillaGamePadButton>;

Dynamic array of gamepad buttons.

Helper Records

TGorillaGamePadButtonHelper

type
  TGorillaGamePadButtonHelper = record
    class function ToInputCode(const ABtn: TGorillaGamePadButton): TGorillaInputCode; static;
    class function FromInputCode(const ACode: TGorillaInputCode): TGorillaGamePadButton; static;
  end;

Helper for converting between gamepad buttons and input codes.

ToInputCode

class function ToInputCode(const ABtn: TGorillaGamePadButton): TGorillaInputCode; static;

Converts gamepad button to input code.

Parameters:

  • ABtn - Gamepad button

Returns: Input code constant or -1 if None

Example:

var
  LCode: TGorillaInputCode;
begin
  LCode := TGorillaGamePadButtonHelper.ToInputCode(TGorillaGamePadButton.ButtonA);
  // LCode = GORILLA_INPUT_GAMEPAD_BUTTON_A
end;

FromInputCode

class function FromInputCode(const ACode: TGorillaInputCode): TGorillaGamePadButton; static;

Converts input code to gamepad button.

Parameters:

  • ACode - Input code

Returns: Gamepad button or None if invalid

Example:

var
  LButton: TGorillaGamePadButton;
begin
  LButton := TGorillaGamePadButtonHelper.FromInputCode(GORILLA_INPUT_GAMEPAD_BUTTON_A);
  // LButton = TGorillaGamePadButton.ButtonA
end;

TGorillaGamePadVector2

type
  TGorillaGamePadVector2 = record
    X: NativeUInt;
    Y: NativeUInt;

    constructor Create(AX, AY: NativeUInt);
    class function Zero(): TGorillaGamePadVector2; static;

    class operator Subtract(V1, V2: TGorillaGamePadVector2): TGorillaGamePadVector2;
    class operator Multiply(V: TGorillaGamePadVector2; F: Single): TGorillaGamePadVector2;
  end;

2D vector for gamepad thumbstick positions.

Create

constructor Create(AX, AY: NativeUInt);

Creates vector with specified coordinates.

Zero

class function Zero(): TGorillaGamePadVector2; static;

Returns zero vector (0, 0).

Subtract Operator

class operator Subtract(V1, V2: TGorillaGamePadVector2): TGorillaGamePadVector2;

Subtracts two vectors.

Example:

var
  LDelta: TGorillaGamePadVector2;
begin
  LDelta := LCurrentPos - LPreviousPos;
end;

Multiply Operator

class operator Multiply(V: TGorillaGamePadVector2; F: Single): TGorillaGamePadVector2;

Multiplies vector by scalar.

Example:

var
  LScaled: TGorillaGamePadVector2;
begin
  LScaled := LPos * 0.5;  // Scale to 50%
end;

Record Types

TGorillaInputMessage

type
  TGorillaInputMessage = record
    Device: TGorillaInputDeviceType;
    Mode: TGorillaInputMode;
    Persistent: Boolean;
    Time: NativeUInt;
    Code: TGorillaInputCode;
    Flags: NativeUInt;
    WParam: NativeInt;
    LParam: NativeInt;
    Result: NativeInt;
    Data: TValue;

    constructor Create(const ADevice: TGorillaInputDeviceType;
      const AMode: TGorillaInputMode);
  end;

Raw input message structure.

Fields:

Field Type Description
Device TGorillaInputDeviceType Source device (Keyboard, Mouse, GamePad)
Mode TGorillaInputMode Activated or Deactivated
Persistent Boolean True for continuous messages (position, triggers)
Time NativeUInt Timestamp (GetTickCount)
Code TGorillaInputCode Input code constant
Flags NativeUInt Platform-specific flags
WParam NativeInt Platform-specific parameter
LParam NativeInt Platform-specific parameter
Result NativeInt Platform-specific result
Data TValue Generic data container (TPoint, TPointF, etc.)

Usage:

var
  LMsg: TGorillaInputMessage;
  LPos: TPoint;
begin
  if GorillaInputController1.GetPersistentMessage(Mouse,
    GORILLA_INPUT_MOUSE_POSITION, LMsg) then
  begin
    LPos := LMsg.Data.AsType<TPoint>;
    ShowMessage(Format('Mouse at %d, %d', [LPos.X, LPos.Y]));
  end;
end;

TGorillaHotKeyInputRaw

type
  TGorillaHotKeyInputRaw = record
    Count: Byte;
    Codes: Array[0..GORILLA_HOTKEY_INPUTS_MAX - 1] of TGorillaInputCode;

    procedure Sort();
    function Contains(const AInput: TGorillaHotKeyInputRaw): Boolean;
    function ToString(): String;
  end;

Raw input combination for single device (internal use).

Fields:

  • Count - Number of active inputs
  • Codes - Array of input codes

Methods:

Sort

procedure Sort();

Sorts input codes from low to high value (for comparison).

Contains

function Contains(const AInput: TGorillaHotKeyInputRaw): Boolean;

Checks if this input contains all codes from AInput.

ToString

function ToString(): String;

Converts to string format for debugging.

TGorillaHotKeyRaw

type
  TGorillaHotKeyRaw = record
    Inputs: Array[TGorillaInputDeviceType] of TGorillaHotKeyInputRaw;

    class function Create(): TGorillaHotKeyRaw; static;
    procedure AddInput(const AInput: TGorillaHotKeyInputItem);
    procedure Sort();
    function GetWeight(): Integer;
    function Contains(const AKey: TGorillaHotKeyRaw): Boolean;
    function ToString(): String;
  end;

Complete HotKey combination across all devices (internal use).

Methods:

Create

class function Create(): TGorillaHotKeyRaw; static;

Creates empty raw HotKey.

AddInput

procedure AddInput(const AInput: TGorillaHotKeyInputItem);

Adds input from collection item.

GetWeight

function GetWeight(): Integer;

Returns priority weight (more inputs = higher weight).

Usage: Resolves conflicts when multiple HotKeys match current input.

Contains

function Contains(const AKey: TGorillaHotKeyRaw): Boolean;

Checks if this HotKey contains all inputs from AKey.

See Also