autotyper/keyhandler.h
2019-10-26 16:16:22 +03:00

64 lines
1.0 KiB
C++

#ifndef KEYHANDLER_H
#define KEYHANDLER_H
#include <string>
enum class SpecialKey
{
NONE,
UP,
DOWN,
LEFT,
RIGHT,
HOME,
END,
RETURN,
ESCAPE
};
enum KeyModifiers
{
KM_NONE = 0,
KM_LSHIFT = 0x1,
KM_RSHIFT = 0x2,
KM_SHIFT = KM_LSHIFT,
KM_SHIFT_MASK = KM_LSHIFT | KM_RSHIFT,
KM_LCTRL = 0x4,
KM_RCTRL = 0x8,
KM_CTRL = KM_LCTRL,
KM_CTRL_MASK = KM_LCTRL | KM_RCTRL,
KM_LALT = 0x10,
KM_RALT = 0x20,
KM_ALT = KM_LALT,
KM_ALT_MASK = KM_LALT | KM_RALT,
KM_LMETA = 0x40,
KM_RMETA = 0x80,
KM_META = KM_LMETA,
KM_META_MASK = KM_LMETA | KM_RMETA,
};
class KeyHandler
{
public:
KeyHandler() : m_paused(false) { }
virtual ~KeyHandler();
virtual void Key(SpecialKey key, KeyModifiers mods = KeyModifiers::KM_NONE);
virtual void Key(char key, KeyModifiers mods = KeyModifiers::KM_NONE);
void TogglePaused();
protected:
void WaitUntilNotPaused();
private:
volatile bool m_paused;
};
#endif // KEYHANDLER_H