Version 1 (modified by rgrieder, 16 years ago) (diff) |
---|
KeyBinder
Concepts
When creating the concept for input processing, we were left with two possibilities. The first and simpler one was to have an ID for every possible event. When you press a key, that event is fired and all listeners get informed. But as my colleague pointed out, this doesn't really scale since you have add new events over and over.
Instead he suggested to write a command interpreter that would parse a string and execute a command (CommandExecutor). Consequently this simplifies the KeyBinder by magnitudes: Every key can be assigned a string and whenever you press the key, the string gets executed. The obvious disadvantage is performance, but that has been dealt with preparsing so that the overhead gets minmal.
A quick how to
There is a built in ConsoleCommand named "keybind" which helps you assign the keys. Write 'keybind' followed by an arbitrary ConsoleCommand with arguments, hit enter and press the key you would like to assign it to. This also works for mouse and joystick axes. However you have to do some double work since those axes are split in half ones. For simple left-right movement for instance, this means you have to assign left movement to the left axis and vice versa.