PageRenderTime 82ms CodeModel.GetById 19ms app.highlight 57ms RepoModel.GetById 1ms app.codeStats 0ms

/src/ois/src/SDL/SDLKeyboard.cpp

https://bitbucket.org/cabalistic/ogredeps/
C++ | 377 lines | 327 code | 17 blank | 33 comment | 21 complexity | efdc31834c8cc9bd7851d2212663ee63 MD5 | raw file
  1/*
  2The zlib/libpng License
  3
  4Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
  5
  6This software is provided 'as-is', without any express or implied warranty. In no event will
  7the authors be held liable for any damages arising from the use of this software.
  8
  9Permission is granted to anyone to use this software for any purpose, including commercial 
 10applications, and to alter it and redistribute it freely, subject to the following
 11restrictions:
 12
 13    1. The origin of this software must not be misrepresented; you must not claim that 
 14		you wrote the original software. If you use this software in a product, 
 15		an acknowledgment in the product documentation would be appreciated but is 
 16		not required.
 17
 18    2. Altered source versions must be plainly marked as such, and must not be 
 19		misrepresented as being the original software.
 20
 21    3. This notice may not be removed or altered from any source distribution.
 22*/
 23#include "SDL/SDLKeyboard.h"
 24#include "SDL/SDLInputManager.h"
 25#include "OISException.h"
 26#include "OISEvents.h"
 27#include <sstream>
 28
 29using namespace OIS;
 30
 31//-------------------------------------------------------------------//
 32SDLKeyboard::SDLKeyboard( bool buffered )
 33{
 34	mBuffered = buffered;
 35	mType = OISKeyboard;
 36	listener = 0;
 37
 38	//Clear our keyboard state buffer
 39	memset( &KeyBuffer, 0, 256 );
 40}
 41
 42//-------------------------------------------------------------------//
 43void SDLKeyboard::_initialize()
 44{
 45	mModifiers = 0;
 46	mSDLBuff = 0;
 47
 48	mKeyMap.insert( KeyMap::value_type(SDLK_ESCAPE,KC_ESCAPE) );
 49	mKeyMap.insert( KeyMap::value_type(SDLK_1, KC_1) );
 50	mKeyMap.insert( KeyMap::value_type(SDLK_2, KC_2) );
 51	mKeyMap.insert( KeyMap::value_type(SDLK_3, KC_3) );
 52	mKeyMap.insert( KeyMap::value_type(SDLK_4, KC_4) );
 53	mKeyMap.insert( KeyMap::value_type(SDLK_5, KC_5) );
 54	mKeyMap.insert( KeyMap::value_type(SDLK_6, KC_6) );
 55	mKeyMap.insert( KeyMap::value_type(SDLK_7, KC_7) );
 56	mKeyMap.insert( KeyMap::value_type(SDLK_8, KC_8) );
 57	mKeyMap.insert( KeyMap::value_type(SDLK_9, KC_9) );
 58	mKeyMap.insert( KeyMap::value_type(SDLK_0, KC_0) );
 59	mKeyMap.insert( KeyMap::value_type(SDLK_MINUS, KC_MINUS) );
 60	mKeyMap.insert( KeyMap::value_type(SDLK_EQUALS, KC_EQUALS) );
 61	mKeyMap.insert( KeyMap::value_type(SDLK_BACKSPACE, KC_BACK) );
 62	mKeyMap.insert( KeyMap::value_type(SDLK_TAB, KC_TAB) );
 63	mKeyMap.insert( KeyMap::value_type(SDLK_q, KC_Q) );
 64	mKeyMap.insert( KeyMap::value_type(SDLK_w, KC_W) );
 65	mKeyMap.insert( KeyMap::value_type(SDLK_e, KC_E) );
 66	mKeyMap.insert( KeyMap::value_type(SDLK_r, KC_R) );
 67	mKeyMap.insert( KeyMap::value_type(SDLK_t, KC_T) );
 68	mKeyMap.insert( KeyMap::value_type(SDLK_y, KC_Y) );
 69	mKeyMap.insert( KeyMap::value_type(SDLK_u, KC_U) );
 70	mKeyMap.insert( KeyMap::value_type(SDLK_i, KC_I) );
 71	mKeyMap.insert( KeyMap::value_type(SDLK_o, KC_O) );
 72	mKeyMap.insert( KeyMap::value_type(SDLK_p, KC_P) );
 73	mKeyMap.insert( KeyMap::value_type(SDLK_RETURN, KC_RETURN) );
 74	mKeyMap.insert( KeyMap::value_type(SDLK_LCTRL, KC_LCONTROL));
 75	mKeyMap.insert( KeyMap::value_type(SDLK_a, KC_A) );
 76	mKeyMap.insert( KeyMap::value_type(SDLK_s, KC_S) );
 77	mKeyMap.insert( KeyMap::value_type(SDLK_d, KC_D) );
 78	mKeyMap.insert( KeyMap::value_type(SDLK_f, KC_F) );
 79	mKeyMap.insert( KeyMap::value_type(SDLK_g, KC_G) );
 80	mKeyMap.insert( KeyMap::value_type(SDLK_h, KC_H) );
 81	mKeyMap.insert( KeyMap::value_type(SDLK_j, KC_J) );
 82	mKeyMap.insert( KeyMap::value_type(SDLK_k, KC_K) );
 83	mKeyMap.insert( KeyMap::value_type(SDLK_l, KC_L) );
 84	mKeyMap.insert( KeyMap::value_type(SDLK_SEMICOLON, KC_SEMICOLON) );
 85	mKeyMap.insert( KeyMap::value_type(SDLK_COLON, KC_COLON) );
 86	mKeyMap.insert( KeyMap::value_type(SDLK_QUOTE, KC_APOSTROPHE) );
 87	mKeyMap.insert( KeyMap::value_type(SDLK_BACKQUOTE, KC_GRAVE)  );
 88	mKeyMap.insert( KeyMap::value_type(SDLK_LSHIFT, KC_LSHIFT) );
 89	mKeyMap.insert( KeyMap::value_type(SDLK_BACKSLASH, KC_BACKSLASH) );
 90	mKeyMap.insert( KeyMap::value_type(SDLK_SLASH, KC_SLASH) );
 91	mKeyMap.insert( KeyMap::value_type(SDLK_z, KC_Z) );
 92	mKeyMap.insert( KeyMap::value_type(SDLK_x, KC_X) );
 93	mKeyMap.insert( KeyMap::value_type(SDLK_c, KC_C) );
 94	mKeyMap.insert( KeyMap::value_type(SDLK_v, KC_V) );
 95	mKeyMap.insert( KeyMap::value_type(SDLK_b, KC_B) );
 96	mKeyMap.insert( KeyMap::value_type(SDLK_n, KC_N) );
 97	mKeyMap.insert( KeyMap::value_type(SDLK_m, KC_M) );
 98	mKeyMap.insert( KeyMap::value_type(SDLK_COMMA, KC_COMMA)  );
 99	mKeyMap.insert( KeyMap::value_type(SDLK_PERIOD, KC_PERIOD));
100	mKeyMap.insert( KeyMap::value_type(SDLK_RSHIFT, KC_RSHIFT));
101	mKeyMap.insert( KeyMap::value_type(SDLK_KP_MULTIPLY, KC_MULTIPLY) );
102	mKeyMap.insert( KeyMap::value_type(SDLK_LALT, KC_LMENU) );
103	mKeyMap.insert( KeyMap::value_type(SDLK_SPACE, KC_SPACE));
104	mKeyMap.insert( KeyMap::value_type(SDLK_CAPSLOCK, KC_CAPITAL) );
105	mKeyMap.insert( KeyMap::value_type(SDLK_F1, KC_F1) );
106	mKeyMap.insert( KeyMap::value_type(SDLK_F2, KC_F2) );
107	mKeyMap.insert( KeyMap::value_type(SDLK_F3, KC_F3) );
108	mKeyMap.insert( KeyMap::value_type(SDLK_F4, KC_F4) );
109	mKeyMap.insert( KeyMap::value_type(SDLK_F5, KC_F5) );
110	mKeyMap.insert( KeyMap::value_type(SDLK_F6, KC_F6) );
111	mKeyMap.insert( KeyMap::value_type(SDLK_F7, KC_F7) );
112	mKeyMap.insert( KeyMap::value_type(SDLK_F8, KC_F8) );
113	mKeyMap.insert( KeyMap::value_type(SDLK_F9, KC_F9) );
114	mKeyMap.insert( KeyMap::value_type(SDLK_F10, KC_F10) );
115	mKeyMap.insert( KeyMap::value_type(SDLK_NUMLOCK, KC_NUMLOCK) );
116	mKeyMap.insert( KeyMap::value_type(SDLK_SCROLLOCK, KC_SCROLL));
117	mKeyMap.insert( KeyMap::value_type(SDLK_KP7, KC_NUMPAD7) );
118	mKeyMap.insert( KeyMap::value_type(SDLK_KP8, KC_NUMPAD8) );
119	mKeyMap.insert( KeyMap::value_type(SDLK_KP9, KC_NUMPAD9) );
120	mKeyMap.insert( KeyMap::value_type(SDLK_KP_MINUS, KC_SUBTRACT) );
121	mKeyMap.insert( KeyMap::value_type(SDLK_KP4, KC_NUMPAD4) );
122	mKeyMap.insert( KeyMap::value_type(SDLK_KP5, KC_NUMPAD5) );
123	mKeyMap.insert( KeyMap::value_type(SDLK_KP6, KC_NUMPAD6) );
124	mKeyMap.insert( KeyMap::value_type(SDLK_KP_PLUS, KC_ADD) );
125	mKeyMap.insert( KeyMap::value_type(SDLK_KP1, KC_NUMPAD1) );
126	mKeyMap.insert( KeyMap::value_type(SDLK_KP2, KC_NUMPAD2) );
127	mKeyMap.insert( KeyMap::value_type(SDLK_KP3, KC_NUMPAD3) );
128	mKeyMap.insert( KeyMap::value_type(SDLK_KP0, KC_NUMPAD0) );
129	mKeyMap.insert( KeyMap::value_type(SDLK_KP_PERIOD, KC_DECIMAL) );
130	mKeyMap.insert( KeyMap::value_type(SDLK_F11, KC_F11) );
131	mKeyMap.insert( KeyMap::value_type(SDLK_F12, KC_F12) );
132	mKeyMap.insert( KeyMap::value_type(SDLK_F13, KC_F13) );
133	mKeyMap.insert( KeyMap::value_type(SDLK_F14, KC_F14) );
134	mKeyMap.insert( KeyMap::value_type(SDLK_F15, KC_F15) );
135	mKeyMap.insert( KeyMap::value_type(SDLK_KP_EQUALS, KC_NUMPADEQUALS) );
136	mKeyMap.insert( KeyMap::value_type(SDLK_KP_DIVIDE, KC_DIVIDE) );
137	mKeyMap.insert( KeyMap::value_type(SDLK_SYSREQ, KC_SYSRQ) );
138	mKeyMap.insert( KeyMap::value_type(SDLK_RALT, KC_RMENU) );
139	mKeyMap.insert( KeyMap::value_type(SDLK_HOME, KC_HOME) );
140	mKeyMap.insert( KeyMap::value_type(SDLK_UP, KC_UP) );
141	mKeyMap.insert( KeyMap::value_type(SDLK_PAGEUP, KC_PGUP) );
142	mKeyMap.insert( KeyMap::value_type(SDLK_LEFT, KC_LEFT) );
143	mKeyMap.insert( KeyMap::value_type(SDLK_RIGHT, KC_RIGHT) );
144	mKeyMap.insert( KeyMap::value_type(SDLK_END, KC_END) );
145	mKeyMap.insert( KeyMap::value_type(SDLK_DOWN, KC_DOWN) );
146	mKeyMap.insert( KeyMap::value_type(SDLK_PAGEDOWN, KC_PGDOWN) );
147	mKeyMap.insert( KeyMap::value_type(SDLK_INSERT, KC_INSERT) );
148	mKeyMap.insert( KeyMap::value_type(SDLK_DELETE, KC_DELETE) );
149	mKeyMap.insert( KeyMap::value_type(SDLK_LSUPER, KC_LWIN) );
150	mKeyMap.insert( KeyMap::value_type(SDLK_RSUPER, KC_RWIN) );
151
152	SDL_EnableUNICODE(1);
153}
154
155//-------------------------------------------------------------------//
156SDLKeyboard::~SDLKeyboard()
157{
158}
159
160//-------------------------------------------------------------------//
161void SDLKeyboard::capture()
162{
163	SDL_Event events[OIS_SDL_KEY_BUFF];
164	int count = SDL_PeepEvents(events, OIS_SDL_KEY_BUFF, SDL_GETEVENT, 
165		SDL_EVENTMASK(SDL_KEYDOWN) | SDL_EVENTMASK(SDL_KEYUP));
166
167	for( int i = 0; i < count; ++i )
168	{
169		KeyCode kc = mKeyMap[events[i].key.keysym.sym];
170		KeyBuffer[kc] = events[i].key.state;
171
172		if( mBuffered && listener )
173		{
174			if( events[i].key.state == SDL_PRESSED )
175			{
176				if( listener->keyPressed(KeyEvent(this, 0, kc, events[i].key.keysym.unicode)) == false )
177					break;
178			}
179			else
180			{
181				if( listener->keyReleased(KeyEvent(this, 0, kc, events[i].key.keysym.unicode)) == false )
182					break;
183			}
184		}
185	}
186
187	//Release Grab mode on Alt-Tab combinations (for non-window systems)
188	if( KeyBuffer[KC_RMENU] || KeyBuffer[KC_LMENU])
189	{
190		if( KeyBuffer[KC_TAB] )
191			static_cast<SDLInputManager*>(InputManager::getSingletonPtr())->_setGrabMode(false);
192	}
193}
194
195//-------------------------------------------------------------------//
196bool SDLKeyboard::isKeyDown( KeyCode key )
197{
198	return KeyBuffer[key] == 1 ? true : false;
199}
200
201//-------------------------------------------------------------------//
202const std::string& SDLKeyboard::getAsString( KeyCode kc )
203{
204    switch(kc)
205    {
206    case KC_ESCAPE: mGetString = SDL_GetKeyName(SDLK_ESCAPE); break;
207    case KC_1: mGetString = SDL_GetKeyName(SDLK_1); break;
208    case KC_2: mGetString = SDL_GetKeyName(SDLK_2); break;
209    case KC_3: mGetString = SDL_GetKeyName(SDLK_3); break;
210    case KC_4: mGetString = SDL_GetKeyName(SDLK_4); break;
211    case KC_5: mGetString = SDL_GetKeyName(SDLK_5); break;
212    case KC_6: mGetString = SDL_GetKeyName(SDLK_6); break;
213    case KC_7: mGetString = SDL_GetKeyName(SDLK_7); break;
214    case KC_8: mGetString = SDL_GetKeyName(SDLK_8); break;
215    case KC_9: mGetString = SDL_GetKeyName(SDLK_9); break;
216    case KC_0: mGetString = SDL_GetKeyName(SDLK_0); break;
217    case KC_MINUS: mGetString = SDL_GetKeyName(SDLK_MINUS); break;
218    case KC_EQUALS: mGetString = SDL_GetKeyName(SDLK_EQUALS); break;
219    case KC_BACK: mGetString = SDL_GetKeyName(SDLK_BACKSPACE); break;
220    case KC_TAB: mGetString = SDL_GetKeyName(SDLK_TAB); break;
221    case KC_Q: mGetString = SDL_GetKeyName(SDLK_q); break;
222    case KC_W: mGetString = SDL_GetKeyName(SDLK_w); break;
223    case KC_E: mGetString = SDL_GetKeyName(SDLK_e); break;
224    case KC_R: mGetString = SDL_GetKeyName(SDLK_r); break;
225    case KC_T: mGetString = SDL_GetKeyName(SDLK_t); break;
226    case KC_Y: mGetString = SDL_GetKeyName(SDLK_y); break;
227    case KC_U: mGetString = SDL_GetKeyName(SDLK_u); break;
228    case KC_I: mGetString = SDL_GetKeyName(SDLK_i); break;
229    case KC_O: mGetString = SDL_GetKeyName(SDLK_o); break;
230    case KC_P: mGetString = SDL_GetKeyName(SDLK_p); break;
231    case KC_LBRACKET: mGetString = "["; break;
232    case KC_RBRACKET: mGetString = "]"; break;
233    case KC_RETURN: mGetString = SDL_GetKeyName(SDLK_RETURN); break;
234    case KC_LCONTROL: mGetString = SDL_GetKeyName(SDLK_LCTRL); break;
235    case KC_A: mGetString = SDL_GetKeyName(SDLK_a); break;
236    case KC_S: mGetString = SDL_GetKeyName(SDLK_s); break;
237    case KC_D: mGetString = SDL_GetKeyName(SDLK_d); break;
238    case KC_F: mGetString = SDL_GetKeyName(SDLK_f); break;
239    case KC_G: mGetString = SDL_GetKeyName(SDLK_g); break;
240    case KC_H: mGetString = SDL_GetKeyName(SDLK_h); break;
241    case KC_J: mGetString = SDL_GetKeyName(SDLK_j); break;
242    case KC_K: mGetString = SDL_GetKeyName(SDLK_k); break;
243    case KC_L: mGetString = SDL_GetKeyName(SDLK_l); break;
244    case KC_SEMICOLON: mGetString = SDL_GetKeyName(SDLK_SEMICOLON); break;
245    case KC_APOSTROPHE: mGetString = SDL_GetKeyName(SDLK_QUOTE); break;
246    case KC_GRAVE: mGetString = SDL_GetKeyName(SDLK_BACKQUOTE); break;
247    case KC_LSHIFT: mGetString = SDL_GetKeyName(SDLK_LSHIFT); break;
248    case KC_BACKSLASH: mGetString = SDL_GetKeyName(SDLK_BACKSLASH); break;
249    case KC_Z: mGetString = SDL_GetKeyName(SDLK_z); break;
250    case KC_X: mGetString = SDL_GetKeyName(SDLK_x); break;
251    case KC_C: mGetString = SDL_GetKeyName(SDLK_c); break;
252    case KC_V: mGetString = SDL_GetKeyName(SDLK_v); break;
253    case KC_B: mGetString = SDL_GetKeyName(SDLK_b); break;
254    case KC_N: mGetString = SDL_GetKeyName(SDLK_n); break;
255    case KC_M: mGetString = SDL_GetKeyName(SDLK_m); break;
256    case KC_COMMA: mGetString = SDL_GetKeyName(SDLK_COMMA); break;
257    case KC_PERIOD: mGetString = SDL_GetKeyName(SDLK_PERIOD); break;
258    case KC_SLASH: mGetString = SDL_GetKeyName(SDLK_SLASH); break;
259    case KC_RSHIFT: mGetString = SDL_GetKeyName(SDLK_RSHIFT); break;
260    case KC_MULTIPLY: mGetString = SDL_GetKeyName(SDLK_KP_MULTIPLY); break;
261    case KC_LMENU: mGetString = SDL_GetKeyName(SDLK_LALT); break;
262    case KC_SPACE: mGetString = SDL_GetKeyName(SDLK_SPACE); break;
263    case KC_CAPITAL: mGetString = SDL_GetKeyName(SDLK_CAPSLOCK); break;
264    case KC_F1: mGetString = SDL_GetKeyName(SDLK_F1); break;
265    case KC_F2: mGetString = SDL_GetKeyName(SDLK_F2); break;
266    case KC_F3: mGetString = SDL_GetKeyName(SDLK_F3); break;
267    case KC_F4: mGetString = SDL_GetKeyName(SDLK_F4); break;
268    case KC_F5: mGetString = SDL_GetKeyName(SDLK_F5); break;
269    case KC_F6: mGetString = SDL_GetKeyName(SDLK_F6); break;
270    case KC_F7: mGetString = SDL_GetKeyName(SDLK_F7); break;
271    case KC_F8: mGetString = SDL_GetKeyName(SDLK_F8); break;
272    case KC_F9: mGetString = SDL_GetKeyName(SDLK_F9); break;
273    case KC_F10: mGetString = SDL_GetKeyName(SDLK_F10); break;
274    case KC_NUMLOCK: mGetString = SDL_GetKeyName(SDLK_NUMLOCK); break;
275    case KC_SCROLL: mGetString = SDL_GetKeyName(SDLK_SCROLLOCK); break;
276    case KC_NUMPAD7: mGetString = SDL_GetKeyName(SDLK_KP7); break;
277    case KC_NUMPAD8: mGetString = SDL_GetKeyName(SDLK_KP8); break;
278    case KC_NUMPAD9: mGetString = SDL_GetKeyName(SDLK_KP9); break;
279    case KC_SUBTRACT: mGetString = SDL_GetKeyName(SDLK_KP_MINUS); break;
280    case KC_NUMPAD4: mGetString = SDL_GetKeyName(SDLK_KP4); break;
281    case KC_NUMPAD5: mGetString = SDL_GetKeyName(SDLK_KP5); break;
282    case KC_NUMPAD6: mGetString = SDL_GetKeyName(SDLK_KP6); break;
283    case KC_ADD: mGetString = SDL_GetKeyName(SDLK_KP_PLUS); break;
284    case KC_NUMPAD1: mGetString = SDL_GetKeyName(SDLK_KP1); break;
285    case KC_NUMPAD2: mGetString = SDL_GetKeyName(SDLK_KP2); break;
286    case KC_NUMPAD3: mGetString = SDL_GetKeyName(SDLK_KP3); break;
287    case KC_NUMPAD0: mGetString = SDL_GetKeyName(SDLK_KP0); break;
288    case KC_DECIMAL: mGetString = SDL_GetKeyName(SDLK_KP_PERIOD); break;
289    case KC_OEM_102: mGetString = "OEM_102"; break;
290    case KC_F11: mGetString = SDL_GetKeyName(SDLK_F11); break;
291    case KC_F12: mGetString = SDL_GetKeyName(SDLK_F12); break;
292    case KC_F13: mGetString = SDL_GetKeyName(SDLK_F13); break;
293    case KC_F14: mGetString = SDL_GetKeyName(SDLK_F14); break;
294    case KC_F15: mGetString = SDL_GetKeyName(SDLK_F15); break;
295    case KC_KANA: mGetString = "Kana"; break;
296    case KC_ABNT_C1: mGetString = "ABNT_C1"; break;
297    case KC_CONVERT: mGetString = "CONVERT"; break;
298    case KC_NOCONVERT: mGetString = "NOCONVERT"; break;
299    case KC_YEN: mGetString = "YEN"; break;
300    case KC_ABNT_C2: mGetString = "ABNT_C2"; break;
301    case KC_NUMPADEQUALS: mGetString = SDL_GetKeyName(SDLK_KP_EQUALS); break;
302    case KC_PREVTRACK: mGetString = "KC_PREVTRACK"; break;
303    case KC_AT: mGetString = "KC_AT"; break;
304    case KC_COLON: mGetString = SDL_GetKeyName(SDLK_COLON); break;
305    case KC_UNDERLINE: mGetString = "KC_UNDERLINE"; break;
306    case KC_KANJI: mGetString = "KC_KANJI"; break;
307    case KC_STOP: mGetString = "KC_STOP"; break;
308    case KC_AX: mGetString = "KC_AX"; break;
309    case KC_UNLABELED: mGetString = "KC_UNLABELED"; break;
310    case KC_NEXTTRACK: mGetString = "KC_NEXTTRACK"; break;
311    case KC_NUMPADENTER: mGetString = "KC_NUMPADENTER"; break;
312    case KC_RCONTROL: mGetString = "KC_RCONTROL"; break;
313    case KC_MUTE: mGetString = "KC_MUTE"; break;
314    case KC_CALCULATOR: mGetString = "KC_CALCULATOR"; break;
315    case KC_PLAYPAUSE: mGetString = "KC_PLAYPAUSE"; break;
316    case KC_MEDIASTOP: mGetString = "KC_MEDIASTOP"; break;
317    case KC_VOLUMEDOWN: mGetString = "KC_VOLUMEDOWN"; break;
318    case KC_VOLUMEUP: mGetString = "KC_VOLUMEUP"; break;
319    case KC_WEBHOME: mGetString = "KC_WEBHOME"; break;
320    case KC_NUMPADCOMMA: mGetString = "KC_NUMPADCOMMA"; break;
321    case KC_DIVIDE: mGetString = SDL_GetKeyName(SDLK_KP_DIVIDE); break;
322    case KC_SYSRQ: mGetString = SDL_GetKeyName(SDLK_SYSREQ); break;
323    case KC_RMENU: mGetString = SDL_GetKeyName(SDLK_RALT); break;
324    case KC_PAUSE: mGetString = "Pause"; break;
325    case KC_HOME: mGetString = SDL_GetKeyName(SDLK_HOME); break;
326    case KC_UP: mGetString = SDL_GetKeyName(SDLK_UP); break;
327    case KC_PGUP: mGetString = SDL_GetKeyName(SDLK_PAGEUP); break;
328    case KC_LEFT: mGetString = SDL_GetKeyName(SDLK_LEFT); break;
329    case KC_RIGHT: mGetString = SDL_GetKeyName(SDLK_RIGHT); break;
330    case KC_END:  mGetString = SDL_GetKeyName(SDLK_END); break;
331    case KC_DOWN: mGetString = SDL_GetKeyName(SDLK_DOWN); break;
332    case KC_PGDOWN: mGetString = SDL_GetKeyName(SDLK_PAGEDOWN); break;
333    case KC_INSERT: mGetString = SDL_GetKeyName(SDLK_INSERT); break;
334    case KC_DELETE: mGetString = SDL_GetKeyName(SDLK_DELETE); break;
335    case KC_LWIN: mGetString = SDL_GetKeyName(SDLK_LSUPER); break;
336    case KC_RWIN: mGetString = SDL_GetKeyName(SDLK_RSUPER); break;
337    case KC_APPS: mGetString = "KC_APPS"; break;
338    case KC_POWER: mGetString = "KC_POWER"; break;
339    case KC_SLEEP: mGetString = "KC_SLEEP"; break;
340    case KC_WAKE: mGetString = "KC_WAKE"; break;
341    case KC_WEBSEARCH: mGetString = "KC_WEBSEARCH"; break;
342    case KC_WEBFAVORITES: mGetString = "KC_WEBFAVORITES"; break;
343    case KC_WEBREFRESH: mGetString = "KC_WEBREFRESH"; break;
344    case KC_WEBSTOP: mGetString = "KC_WEBSTOP"; break;
345    case KC_WEBFORWARD: mGetString = "KC_WEBFORWARD"; break;
346    case KC_WEBBACK: mGetString = "KC_WEBBACK"; break;
347    case KC_MYCOMPUTER: mGetString = "KC_MYCOMPUTER"; break;
348    case KC_MAIL: mGetString = "KC_MAIL"; break;
349    case KC_MEDIASELECT: mGetString = "KC_MEDIASELECT"; break;
350    default: mGetString = "Unknown"; break;
351    };
352
353	return mGetString;
354}
355
356//-------------------------------------------------------------------//
357void SDLKeyboard::copyKeyStates( char keys[256] )
358{
359	for(int i = 0; i < 256; ++i)
360		keys[i] = KeyBuffer[i];
361}
362
363//-------------------------------------------------------------------//
364void SDLKeyboard::setBuffered(bool buffered)
365{
366	mBuffered = buffered;
367}
368
369//-------------------------------------------------------------------//
370void SDLKeyboard::setTextTranslation( TextTranslationMode mode )
371{
372	mTextMode = mode;
373	if( mode == Off || mode == Ascii )
374		SDL_EnableUNICODE(0);
375	else if( mode == Unicode )
376		SDL_EnableUNICODE(1);
377}