We have some global key/mouse shortcuts:
CastlePlayerunit. These are useful if you make a typical 3D game with the help of
TPlayerclass. In this case,
PlayerInput_*override some navigation shortcuts, and allow to use player's inventory.
There are also local inputs, local to a specific navigation instance,
Input_Xxx properties of
If you use TPlayer then
TPlayer uses it's own
and overrides (most of) navigation inputs with global
PlayerInput_Xxx, so (most of) the
should not be accessed directly, instead change only the global
PlayerInput_Xxx. TPlayer sets typical AWSD key
controls scheme, and they are also state-sensitive: they change appropriately
when player is dead or blocked (see
Every key/mouse shortcut is a TInputShortcut.
They are configurable,
you can change the shortcuts whenever you want (see
TInputShortcut.Assign and other methods). You can also detect
conflicts in the keymap and handle them however you like (see
GameControlsMenu unit in "The Castle 1" sources
The state of keys on the global keymap (
be saved/loaded to the config file, if you call
See the chapter User preferences for more information about this.
You can also create new
Then can be global (added to
InputsAll, saved to config file and such) or local. See
unit API docs. You can easily handle them by overriding
TCastleWindowBase.EventPress methods, or assigning
TCastleWindowBase.OnPress callbacks. You will find then useful methods
TInputShortcut.IsEvent(TInputPressRelease) (to detect press/release of
TInputShortcut.IsPressed(IUIContainer) (to detect holding
(keeping pressed) of input).
An example application that creates a set of custom TInputShortcut instances, and saves/loads them to config file, is in examples/3d_rendering_processing/custom_input_shortcuts_saved_to_config.lpr.
Copyright Michalis Kamburelis and other Castle Game Engine developers.
Thank you to Paweł Wojciechowicz from Cat-astrophe Games for various graphics.
This documentation is also open-source and you can even redistribute it on open-source terms.