#include <gadget/Devices/Sim/SimAnalog.h>
Inheritance diagram for gadget::SimAnalog:


Public Member Functions | |
| SimAnalog () | |
| Default Constructor. | |
| virtual | ~SimAnalog () |
| Destructor. | |
| virtual bool | config (jccl::ConfigElementPtr element) |
| Reads the minimum and maximum value configuration information for this analog device. | |
| bool | startSampling () |
| These functions don't do anything. | |
| bool | stopSampling () |
| bool | sample () |
| virtual void | updateData () |
| Updates the data. | |
| virtual std::vector< KeyModPair > | getUpKeys () |
| virtual std::vector< KeyModPair > | getDownKeys () |
| void | operator delete (void *p) |
| Invokes the global scope delete operator. | |
Static Public Member Functions | |
| static std::string | getElementType () |
Protected Member Functions | |
| virtual void | destroy () |
| Deletes this object. | |
Simulates an analog device from a keyboard device. It allows any number of simulated analog devices to be created.
This class should not be used directly by the user.
Definition at line 59 of file SimAnalog.h.
| gadget::SimAnalog::SimAnalog | ( | ) |
Default Constructor.
Definition at line 40 of file SimAnalog.cpp.
00041 : mAnaStep(0.0f) 00042 , mInitialValue(0.0f) 00043 { 00044 //vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL)<<"*** SimAnalog::SimPinchGlove()\n"<< vprDEBUG_FLUSH; 00045 }
| gadget::SimAnalog::~SimAnalog | ( | ) | [virtual] |
Destructor.
Definition at line 48 of file SimAnalog.cpp.
00049 { 00050 //vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL)<<"*** SimAnalog::~SimPinchGlove()\n"<< vprDEBUG_FLUSH; 00051 }
| bool gadget::SimAnalog::config | ( | jccl::ConfigElementPtr | element | ) | [virtual] |
Reads the minimum and maximum value configuration information for this analog device.
| element | The config element for an analog device. It must derive from the base config element type 'analog'. |
Definition at line 58 of file SimAnalog.cpp.
References gadget::SimInput::config(), gadget::Analog::config(), and gadget::Input::config().
00059 { 00060 //vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL)<<"*** SimAnalog::config()\n"<< vprDEBUG_FLUSH; 00061 if (! (Input::config(element) && Analog::config(element) && 00062 SimInput::config(element)) ) 00063 { 00064 return false; 00065 } 00066 00067 std::vector<jccl::ConfigElementPtr> key_inc_list, key_dec_list; 00068 00069 int key_count = element->getNum("increment_keypress"); 00070 00071 for ( int i = 0; i < key_count; ++i ) 00072 { 00073 key_inc_list.push_back(element->getProperty<jccl::ConfigElementPtr>("increment_keypress", i)); 00074 } 00075 00076 key_count = element->getNum("decrement_keypress"); 00077 00078 for ( int i = 0; i < key_count; ++i ) 00079 { 00080 key_dec_list.push_back(element->getProperty<jccl::ConfigElementPtr>("decrement_keypress", i)); 00081 } 00082 00083 mSimKeysUp = readKeyList(key_inc_list); 00084 mSimKeysDown = readKeyList(key_dec_list); 00085 00086 mAnaStep = element->getProperty<float>("delta"); 00087 mInitialValue = element->getProperty<float>("initial_value"); 00088 00089 // Initialize all the data to the inital_value 00090 size_t num_pairs = mSimKeysUp.size(); 00091 mAnaData = std::vector<AnalogData>(num_pairs); 00092 for (size_t i=0; i<num_pairs; ++i) 00093 { 00094 mAnaData[i].setAnalog(mInitialValue); 00095 } 00096 00097 return true; 00098 }
| bool gadget::SimAnalog::startSampling | ( | ) | [inline] |
| bool gadget::SimAnalog::stopSampling | ( | ) | [inline] |
| bool gadget::SimAnalog::sample | ( | ) | [inline] |
| void gadget::SimAnalog::updateData | ( | ) | [virtual] |
Updates the data.
Definition at line 100 of file SimAnalog.cpp.
00101 { 00102 //vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL)<<"*** SimAnalog::updateData()\n"<< vprDEBUG_FLUSH; 00103 00104 // Make an list of the data that will be normalized 00105 std::vector<AnalogData> norm_data(mAnaData.size()); 00106 00107 // -- Update analog data --- // 00108 for (unsigned int i = 0; i < mSimKeysUp.size(); ++i) 00109 { 00110 mAnaData[i].setTime(); 00111 mAnaData[i].setAnalog(mAnaData[i].getAnalog() 00112 + (float)checkKeyPair(mSimKeysUp[i]) * mAnaStep); 00113 mAnaData[i].setAnalog(mAnaData[i].getAnalog() 00114 - (float)checkKeyPair(mSimKeysDown[i]) * mAnaStep); 00115 00116 // Clamp to the min/max range 00117 mAnaData[i].setAnalog(gmtl::Math::clamp(mAnaData[i].getAnalog(), 00118 getMin(), getMax())); 00119 00120 float normalized_value; 00121 normalizeMinToMax(mAnaData[i].getAnalog(), normalized_value); 00122 00123 // Set the normalized data 00124 norm_data[i] = normalized_value; 00125 norm_data[i].setTime(mKeyboardMouse->getTimeStamp()); 00126 } 00127 00128 // Locks and then swaps the indices. 00129 addAnalogSample(norm_data); 00130 swapAnalogBuffers(); 00131 }
| std::string gadget::SimAnalog::getElementType | ( | ) | [static] |
| virtual std::vector<KeyModPair> gadget::SimAnalog::getUpKeys | ( | ) | [inline, virtual] |
| virtual std::vector<KeyModPair> gadget::SimAnalog::getDownKeys | ( | ) | [inline, virtual] |
| void gadget::SimAnalog::operator delete | ( | void * | p | ) | [inline] |
Invokes the global scope delete operator.
This is required for proper releasing of memory in DLLs on Win32.
Definition at line 110 of file SimAnalog.h.
| virtual void gadget::SimAnalog::destroy | ( | ) | [inline, protected, virtual] |
Deletes this object.
This is an implementation of the pure virtual gadget::Input::destroy() method.
Definition at line 120 of file SimAnalog.h.
1.5.1