Home | History | Annotate | Download | only in mac
      1 /*
      2  The zlib/libpng License
      3 
      4  Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
      5 
      6  This software is provided 'as-is', without any express or implied warranty. In no event will
      7  the authors be held liable for any damages arising from the use of this software.
      8 
      9  Permission is granted to anyone to use this software for any purpose, including commercial
     10  applications, and to alter it and redistribute it freely, subject to the following
     11  restrictions:
     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 
     24 #ifndef __LP64__
     25 
     26 #include "mac/MacKeyboard.h"
     27 #include "mac/MacInputManager.h"
     28 #include "mac/MacHelpers.h"
     29 #include "OISException.h"
     30 #include "OISEvents.h"
     31 
     32 #include <Carbon/Carbon.h>
     33 
     34 #include <list>
     35 #include <string>
     36 
     37 const EventTypeSpec DownSpec[] = {{kEventClassKeyboard, kEventRawKeyDown},	//non - repeats
     38 							{kEventClassKeyboard, kEventRawKeyRepeat}}; //repeats
     39 const EventTypeSpec UpSpec = {kEventClassKeyboard, kEventRawKeyUp},
     40 			  ModSpec = {kEventClassKeyboard, kEventRawKeyModifiersChanged};
     41 
     42 const EventTypeSpec AllSpecs[] = {{kEventClassKeyboard, kEventRawKeyDown},
     43 						  {kEventClassKeyboard, kEventRawKeyRepeat},
     44 						  {kEventClassKeyboard, kEventRawKeyUp},
     45 						  {kEventClassKeyboard, kEventRawKeyModifiersChanged}};
     46 
     47 using namespace OIS;
     48 
     49 //-------------------------------------------------------------------//
     50 MacKeyboard::MacKeyboard( InputManager* creator, bool buffered, bool repeat )
     51 	: Keyboard(creator->inputSystemName(), buffered, 0, creator)
     52 {
     53 	keyDownEventRef = NULL;
     54 	keyUpEventRef = NULL;
     55 	keyModEventRef = NULL;
     56 
     57 	useRepeat = repeat;
     58 
     59 	// Get a so-called "Univeral procedure pointer" for our callback
     60 	keyDownUPP = NewEventHandlerUPP( KeyDownWrapper );
     61 	keyUpUPP   = NewEventHandlerUPP( KeyUpWrapper );
     62 	keyModUPP  = NewEventHandlerUPP( KeyModWrapper );
     63 
     64 	// populate the conversion map
     65 	populateKeyConversion();
     66 
     67 	static_cast<MacInputManager*>(mCreator)->_setKeyboardUsed(true);
     68 }
     69 
     70 //-------------------------------------------------------------------//
     71 MacKeyboard::~MacKeyboard()
     72 {
     73 	// Remove our handlers so that this instance doesn't get called
     74 	// after it is deleted
     75 	if (keyDownEventRef != NULL)
     76 		RemoveEventHandler(keyDownEventRef);
     77 
     78 	if (keyUpEventRef != NULL)
     79 		RemoveEventHandler(keyUpEventRef);
     80 
     81 	if (keyModEventRef != NULL)
     82 		RemoveEventHandler(keyModEventRef);
     83 
     84 	// dispose of our UPPs
     85 	DisposeEventHandlerUPP(keyDownUPP);
     86 	DisposeEventHandlerUPP(keyUpUPP);
     87 	DisposeEventHandlerUPP(keyModUPP);
     88 
     89 	//Free the input managers keyboard
     90 	static_cast<MacInputManager*>(mCreator)->_setKeyboardUsed(false);
     91 }
     92 
     93 //-------------------------------------------------------------------//
     94 void MacKeyboard::_initialize()
     95 {
     96 	EventTargetRef event = ((MacInputManager*)mCreator)->_getEventTarget();
     97 
     98 	memset( &KeyBuffer, 0, 256 );
     99 	mModifiers = 0;
    100 	prevModMask = 0;
    101 
    102 	// just in case this gets called after the first time.. better safe
    103 	if (keyDownEventRef != NULL)
    104 		RemoveEventHandler(keyDownEventRef);
    105 
    106 	if (keyUpEventRef != NULL)
    107 		RemoveEventHandler(keyUpEventRef);
    108 
    109 	if (keyModEventRef != NULL)
    110 		RemoveEventHandler(keyModEventRef);
    111 
    112 	keyDownEventRef = NULL;
    113 	keyUpEventRef = NULL;
    114 	keyModEventRef = NULL;
    115 
    116 	OSStatus status;
    117 	// send both elements of downspec array... second index is for repeat events
    118 	if ( useRepeat )
    119 		status = InstallEventHandler( event, keyDownUPP, 2, DownSpec, this, &keyDownEventRef );
    120 	else
    121 		status = InstallEventHandler( event, keyDownUPP, 1, DownSpec, this, &keyDownEventRef );
    122 
    123 	if (status != noErr)
    124 		OIS_EXCEPT( E_General, "MacKeyboard::_initialize >> Error loading KeyDown event handler" );
    125 
    126 	if (InstallEventHandler( event, keyUpUPP, 1, &UpSpec, this, &keyUpEventRef ) != noErr)
    127 		OIS_EXCEPT( E_General, "MacKeyboard::_initialize >> Error loading KeyUp event handler" );
    128 
    129 	if (InstallEventHandler( event, keyModUPP, 1, &ModSpec, this, &keyModEventRef ) != noErr )
    130 		OIS_EXCEPT( E_General, "MacKeyboard::_initialize >> Error loading Keymods event handler" );
    131 }
    132 
    133 //-------------------------------------------------------------------//
    134 bool MacKeyboard::isKeyDown( KeyCode key ) const
    135 {
    136 	return (bool)KeyBuffer[key];
    137 }
    138 
    139 
    140 //-------------------------------------------------------------------//
    141 void MacKeyboard::capture()
    142 {
    143 	// if not buffered just return, we update the unbuffered automatically
    144 	if ( !mBuffered || !mListener )
    145 		return;
    146 
    147 	// run through our event stack
    148 	eventStack::iterator cur_it;
    149 
    150 	for (cur_it = pendingEvents.begin(); cur_it != pendingEvents.end(); cur_it++)
    151 	{
    152 
    153 		if ( (*cur_it).Type == MAC_KEYDOWN || (*cur_it).Type == MAC_KEYREPEAT)
    154 			mListener->keyPressed( (*cur_it).Event );
    155 		else if ( (*cur_it).Type == MAC_KEYUP )
    156 			mListener->keyReleased( (*cur_it).Event );
    157 	}
    158 
    159 	pendingEvents.clear();
    160 }
    161 
    162 
    163 //-------------------------------------------------------------------//
    164 std::string& MacKeyboard::getAsString( KeyCode key )
    165 {
    166     CGKeyCode deviceKeycode;
    167 
    168     // Convert OIS KeyCode back into device keycode
    169     for(VirtualtoOIS_KeyMap::iterator it = keyConversion.begin(); it != keyConversion.end(); ++it)
    170     {
    171         if(it->second == key)
    172             deviceKeycode = it->first;
    173     }
    174 
    175     UniChar unicodeString[1];
    176     UniCharCount actualStringLength = 0;
    177 
    178     CGEventSourceRef sref = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
    179     CGEventRef ref = CGEventCreateKeyboardEvent(sref, deviceKeycode, true);
    180     CGEventKeyboardGetUnicodeString(ref, sizeof(unicodeString) / sizeof(*unicodeString), &actualStringLength, unicodeString);
    181 //    NSLog([NSString stringWithFormat:@"%C\n", unicodeString[0]]);
    182     getString = unicodeString[0];
    183 
    184 	return getString;
    185 }
    186 
    187 //-------------------------------------------------------------------//
    188 void MacKeyboard::setBuffered( bool buffered )
    189 {
    190 	mBuffered = buffered;
    191 }
    192 
    193 #include <iostream>
    194 //-------------------------------------------------------------------//
    195 void MacKeyboard::_keyDownCallback( EventRef theEvent )
    196 {
    197 
    198 	UInt32 virtualKey;
    199 	OSStatus status;
    200 
    201 	unsigned int time = (unsigned int)GetEventTime(theEvent);
    202 
    203 	status = GetEventParameter(theEvent,
    204 					'kcod',			// get it in virtual keycode
    205 					typeUInt32, NULL,	// desired return type
    206 					sizeof(UInt32), NULL, 	// bufsize
    207 					&virtualKey );
    208 
    209 	KeyCode kc = keyConversion[virtualKey];
    210 
    211 	// record what kind of text we should pass the KeyEvent
    212 	UniChar text[10];
    213 	char macChar;
    214 
    215 	// TODO clean this up
    216 	if (mTextMode == Unicode)
    217 	{
    218 		//get string size
    219 		UInt32 stringsize;
    220 		//status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, 0, &stringsize, NULL);
    221 		//status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, sizeof(UniChar)*10, NULL, &text );
    222 		status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, sizeof(UniChar) * 10, &stringsize, &text );
    223 //		std::cout << "String length: " << stringsize << std::endl;
    224 
    225 		//wstring unitext;
    226 		//for (int i=0;i<10;i++) unitext += (wchar_t)text[i];
    227 		//wcout << "Unicode out: " << unitext << endl;
    228 
    229 		if(stringsize > 0)
    230 		{
    231 			// for each unicode char, send an event
    232 			stringsize--; // no termination char
    233 			for ( int i = 0; i < stringsize; i++ )
    234 			{
    235 				injectEvent( kc, time, MAC_KEYDOWN, (unsigned int)text[i] );
    236 			}
    237 		}
    238 	}
    239 	else if (mTextMode == Ascii)
    240 	{
    241 
    242 		status = GetEventParameter( theEvent, 'kchr', typeChar, NULL, sizeof(char), NULL, &macChar );
    243 		injectEvent( kc, time, MAC_KEYDOWN, (unsigned int)macChar );
    244 	}
    245 	else
    246 	{
    247 		injectEvent( kc, time, MAC_KEYDOWN );
    248 	}
    249 }
    250 
    251 //-------------------------------------------------------------------//
    252 void MacKeyboard::_keyUpCallback( EventRef theEvent )
    253 {
    254 	UInt32 virtualKey;
    255 
    256 	OSStatus status;
    257 	status = GetEventParameter( theEvent, kEventParamKeyCode, typeUInt32,
    258 								NULL, sizeof(UInt32), NULL, &virtualKey );
    259 
    260 	KeyCode kc = keyConversion[virtualKey];
    261 	injectEvent( kc, (int)GetEventTime(theEvent), MAC_KEYUP );
    262 
    263 }
    264 
    265 //-------------------------------------------------------------------//
    266 void MacKeyboard::_modChangeCallback( EventRef theEvent )
    267 {
    268 	UInt32 mods;
    269 
    270 	OSStatus status;
    271 	status = GetEventParameter( theEvent, kEventParamKeyModifiers,
    272 								typeUInt32, NULL, sizeof(UInt32), NULL, &mods );
    273 
    274 	// find the changed bit
    275 	UInt32 change = prevModMask ^ mods;
    276 	MacEventType newstate = ((change & prevModMask) > 0) ? MAC_KEYUP : MAC_KEYDOWN;
    277 	unsigned int time = (int)GetEventTime( theEvent );
    278 
    279 	//cout << "preMask: " << hex << prevModMask << endl;
    280 	//cout << "ModMask: " << hex << mods << endl;
    281 	//cout << "Change:  " << hex << (change & prevModMask) << endl << endl;
    282 
    283 	// TODO test modifiers on a full keyboard to check if different mask for left/right
    284 	switch (change)
    285 	{
    286 		case (shiftKey): // shift
    287 			mModifiers &= (newstate == MAC_KEYDOWN) ? Shift : ~Shift;
    288 			injectEvent( KC_LSHIFT, time, newstate );
    289 			//injectEvent( KC_RSHIFT, time, newstate );
    290 			break;
    291 
    292 		case (optionKey): // option (alt)
    293 			mModifiers &= (newstate == MAC_KEYDOWN) ? Alt : -Alt;
    294 			//injectEvent( KC_RMENU, time, newstate );
    295 			injectEvent( KC_LMENU, time, newstate );
    296 			break;
    297 
    298 		case (controlKey): // Ctrl
    299 			mModifiers += (newstate == MAC_KEYDOWN) ? Ctrl : -Ctrl;
    300 			//injectEvent( KC_RCONTROL, time, newstate );
    301 			injectEvent( KC_LCONTROL, time, newstate );
    302 			break;
    303 
    304 		case (cmdKey): // apple
    305 			//injectEvent( KC_RWIN, time, newstate );
    306 			injectEvent( KC_LWIN, time, newstate );
    307 			break;
    308 
    309 		case (kEventKeyModifierFnMask): // fn key
    310 			injectEvent( KC_APPS, time, newstate );
    311 			break;
    312 
    313 		case (kEventKeyModifierNumLockMask): // numlock
    314 			injectEvent( KC_NUMLOCK, time, newstate );
    315 			break;
    316 
    317 		case (alphaLock): // caps lock
    318 			injectEvent( KC_CAPITAL, time, newstate );
    319 			break;
    320 	}
    321 
    322 	prevModMask = mods;
    323 }
    324 
    325 //-------------------------------------------------------------------//
    326 void MacKeyboard::injectEvent( KeyCode kc, unsigned int time, MacEventType type, unsigned int txt )
    327 {
    328 	// set to 1 if this is either a keydown or repeat
    329 	KeyBuffer[kc] = ( type == MAC_KEYUP ) ? 0 : 1;
    330 
    331 	if ( mBuffered && mListener )
    332 		pendingEvents.push_back( MacKeyStackEvent( KeyEvent(this, kc, txt), type) );
    333 }
    334 
    335 
    336 //-------------------------------------------------------------------//
    337 void MacKeyboard::copyKeyStates( char keys[256] ) const
    338 {
    339 	memcpy( keys, KeyBuffer, 256 );
    340 }
    341 
    342 
    343 
    344 //-------------------------------------------------------------------//
    345 void MacKeyboard::populateKeyConversion()
    346 {
    347 	// TODO finish the key mapping
    348 
    349 	// Virtual Key Map to KeyCode
    350 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x12, KC_1));
    351 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x13, KC_2));
    352 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x14, KC_3));
    353 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x15, KC_4));
    354 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x17, KC_5));
    355 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x16, KC_6));
    356 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1A, KC_7));
    357 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1C, KC_8));
    358 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x19, KC_9));
    359 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1D, KC_0));
    360 
    361 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x33, KC_BACK));  // might be wrong
    362 
    363 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1B, KC_MINUS));
    364 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x18, KC_EQUALS));
    365 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x31, KC_SPACE));
    366 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2B, KC_COMMA));
    367 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2F, KC_PERIOD));
    368 
    369 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2A, KC_BACKSLASH));
    370 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2C, KC_SLASH));
    371 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x21, KC_LBRACKET));
    372 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1E, KC_RBRACKET));
    373 
    374 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x35, KC_ESCAPE));
    375 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x39, KC_CAPITAL));
    376 
    377 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x30, KC_TAB));
    378 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x24, KC_RETURN));  // double check return/enter
    379 
    380 	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_colon, KC_COLON));	 // no colon?
    381 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x29, KC_SEMICOLON));
    382 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x27, KC_APOSTROPHE));
    383 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x32, KC_GRAVE));
    384 
    385 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x0B, KC_B));
    386 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x00, KC_A));
    387 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x08, KC_C));
    388 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x02, KC_D));
    389 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x0E, KC_E));
    390 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x03, KC_F));
    391 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x05, KC_G));
    392 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x04, KC_H));
    393 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x22, KC_I));
    394 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x26, KC_J));
    395 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x28, KC_K));
    396 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x25, KC_L));
    397 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2E, KC_M));
    398 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2D, KC_N));
    399 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1F, KC_O));
    400 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x23, KC_P));
    401 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x0C, KC_Q));
    402 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x0F, KC_R));
    403 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x01, KC_S));
    404 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x11, KC_T));
    405 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x20, KC_U));
    406 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x09, KC_V));
    407 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x0D, KC_W));
    408 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x07, KC_X));
    409 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x10, KC_Y));
    410 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x06, KC_Z));
    411 
    412 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7A, KC_F1));
    413 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x78, KC_F2));
    414 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x63, KC_F3));
    415 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x76, KC_F4));
    416 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x60, KC_F5));
    417 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x61, KC_F6));
    418 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x62, KC_F7));
    419 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x64, KC_F8));
    420 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x65, KC_F9));
    421 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x6D, KC_F10));
    422 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x67, KC_F11));
    423 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x6F, KC_F12));
    424 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x69, KC_F13));
    425 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x6B, KC_F14));
    426 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x71, KC_F15));
    427 
    428 	//Keypad
    429 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x52, KC_NUMPAD0));
    430 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x53, KC_NUMPAD1));
    431 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x54, KC_NUMPAD2));
    432 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x55, KC_NUMPAD3));
    433 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x56, KC_NUMPAD4));
    434 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x57, KC_NUMPAD5));
    435 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x58, KC_NUMPAD6));
    436 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x59, KC_NUMPAD7));
    437 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x5B, KC_NUMPAD8));
    438 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x5C, KC_NUMPAD9));
    439 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x45, KC_ADD));
    440 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x4E, KC_SUBTRACT));
    441 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x41, KC_DECIMAL));
    442 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x51, KC_NUMPADEQUALS));
    443 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x4B, KC_DIVIDE));
    444 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x43, KC_MULTIPLY));
    445 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x4C, KC_NUMPADENTER));
    446 
    447 	//Keypad with numlock off
    448 	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x73, KC_NUMPAD7));  // not sure of these
    449 	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Up, KC_NUMPAD8)); // check on a non-laptop
    450 	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Page_Up, KC_NUMPAD9));
    451 	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Left, KC_NUMPAD4));
    452 	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Begin, KC_NUMPAD5));
    453 	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Right, KC_NUMPAD6));
    454 	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_End, KC_NUMPAD1));
    455 	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Down, KC_NUMPAD2));
    456 	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Page_Down, KC_NUMPAD3));
    457 	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Insert, KC_NUMPAD0));
    458 	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Delete, KC_DECIMAL));
    459 
    460 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7E, KC_UP));
    461 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7D, KC_DOWN));
    462 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7B, KC_LEFT));
    463 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7C, KC_RIGHT));
    464 
    465 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x74, KC_PGUP));
    466 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x79, KC_PGDOWN));
    467 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x73, KC_HOME));
    468 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x77, KC_END));
    469 
    470 	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Print, KC_SYSRQ));		// ??
    471 	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Scroll_Lock, KC_SCROLL)); // ??
    472 	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Pause, KC_PAUSE));		// ??
    473 
    474 
    475 	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Insert, KC_INSERT));	  // ??
    476 	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x75, KC_DELETE)); // del under help key?
    477 }
    478 
    479 #endif
    480