Hold keyboard and mouse state.* For mouse absolute position and delta motion, this should be obvious. * For mouse button, use constants SDL_BUTTON_LEFT, ..., see SDL_MouseButtonEvent(5). * For keyboard, two informations are available. Keys currently pressed, and keys being pressed since the last updat.e occured. Access key using ascii character, eg: if (key_['b']) {...} * For keyboard modifier, use class convenience function. More...
#include <Input.hh>
Public Member Functions | |
| void | reset () |
| To call before a serie of update();. | |
| void | update (SDL_Event &event) |
| Update Input structure. To use in the main loop only. | |
| bool | isModDown (int mod) const |
See if keyboard modifier mod is down. | |
| bool | isModPressed (int mod) const |
| Same as isModDown, but since last update. | |
| bool | lockKeyboard (const std::string &lock_id) |
| Locks the keyboard, so that key_ and key_pressed_ will always be empty, until it is unlocked with the same lock_id. | |
| bool | unlockKeyboard (const std::string &lock_id) |
| Unlock the keyboard. | |
| bool | isKeyboardLocked () const |
| Check if the keyboard is locked. | |
| const std::string & | getString () const |
Static Public Member Functions | |
| static Input * | getInst () |
Public Attributes | |
| Point | mouse_delta_ |
| Mouse motion since last update. | |
| Point | mouse_ |
| Mouse position. | |
| bool | button_ [10] |
| Mouse button currently down. | |
| bool | button_pressed_ [10] |
| Mouse button pressed since last update. | |
| bool | key_ [SDLK_LAST] |
| Keys currently pressed. | |
| bool | key_pressed_ [SDLK_LAST] |
| Keys pressed between last updat and now. | |
Hold keyboard and mouse state.
* For mouse absolute position and delta motion, this should be obvious. * For mouse button, use constants SDL_BUTTON_LEFT, ..., see SDL_MouseButtonEvent(5). * For keyboard, two informations are available. Keys currently pressed, and keys being pressed since the last updat.e occured. Access key using ascii character, eg: if (key_['b']) {...} * For keyboard modifier, use class convenience function.
It also provides a easy way to gain exclusive access to the keyboard, by locking and unlocking it.
| bool Input::isModDown | ( | int | mod | ) | const |
See if keyboard modifier mod is down.
Use constants KMOD_CTRL, ... as specified in SDL_GetModState(5).
| bool Input::lockKeyboard | ( | const std::string & | lock_id | ) |
Locks the keyboard, so that key_ and key_pressed_ will always be empty, until it is unlocked with the same lock_id.
References key_, and key_pressed_.
Referenced by InputTextSurface::acquireInput(), and InputTextSurface::update().
| bool Input::unlockKeyboard | ( | const std::string & | lock_id | ) |
Unlock the keyboard.
References key_, and key_pressed_.
Referenced by InputTextSurface::update().
1.6.3