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