Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
inputpolling [2019/04/18 16:10] – [Mouse] admin | inputpolling [2020/11/04 14:52] – [Runtime] admin | ||
---|---|---|---|
Line 6: | Line 6: | ||
Therefor we provide the easy to use **TGorillaInputController** component to access keyboard, mouse and gamepad feedbacks. Also in combination! | Therefor we provide the easy to use **TGorillaInputController** component to access keyboard, mouse and gamepad feedbacks. Also in combination! | ||
+ | |||
+ | ===== Input Devices ===== | ||
+ | The input controller sets up handlers for keyboard, mouse and gamepad, and enables all by default. | ||
+ | |||
+ | <file pascal> | ||
+ | FInput.Supported := [TGorillaInputDeviceType.Keyboard, | ||
+ | TGorillaInputDeviceType.GamePad]; | ||
+ | </ | ||
+ | |||
+ | If you do not need any of the device, you can disable them, by reducing the " | ||
+ | |||
+ | <file pascal> | ||
+ | FInput.Supported := [TGorillaInputDeviceType.GamePad]; | ||
+ | </ | ||
+ | |||
===== HotKey ===== | ===== HotKey ===== | ||
- | A HotKey is a configuration inside | + | A HotKey is a combination |
- | Those keys use a callback method or can be linked | + | An input is a hardware message: |
+ | |||
+ | * For keyboards, | ||
+ | * For mouse, inputs are pressed mouse buttons | ||
+ | * For gamepad, inputs are pressed gamepad buttons | ||
+ | |||
+ | You can define up to 4 inputs per device. Which means you can handle up to 12 simultanously active input messages. | ||
+ | |||
+ | In case you define an input in two different HotKeys, the system will detect the more important Hotkey. The importance is defined by the number of set inputs. | ||
+ | |||
+ | If a HotKey was detected, the controller will call the OnTriggered event and/or an attached | ||
+ | |||
+ | You are allowed to setup your HotKeys at design- and runtime. | ||
- | You are allowed to setup your keys at design- and at runtime. | + | ==== LockTime ==== |
+ | Set the LockTime property (in milliseconds) to suppress a hotkey for a specific time. | ||
+ | Because input commands come very often, f.e. if a button on the gamepad was pressed. As long as you hold the button the system will recognize the hotkey for this button. | ||
+ | For sequence detection this may be a problem. Therefor we want to lock the gamepad hotkey for a certain time. | ||
==== DesignTime ==== | ==== DesignTime ==== | ||
Line 24: | Line 54: | ||
- Here we can now add a new **TGorillaHotKeyInputItem**. | - Here we can now add a new **TGorillaHotKeyInputItem**. | ||
- In the item select the " | - In the item select the " | ||
- | - and add the message input code | + | - and add the message input code (tables below) |
- Repeat it for any further inputs you wish to combine. | - Repeat it for any further inputs you wish to combine. | ||
==== Runtime ==== | ==== Runtime ==== | ||
Line 37: | Line 67: | ||
end; | end; | ||
+ | procedure TForm1.FormCreate(Sender: | ||
var | var | ||
FInput : TGorillaInputController; | FInput : TGorillaInputController; | ||
Line 50: | Line 81: | ||
LHotKey.AddInput(TGorillaInputDeviceType.Keyboard, | LHotKey.AddInput(TGorillaInputDeviceType.Keyboard, | ||
LHotKey.AddInput(TGorillaInputDeviceType.Keyboard, | LHotKey.AddInput(TGorillaInputDeviceType.Keyboard, | ||
+ | end; | ||
+ | | ||
+ | procedure TForm1.FormClose(Sender: | ||
+ | begin | ||
+ | FInput.DisposeOf(); | ||
+ | FInput := nil; | ||
+ | end; | ||
</ | </ | ||
- | |||
- | |||
===== Persistent Messages ===== | ===== Persistent Messages ===== | ||
- | Besides the HotKey settings the component supports persistent/continuously | + | Besides the HotKey settings the component supports persistent/continuous |
A persistent message is a continuously notified message from the system and not a temporary message like a click or key-press. | A persistent message is a continuously notified message from the system and not a temporary message like a click or key-press. | ||
+ | |||
+ | Persistent messages can not be notified by HotKeys. You need to request those separately. | ||
Supported persistent messages are: | Supported persistent messages are: | ||
Line 83: | Line 121: | ||
</ | </ | ||
- | ===== Input-Codes ===== | + | ===== Input-Codes |
- | All available InputCodes are defined in the Gorilla.Controller.Input.Consts unit. | + | All available InputCodes |
==== Keyboard ==== | ==== Keyboard ==== | ||
Line 192: | Line 230: | ||
| GORILLA_INPUT_MOUSE_XBUTTON_DBLCLK|8| | | GORILLA_INPUT_MOUSE_XBUTTON_DBLCLK|8| | ||
| GORILLA_INPUT_MOUSE_WHEEL|9| | | GORILLA_INPUT_MOUSE_WHEEL|9| | ||
- | | + | |
- | + | ||
==== GamePad ==== | ==== GamePad ==== | ||
Line 210: | Line 249: | ||
| GORILLA_INPUT_GAMEPAD_SHOULDER_LEFT|9| | | GORILLA_INPUT_GAMEPAD_SHOULDER_LEFT|9| | ||
| GORILLA_INPUT_GAMEPAD_SHOULDER_RIGHT|10| | | GORILLA_INPUT_GAMEPAD_SHOULDER_RIGHT|10| | ||
- | |||
| GORILLA_INPUT_GAMEPAD_BUTTON_A|11| | | GORILLA_INPUT_GAMEPAD_BUTTON_A|11| | ||
| GORILLA_INPUT_GAMEPAD_BUTTON_B|12| | | GORILLA_INPUT_GAMEPAD_BUTTON_B|12| | ||
| GORILLA_INPUT_GAMEPAD_BUTTON_X|13| | | GORILLA_INPUT_GAMEPAD_BUTTON_X|13| | ||
| GORILLA_INPUT_GAMEPAD_BUTTON_Y|14| | | GORILLA_INPUT_GAMEPAD_BUTTON_Y|14| | ||
- | |||
| GORILLA_INPUT_GAMEPAD_TRIGGERS|$100| | | GORILLA_INPUT_GAMEPAD_TRIGGERS|$100| | ||
- | |||
| GORILLA_INPUT_GAMEPAD_THUMBSTICK_POS_LEFT|$200| | | GORILLA_INPUT_GAMEPAD_THUMBSTICK_POS_LEFT|$200| | ||
| GORILLA_INPUT_GAMEPAD_THUMBSTICK_POS_RIGHT|$201| | | GORILLA_INPUT_GAMEPAD_THUMBSTICK_POS_RIGHT|$201| | ||
+ | |||
+ | ===== Sequences ===== | ||
+ | |||
+ | HotKeys are a nice feature, but only work for simultaneous inputs. | ||
+ | |||
+ | Imagine you build a combat game, where attacks or defences are represented by input-combos. For example a user needs to press Button A, then Button B and then Button X to do roundhouse kick. | ||
+ | Therefor sequences come in place. Sequences are a descriptive plan of hotkeys, where the order is important. | ||
+ | |||
+ | So Sequence #1 | ||
+ | < | ||
+ | Button A + Button B + Button X | ||
+ | </ | ||
+ | |||
+ | is not the same like | ||
+ | |||
+ | < | ||
+ | Button B + Button A + Button X | ||
+ | </ | ||
+ | |||
+ | __Notes:__ | ||
+ | You are allowed declare an input multiple times in a sequence. | ||
+ | |||
+ | Each sequence can hold up to 16 HotKeys. | ||
+ | ==== DesignTime ==== | ||
+ | |||
+ | ==== Runtime ==== | ||
+ | <file pascal> | ||
+ | procedure TForm1.DoOnSequence(const ASequence : TGorillaInputSequenceItem); | ||
+ | begin | ||
+ | DebugOutput(Format('>>> | ||
+ | end; | ||
+ | |||
+ | [...] | ||
+ | |||
+ | var LSequence: TGorillaInputSequenceItem; | ||
+ | LSeq1HK1, LSeq1HK2, LSeq1HK3 : TGorillaHotKeyItem; | ||
+ | | ||
+ | [...] | ||
+ | | ||
+ | // create hotkey #1 | ||
+ | LSeq1HK1 := FInput.AddHotKey(' | ||
+ | LSeq1HK1.AddInput(TGorillaInputDeviceType.Keyboard, | ||
+ | |||
+ | // create hotkey #2 | ||
+ | LSeq1HK2 := FInput.AddHotKey(' | ||
+ | LSeq1HK2.AddInput(TGorillaInputDeviceType.Keyboard, | ||
+ | |||
+ | // create hotkey #3 | ||
+ | LSeq1HK3 := FInput.AddHotKey(' | ||
+ | LSeq1HK3.AddInput(TGorillaInputDeviceType.Keyboard, | ||
+ | |||
+ | // create the sequence and add the relevant hotkeys | ||
+ | LSequence := FInput.AddSequence(' | ||
+ | LSequence.OnTriggered := DoOnSequence; | ||
+ | </ | ||
+ | |||
+ | Next: [[Pathfinding|Pathfinding]] |