e2d::core::Keyboard Class Reference

List of all members.

Detailed Description

This class mantains a record of what keys are being pressed at a given moment. You can read the key states (pressed/unpressed) and set these states yourself, if you feel like doing so.

This class is a Singleton, what means you can't make an instance of Keyboard yourself. It is available to you via Utilities.

Public Member Functions

bool CheckKeyState (int key)
 Checks key state.
void ClearBuffer ()
 Clears the key buffer.
void PopState ()
 Un-stacks the current state.
void PushState ()
 Stacks the current state.
void SetKeyState (bool pressed, int key)
 Sets key state.

Static Public Member Functions

static KeyboardGetInstance (void)
 Gets an object for this class.

Member Function Documentation

Keyboard * e2d::core::Keyboard::GetInstance ( void   )  [static]

This class is a Singleton. If you want an instance of this class to work with, get it via this method.

bool e2d::core::Keyboard::CheckKeyState ( int  key  ) 

With this method you are able to verify if a key is being or not pressed on the keyboard.

key The key you want to check the state of: see SDL documentation for key constants.
True if the key is being pressed; false otherwise.

void e2d::core::Keyboard::ClearBuffer (  ) 

Clears the key buffer by setting all key states to false.

void e2d::core::Keyboard::PopState (  ) 

Recovers the last pushed keyboard buffer state, or resets the buffer (with ClearBuffer()) if there was nothing on the stack.

void e2d::core::Keyboard::PushState (  ) 

Stores the current keyboard buffer state into an internal stack.

void e2d::core::Keyboard::SetKeyState ( bool  pressed,
int  key 

With this method you can set a key state yourself. Note that if a key is not pressed and you set its state to pressed, it will remain in a state of pressed even if the key is not really being pressed on the keyboard. But, if the real key is pressed and then released, then it will switch to the state of unpressed.

pressed Set it to true if you want the key to be seen as pressed, and set it to false otherwise.
key The key you want to change the state: see SDL documentation for key constants.

Generated on Tue Dec 8 10:32:44 2009 for Easy2D by  doxygen 1.5.6