KeyboardManager: a class to manage the polling of a switch-matrix keyboard
SingleKeyPressMonitor.cpp
- Committer:
- osmeest
- Date:
- 2011-01-23
- Revision:
- 2:eb4cc53ff33d
- Child:
- 3:1310c57aca77
File content as of revision 2:eb4cc53ff33d:
#include "kbd_mgr/SingleKeyPressMonitor.h" namespace kbd_mgr { void SingleKeyPressMonitor::operator()(const KeyboardState &newState) { int key; if (newState.getKeyPressType(key) == KeyboardState::SingleKeyPress && this->lastReportedState.empty()) { if (this->handler) { (*this->handler)(key, true); } this->lastReportedState = newState; this->lastReportedKey = key; } else if (!this->lastReportedState.empty() && (newState & this->lastReportedState).empty()) { if (this->handler) { (*this->handler)(this->lastReportedKey, false); } this->lastReportedState.clear(); this->lastReportedKey = KeyPressEventHandler::NoKey; } } } // kbd_mgr