KeyboardManager: a class to manage the polling of a switch-matrix keyboard

Dependents:   KeyboardTest

kbd_mgr/SingleKeyPressMonitor.h

Committer:
osmeest
Date:
2011-01-23
Revision:
2:eb4cc53ff33d
Child:
3:1310c57aca77

File content as of revision 2:eb4cc53ff33d:

#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_