Om  1.0.0
A universal framework for multimedia simulation
Classes | Public Member Functions | Static Public Member Functions | List of all members
om::gui::input::Keyboard Class Reference

A class that stores the state of a virtual keyboard input device. More...

#include <omGUIInputKeyboard.h>

Public Member Functions

 Keyboard ()
 Create a new empty keyboard with no keys. More...
 
Size getKeyCount () const
 Return the total number of keys that there are for this keyboard. More...
 
const KeygetKey (KeyCode keyCode) const
 Return a pointer to the key in this keyboard with the specified code. More...
 
const KeygetNativeKey (KeyCode nativeKeyCode) const
 Return a pointer to the key in this keyboard with the specified native key code. More...
 
void addKey (const Key &newKey, KeyCode nativeKeyCode, Bool isPressed=false)
 Add a new key to this keyboard with the specified initial state. More...
 
Bool hasKey (KeyCode keyCode)
 Return whether or not this keyboard contains a key with the specified key code. More...
 
Bool removeKey (KeyCode keyCode)
 Remove the key with the specified key code from this keyboard. More...
 
void clearKeys ()
 Remove all keys from this keyboard. More...
 
Bool isPressed (KeyCode keyCode) const
 Return whether or not the key with the specified code is pressed on the keyboard. More...
 
Bool isPressed (const Key &key) const
 Return whether or not the specified key is pressed on the keyboard. More...
 
void unpressAll ()
 Set the state of all keys in the keyboard to the unpressed state. More...
 
KeyCode convertNativeCode (KeyCode keyCode) const
 Convert the specified platform-native key code to a generic key code based on this keyboard's mapping. More...
 
KeyCode convertToNativeCode (KeyCode keyCode) const
 Convert the specified generic key code to a platform-native key code based on this keyboard's mapping. More...
 
void keyEvent (const KeyEvent &keyEvent)
 Change the state of the keyboard to reflect the specified keyboard event. More...
 

Static Public Member Functions

static const KeyboardgetDefault ()
 Return a const reference the default keyboard for the current system platform. More...
 
static void getDefaultKeys (Keyboard &keybaord)
 Add the default keys to the specified keyboard object for the current system platform. More...
 

Detailed Description

A class that stores the state of a virtual keyboard input device.

Constructor & Destructor Documentation

om::gui::input::Keyboard::Keyboard ( )

Create a new empty keyboard with no keys.

Member Function Documentation

Size om::gui::input::Keyboard::getKeyCount ( ) const
inline

Return the total number of keys that there are for this keyboard.

const Key* om::gui::input::Keyboard::getKey ( KeyCode  keyCode) const

Return a pointer to the key in this keyboard with the specified code.

The method returns NULL if there is no key with that code.

const Key* om::gui::input::Keyboard::getNativeKey ( KeyCode  nativeKeyCode) const

Return a pointer to the key in this keyboard with the specified native key code.

This method uses the internal native key code map to convert the key code, then uses the converted key code to find the key with that code. The method returns NULL if there is no key with that native key code.

void om::gui::input::Keyboard::addKey ( const Key newKey,
KeyCode  nativeKeyCode,
Bool  isPressed = false 
)

Add a new key to this keyboard with the specified initial state.

If there is already a key with the new key's code in this keyboard, the old key is replaced with the new one. A key code conversion mapping is added for the specified native key code that maps to the given key.

Bool om::gui::input::Keyboard::hasKey ( KeyCode  keyCode)

Return whether or not this keyboard contains a key with the specified key code.

Bool om::gui::input::Keyboard::removeKey ( KeyCode  keyCode)

Remove the key with the specified key code from this keyboard.

The method returns whether or not the key with that code was able to be removed.

void om::gui::input::Keyboard::clearKeys ( )

Remove all keys from this keyboard.

Bool om::gui::input::Keyboard::isPressed ( KeyCode  keyCode) const

Return whether or not the key with the specified code is pressed on the keyboard.

Bool om::gui::input::Keyboard::isPressed ( const Key key) const
inline

Return whether or not the specified key is pressed on the keyboard.

void om::gui::input::Keyboard::unpressAll ( )

Set the state of all keys in the keyboard to the unpressed state.

KeyCode om::gui::input::Keyboard::convertNativeCode ( KeyCode  keyCode) const
inline

Convert the specified platform-native key code to a generic key code based on this keyboard's mapping.

KeyCode om::gui::input::Keyboard::convertToNativeCode ( KeyCode  keyCode) const
inline

Convert the specified generic key code to a platform-native key code based on this keyboard's mapping.

void om::gui::input::Keyboard::keyEvent ( const KeyEvent keyEvent)

Change the state of the keyboard to reflect the specified keyboard event.

static const Keyboard& om::gui::input::Keyboard::getDefault ( )
static

Return a const reference the default keyboard for the current system platform.

static void om::gui::input::Keyboard::getDefaultKeys ( Keyboard keybaord)
static

Add the default keys to the specified keyboard object for the current system platform.


The documentation for this class was generated from the following file: