gadget::SimInput Class Reference

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

#include <gadget/Devices/Sim/SimInput.h>

Inheritance diagram for gadget::SimInput:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SimInput ()
virtual ~SimInput ()
virtual bool config (jccl::ConfigElementPtr element)
 Configures the keyboard interface.
virtual std::string getInputTypeName ()
virtual vpr::ReturnStatus writeObject (vpr::ObjectWriter *writer)
virtual vpr::ReturnStatus readObject (vpr::ObjectReader *reader)

Protected Member Functions

virtual int checkKeyPair (KeyModPair &pair)
 Checks the given keypair.
std::vector< KeyModPairreadKeyList (std::vector< jccl::ConfigElementPtr > &keyList)
 Constructs the mod pair from a mod pair element.

Protected Attributes

KeyboardMouseInterface mKeyboardMouse
 The keyboard/mouse device from which we receive events.

Classes

class  KeyModPair

Detailed Description

Base class for all simulated input devices.

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

Definition at line 55 of file SimInput.h.


Constructor & Destructor Documentation

gadget::SimInput::SimInput (  )  [inline]

Definition at line 91 of file SimInput.h.

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

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

Definition at line 95 of file SimInput.h.

00095 {}


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 gadget::BaseDeviceInterface::init(), and mKeyboardMouse.

Referenced by gadget::SimPosition::config(), gadget::SimGloveGesture::config(), gadget::SimDigitalGlove::config(), gadget::SimDigital::config(), and gadget::SimAnalog::config().

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

virtual std::string gadget::SimInput::getInputTypeName (  )  [inline, virtual]

Definition at line 103 of file SimInput.h.

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

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

Definition at line 108 of file SimInput.h.

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

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

Definition at line 114 of file SimInput.h.

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

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 gadget::SimInput::KeyModPair::mKey, mKeyboardMouse, and gadget::SimInput::KeyModPair::mModifier.

00079 {
00080    // If the modifier is any
00081    //   - Then check to see if the key is pressed.
00082    // Else
00083    //   - The modifier and the key must be pressed.
00084    
00085    // NOTE: If the modifier is NONE, then if any modifier
00086    //       is pressed we will return 0;
00087 
00088    if (pair.mModifier == -1)
00089    {
00090       return mKeyboardMouse->keyPressed(pair.mKey);
00091    }
00092    if (mKeyboardMouse->modifierOnly(pair.mModifier))
00093    {
00094       return mKeyboardMouse->keyPressed(pair.mKey);
00095    }
00096    else
00097    {
00098       return 0;
00099    }
00100 }

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 KeyModPair objects.

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

KeyboardMouseInterface gadget::SimInput::mKeyboardMouse [protected]

The keyboard/mouse device from which we receive events.

Definition at line 143 of file SimInput.h.

Referenced by checkKeyPair(), and config().


The documentation for this class was generated from the following files:
Generated on Thu Jan 4 10:44:40 2007 for Gadgeteer by  doxygen 1.5.1