Gorilla.Controller.Input
Unit Gorilla.Controller.Input.pasClasses
- TGorillaInputMessageBuffer = class ( TObject )
- TGorillaInputHandler = class ( TThread )
- TGorillaHotKeyInputItem = class ( TCollectionItem )
- TGorillaHotKeyCombinations = class ( TCollection )
- TGorillaHotKeyItem = class ( TCollectionItem )
- TGorillaHotKeyCollection = class ( TCollection )
- TGorillaInputSequenceHotKeyItem = class ( TCollectionItem )
- TGorillaInputSequenceHotKeyCollection = class ( TCollection )
- TGorillaInputSequenceItem = class ( TCollectionItem )
- TGorillaInputSequenceCollection = class ( TCollection )
- TGorillaInputThread = class ( TThread )
- TGorillaInputController = class ( TGorillaController )
Records
- record TGorillaHotKeyInputRaw
- record TGorillaHotKeyRaw
- record TGorillaInputMessage
- record TGorillaInputSequenceBufferItem
Enumerations
- enum TGorillaInputDeviceType = ( Keyboard, Mouse, GamePad ) ;
- enum TGorillaInputMode = ( Activated, Deactivated ) ;
- enum TGorillaMouseState = ( LButtonDown, LButtonUp, RButtonDown, RButtonUp, MButtonDown, MButtonUp, X1ButtonDown, X1ButtonUp, X2ButtonDown, X2ButtonUp, LButtonDblClick, RButtonDblClick, MButtonDblClick, X1ButtonDblClick, X2ButtonDblClick, MouseMove, MouseWheel ) ;
Constants
Mics. types
- type TGorillaInputCode = Int64;
- type PGorillaHotKeyInputRaw = pointer to TGorillaHotKeyInputRaw;
- type TGorillaInputHandlerClass = class of TGorillaInputHandler;
TGorillaHotKeyInputRaw
Fields
Methods
- public procedure Sort
(
)
;
In the end all inputs need to be sorted from low to high value.
- public function Contains
(
const
AInput :
TGorillaHotKeyInputRaw
)
: Boolean
;
Compares both inputs to verify if AInput exists in Self.
- public function ToString ( ) : string ;
TGorillaHotKeyRaw
Fields
Methods
- public function Create ( ) : TGorillaHotKeyRaw ; static;
- public procedure AddInput
(
const
AInput :
TGorillaHotKeyInputItem
)
;
Adds a collection item to raw format
- public procedure Sort
(
)
;
In the end all inputs need to be sorted from low to high value.
- public function GetWeight
(
)
: Integer
;
Returns the weight / importance of a raw hotkey. Due to double declaration of input codes, we need a priority handling done by the hotkey weights. The more input codes are used, the more important the hotkey is.
- public function Contains
(
const
AKey :
TGorillaHotKeyRaw
)
: Boolean
;
Checks if the supplied raw key is available in the source raw key. This is used for none explicit hotkey search.
- public function ToString
(
)
: string
;
Outputs the structure as string for debugging purposes.
TGorillaInputMessage
TGorillaInputMessageBuffer
A stack buffer for storing a limited number of inputs.
Ancestors
Members
Fields
Methods
- public constructor Create ( ) ;
- public destructor Destroy ( ) ;
- public procedure Lock ( ) ;
- public procedure Unlock ( ) ;
- public procedure Add ( const AMessage : TGorillaInputMessage ) ; virtual;
- public procedure Remove ( const ACode : NativeInt ) ; virtual;
- public function Get ( const ACode : NativeInt; out AMessage : TGorillaInputMessage ) : Boolean ; virtual;
- public function Contains ( const ACode : NativeInt ) : Boolean ; virtual;
- public function GetRawKey ( ) : TGorillaHotKeyInputRaw ; virtual;
TGorillaInputHandler
Custom input handler class as basis class for keyboard and gamepad handlers.
Remarks
The handler registers itself in constructor and unregisters itself on destructor.Ancestors
Members
Fields
- protected FController :
TGorillaInputController
- protected FKind :
TGorillaInputDeviceType
- protected FEnabled :
Boolean
- protected FSensitivity :
Integer
- protected FBuffer :
TGorillaInputMessageBuffer
- protected FChanged :
Boolean
Methods
- public constructor Create ( ACtrl : TGorillaInputController ) ;
- public destructor Destroy ( ) ;
- protected procedure SetEnabled ( const AValue : Boolean ) ; virtual;
- protected procedure SetSensitivity ( const AValue : Integer ) ; virtual;
- protected procedure Execute ( ) ; override;
- protected procedure DoChange ( const AMode : TGorillaInputMode ) ; virtual;
- protected procedure DoBeginExecute ( ) ; abstract virtual;
- protected procedure DoEndExecute ( ) ; abstract virtual;
- protected procedure DoRequestInput ( ) ; abstract virtual;
- public procedure Changed
(
const
AMode :
TGorillaInputMode
)
;
Called by the handler itself, when the buffer has changed and the input controller needs to check for hotkeys.
Properties
TGorillaHotKeyInputItem
The combination item is a part of the combination collection, representing a virtual keyboard, virtual gamepad or mouse event.
Ancestors
Members
Fields
Methods
- protected function GetDisplayName ( ) : string ; override;
- protected procedure SetDisplayName ( const AValue : string ) ; override;
- protected procedure SetKind ( const AValue : TGorillaInputDeviceType ) ;
- protected procedure SetCode ( const AValue : NativeInt ) ;
- protected procedure DoUpdate ( ) ; virtual;
Properties
TGorillaHotKeyCombinations
Is the collection which holds the input combination.
Ancestors
Members
Fields
Properties
TGorillaHotKeyItem
Setup input combinations to react on specific input combinations. It is possible to combine different input devices, f.e. "E" + "Right Mouse Click"
Ancestors
Members
Fields
- protected FName :
string
- protected FEnabled :
Boolean
- protected FTriggerOnActivate :
Boolean
- protected FCombinations :
TGorillaHotKeyCombinations
- protected FLockTime :
Cardinal
- protected FLastTriggerTime :
Int64
- protected FAction :
TAction
- protected FOnTriggered :
TGorillaOnHotKeyTriggered
Methods
- public constructor Create ( ACollection : TCollection ) ;
- public destructor Destroy ( ) ;
- protected function GetDisplayName ( ) : string ; override;
- protected procedure SetDisplayName ( const AValue : string ) ; override;
- protected procedure SetEnabled ( const AValue : Boolean ) ; virtual;
- protected procedure SetTriggerOnActivate ( const AValue : Boolean ) ; virtual;
- public function AddInput
(
const
AKind :
TGorillaInputDeviceType; const
ACode :
NativeInt
)
: TGorillaHotKeyInputItem
;
Adds an input as part of the hotkey combination
- public function GetRawKey
(
)
: TGorillaHotKeyRaw
;
Returns the binary format of a hotkey combination.
- public procedure Trigger
(
const
ACurrentInput :
TGorillaHotKeyRaw
)
;
virtual;
You can trigger manually a specific hotkey for simulation purposes.
- public function TriggerSync
(
const
ACurrentInput :
TGorillaHotKeyRaw
)
: Boolean
;
virtual;
You can trigger manually a specific hotkey for simulation purposes. The method will automatically be synchronized with the main thread.
Properties
- published Name : string
- published Enabled : Boolean
Defines if the hotkey is enabled or not. If not, it will not be considered while hotkey detection.
read FEnabled
write SetEnabled - published TriggerOnActivate : Boolean
Defines if the hotkey getting triggered when all inputs are activated (pressing down a key) or when they are about to be deactivated (release a key)
read FTriggerOnActivate
write SetTriggerOnActivate - published Combinations : TGorillaHotKeyCombinations
A collection with all components setting up this specific input combination.
read FCombinations
write FCombinations - published Action : TAction
- published LockTime : Cardinal
TGorillaHotKeyCollection
Provides a collection of hotkey items, where keyboard, mouse and gamepad inputs can be combined.
Ancestors
Members
Fields
- protected FUpdateRawMap :
Boolean
- protected FOnActivatedRawMap :
TGorillaRawHotKeyMap
- protected FOnDeactivatedRawMap :
TGorillaRawHotKeyMap
Methods
- public destructor Destroy ( ) ;
- public procedure SetUpdateRawMap
(
)
;
Call this method to flag the hotkey collection for updating the raw keymap.
- public procedure UpdateRawMap
(
)
;
Clears the previous raw map, creates a new rawkey for each hotkey and adds it to the hashmap. This method getting called by the TGorillaInputController.Execute method.
TGorillaInputSequenceHotKeyItem
A linked hotkey inside of the sequence hotkey collection.
Ancestors
Members
Fields
Properties
TGorillaInputSequenceHotKeyCollection
This kind of collection holds the hotkeys for triggering a specific sequence.
Ancestors
TGorillaInputSequenceItem
A input sequence is a descriptive plan for executing hotkeys one after another.
Ancestors
Members
Fields
- protected FName :
string
- protected FEnabled :
Boolean
- protected FSensitivity :
Integer
- protected FHotKeys :
TGorillaInputSequenceHotKeyCollection
- protected FOnTriggered :
TOnGorillaInputSequenceTriggered
- protected FAction :
TAction
Methods
- public constructor Create ( ACollection : TCollection ) ;
- public destructor Destroy ( ) ;
- protected function GetDisplayName ( ) : string ; override;
- protected procedure SetDisplayName ( const AValue : string ) ; override;
- public procedure Trigger
(
)
;
virtual;
Trigger a specific sequence manually. Used for simlution purposes.
- public procedure TriggerSync
(
)
;
virtual;
Trigger a specific sequence manually. Used for simlution purposes. The method will be automatically synced with main thread.
Properties
TGorillaInputSequenceCollection
A input sequence collection contains a number of sequence item, which hold a serial execution plan for hotkeys.
Ancestors
TGorillaInputThread
The input thread checks for hotkeys and sequences and dispatches those feedbacks to main thread. It is unperformant to this in main thread.
Ancestors
Members
Fields
Methods
- public constructor Create ( const AController : TGorillaInputController ) ;
- public destructor Destroy ( ) ;
- protected procedure Execute ( ) ; override;
- protected procedure LockController ( ) ;
- protected procedure UnlockController ( ) ;
- protected procedure DoExecuteSequenceDetection ( ) ; virtual;
- protected procedure DoPushHotKeyToSequenceBuffer ( const AHotKey : TGorillaHotKeyItem ) ; virtual;
- protected procedure CheckForHotKeys
(
const
AMode :
TGorillaInputMode
)
;
Method getting called on FEvent set by handlers. The routine will check the controllers hotkey collection for activated & deactivated hotkeys.
TGorillaInputController
The input controller handles keyboard or gamepad input.
Remarks
By this asynchronous feedback component fast input controlling is possible.Ancestors
Members
Fields
- protected FClassLock :
TCriticalSection
- protected FHandlerClasses :
TGorillaInputHandlerClassList
- protected FCS :
TCriticalSection
- protected FThread :
TGorillaInputThread
- protected FSupported :
TGorillaInputDeviceTypes
- protected FHandlers :
TGorillaInputHandlerList
- protected FHotKeys :
TGorillaHotKeyCollection
- protected FSequences :
TGorillaInputSequenceCollection
- protected FSequenceBuffer :
TGorillaInputSequenceBuffer
- protected FOnMouseDown :
TGorillaInputMouseEvent
- protected FOnMouseUp :
TGorillaInputMouseEvent
- protected FOnMouseDblClick :
TGorillaInputMouseEvent
- protected FOnMouseMove :
TGorillaInputMouseMoveEvent
- protected FOnMouseWheel :
TGorillaInputMouseWheelEvent
- protected FOnKeyDown :
TGorillaInputKeyEvent
- protected FOnKeyUp :
TGorillaInputKeyEvent
Methods
- public constructor Create ( AOwner : TComponent ) ;
- public destructor Destroy ( ) ;
- protected procedure SetEnabled ( AValue : Boolean ) ; override;
- protected function GetEnabled ( ) : Boolean ; override;
- protected procedure SetSupported ( const AValue : TGorillaInputDeviceTypes ) ; virtual;
- protected procedure SetupHandlers
(
)
;
virtual;
Creates a handler for each registered handler class.
- protected procedure FreeHandlers
(
)
;
virtual;
Stops all handler threads and removes them from handlers list.
- protected procedure RegisterHandler
(
const
AHandler :
TGorillaInputHandler
)
;
virtual;
Registers threadsafe a specific handler in the controller.
- protected procedure UnregisterHandler
(
const
AHandler :
TGorillaInputHandler
)
;
virtual;
Unregisters threadsafe a specific handler in the controller.
- protected procedure DoClearSequenceBuffer
(
)
;
virtual;
Clears the sequence buffer (threadsafe).
- public procedure RegisterHandlerClass
(
const
AClass :
TGorillaInputHandlerClass
)
;
class virtual;
Registers a specific handler class in the input controller management.
- public procedure UnregisterHandlerClass
(
const
AClass :
TGorillaInputHandlerClass
)
;
class virtual;
Unregisters a specific handler class from input controller management.
- public procedure Initialize
(
)
;
class virtual;
Used to create available handler classes on unit initialization.
- public procedure Finalize
(
)
;
class virtual;
Used to destroy all registered handler classes on unit finalization.
- public function GetHandler
(
const
ADevice :
TGorillaInputDeviceType
)
: TGorillaInputHandler
;
virtual;
Request a specific input handler defined by the supplied type. If no handler with this device type can be found, the method returns nil.
- public function AddHotKey
(
const
AName :
string
)
: TGorillaHotKeyItem
;
virtual;
Adds a new empty hotkey item to the collection. You need to add inputs to this item afterwards.
- public function AddSequence
(
const
AName :
string; const
AHotKeys :
TArray<Gorilla.Controller.Input.TGorillaHotKeyItem>
)
: TGorillaInputSequenceItem
;
virtual;
Adds a new hotkey sequence to the input controller. In case no hotkeys are supplied, the method returns nil.
- public function GetPersistentMessage
(
const
ADevice :
TGorillaInputDeviceType; const
ACode :
NativeInt; out
AMessage :
TGorillaInputMessage
)
: Boolean
;
virtual;
The system supports persistent messages like the mouse position.
- public procedure NotifyMessage
(
const
AMode :
TGorillaInputMode
)
;
virtual;
In case a handler has detected some input, it will call this method to inform the input thread to check for hotkeys and sequences.
- public procedure DispatchKeyMessage ( const AIsKeyDown : Boolean; const AKey : Integer ) ; virtual;
- public procedure DispatchMouseMessage ( const AEvent : TGorillaMouseState; const AStates : TGorillaMouseStates; const APos : TPointF; const AFlags : Integer ) ; virtual;
- class private procedure Create@ ( ) ; class constructor noself;
- class private procedure Destroy@ ( ) ; class destructor noself;
Properties
- public Handlers : TObjectList<Gorilla.Controller.Input.TGorillaInputHandler>
- public SequenceBuffer : TQueue<Gorilla.Controller.Input.TGorillaInputSequenceBufferItem>
- published Enabled : Boolean
- published Supported : TGorillaInputDeviceTypes
By this property you can enable devices for capturing inputs. Only those devices will be considered for hotkey checks.
read FSupported
write SetSupported - published HotKeys : TGorillaHotKeyCollection
- published Sequences : TGorillaInputSequenceCollection
A published list of all available hotkey sequences. A Sequence allows you to combine predefined hotkeys for sequential execution.
read FSequences
write FSequences