#include <OMKKeyListener.h>
Inheritance diagram for OMK::Inp::KeyListener:
Public Member Functions | |
virtual | ~KeyListener () |
The destructor. | |
Static Public Member Functions | |
static const EventIdentifier | getKeyPressCode (const std::string &code) |
To get the event identifier for key press. | |
static const EventIdentifier | getKeyReleaseCode (const std::string &code) |
To get the event identifier for key release. | |
Private Member Functions | |
KeyListener (ExtensibleSimulatedObject *sender, const std::string &code, const ConfigurationParameterDescriptor *node) | |
The constructor. | |
virtual bool | keyPressed (const OIS::KeyEvent &e) |
Dispatches key pressed event. | |
virtual bool | keyReleased (const OIS::KeyEvent &e) |
Dispatches key released event. | |
bool | sendKeyEvent (OIS::KeyCode key, bool pressed) |
Inner method to send the event. | |
void | addListeningObject (const Name &object) |
Add a object in the list. | |
Private Attributes | |
std::vector< Name > | _listeningObjects |
The ojbects' name which will be informed of the key press and release. | |
OIS::KeyCode | _code |
The code of the listening key. | |
const EventIdentifier | _keyPressedCode |
The event identifier for key press. | |
const EventIdentifier | _keyReleasedCode |
The event identifier for key release. | |
Friends | |
class | InputExtension |
This is the only one which can create this object. |
To add this listener you don't have to declare it as an input listener, see Keys parameter in InputExtension for more details.
Definition at line 44 of file OMKKeyListener.h.
KeyListener::KeyListener | ( | ExtensibleSimulatedObject * | sender, | |
const std::string & | code, | |||
const ConfigurationParameterDescriptor * | node | |||
) | [private] |
The constructor.
It is a private one because only the friend class InputExtension, can create it.
Definition at line 21 of file OMKKeyListener.cpp.
References _listeningObjects, and OMK::ParametersAccessor::get().
00024 : InputListener( sender, code, node ), 00025 _code( retrieveCode( code ) ), 00026 _keyPressedCode( getKeyPressCode( code ) ), 00027 _keyReleasedCode( getKeyReleaseCode( code ) ) 00028 { 00029 ParametersAccessor::get( node, code, _listeningObjects ) ; 00030 }
KeyListener::~KeyListener | ( | ) | [virtual] |
const EventIdentifier KeyListener::getKeyPressCode | ( | const std::string & | code | ) | [static] |
To get the event identifier for key press.
[in] | code | The code of the key, see the valid codes. |
Definition at line 11 of file OMKKeyListener.cpp.
Referenced by OMK::Inp::GenericKeyExtension< OMK::ExtensibleSimulatedObject >::loadExtensionParameters().
00012 { 00013 return EventIdentifier( "Key_" + code + "_is_pressed" ) ; 00014 }
const EventIdentifier KeyListener::getKeyReleaseCode | ( | const std::string & | code | ) | [static] |
To get the event identifier for key release.
[in] | code | The code of the key, see the valid codes. |
Definition at line 16 of file OMKKeyListener.cpp.
Referenced by OMK::Inp::InputExtension::initCallBackForKey(), and OMK::Inp::GenericKeyExtension< OMK::ExtensibleSimulatedObject >::loadExtensionParameters().
00017 { 00018 return EventIdentifier( "Key_" + code + "_is_released" ) ; 00019 }
virtual bool OMK::Inp::KeyListener::keyPressed | ( | const OIS::KeyEvent & | e | ) | [inline, private, virtual] |
Dispatches key pressed event.
Definition at line 68 of file OMKKeyListener.h.
00068 { return sendKeyEvent( e.key, true ) ; }
virtual bool OMK::Inp::KeyListener::keyReleased | ( | const OIS::KeyEvent & | e | ) | [inline, private, virtual] |
Dispatches key released event.
Definition at line 70 of file OMKKeyListener.h.
00070 { return sendKeyEvent( e.key, false ) ; }
Inner method to send the event.
Call by keyPressed and keyReleased.
Definition at line 36 of file OMKKeyListener.cpp.
References _code, _keyPressedCode, _keyReleasedCode, _listeningObjects, and OMK::Inp::InputListener::sendEvent().
00037 { 00038 if( _code == key ) 00039 { 00040 for( std::vector< Name >::iterator i = _listeningObjects.begin() ; 00041 i != _listeningObjects.end() ; 00042 i++ ) 00043 { 00044 sendEvent( *i, pressed ? _keyPressedCode : _keyReleasedCode ) ; 00045 } 00046 } 00047 return true ; 00048 }
void KeyListener::addListeningObject | ( | const Name & | object | ) | [private] |
Add a object in the list.
Definition at line 50 of file OMKKeyListener.cpp.
References _listeningObjects.
Referenced by OMK::Inp::InputExtension::addKeyListener().
00051 { 00052 _listeningObjects.insert( _listeningObjects.end(), object ) ; 00053 }
friend class InputExtension [friend] |
std::vector< Name > OMK::Inp::KeyListener::_listeningObjects [private] |
The ojbects' name which will be informed of the key press and release.
Definition at line 77 of file OMKKeyListener.h.
Referenced by addListeningObject(), KeyListener(), and sendKeyEvent().
OIS::KeyCode OMK::Inp::KeyListener::_code [private] |
The code of the listening key.
Definition at line 79 of file OMKKeyListener.h.
Referenced by sendKeyEvent().
const EventIdentifier OMK::Inp::KeyListener::_keyPressedCode [private] |
The event identifier for key press.
Definition at line 81 of file OMKKeyListener.h.
Referenced by sendKeyEvent().
const EventIdentifier OMK::Inp::KeyListener::_keyReleasedCode [private] |
The event identifier for key release.
Definition at line 83 of file OMKKeyListener.h.
Referenced by sendKeyEvent().
Documentation generated on Mon Jun 9 11:46:04 2008 |
Generated with doxygen by Dimitri van Heesch , 1997-2007 |