KeyboardManager: a class to manage the polling of a switch-matrix keyboard
Diff: kbd_mgr/SingleKeyPressMonitor.h
- Revision:
- 2:eb4cc53ff33d
- Child:
- 3:1310c57aca77
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/kbd_mgr/SingleKeyPressMonitor.h Sun Jan 23 23:15:36 2011 +0000 @@ -0,0 +1,29 @@ +#ifndef SINGLE_KEY_PRESS_MONITOR_H_ +#define SINGLE_KEY_PRESS_MONITOR_H_ + +#include "kbd_mgr/KeyboardStateChangeMonitor.h" +#include "kbd_mgr/KeyPressEventHandler.h" + +namespace kbd_mgr { + +/** + * @brief A keyboard state change handler that reports on single keypresses. + * It voluntarily ignores key combinations (only the first key pressed in a combo is reported). + */ +class SingleKeyPressMonitor : public KeyboardStateChangeHandler { +public: + SingleKeyPressMonitor(KeyPressEventHandler *handler) : + handler(handler), lastReportedState(), lastReportedKey(KeyPressEventHandler::NoKey) + { } + + virtual void operator()(const KeyboardState &newState); + +private: + KeyPressEventHandler *handler; + KeyboardState lastReportedState; + int lastReportedKey; +}; + +} // kbd_mgr + +#endif // SINGLE_KEY_PRESS_MONITOR_H_