Gainput
v1.0.0
|
This page gives an overview on how to get Gainput into your game and use it for getting your players' input.
Gainput can be obtained in source from GitHub.
Build Gainput as described on the Building page.
To begin with, your project should link to the dynamic or static version of the Gainput library. On Linux, the files are libgainput.so
(dynamic library) and libgainputstatic.a
(static library). On Windows, the filenames are gainput.lib
(used with gainput.dll
) and gainputstatic.lib
. In case you decide to use the dynamic library, make sure to distribute the dynamic library together with your executable.
To have the API available, you have to include Gainput's main header file:
You should have the lib/include/
folder as an include folder in your project settings for this to work. The file includes most of Gainput's other header files so that you shouldn't need to include anything else.
Gainput's most important class is gainput::InputManager. You should create one that you use throughout your game. Create some input devices using gainput::InputManager::CreateDevice(). And then, during your game loop, call gainput::InputManager::Update() every frame.
Some platform-specific function calls may be necessary, like gainput::InputManager::HandleMessage().
On top of your gainput::InputManager, you should create at least one gainput::InputMap and map some device-specific buttons to your custom user buttons using gainput::InputMap::MapBool() or gainput::InputMap::MapFloat(). This will allow you to more conventienly provide alternative input methods or enable the player to change button mappings.
After everything has been set up, use gainput::InputMap::GetBool() or gainput::InputMap::GetFloat() (and related functions) anywhere in your game to get player input.