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


Public Member Functions | |
| KeyboardMouseDevice () | |
| ~KeyboardMouseDevice () | |
| virtual bool | config (jccl::ConfigElementPtr e) |
| virtual bool | startSampling () |
| Start the windows sampling. | |
| virtual bool | stopSampling () |
| Stop window sampling. | |
| virtual bool | sample () |
| Dop nothing. | |
| virtual void | updateData () |
| Update the keys and event queue data structures with current data. | |
| void | operator delete (void *p) |
| Invokes the global scope delete operator. | |
Static Public Member Functions | |
| static std::string | getElementType () |
| Return the element type associated with this device type. | |
Public Attributes | |
| vpr::Mutex | mKeysLock |
| Must hold this lock when accessing m_keys. | |
Event window state holders | |
| int | mKeys [gadget::LAST_KEY] |
| (0,*): The num key presses during an UpdateData (ie. | |
| int | mRealkeys [gadget::LAST_KEY] |
| (0,1): The real keyboard state, all events processed (ie. | |
Protected Member Functions | |
| void | destroy () |
| Deletes this object. | |
Classes | |
| class | KeyboardMouseDeviceRegistry |
| Holds list of registered windows that may be used for keyboard/moues Input. More... | |
Definition at line 57 of file KeyboardMouseDevice.h.
| gadget::KeyboardMouseDevice::KeyboardMouseDevice | ( | ) | [inline] |
| gadget::KeyboardMouseDevice::~KeyboardMouseDevice | ( | ) | [inline] |
Definition at line 106 of file KeyboardMouseDevice.h.
References stopSampling().
00107 { 00108 stopSampling(); 00109 }
| bool gadget::KeyboardMouseDevice::config | ( | jccl::ConfigElementPtr | e | ) | [virtual] |
Definition at line 46 of file KeyboardMouseDevice.cpp.
References gadget::KeyboardMouse::config(), gadget::Input::config(), gadgetDBG_INPUT_MGR(), gadget::LAST_KEY, gadget::KeyboardMouseDevice::KeyboardMouseDeviceRegistry::KeyboardMouseDeviceInfo::mKeyboardMouseDevice, mKeys, mRealkeys, and gadget::KeyboardMouseDevice::KeyboardMouseDeviceRegistry::KeyboardMouseDeviceInfo::mSourceName.
00047 { 00048 unsigned required_definition_ver(1); 00049 00050 if(e->getVersion() < required_definition_ver) 00051 { 00052 vprDEBUG(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) 00053 << clrOutBOLD(clrRED, "ERROR") 00054 << ": [gadget::KeyboardMouseDevice::config()] Element named '" 00055 << e->getName() << "'" << std::endl << vprDEBUG_FLUSH; 00056 vprDEBUG_NEXT(gadgetDBG_INPUT_MGR, vprDBG_CRITICAL_LVL) 00057 << "is version " << e->getVersion() 00058 << ", but we require at least version " << required_definition_ver 00059 << ". Ignoring.\n" << vprDEBUG_FLUSH; 00060 return false; 00061 } 00062 00063 if ( ! (Input::config(e) && KeyboardMouse::config(e) ) ) 00064 { 00065 return false; 00066 } 00067 00068 mMouseSensitivity = e->getProperty<float>("mouse_sensitivity"); 00069 if (0.0f == mMouseSensitivity) 00070 { 00071 mMouseSensitivity = 0.5; 00072 } 00073 00074 for ( int i = 0; i < gadget::LAST_KEY; ++i ) 00075 { 00076 mRealkeys[i] = mKeys[i] = mCurKeys[i]; 00077 } 00078 00079 KeyboardMouseDeviceRegistry::KeyboardMouseDeviceInfo event_source_info; 00080 event_source_info.mSourceName = e->getName(); 00081 event_source_info.mKeyboardMouseDevice = this; 00082 00083 KeyboardMouseDeviceRegistry::instance()->addKeyboardMouseDevice(e->getName(), event_source_info); 00084 00085 return true; 00086 }
| virtual bool gadget::KeyboardMouseDevice::startSampling | ( | ) | [inline, virtual] |
| virtual bool gadget::KeyboardMouseDevice::stopSampling | ( | ) | [inline, virtual] |
Stop window sampling.
Definition at line 120 of file KeyboardMouseDevice.h.
Referenced by ~KeyboardMouseDevice().
| virtual bool gadget::KeyboardMouseDevice::sample | ( | ) | [inline, virtual] |
| void gadget::KeyboardMouseDevice::updateData | ( | ) | [virtual] |
Update the keys and event queue data structures with current data.
Definition at line 88 of file KeyboardMouseDevice.cpp.
References gadget::LAST_KEY, mKeys, mKeysLock, gadget::MOUSE_NEGX, gadget::MOUSE_NEGY, gadget::MOUSE_POSX, gadget::MOUSE_POSY, and mRealkeys.
00089 { 00090 vpr::Guard<vpr::Mutex> guard(mKeysLock); // Lock access to the mKeys array 00091 00092 // Scale mouse values based on sensitivity 00093 mKeys[gadget::MOUSE_POSX] = int(float(mKeys[gadget::MOUSE_POSX]) * mMouseSensitivity); 00094 mKeys[gadget::MOUSE_NEGX] = int(float(mKeys[gadget::MOUSE_NEGX]) * mMouseSensitivity); 00095 mKeys[gadget::MOUSE_POSY] = int(float(mKeys[gadget::MOUSE_POSY]) * mMouseSensitivity); 00096 mKeys[gadget::MOUSE_NEGY] = int(float(mKeys[gadget::MOUSE_NEGY]) * mMouseSensitivity); 00097 00098 /* 00099 vprDEBUG(vprDBG_ALL, vprDBG_CRITICAL_LVL) 00100 << "gadget::KeyboardMouseDevice::updateData:" << mInstName << " -- " 00101 << "mouse_keys: px:" << mKeys[gadget::MOUSE_POSX] 00102 << " nx:" << mKeys[gadget::MOUSE_NEGX] 00103 << " py:" << mKeys[gadget::MOUSE_POSY] 00104 << " ny:" << mKeys[gadget::MOUSE_NEGY] 00105 << std::endl << vprDEBUG_FLUSH; 00106 */ 00107 00108 // Copy over values 00109 for ( unsigned int i = 0; i < gadget::LAST_KEY; ++i ) 00110 { 00111 mCurKeys[i] = mKeys[i]; 00112 } 00113 00114 // Re-initialize the mKeys based on current key state in realKeys 00115 // Set the initial state of the mKey key counts based on the current state 00116 // of the system this is to ensure that if a key is still down, we get at 00117 // least one event for it. 00118 for ( unsigned int j = 0; j < gadget::LAST_KEY; ++j ) 00119 { 00120 mKeys[j] = mRealkeys[j]; 00121 } 00122 00123 updateEventQueue(); 00124 }
| std::string gadget::KeyboardMouseDevice::getElementType | ( | ) | [static] |
Return the element type associated with this device type.
Definition at line 41 of file KeyboardMouseDevice.cpp.
| void gadget::KeyboardMouseDevice::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 142 of file KeyboardMouseDevice.h.
| void gadget::KeyboardMouseDevice::destroy | ( | ) | [inline, protected] |
Deletes this object.
This is an implementation of the pure virtual gadget::Input::destroy() method.
Definition at line 152 of file KeyboardMouseDevice.h.
| vpr::Mutex gadget::KeyboardMouseDevice::mKeysLock |
Must hold this lock when accessing m_keys.
Definition at line 161 of file KeyboardMouseDevice.h.
Referenced by gadget::InputAreaXWin::handleEvents(), and updateData().
| int gadget::KeyboardMouseDevice::mKeys[gadget::LAST_KEY] |
(0,*): The num key presses during an UpdateData (ie.
How many keypress events).
Definition at line 172 of file KeyboardMouseDevice.h.
Referenced by config(), gadget::InputAreaXWin::handleEvent(), updateData(), and gadget::InputAreaWin32::updKeys().
| int gadget::KeyboardMouseDevice::mRealkeys[gadget::LAST_KEY] |
(0,1): The real keyboard state, all events processed (ie.
what is the key now).
Definition at line 178 of file KeyboardMouseDevice.h.
Referenced by gadget::InputAreaWin32::addKeyEvent(), config(), gadget::InputAreaWin32::getButtonMask(), gadget::InputAreaWin32::getModifierMask(), gadget::InputAreaXWin::handleEvent(), updateData(), and gadget::InputAreaWin32::updKeys().
1.5.1