|
CPP-TOOLBOX
|
Files | |
| input_state.cpp | |
| input_state.hpp | |
SUBPROJECT
when making games you need a good and robust way to query the current mouse and keyboard state, usually all this logic occurs inside of a key callback, something like this allows you instead query the keyboard state werever you have access to the input_state object allowing you to put the logic where you please instead of it all building up in the key callback.
Additionally you'll want to be able to know what key is pressed, and what the string is for a given key, when using a char callback the logic can become even more fragmented, thus this class also gives you tools to know what the string is for a key.
In order to integrate this into your system first initialize one of these somewhere:
Then use the callbacks provided:
note that since this system relies on TemporalBinarySignal you need to make this call once per tick
then to check if a key has just been pressed we do:
or to see if it's actively being pressed do: