Key and mouse shortcuts (TInputShortcut) and global management of them.
TInputShortcut instance represents a key/mouse shortcut. Instances of this class are spread throughout the engine. We have two different ways of using TInputShortcut instance:
The purpose of such global input map is to be able to detect key conflicts, be able to restore whole input map to default, load/save them to the user config file, and so on. All shortcuts used in a typical 3D game, with normal CastleLevels and CastlePlayer usage, are global.
Global shortcuts are owned (they will be freed by) this unit (more specifically, they will be freed by InputsAll). When creating them, pass Nil to the Owner parameter of constructor TInputShortcut.Create. This implies that InputsAll and InputsGroup[Group] lists will never shrink, which is useful — once added, shortcuts will not disappear. Global TInputShortcut instances are always in practice also global variables.
TInputShortcut instance with TInputShortcut.Group = igLocal is called "local". Basically, it means it's a normal component, it's not magically present on any global list, it's not magically managed by any list.
Although it seems like "global" inputs are such a good idea, there are some reasons for having some inputs "local":
You can set them locally, obviously, not program-wide.
You can set them from Lazarus object inspector e.g. for cameras.
We cannot add shortcuts of both TExamineCamera and TWalkCamera to global, as they would conflict (e.g. "up arrow key" is used by both by default). The InputsAll doesn't have (for now) any mechanism to indicate that only one of the cameras will be in practice used for a given TCastleSceneManager.
We cannot add shortcuts of TCamera descendants also because CastlePlayer has shortcuts that override camera shortcuts. One day this problem may disappear, when TPlayer and TCamera will become integrated more.
You create new inputs by simply constructing new TInputShortcut instances. Make sure you add all global inputs before calling Config.Load, as some functionality assumes that all shortcuts are already added at the time Config.Load is called. The engine units themselves never call Config.Load, it is left to the final application.
List of all global inputs. Will be created in initialization and freed in finalization of this unit. All TInputShortcut instances will automatically add to this.