Changes between Initial Version and Version 1 of doc/lol/input/controller.h


Ignore:
Timestamp:
Mar 15, 2015, 10:18:09 PM (4 years ago)
Author:
touky
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • doc/lol/input/controller.h

    v1 v1  
     1[[TOC]]
     2= <lol/input/controller.h> =
     3
     4View this file in the source browser: [browser:trunk/src/input/controller.h]
     5
     6== Controller ==
     7
     8The controller is the central hub to manage your input in lolengine.
     9
     10There are two way to initialize it:
     11
     12- By hand:
     13{{{
     14#!cpp
     15Controller* my_controller = new Controller("MyName");
     16my_controller->SetInputCount(MAX_KEYS, MAX_AXIS);
     17
     18my_controller->GetKey(Key0).Bind("Keyboard", "Space");
     19my_controller->GetAxis(Axis0).Bind("Mouse", "Y");
     20Etc...
     21}}}
     22
     23- More easily, by InputProfile:
     24{{{
     25#!cpp
     26InputProfile my_profile;
     27my_profile << InputProfile::Keyboard(key0, key0_name)
     28           << InputProfile::MouseAxis(key1, key1_name)
     29           << InputProfile::JoystickKey(joy1_key0, joy1_nb, joy1_key0_name);
     30
     31Controller* my_controller = new Controller("MyName", my_profile);
     32}}}
     33
     34Using the Input profiles allows you to use several profiles by using `Init()` and `ClearProfile()`.
     35
     36Please note that Key value must all be unique, even if the device (mouse/keyboard/....) is different.
     37Same rule applies to axis.
     38
     39=== Querying the controller ===
     40
     41To query the input status, use the corresponding methods:
     42
     43{{{
     44#!cpp
     45KeyBinding& key = my_controller->GetKey(Key0);
     46AxisBinding& axis = my_controller->GetAxis(Axis0);
     47}}}
     48
     49And then use the status methods for your usage:
     50
     51With keys:
     52- `IsDown()`: Indicates wheither the key is currently pressed
     53- `IsUp()`:   Indicates wheither the key is currently released
     54- `JustPressed()`:  Indicates wheither the key has just been pressed
     55- `JustReleased()`: Indicates wheither the key has just been released
     56
     57Or axis:
     58- `GetValue()`: Gets the current absolute value of this axis
     59- `GetDelta()`: Gets the current delta value of this axis
     60
     61