Gorilla.Controller.Input.XInput
Unit Gorilla.Controller.Input.XInput.pasClasses
- TXInputManager = class ( TObject )
Records
- record TXInputKeystroke
- record TXInputGamepad
- record TXInputVibration
- record TXInputCapabilities
- record TXInputBatteryInformation
- record TXInputState
Enumerations
- enum TXInputTrigger = ( xitLeft, xitRight ) ;
- enum TXInputThumb = ( xithumbLeft, xithumbRight ) ;
- enum TXInputDirection = ( xidNone, xidRight, xidUpRight, xidUp, xidUpLeft, xidLeft, xidDownLeft, xidDown, xidDownRight ) ;
Constants
- const ERROR_DEVICE_NOT_CONNECTED : Integer = $48F;
- const XINPUT_KEYSTROKE_KEYDOWN : Integer = $1;
- const XINPUT_KEYSTROKE_KEYUP : Integer = $2;
- const XINPUT_KEYSTROKE_REPEAT : Integer = $4;
- const VK_PAD_A : Integer = $5800;
- const VK_PAD_B : Integer = $5801;
- const VK_PAD_X : Integer = $5802;
- const VK_PAD_Y : Integer = $5803;
- const VK_PAD_RSHOULDER : Integer = $5804;
- const VK_PAD_LSHOULDER : Integer = $5805;
- const VK_PAD_LTRIGGER : Integer = $5806;
- const VK_PAD_RTRIGGER : Integer = $5807;
- const VK_PAD_DPAD_UP : Integer = $5810;
- const VK_PAD_DPAD_DOWN : Integer = $5811;
- const VK_PAD_DPAD_LEFT : Integer = $5812;
- const VK_PAD_DPAD_RIGHT : Integer = $5813;
- const VK_PAD_START : Integer = $5814;
- const VK_PAD_BACK : Integer = $5815;
- const VK_PAD_LTHUMB_PRESS : Integer = $5816;
- const VK_PAD_RTHUMB_PRESS : Integer = $5817;
- const VK_PAD_LTHUMB_UP : Integer = $5820;
- const VK_PAD_LTHUMB_DOWN : Integer = $5821;
- const VK_PAD_LTHUMB_RIGHT : Integer = $5822;
- const VK_PAD_LTHUMB_LEFT : Integer = $5823;
- const VK_PAD_LTHUMB_UPLEFT : Integer = $5824;
- const VK_PAD_LTHUMB_UPRIGHT : Integer = $5825;
- const VK_PAD_LTHUMB_DOWNRIGHT : Integer = $5826;
- const VK_PAD_LTHUMB_DOWNLEFT : Integer = $5827;
- const VK_PAD_RTHUMB_UP : Integer = $5830;
- const VK_PAD_RTHUMB_DOWN : Integer = $5831;
- const VK_PAD_RTHUMB_RIGHT : Integer = $5832;
- const VK_PAD_RTHUMB_LEFT : Integer = $5833;
- const VK_PAD_RTHUMB_UPLEFT : Integer = $5834;
- const VK_PAD_RTHUMB_UPRIGHT : Integer = $5835;
- const VK_PAD_RTHUMB_DOWNRIGHT : Integer = $5836;
- const VK_PAD_RTHUMB_DOWNLEFT : Integer = $5837;
- const XINPUT_GAMEPAD_DPADUP : Integer = $1;
- const XINPUT_GAMEPAD_DPADDOWN : Integer = $2;
- const XINPUT_GAMEPAD_DPADLEFT : Integer = $4;
- const XINPUT_GAMEPAD_DPADRIGHT : Integer = $8;
- const XINPUT_GAMEPAD_START : Integer = $10;
- const XINPUT_GAMEPAD_MODE : Integer = $11;
- const XINPUT_GAMEPAD_BACK : Integer = $20;
- const XINPUT_GAMEPAD_LEFTTHUMB : Integer = $40;
- const XINPUT_GAMEPAD_RIGHTTHUMB : Integer = $80;
- const XINPUT_GAMEPAD_LEFTSHOULDER : Integer = $100;
- const XINPUT_GAMEPAD_RIGHTSHOULDER : Integer = $200;
- const XINPUT_GAMEPAD_A : Integer = $1000;
- const XINPUT_GAMEPAD_B : Integer = $2000;
- const XINPUT_GAMEPAD_X : Integer = $4000;
- const XINPUT_GAMEPAD_Y : Integer = $8000;
- const XINPUT_DEVICETYPE_GAMEPAD : Integer = $1;
- const XINPUT_DEVSUBTYPE_GAMEPAD : Integer = $1;
- const XINPUT_DEVSUBTYPE_WHEEL : Integer = $2;
- const XINPUT_DEVSUBTYPE_ARCADESTICK : Integer = $3;
- const XINPUT_DEVSUBTYPE_FLIGHTSTICK : Integer = $4;
- const XINPUT_DEVSUBTYPE_DANCEPAD : Integer = $5;
- const XINPUT_DEVSUBTYPE_GUITAR : Integer = $6;
- const XINPUT_DEVSUBTYPE_DRUMKIT : Integer = $8;
- const XINPUT_CAPS_VOICE_SUPPORTED : Integer = $4;
- const XINPUT_BATTERY_DEVICETYPE_GAMEPAD : Integer = $0;
- const XINPUT_BATTERY_DEVICETYPE_HEADSET : Integer = $1;
- const XINPUT_BATTERY_TYPE_DISCONNECTED : Integer = $0;
- const XINPUT_BATTERY_TYPE_WIRED : Integer = $1;
- const XINPUT_BATTERY_TYPE_ALKALINE : Integer = $2;
- const XINPUT_BATTERY_TYPE_NIMH : Integer = $3;
- const XINPUT_BATTERY_TYPE_UNKNOWN : Integer = $FF;
- const XINPUT_BATTERY_LEVEL_EMPTY : Integer = $0;
- const XINPUT_BATTERY_LEVEL_LOW : Integer = $1;
- const XINPUT_BATTERY_LEVEL_MEDIUM : Integer = $2;
- const XINPUT_BATTERY_LEVEL_FULL : Integer = $3;
- const XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE : Integer = $1EA9;
- const XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE : Integer = $21F1;
- const XINPUT_GAMEPAD_TRIGGER_THRESHOLD : Integer = $1E;
- const XINPUT_DEVICE_SCAN_PERIOD : Integer = $64;
- const XINPUT_MAX_USERS : Integer = $4;
- const XINPUT_MAX_USER_INDEX : Integer = $3;
- const XINPUT_THUMB_SCALER : Integer = $8000;
- const XINPUT_MAX_BUTTON_INDEX : Integer = $D;
- const XINPUT_BUTTONS : array[0..13] of Word = ;
Mics. types
- type PXInputKeystroke = pointer to TXInputKeystroke;
- type PXInputGamepad = pointer to TXInputGamepad;
- type PXInputVibration = pointer to TXInputVibration;
- type PXInputCapabilities = pointer to TXInputCapabilities;
- type PXInputBatteryInformation = pointer to TXInputBatteryInformation;
- type PXInputState = pointer to TXInputState;
- type TXInputControllerConnected = array [0..3] of Boolean;
- type TXInputControllerGUID = array [0..3] of TGUID;
- type TXInputControllerState = array [0..3] of TXInputState;
- type TXInputControllerDeadzone = array [0..3] of Word;
- type TXInputControllerThreshold = array [0..3] of Byte;
- type TXInputControllerCapabilities = array [0..3] of TXInputCapabilities;
- type TXInputControllerBatteryState = array [0..3] of Byte;
Functions / Procedures
TXInputManager
Ancestors
Members
Fields
- protected FXInputHandle :
NativeUInt
- protected FInitialized :
Boolean
- protected FDeviceScanCount :
Integer
- protected FFireEventsBeforeStoringState :
Boolean
- protected FLatestCheck :
NativeUInt
- protected FXIGetState :
TXInputGetState
- protected FXISetState :
TXInputSetState
- protected FXIEnable :
TXInputEnable
- protected FXIGetCapabilities :
TXInputGetCapabilities
- protected FXIGetBatteryInformation :
TXInputGetBatteryInformation
- protected FXIGetKeystroke :
TXInputGetKeystroke
- protected FLeftThumbDeadzone :
TXInputControllerDeadzone
- protected FRightThumbDeadzone :
TXInputControllerDeadzone
- protected FTriggerThreshold :
TXInputControllerThreshold
- protected FConnected :
TXInputControllerConnected
- protected FCapabilities :
TXInputControllerCapabilities
- protected FState :
TXInputControllerState
- protected FBattery :
TXInputControllerConnected
- protected FBatteryState :
TXInputControllerBatteryState
- protected FOnConnect :
TXInputConnectEvent
- protected FOnDisconnect :
TXInputConnectEvent
- protected FOnBatteryWarning :
TXInputBatteryWarningEvent
- protected FOnStateChange :
TXInputStateChangeEvent
- protected FOnButtonsDown :
TXInputButtonEvent
- protected FOnButtonsUp :
TXInputButtonEvent
- protected FOnButtonsPressed :
TXInputButtonEvent
- protected FOnTrigger :
TXInputTriggerEvent
- protected FOnThumbStick :
TXInputThumbStickEvent
Methods
- public constructor Create ( ) ;
- public destructor Destroy ( ) ;
- protected function GetConnected ( AIndex : Byte ) : Boolean ;
- protected function GetState ( AIndex : Byte ) : TXInputState ;
- protected function GetCapabilities ( AIndex : Byte ) : TXInputCapabilities ;
- protected function GetBattery ( AIndex : Byte ) : Boolean ;
- protected function GetBatteryState ( AIndex : Byte ) : Byte ;
- protected function GetGamepadLeftThumbDeadzone ( AIndex : Byte ) : Word ;
- protected procedure SetGamepadLeftThumbDeadzone ( AIndex : Byte; AValue : Word ) ;
- protected function GetGamepadRightThumbDeadzone ( AIndex : Byte ) : Word ;
- protected procedure SetGamepadRightThumbDeadzone ( AIndex : Byte; AValue : Word ) ;
- protected function GetGamepadTriggerThreshold ( AIndex : Byte ) : Byte ;
- protected procedure SetGamepadTriggerThreshold ( AIndex : Byte; AValue : Byte ) ;
- protected procedure InitializeVariables ( ) ;
- protected procedure ScanForDevices ( ) ;
- protected procedure ScanForState ( ) ;
- protected procedure CheckIndex ( AIndex : Byte; AMethodName : string ) ;
- protected procedure CheckInitialized ( AMethodName : string ) ;
- protected function DeviceDisconnected ( AIndex : Byte; ALastResult : Integer ) : Boolean ;
- protected function DecodeDirection ( X : Double; Y : Double ) : TXInputDirection ;
- protected function FactorInDeadZone ( ASrc : SmallInt; ADeadZoneValue : SmallInt; var AUseDeadZone : Boolean ) : Double ;
- protected procedure DoCheckTriggerPressed ( AIndex : Byte; AWhichTrigger : TXInputTrigger ) ;
- protected procedure DoCheckThumbSticks ( AIndex : Byte ) ;
- public function Initialize ( ) : Boolean ;
- public procedure Uninitialize ( ) ;
- public function LowLevelGetState ( AUserIndex : Cardinal; AState : PXInputState ) : Cardinal ;
- public function LowLevelSetState ( AUserIndex : Cardinal; AVibration : PXInputVibration ) : Cardinal ;
- public function LowLevelGetCapabilities ( AUserIndex : Cardinal; AFlags : Cardinal; ACapabilities : PXInputCapabilities ) : Cardinal ;
- public procedure LowLevelEnable ( AEnable : Boolean ) ;
- public function LowLevelGetBatteryInformation ( AUserIndex : Cardinal; ADevType : Byte; ABatteryInformation : PXInputBatteryInformation ) : Cardinal ;
- public function LowLevelGetKeystroke ( AUserIndex : Cardinal; AReserved : Cardinal; AKeystroke : PXInputKeystroke ) : Cardinal ;
- public procedure Refresh
(
)
;
Call this to update the states as required - Events are fired in the context of the calling thread.
- public procedure ThumbFromState ( AIndex : Byte; AWhichThumb : TXInputThumb; AState : TXInputState; var X : Double; var Y : Double; AUseDeadZones : Boolean = True ) ;
- public function IsButtonPressed ( AIndex : Byte; AButton : Word ) : Boolean ;
- public function IsTriggerPressed ( AIndex : Byte; AWhichTrigger : TXInputTrigger ) : Boolean ;
- public procedure LeftThumb ( AIndex : Byte; var X : Double; var Y : Double; AUseDeadZones : Boolean = True ) ;
- public procedure RightThumb ( AIndex : Byte; var X : Double; var Y : Double; AUseDeadZones : Boolean = True ) ;
- public function GetTriggerValue ( AIndex : Byte; AWhichTrigger : TXInputTrigger ) : Byte ;
- public function LeftJoystick ( AIndex : Byte ) : TXInputDirection ;
- public function RightJoystick ( AIndex : Byte ) : TXInputDirection ;
- public procedure Vibrate ( AIndex : Byte; ALowSpeed : Word; AHighSpeed : Word ) ;
Properties
- public LatestCheck : NativeUIntread FLatestCheck
- public Connected[Index] : Booleanread GetConnected
- public Capabilities[Index] : TXInputCapabilitiesread GetCapabilities
- public State[Index] : TXInputStateread GetState
- public Battery[Index] : Booleanread GetBattery
- public BatteryState[Index] : Byteread GetBatteryState
- public GamepadLeftThumbDeadzone[Index] : Word
- public GamepadRightThumbDeadzone[Index] : Word
- public GamepadTriggerThreshold[Index] : Byte
- public FireEventsBeforeStoringState : Boolean