Changeset 2348 in vbox
- Timestamp:
- Apr 26, 2007 4:24:35 AM (18 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r2322 r2348 1396 1396 /* calc flags. */ 1397 1397 int flags = 0; 1398 UInt32 EventKind = ::GetEventKind (inEvent);1399 1398 if (EventKind != kEventRawKeyUp) 1400 1399 flags |= KeyPressed; 1401 if (scanCode & 0x8000) /* modifiers (just in case) */ 1402 { 1403 flags |= KeyPressed; 1404 scanCode &= ~0x8000; 1405 } 1406 if (scanCode & 0x80) 1407 { 1400 if (scanCode & VBOXKEY_EXTENDED) 1408 1401 flags |= KeyExtended; 1409 scanCode &= ~0x80;1410 }1411 1402 /** @todo KeyPause, KeyPrint. */ 1412 1413 /* get the keycode and unicode string (if present). */ 1414 UInt32 keyCode = ~0; 1415 ::GetEventParameter (inEvent, kEventParamKeyCode, typeUInt32, NULL, 1416 sizeof (keyCode), NULL, &keyCode); 1403 scanCode &= VBOXKEY_SCANCODE_MASK; 1404 1405 /* get the unicode string (if present). */ 1417 1406 AssertCompileSize (wchar_t, 2); 1418 1407 AssertCompileSize (UniChar, 2); … … 1446 1435 Assert (keyCode); 1447 1436 1448 unsigned flags = (newMask & (1 << bit)) ? KeyPressed : 0; 1449 if (scanCode & 0x80) 1437 if (!(scanCode & VBOXKEY_LOCK)) 1450 1438 { 1451 flags |= KeyExtended; 1452 scanCode &= ~0x80; 1439 unsigned flags = (newMask & (1 << bit)) ? KeyPressed : 0; 1440 if (scanCode & VBOXKEY_EXTENDED) 1441 flags |= KeyExtended; 1442 scanCode &= VBOXKEY_SCANCODE_MASK; 1443 ret |= keyEvent (keyCode, scanCode & 0xff, flags); 1453 1444 } 1454 ret |= keyEvent (keyCode, scanCode, flags); 1445 else 1446 { 1447 unsigned flags = 0; 1448 if (scanCode & VBOXKEY_EXTENDED) 1449 flags |= KeyExtended; 1450 scanCode &= VBOXKEY_SCANCODE_MASK; 1451 ret |= keyEvent (keyCode, scanCode, flags | KeyPressed); 1452 ret |= keyEvent (keyCode, scanCode, flags); 1453 } 1455 1454 } 1456 1455 } … … 1627 1626 #elif defined(Q_WS_MAC) 1628 1627 1629 if (muNumLockAdaptionCnt) 1630 { 1631 /* Numlock isn't in the modifier mask. */ 1632 KeyMap keys = {{0},{0},{0},{0}}; 1633 GetKeys(keys); 1634 if (mfNumLock ^ ASMBitTest(keys, 0x47 /* QZ_NUMLOCK */)) 1635 { 1636 muNumLockAdaptionCnt--; 1637 codes[(*count)++] = 0x45; 1638 codes[(*count)++] = 0x45 | 0x80; 1639 } 1640 } 1628 /* if (muNumLockAdaptionCnt) ... - NumLock isn't implemented by Mac OS X so ignore it. */ 1641 1629 if (muCapsLockAdaptionCnt && (mfCapsLock ^ !!(::GetCurrentEventKeyModifiers() & alphaLock))) 1642 1630 { -
trunk/src/VBox/Frontends/VirtualBox/src/darwin/DarwinKeyboard.cpp
r2342 r2348 81 81 #define QZ_NUMLOCK 0x47 82 82 83 /** short hand for an extended key. */ 84 #define K_EX VBOXKEY_EXTENDED 85 /** short hand for a modifier key. */ 86 #define K_MOD VBOXKEY_MODIFIER 87 /** short hand for a lock key. */ 88 #define K_LOCK VBOXKEY_LOCK 89 83 90 #ifdef USE_HID_FOR_MODIFIERS 84 91 … … 98 105 * for looking at SDL and other odd places for docs.) 99 106 */ 100 static const uint 8_t g_aDarwinToSet1[] =101 { 102 /* set-1 SDL_QuartzKeys.h */103 0x1e, /* QZ_a 0x00 */104 0x1f, /* QZ_s 0x01 */105 0x20, /* QZ_d 0x02 */106 0x21, /* QZ_f 0x03 */107 0x23, /* QZ_h 0x04 */108 0x22, /* QZ_g 0x05 */109 0x2c, /* QZ_z 0x06 */110 0x2d, /* QZ_x 0x07 */111 0x2e, /* QZ_c 0x08 */112 0x2f, /* QZ_v 0x09 */113 0x56, /* between lshift and z. 'INT 1'? */114 0x30, /* QZ_b 0x0B */115 0x10, /* QZ_q 0x0C */116 0x11, /* QZ_w 0x0D */117 0x12, /* QZ_e 0x0E */118 0x13, /* QZ_r 0x0F */119 0x15, /* QZ_y 0x10 */120 0x14, /* QZ_t 0x11 */121 0x02, /* QZ_1 0x12 */122 0x03, /* QZ_2 0x13 */123 0x04, /* QZ_3 0x14 */124 0x05, /* QZ_4 0x15 */125 0x07, /* QZ_6 0x16 */126 0x06, /* QZ_5 0x17 */127 0x0d, /* QZ_EQUALS 0x18 */128 0x0a, /* QZ_9 0x19 */129 0x08, /* QZ_7 0x1A */130 0x0c, /* QZ_MINUS 0x1B */131 0x09, /* QZ_8 0x1C */132 0x0b, /* QZ_0 0x1D */133 0x1b, /* QZ_RIGHTBRACKET 0x1E */134 0x18, /* QZ_o 0x1F */135 0x16, /* QZ_u 0x20 */136 0x1a, /* QZ_LEFTBRACKET 0x21 */137 0x17, /* QZ_i 0x22 */138 0x19, /* QZ_p 0x23 */139 0x1c, /* QZ_RETURN 0x24 */140 0x26, /* QZ_l 0x25 */141 0x24, /* QZ_j 0x26 */142 0x28, /* QZ_QUOTE 0x27 */143 0x25, /* QZ_k 0x28 */144 0x27, /* QZ_SEMICOLON 0x29 */145 0x2b, /* QZ_BACKSLASH 0x2A */146 0x33, /* QZ_COMMA 0x2B */147 0x35, /* QZ_SLASH 0x2C */148 0x31, /* QZ_n 0x2D */149 0x32, /* QZ_m 0x2E */150 0x34, /* QZ_PERIOD 0x2F */151 0x0f, /* QZ_TAB 0x30 */152 0x39, /* QZ_SPACE 0x31 */153 0x29, /* QZ_BACKQUOTE 0x32 */154 0x0e, /* QZ_BACKSPACE 0x33 */155 0x9c, /* QZ_IBOOK_ENTER 0x34 */156 0x01, /* QZ_ESCAPE 0x35 */157 0x5c| 0x80,/* QZ_RMETA 0x36 */158 0x5b| 0x80,/* QZ_LMETA 0x37 */159 0x2a ,/* QZ_LSHIFT 0x38 */160 0x3a ,/* QZ_CAPSLOCK 0x39 */161 0x38 ,/* QZ_LALT 0x3A */162 0x1d ,/* QZ_LCTRL 0x3B */163 0x36 ,/* QZ_RSHIFT 0x3C */164 0x38| 0x80,/* QZ_RALT 0x3D */165 0x1d| 0x80,/* QZ_RCTRL 0x3E */166 0, /* */167 0, /* */168 0x53, /* QZ_KP_PERIOD 0x41 */169 0, /* */170 0x37, /* QZ_KP_MULTIPLY 0x43 */171 0, /* */172 0x4e, /* QZ_KP_PLUS 0x45 */173 0, /* */174 0x45 ,/* QZ_NUMLOCK 0x47 */175 0, /* */176 0, /* */177 0, /* */178 0x35| 0x80,/* QZ_KP_DIVIDE 0x4B */179 0x1c| 0x80,/* QZ_KP_ENTER 0x4C */180 0, /* */181 0x4a, /* QZ_KP_MINUS 0x4E */182 0, /* */183 0, /* */184 0x0d/*?*/, /* QZ_KP_EQUALS 0x51 */185 0x52, /* QZ_KP0 0x52 */186 0x4f, /* QZ_KP1 0x53 */187 0x50, /* QZ_KP2 0x54 */188 0x51, /* QZ_KP3 0x55 */189 0x4b, /* QZ_KP4 0x56 */190 0x4c, /* QZ_KP5 0x57 */191 0x4d, /* QZ_KP6 0x58 */192 0x47, /* QZ_KP7 0x59 */193 0, /* */194 0x48, /* QZ_KP8 0x5B */195 0x49, /* QZ_KP9 0x5C */196 0, /* */197 0, /* */198 0, /* */199 0x3f, /* QZ_F5 0x60 */200 0x40, /* QZ_F6 0x61 */201 0x41, /* QZ_F7 0x62 */202 0x3d, /* QZ_F3 0x63 */203 0x42, /* QZ_F8 0x64 */204 0x43, /* QZ_F9 0x65 */205 0, /* */206 0x57, /* QZ_F11 0x67 */207 0, /* */208 0x37| 0x80,/* QZ_PRINT / F13 0x69 */209 0x63, /* QZ_F16 0x6A */210 0x46 ,/* QZ_SCROLLOCK 0x6B */211 0, /* */212 0x44, /* QZ_F10 0x6D */213 0x5d| 0x80,/* */214 0x58, /* QZ_F12 0x6F */215 0, /* */216 0/* 0xe1,0x1d,0x45*/, /* QZ_PAUSE 0x71 */217 0x52| 0x80,/* QZ_INSERT / HELP 0x72 */218 0x47| 0x80,/* QZ_HOME 0x73 */219 0x49| 0x80,/* QZ_PAGEUP 0x74 */220 0x53| 0x80,/* QZ_DELETE 0x75 */221 0x3e, /* QZ_F4 0x76 */222 0x4f| 0x80,/* QZ_END 0x77 */223 0x3c, /* QZ_F2 0x78 */224 0x51| 0x80,/* QZ_PAGEDOWN 0x79 */225 0x3b, /* QZ_F1 0x7A */226 0x4b| 0x80,/* QZ_LEFT 0x7B */227 0x4d| 0x80,/* QZ_RIGHT 0x7C */228 0x50| 0x80,/* QZ_DOWN 0x7D */229 0x48| 0x80,/* QZ_UP 0x7E */230 0x5e| 0x80,/* QZ_POWER 0x7F */ /* have different break key! */107 static const uint16_t g_aDarwinToSet1[] = 108 { 109 /* set-1 SDL_QuartzKeys.h */ 110 0x1e, /* QZ_a 0x00 */ 111 0x1f, /* QZ_s 0x01 */ 112 0x20, /* QZ_d 0x02 */ 113 0x21, /* QZ_f 0x03 */ 114 0x23, /* QZ_h 0x04 */ 115 0x22, /* QZ_g 0x05 */ 116 0x2c, /* QZ_z 0x06 */ 117 0x2d, /* QZ_x 0x07 */ 118 0x2e, /* QZ_c 0x08 */ 119 0x2f, /* QZ_v 0x09 */ 120 0x56, /* between lshift and z. 'INT 1'? */ 121 0x30, /* QZ_b 0x0B */ 122 0x10, /* QZ_q 0x0C */ 123 0x11, /* QZ_w 0x0D */ 124 0x12, /* QZ_e 0x0E */ 125 0x13, /* QZ_r 0x0F */ 126 0x15, /* QZ_y 0x10 */ 127 0x14, /* QZ_t 0x11 */ 128 0x02, /* QZ_1 0x12 */ 129 0x03, /* QZ_2 0x13 */ 130 0x04, /* QZ_3 0x14 */ 131 0x05, /* QZ_4 0x15 */ 132 0x07, /* QZ_6 0x16 */ 133 0x06, /* QZ_5 0x17 */ 134 0x0d, /* QZ_EQUALS 0x18 */ 135 0x0a, /* QZ_9 0x19 */ 136 0x08, /* QZ_7 0x1A */ 137 0x0c, /* QZ_MINUS 0x1B */ 138 0x09, /* QZ_8 0x1C */ 139 0x0b, /* QZ_0 0x1D */ 140 0x1b, /* QZ_RIGHTBRACKET 0x1E */ 141 0x18, /* QZ_o 0x1F */ 142 0x16, /* QZ_u 0x20 */ 143 0x1a, /* QZ_LEFTBRACKET 0x21 */ 144 0x17, /* QZ_i 0x22 */ 145 0x19, /* QZ_p 0x23 */ 146 0x1c, /* QZ_RETURN 0x24 */ 147 0x26, /* QZ_l 0x25 */ 148 0x24, /* QZ_j 0x26 */ 149 0x28, /* QZ_QUOTE 0x27 */ 150 0x25, /* QZ_k 0x28 */ 151 0x27, /* QZ_SEMICOLON 0x29 */ 152 0x2b, /* QZ_BACKSLASH 0x2A */ 153 0x33, /* QZ_COMMA 0x2B */ 154 0x35, /* QZ_SLASH 0x2C */ 155 0x31, /* QZ_n 0x2D */ 156 0x32, /* QZ_m 0x2E */ 157 0x34, /* QZ_PERIOD 0x2F */ 158 0x0f, /* QZ_TAB 0x30 */ 159 0x39, /* QZ_SPACE 0x31 */ 160 0x29, /* QZ_BACKQUOTE 0x32 */ 161 0x0e, /* QZ_BACKSPACE 0x33 */ 162 0x9c, /* QZ_IBOOK_ENTER 0x34 */ 163 0x01, /* QZ_ESCAPE 0x35 */ 164 0x5c|K_EX|K_MOD, /* QZ_RMETA 0x36 */ 165 0x5b|K_EX|K_MOD, /* QZ_LMETA 0x37 */ 166 0x2a|K_MOD, /* QZ_LSHIFT 0x38 */ 167 0x3a|K_LOCK, /* QZ_CAPSLOCK 0x39 */ 168 0x38|K_MOD, /* QZ_LALT 0x3A */ 169 0x1d|K_MOD, /* QZ_LCTRL 0x3B */ 170 0x36|K_MOD, /* QZ_RSHIFT 0x3C */ 171 0x38|K_EX|K_MOD, /* QZ_RALT 0x3D */ 172 0x1d|K_EX|K_MOD, /* QZ_RCTRL 0x3E */ 173 0, /* */ 174 0, /* */ 175 0x53, /* QZ_KP_PERIOD 0x41 */ 176 0, /* */ 177 0x37, /* QZ_KP_MULTIPLY 0x43 */ 178 0, /* */ 179 0x4e, /* QZ_KP_PLUS 0x45 */ 180 0, /* */ 181 0x45|K_LOCK, /* QZ_NUMLOCK 0x47 */ 182 0, /* */ 183 0, /* */ 184 0, /* */ 185 0x35|K_EX, /* QZ_KP_DIVIDE 0x4B */ 186 0x1c|K_EX, /* QZ_KP_ENTER 0x4C */ 187 0, /* */ 188 0x4a, /* QZ_KP_MINUS 0x4E */ 189 0, /* */ 190 0, /* */ 191 0x0d/*?*/, /* QZ_KP_EQUALS 0x51 */ 192 0x52, /* QZ_KP0 0x52 */ 193 0x4f, /* QZ_KP1 0x53 */ 194 0x50, /* QZ_KP2 0x54 */ 195 0x51, /* QZ_KP3 0x55 */ 196 0x4b, /* QZ_KP4 0x56 */ 197 0x4c, /* QZ_KP5 0x57 */ 198 0x4d, /* QZ_KP6 0x58 */ 199 0x47, /* QZ_KP7 0x59 */ 200 0, /* */ 201 0x48, /* QZ_KP8 0x5B */ 202 0x49, /* QZ_KP9 0x5C */ 203 0, /* */ 204 0, /* */ 205 0, /* */ 206 0x3f, /* QZ_F5 0x60 */ 207 0x40, /* QZ_F6 0x61 */ 208 0x41, /* QZ_F7 0x62 */ 209 0x3d, /* QZ_F3 0x63 */ 210 0x42, /* QZ_F8 0x64 */ 211 0x43, /* QZ_F9 0x65 */ 212 0, /* */ 213 0x57, /* QZ_F11 0x67 */ 214 0, /* */ 215 0x37|K_EX, /* QZ_PRINT / F13 0x69 */ 216 0x63, /* QZ_F16 0x6A */ 217 0x46|K_LOCK, /* QZ_SCROLLOCK 0x6B */ 218 0, /* */ 219 0x44, /* QZ_F10 0x6D */ 220 0x5d|K_EX, /* */ 221 0x58, /* QZ_F12 0x6F */ 222 0, /* */ 223 0/* 0xe1,0x1d,0x45*/, /* QZ_PAUSE 0x71 */ 224 0x52|K_EX, /* QZ_INSERT / HELP 0x72 */ 225 0x47|K_EX, /* QZ_HOME 0x73 */ 226 0x49|K_EX, /* QZ_PAGEUP 0x74 */ 227 0x53|K_EX, /* QZ_DELETE 0x75 */ 228 0x3e, /* QZ_F4 0x76 */ 229 0x4f|K_EX, /* QZ_END 0x77 */ 230 0x3c, /* QZ_F2 0x78 */ 231 0x51|K_EX, /* QZ_PAGEDOWN 0x79 */ 232 0x3b, /* QZ_F1 0x7A */ 233 0x4b|K_EX, /* QZ_LEFT 0x7B */ 234 0x4d|K_EX, /* QZ_RIGHT 0x7C */ 235 0x50|K_EX, /* QZ_DOWN 0x7D */ 236 0x48|K_EX, /* QZ_UP 0x7E */ 237 0x5e|K_EX, /* QZ_POWER 0x7F */ /* have different break key! */ 231 238 }; 232 239 … … 238 245 /** Cached connection. */ 239 246 static CGSConnection g_CGSConnection; 240 241 242 247 243 248 … … 311 316 unsigned DarwinModifierMaskToSet1Scancode(UInt32 fModifiers) 312 317 { 313 unsigned uScanCode; 314 315 fModifiers &= shiftKey | rightShiftKey | controlKey | rightControlKey | optionKey | rightOptionKey | cmdKey 316 | kEventKeyModifierRightCmdKeyMask | kEventKeyModifierNumLockMask | alphaLock; 317 if (fModifiers == shiftKey) 318 uScanCode = 0x2a; 319 else if (fModifiers == rightShiftKey) 320 uScanCode = 0x36; 321 else if (fModifiers == controlKey) 322 uScanCode = 0x1d; 323 else if (fModifiers == rightControlKey) 324 uScanCode = 0x1d|0x80; 325 else if (fModifiers == optionKey) 326 uScanCode = 0x38; 327 else if (fModifiers == rightOptionKey) 328 uScanCode = 0x38|0x80; 329 else if (fModifiers == cmdKey) 330 uScanCode = 0x5b|0x80; 331 else if (fModifiers == kEventKeyModifierRightCmdKeyMask /* hack */) 332 uScanCode = 0x5c|0x80; 333 else if (fModifiers == alphaLock) 334 uScanCode = 0x3a; 335 else if (fModifiers == kEventKeyModifierNumLockMask) 336 uScanCode = 0x45; 337 else if (fModifiers == 0) 338 uScanCode = 0; 318 unsigned uScanCode = DarwinModifierMaskToDarwinKeycode(fModifiers); 319 if (uScanCode < RT_ELEMENTS(g_aDarwinToSet1)) 320 uScanCode = g_aDarwinToSet1[uScanCode]; 339 321 else 340 uScanCode = ~0U; /* multiple */322 Assert(uScanCode == ~0U); 341 323 return uScanCode; 342 324 } … … 425 407 426 408 /** 427 * Converts a key event to a set 1 scan code.428 *429 * @returns set 1 scan code.430 * @param Event The event.431 * @param pfCurKeyModifiers Where the current key modifier mask is stored. (in/out)432 */433 unsigned DarwinEventToSet1Scancode(EventRef Event, UInt32 *pfCurKeyModifiers)434 {435 UInt32 EventClass = GetEventClass(Event);436 if (RT_UNLIKELY(EventClass != kEventClassKeyboard))437 return 0;438 439 UInt32 EventKind = GetEventKind(Event);440 switch (EventKind)441 {442 case kEventRawKeyUp:443 case kEventRawKeyDown:444 case kEventRawKeyRepeat:445 {446 UInt32 uKeyCode;447 GetEventParameter(Event, kEventParamKeyCode, typeUInt32, NULL, sizeof(uKeyCode), NULL, &uKeyCode);448 unsigned uScanCode = DarwinKeycodeToSet1Scancode(uKeyCode);449 if (uScanCode == 0)450 {451 /* modifiers and other hacks? */452 /** @todo fallback... */453 }454 #ifdef DEBUG_PRINTF455 RTPrintf("dbg: EventKind=%d: %#x -> %#x\n", EventKind, uKeyCode, uScanCode);456 #endif457 return uScanCode;458 }459 460 case kEventRawKeyModifiersChanged:461 {462 /* get and update the key modifiers. */463 const UInt32 fOldKeyModifiers = *pfCurKeyModifiers;464 UInt32 fKeyModifiers = ~0;465 if (GetEventParameter(Event, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(fKeyModifiers), NULL, &fKeyModifiers))466 {467 #ifdef DEBUG_PRINTF468 RTPrintf("dbg: EventKind=%d: 1\n");469 #endif470 return 0;471 }472 473 /* calc changes and see if they apply to us. */474 UInt32 fChanged = fKeyModifiers ^ fOldKeyModifiers;475 fChanged &= shiftKey | rightShiftKey | controlKey | rightControlKey | optionKey | rightOptionKey | cmdKey;476 if (!fChanged)477 {478 #ifdef DEBUG_PRINTF479 RTPrintf("dbg: EventKind=%d: 2\n");480 #endif481 *pfCurKeyModifiers = fKeyModifiers;482 return 0;483 }484 485 /* see what changed - it better not combine changes! */486 unsigned uScanCode = DarwinModifierMaskToSet1Scancode(fChanged);487 if (uScanCode && (fChanged & fKeyModifiers))488 uScanCode |= 0x8000; /* 0x8000 == key down hack. */ /** @todo define. */489 #ifdef DEBUG_PRINTF490 RTPrintf("dbg: EventKind=%d: %#x ^ %#x = %#x -> %#x\n", EventKind,491 fOldKeyModifiers, fKeyModifiers, fChanged, uScanCode);492 #endif493 if (uScanCode != ~0U)494 *pfCurKeyModifiers = fKeyModifiers;495 return uScanCode;496 }497 498 default:499 #ifdef DEBUG_PRINTF500 RTPrintf("dbg: EventKind=%d\n", EventKind);501 #endif502 return 0;503 }504 }505 506 507 508 /**509 409 * Disables or enabled global hot keys. 510 410 *
Note:
See TracChangeset
for help on using the changeset viewer.