Input Class Reference
[C++ Wrapper for SDL]

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>

List of all members.

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 InputgetInst ()

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.

Detailed Description

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.


Member Function Documentation

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.

Returns:
true if lock is successful, else false (already locked).

References key_, and key_pressed_.

Referenced by InputTextSurface::acquireInput(), and InputTextSurface::update().

bool Input::unlockKeyboard ( const std::string &  lock_id  ) 

Unlock the keyboard.

Returns:
true if unlock successful (same lock_id), else false.

References key_, and key_pressed_.

Referenced by InputTextSurface::update().


The documentation for this class was generated from the following files:
Generated on Mon Apr 5 21:17:34 2010 for Stechec/TBT by  doxygen 1.6.3