![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
A DTMF sequence editor and player for HAM radio equipment command & control.
Diff: KeyboardManager/SingleKeyPressMonitor.cpp
- Revision:
- 0:1324e7d9d471
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/KeyboardManager/SingleKeyPressMonitor.cpp Mon Mar 07 22:51:19 2011 +0000 @@ -0,0 +1,28 @@ +#include "kbd_mgr/SingleKeyPressMonitor.h" + +namespace kbd_mgr { + +void SingleKeyPressMonitor::handleState(const KeyboardState &newState) +{ + int key; + if (newState.getKeyPressType(key) == KeyboardState::SingleKeyPress && this->lastReportedState.empty()) + { + KeyEvent keyDown(key, KeyEvent::KeyDown); + invokeHandler(keyDown); + + this->lastReportedState = newState; + this->lastReportedKey = key; + } + else if (!this->lastReportedState.empty() && + (newState & this->lastReportedState).empty()) + { + KeyEvent keyUp(this->lastReportedKey, KeyEvent::KeyUp); + invokeHandler(keyUp); + + this->lastReportedState.clear(); + this->lastReportedKey = KeyEvent::NoKey; + } + +} + +} // kbd_mgr \ No newline at end of file