- Timestamp:
- Jul 21, 2016 1:16:07 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 3 edited
-
runtime/UIKeyboardHandler.cpp (modified) (2 diffs)
-
widgets/UIHostComboEditor.cpp (modified) (3 diffs)
-
widgets/UIHostComboEditor.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIKeyboardHandler.cpp
r62154 r62396 525 525 * This is just a work-around and is likely to fail in some cases. We are 526 526 * not aware of any ideal solution. Historically we sent an 0xFE scan code, 527 * but this is a real key release code on Brazilian keyboards. */ 527 * but this is a real key release code on Brazilian keyboards. Now we send 528 * a sequence of all modifier keys contained in the host sequence, hoping 529 * that the user will choose something which the guest does not interpret. */ 528 530 for (uint i = 0; i < SIZEOF_ARRAY (m_pressedKeys); i++) 529 531 { … … 532 534 if (!fSentRESEND) 533 535 { 534 LONG aCodes[] = { 0x1D, 0x2A, 0x38, 0x9D, 0xAA, 0xB8 }; 535 QVector <LONG> codes(RT_ELEMENTS(aCodes)); 536 for (unsigned i = 0; i < RT_ELEMENTS(aCodes); ++i) 537 codes[i] = aCodes[i]; 536 QList <unsigned> shortCodes = UIHostCombo::modifiersToScanCodes(m_globalSettings.hostCombo()); 537 QVector <LONG> codes; 538 foreach (unsigned idxCode, shortCodes) 539 { 540 if (idxCode & 0x100) 541 codes << 0xE0; 542 codes << (idxCode & 0x7F); 543 m_pressedKeys[idxCode & 0x7F] &= idxCode & 0x100 ? ~IsExtKeyPressed : ~IsKeyPressed; 544 } 545 foreach (unsigned idxCode, shortCodes) 546 { 547 if (idxCode & 0x100) 548 codes << 0xE0; 549 codes << ((idxCode & 0x7F) | 0x80); 550 } 538 551 keyboard().PutScancodes(codes); 539 m_pressedKeys[0x1D] = m_pressedKeys[0x2A] = m_pressedKeys[0x38] = 0;540 552 fSentRESEND = true; 541 553 } -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHostComboEditor.cpp
r62358 r62396 57 57 #elif defined(VBOX_WS_X11) 58 58 # include "XKeyboard.h" 59 #endif /* VBOX_WS_X11 */ 60 61 /* Other VBox includes: */ 62 #if defined(VBOX_WS_X11) 63 # include <VBox/VBoxKeyboard.h> 59 64 #endif /* VBOX_WS_X11 */ 60 65 … … 276 281 } 277 282 283 unsigned UINativeHotKey::modifierToSet1ScanCode(int iKeyCode) 284 { 285 switch(iKeyCode) 286 { 287 #if defined(VBOX_WS_MAC) 288 289 case controlKey: return 0x1D; 290 case rightControlKey: return 0x11D; 291 case shiftKey: return 0x2A; 292 case rightShiftKey: return 0x36; 293 case optionKey: return 0x38; 294 case rightOptionKey: return 0x138; 295 case cmdKey: return 0x15B; 296 case kEventKeyModifierRightCmdKeyMask: return 0x15C; 297 default: return 0; 298 299 #elif defined(VBOX_WS_WIN) 300 301 case VK_CONTROL: 302 case VK_LCONTROL: return 0x1D; 303 case VK_RCONTROL: return 0x11D; 304 case VK_SHIFT: 305 case VK_LSHIFT: return 0x2A; 306 case VK_RSHIFT: return 0x36; 307 case VK_MENU: 308 case VK_LMENU: return 0x38; 309 case VK_RMENU: return 0x138; 310 case VK_LWIN: return 0x15B; 311 case VK_RWIN: return 0x15C; 312 case VK_APPS: return 0x15D; 313 default: return 0; 314 315 #elif defined(VBOX_WS_X11) 316 317 case XK_Control_L: return 0x1D; 318 case XK_Control_R: return 0x11D; 319 case XK_Shift_L: return 0x2A; 320 case XK_Shift_R: return 0x36; 321 case XK_Alt_L: return 0x38; 322 case XK_ISO_Level3_Shift: 323 case XK_Alt_R: return 0x138; 324 case XK_Meta_L: 325 case XK_Super_L: return 0x15B; 326 case XK_Meta_R: 327 case XK_Super_R: return 0x15C; 328 case XK_Menu: return 0x15D; 329 default: return 0; 330 331 #else 332 333 # warning "port me!" 334 335 default: return 0; 336 337 #endif 338 } 339 } 340 278 341 #if defined(VBOX_WS_WIN) 279 342 … … 380 443 keyCodeList << iKeyCode; 381 444 return keyCodeList; 445 } 446 447 QList<unsigned> UIHostCombo::modifiersToScanCodes(const QString &strKeyCombo) 448 { 449 QStringList encodedKeyList = strKeyCombo.split(','); 450 QList<unsigned> scanCodeList; 451 for (int i = 0; i < encodedKeyList.size(); ++i) 452 if (unsigned idxScanCode = UINativeHotKey::modifierToSet1ScanCode(encodedKeyList[i].toInt())) 453 if (idxScanCode != 0) 454 scanCodeList << idxScanCode; 455 return scanCodeList; 382 456 } 383 457 -
trunk/src/VBox/Frontends/VirtualBox/src/widgets/UIHostComboEditor.h
r60362 r62396 47 47 QString toString(int iKeyCode); 48 48 bool isValidKey(int iKeyCode); 49 /** Translates a modifier key in host platform 50 * encoding to the corresponding set 1 PC scan code. 51 * @note Non-modifier keys will return zero. */ 52 unsigned modifierToSet1ScanCode(int iKeyCode); 49 53 #if defined(VBOX_WS_WIN) 50 54 int distinguishModifierVKey(int wParam, int lParam); … … 63 67 QString toReadableString(const QString &strKeyCombo); 64 68 QList<int> toKeyCodeList(const QString &strKeyCombo); 69 /** Returns a sequence of the set 1 PC scan codes for all 70 * modifiers contained in the (host platform format) sequence passed. */ 71 QList<unsigned> modifiersToScanCodes(const QString &strKeyCombo); 65 72 bool isValidKeyCombo(const QString &strKeyCombo); 66 73 }
Note:
See TracChangeset
for help on using the changeset viewer.

