#ifndef _KEYBOARD_H_ #define _KEYBOARD_H_ #include #include #include #include #include #include #include class IKeyboard : public doste::Agent { friend class WgdKeyboard; public: VOBJECT(doste::Agent, IKeyboard); BEGIN_EVENTS(doste::Agent); EVENT(keyEvent, wgd::WGD(wgd::ix::input)(wgd::ix::keyboard)("press")); END_EVENTS; private: IKeyboard(); }; class WgdKeyboard { public: friend class IKeyboard; enum KeyVal { //Special keys with ascii values KEY_BKSPACE = 8, KEY_TAB = 9, KEY_RETURN = 13, KEY_SHIFT = 16, KEY_CTRL = 17, KEY_PAUSE = 19, KEY_ESCAPE = 27, KEY_SPACE = 32, KEY_F1 = 112, KEY_F2 = 113, KEY_F3 = 114, KEY_F4 = 115, KEY_F5 = 116, KEY_F6 = 117, KEY_F7 = 118, KEY_F8 = 119, KEY_F9 = 120, KEY_F10 = 121, KEY_F11 = 122, KEY_F12 = 123, //Special keys w/o ascii values KEY_END = 128, KEY_PGDOWN = 129, KEY_PGUP = 130, KEY_HOME = 131, KEY_INSERT = 132, KEY_RCTRL = 133, KEY_RSHIFT = 134, KEY_ALT = 135, KEY_ALTGR = 136, KEY_DEL = 137, KEY_ENTER = 138, KEY_LEFT = 139, KEY_UP = 140, KEY_RIGHT = 141, KEY_DOWN = 142 }; static void init (); static void update (); static bool keyUp (char keyCode); static bool keyDown (char keyCode); static bool keyPressed (char keyCode); static bool keyUp (KeyVal keyCode); static bool keyDown (KeyVal keyCode); static bool keyPressed (KeyVal keyCode); private: WgdKeyboard () {} //Prevent external instanciation of this class static void setup (); static IKeyboard* instance; static std::bitset<143> keys; static std::bitset<143> oldKeys; static std::list keyList; static std::map keyMap; //Callbacks, intended for internal use only static void cbPress (); static bool cbCheckRelease (const wgd::OID& key); }; #endif //_KEYBOARD_H_