00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef LUGRE_INPUT_H
00025 #define LUGRE_INPUT_H
00026 #include <list>
00027
00028
00029 namespace Lugre {
00030
00031 class cInputListener { public :
00032 virtual void Notify_KeyPress (const unsigned char iKey,const int iLetter) {}
00033 virtual void Notify_KeyRepeat (const unsigned char iKey,const int iLetter) {}
00034 virtual void Notify_KeyRelease (const unsigned char iKey) {}
00035 };
00036
00038 class cInput {
00039 public :
00040 static int GetKeyNameCount () { return 256; }
00041 static const char* GetKeyNameByIndex (const int i) { return szKeyNames[i]; }
00042 static const char* szKeyNames[256];
00043 static bool bKeys[256];
00044 static bool bButton[3];
00045 static int iMouseWheel;
00046 static int iMouseWheel_pressed;
00047 static int iMouseWheel_all_since_last_step;
00048 static int iMouseWheel_pressed_since_last_step;
00049 static int iMouse[2];
00050 static std::list<cInputListener*> mListeners;
00051 static void RegisterListener (cInputListener* p) { mListeners.push_back(p); }
00052
00053
00054
00055
00056
00057
00058 cInput ();
00059
00060 inline static cInput& GetSingleton () {
00061 static cInput* mSingleton = 0;
00062 if (!mSingleton) mSingleton = new cInput();
00063 return *mSingleton;
00064 }
00065
00066 void Reset ();
00067 void FocusChange (const bool bGain);
00068 void Step ();
00069
00070 unsigned char KeyConvertWin (const int iVKey,const bool bRight);
00071 unsigned char KeyConvertOIS (const int iKeyCode);
00072 unsigned int KeyConvertOISInv (const char iKey);
00073 unsigned char GetNamedKey (const char* szName);
00074 const char* GetKeyName (const unsigned char iKey);
00075
00076 void KeyDown (const unsigned char iKey,const int iLetter=0);
00077 void KeyUp (const unsigned char iKey);
00078
00080 enum {
00081 kListenerEvent_KeyPress,
00082 kListenerEvent_KeyRepeat,
00083 kListenerEvent_KeyRelease,
00084 };
00085
00087 enum kKey {
00088
00089 kkey_mouse1 = 0x01,
00090 kkey_mouse2 = 0x02,
00091 kkey_mouse3 = 0x03,
00092 kkey_mouse4 = 0x04,
00093 kkey_mouse5 = 0x05,
00094 kkey_wheelup = 0x06,
00095 kkey_wheeldown = 0x07,
00096
00097
00098 kkey_escape = 0x1B,
00099 kkey_f1 = 0x70,
00100 kkey_f2 = 0x71,
00101 kkey_f3 = 0x72,
00102 kkey_f4 = 0x73,
00103 kkey_f5 = 0x74,
00104 kkey_f6 = 0x75,
00105 kkey_f7 = 0x76,
00106 kkey_f8 = 0x77,
00107 kkey_f9 = 0x78,
00108 kkey_f10 = 0x79,
00109 kkey_f11 = 0x7A,
00110 kkey_f12 = 0x7B,
00111 kkey_f13 = 0x7C,
00112 kkey_f14 = 0x7D,
00113 kkey_f15 = 0x7E,
00114 kkey_screen = 0x2C,
00115 kkey_scroll = 0x91,
00116 kkey_pause = 0x13,
00117
00118
00119 kkey_console = 0xDC,
00120 kkey_0 = 0x30,
00121 kkey_1 = 0x31,
00122 kkey_2 = 0x32,
00123 kkey_3 = 0x33,
00124 kkey_4 = 0x34,
00125 kkey_5 = 0x35,
00126 kkey_6 = 0x36,
00127 kkey_7 = 0x37,
00128 kkey_8 = 0x38,
00129 kkey_9 = 0x39,
00130 kkey_bslash = 0xDB,
00131 kkey_accent = 0xDD,
00132 kkey_back = 0x08,
00133
00134
00135 kkey_prior = 0x21,
00136 kkey_next = 0x22,
00137 kkey_end = 0x23,
00138 kkey_home = 0x24,
00139 kkey_ins = 0x2D,
00140 kkey_del = 0x2E,
00141
00142
00143 kkey_left = 0x25,
00144 kkey_up = 0x26,
00145 kkey_right = 0x27,
00146 kkey_down = 0x28,
00147
00148
00149 kkey_numpad0 = 0x60,
00150 kkey_numpad1 = 0x61,
00151 kkey_numpad2 = 0x62,
00152 kkey_numpad3 = 0x63,
00153 kkey_numpad4 = 0x64,
00154 kkey_numpad5 = 0x65,
00155 kkey_numpad6 = 0x66,
00156 kkey_numpad7 = 0x67,
00157 kkey_numpad8 = 0x68,
00158 kkey_numpad9 = 0x69,
00159 kkey_np_mult = 0x6A,
00160 kkey_np_add = 0x6B,
00161 kkey_np_sub = 0x6D,
00162 kkey_np_komma = 0x6E,
00163 kkey_np_div = 0x6F,
00164 kkey_np_stopclear = 0x0C,
00165 kkey_numlock = 0x90,
00166
00167
00168 kkey_a = 0x41,
00169 kkey_b = 0x42,
00170 kkey_c = 0x43,
00171 kkey_d = 0x44,
00172 kkey_e = 0x45,
00173 kkey_f = 0x46,
00174 kkey_g = 0x47,
00175 kkey_h = 0x48,
00176 kkey_i = 0x49,
00177 kkey_j = 0x4A,
00178 kkey_k = 0x4B,
00179 kkey_l = 0x4C,
00180 kkey_m = 0x4D,
00181 kkey_n = 0x4E,
00182 kkey_o = 0x4F,
00183 kkey_p = 0x50,
00184 kkey_q = 0x51,
00185 kkey_r = 0x52,
00186 kkey_s = 0x53,
00187 kkey_t = 0x54,
00188 kkey_u = 0x55,
00189 kkey_v = 0x56,
00190 kkey_w = 0x57,
00191 kkey_x = 0x58,
00192 kkey_y = 0x59,
00193 kkey_z = 0x5A,
00194
00195
00196 kkey_lshift = 0x10,
00197 kkey_lcontrol = 0x11,
00198 kkey_lalt = 0x12,
00199 kkey_lwin = 0x5B,
00200 kkey_capslock = 0x14,
00201
00202
00203 kkey_rshift = 0xA1,
00204 kkey_rcontrol = 0xA3,
00205 kkey_ralt = 0xA5,
00206 kkey_rwin = 0x5C,
00207 kkey_menu = 0x5D,
00208
00209
00210 kkey_tab = 0x09,
00211 kkey_return = 0x0D,
00212 kkey_np_enter = 0x0E,
00213 kkey_space = 0x20,
00214
00215 kkey_plus = 0xBB,
00216 kkey_grid = 0xBF,
00217 kkey_minus = 0xBD,
00218 kkey_point = 0xBE,
00219 kkey_komma = 0xBC,
00220 kkey_greater = 0xE2,
00221 kkey_ue = 0xBA,
00222 kkey_ae = 0xDE,
00223 kkey_oe = 0xC0
00224 };
00225 };
00226
00227 };
00228
00229 #endif