Table of Contents
<lol/input/controller.h>
View this file in the source browser: trunk/src/input/controller.h
Controller
The controller is the central hub to manage your input in lolengine.
There are two way to initialize it:
- By hand:
Controller* my_controller = new Controller("MyName"); my_controller->SetInputCount(MAX_KEYS, MAX_AXIS); my_controller->GetKey(Key0).Bind("Keyboard", "Space"); my_controller->GetAxis(Axis0).Bind("Mouse", "Y"); Etc...
- More easily, by InputProfile:
InputProfile my_profile; my_profile << InputProfile::Keyboard(key0, key0_name) << InputProfile::MouseAxis(key1, key1_name) << InputProfile::JoystickKey(joy1_key0, joy1_nb, joy1_key0_name); Controller* my_controller = new Controller("MyName", my_profile);
Using the Input profiles allows you to use several profiles by using Init()
and ClearProfile()
.
Please note that Key value must all be unique, even if the device (mouse/keyboard/....) is different. Same rule applies to axis.
Querying the controller
To query the input status, use the corresponding methods:
KeyBinding& key = my_controller->GetKey(Key0); AxisBinding& axis = my_controller->GetAxis(Axis0);
And then use the status methods for your usage:
With keys:
IsDown()
: Indicates wheither the key is currently pressedIsUp()
: Indicates wheither the key is currently releasedJustPressed()
: Indicates wheither the key has just been pressedJustReleased()
: Indicates wheither the key has just been released
Or axis:
GetValue()
: Gets the current absolute value of this axisGetDelta()
: Gets the current delta value of this axis
Last modified 8 years ago
Last modified on Mar 15, 2015, 10:18:09 PM