Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Examples  

gadget::SimInput Class Reference

Base class for all simulated input devices. More...

#include <SimInput.h>

Inheritance diagram for gadget::SimInput:

Inheritance graph
[legend]
Collaboration diagram for gadget::SimInput:

Collaboration graph
[legend]
List of all members.

Public Methods

 SimInput ()
virtual ~SimInput ()
virtual bool config (jccl::ConfigElementPtr element)
 Configures the keyboard interface. More...

virtual std::string getBaseType ()
virtual vpr::ReturnStatus writeObject (vpr::ObjectWriter *writer)
virtual vpr::ReturnStatus readObject (vpr::ObjectReader *reader)

Protected Methods

virtual int checkKeyPair (KeyModPair &pair)
 Checks the given keypair. More...

virtual int checkKey (gadget::Keys keyId)
 Gets number of times the key was pressed. More...

std::vector< KeyModPairreadKeyList (std::vector< jccl::ConfigElementPtr > &keyList)
 Constructs the mod pair from a mod pair element. More...


Protected Attributes

EventWindowInterface mEventWin
 The event window from which we receive events. More...


Detailed Description

Base class for all simulated input devices.

Has the common routines for accessing and seting up keyboard interface.

Definition at line 54 of file SimInput.h.


Constructor & Destructor Documentation

gadget::SimInput::SimInput   [inline]
 

Definition at line 90 of file SimInput.h.

00091    {
00092       //vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL)<<"*** SimInput::SimInput()\n"<< vprDEBUG_FLUSH;
00093    }

virtual gadget::SimInput::~SimInput   [inline, virtual]
 

Definition at line 94 of file SimInput.h.

00094 {}


Member Function Documentation

bool gadget::SimInput::config jccl::ConfigElementPtr    element [virtual]
 

Configures the keyboard interface.

Postcondition:
Event window proxy is configured.

Reimplemented in gadget::SimGloveGesture.

Definition at line 70 of file SimInput.cpp.

References mEventWin.

00071 {
00072    // Get the event source.
00073    mEventWin.init(element->getProperty<std::string>("event_window_proxy"));
00074 
00075    return true;
00076 }

virtual std::string gadget::SimInput::getBaseType   [inline, virtual]
 

Definition at line 102 of file SimInput.h.

00103    {
00104        return std::string("SimInput");
00105    }

virtual vpr::ReturnStatus gadget::SimInput::writeObject vpr::ObjectWriter *    writer [inline, virtual]
 

Definition at line 107 of file SimInput.h.

00108    {
00109       boost::ignore_unused_variable_warning(writer);
00110       return vpr::ReturnStatus::Succeed;
00111    }

virtual vpr::ReturnStatus gadget::SimInput::readObject vpr::ObjectReader *    reader [inline, virtual]
 

Definition at line 113 of file SimInput.h.

00114    {
00115       boost::ignore_unused_variable_warning(reader);
00116       return vpr::ReturnStatus::Succeed;
00117    }

int gadget::SimInput::checkKeyPair KeyModPair   pair [protected, virtual]
 

Checks the given keypair.

Returns:
Number of times the key was pressed with the modifier alone held down.

Definition at line 78 of file SimInput.cpp.

References mEventWin.

00079 {
00080    if (pair.mModifier == -1)      // ANY modifier
00081    {
00082       return mEventWin->keyPressed(pair.mKey);
00083    }
00084    if (mEventWin->modifierOnly(pair.mModifier))
00085    {
00086       return mEventWin->keyPressed(pair.mKey);
00087    }
00088    else                 // Mod not pressed
00089    {
00090       return 0;
00091    }
00092 }

int gadget::SimInput::checkKey gadget::Keys    keyId [protected, virtual]
 

Gets number of times the key was pressed.

Returns:
Number of times the key was pressed.

Definition at line 94 of file SimInput.cpp.

References mEventWin.

00095 {
00096    return mEventWin->keyPressed(keyId);
00097 }

std::vector< SimInput::KeyModPair > gadget::SimInput::readKeyList std::vector< jccl::ConfigElementPtr > &    keyList [protected]
 

Constructs the mod pair from a mod pair element.

Takes as input a element that has a list of KeyModPair child elements.

Precondition:
keyList must be full of var values containing elements of the type "key_modifier_pair". The KeyModPair element type must have fields named key and modifier_key.
Returns:
vector of KeyModPairs

Definition at line 42 of file SimInput.cpp.

Referenced by gadget::SimGloveGesture::config.

00043 {
00044    std::vector<KeyModPair> key_vec;
00045 
00046    if ( ! keyList.empty() )
00047    {
00048 #ifdef GADGET_DEBUG
00049       jccl::ConfigElementPtr first_element = keyList[0];
00050       std::string element_type(first_element->getID());
00051       vprASSERT(element_type == std::string("key_modifier_pair"));
00052 #endif
00053 
00054       for ( std::vector<jccl::ConfigElementPtr>::iterator i = keyList.begin();
00055             i != keyList.end();
00056             ++i )
00057       {
00058          key_vec.push_back(KeyModPair((gadget::Keys) (*i)->getProperty<int>("key"),
00059                                       (gadget::Keys) (*i)->getProperty<int>("modifier_key")));
00060       }
00061    }
00062 
00063    return key_vec;
00064 }


Member Data Documentation

EventWindowInterface gadget::SimInput::mEventWin [protected]
 

The event window from which we receive events.

Definition at line 147 of file SimInput.h.

Referenced by checkKey, checkKeyPair, and config.


The documentation for this class was generated from the following files:
Generated on Sun May 2 14:26:50 2004 for Gadgeteer by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002