Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 2 and Version 3 of code/doc/KeyBinder


Ignore:
Timestamp:
Sep 18, 2008, 10:58:10 PM (12 years ago)
Author:
rgrieder
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/KeyBinder

    v2 v3  
    11= KeyBinder =
    22
    3 == Concepts ==
     3== ''Concepts'' ==
    44When 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. [[br]]
    55Instead he suggested to write a command interpreter that would parse a string and execute a command ([wiki: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.
    66
    7 == A quick how to ==
    8 There is a built in [wiki: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.
     7== ''A quick how to'' ==
     8There is a built in [wiki: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. [[br]][[br]]
    99
    10 == Internals ==
     10== ''Internals'' ==
    1111One of the basic ideas was not to separate keys, buttons and axes from each other. Every such input 'trigger' should be able to fulfill the same functions. An axis should for instance be able to act as a simple button and any key or buttons has to have the ability to work like an axis. This essentially means that there have to be translation mechanisms.[[br]]
    1212
     
    1818Obviously a half axis cannot simply act as button like that. The conversion however is rather simple: When the axis is moved more than a certain configurable threshold, it triggers the 'button'.[[br]]
    1919The other way round, when a buttons acts axis like, we simply interpret a pressed button as 1.0 and 0.0 otherwise.
     20
     21=== keybindings.ini ===
     22This file governs the key bindings while playing. There might be more with different names to come, but currently, there is only one. Now every key, button or axis can be assigned an arbitrary number of commands. Usually it is only one, but I you never know... [[br]]
     23In order to configure a command it has to be ''preceded'' by one of these non case sensitive tokens: [[br]]
     24|| Command || Effect ||
     25||         ||        ||
     26|| OnPress || Event gets fired when button is pressed ||
     27|| OnRelease || Event gets fired when button is released ||
     28|| OnHold  || Event gets fired every tick if button is held down ||
     29|| ButtonThreshold [0.0 - 1.0] || How much a half axis has to be moved to trigger a button like event ||
     30|| Scale [float] || Scales the output parameter (if any) by [float]. Useful for negative movements ||
     31Some of these tokens might have no effect if used on an physical button/key.