Changeset 255 in vbox
- Timestamp:
- Jan 23, 2007 9:33:50 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/pdm.h
r161 r255 593 593 /** Num Lock */ 594 594 PDMKEYBLEDS_NUMLOCK = 0x0001, 595 /** Caps Lock */ 596 PDMKEYBLEDS_CAPSLOCK = 0x0002, 595 597 /** Scroll Lock */ 596 PDMKEYBLEDS_SCROLLLOCK = 0x0002, 597 /** Caps Lock */ 598 PDMKEYBLEDS_CAPSLOCK = 0x0004 598 PDMKEYBLEDS_SCROLLLOCK = 0x0004 599 599 } PDMKEYBLEDS; 600 600 -
trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp
r153 r255 166 166 static BOOL gfGuestScrollLockPressed = FALSE; 167 167 static int guGuestNumLockAdaptionCnt = 2; 168 static int guGuestCapsLockAdaptionCnt = 2; 168 169 169 170 /** modifier keypress status (scancode as index) */ … … 462 463 } 463 464 464 STDMETHOD(OnKeyboardLedsChange)(BOOL fNumLock, BOOL f ScrollLock, BOOL fCapsLock)465 STDMETHOD(OnKeyboardLedsChange)(BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock) 465 466 { 466 467 /* Don't bother the guest with NumLock scancodes if he doesn't set the NumLock LED */ 467 468 if (gfGuestNumLockPressed != fNumLock) 468 469 guGuestNumLockAdaptionCnt = 2; 470 if (gfGuestCapsLockPressed != fCapsLock) 471 guGuestCapsLockAdaptionCnt = 2; 469 472 gfGuestNumLockPressed = fNumLock; 473 gfGuestCapsLockPressed = fCapsLock; 470 474 gfGuestScrollLockPressed = fScrollLock; 471 gfGuestCapsLockPressed = fCapsLock;472 475 return S_OK; 473 476 } … … 2793 2796 } 2794 2797 2795 /* 2796 * Some keyboards (e.g. the one of mine T60) don't send a NumLock scan code on every 2797 * press of the key. Both the guest and the host should agree on the NumLock state. 2798 * If they differ, we try to alter the guest NumLock state by sending the NumLock key 2799 * scancode. We will get a feedback through the KBD_CMD_SET_LEDS command if the guest 2800 * tries to set/clear the NumLock LED. If a (silly) guest doesn't change the LED, don't 2801 * bother him with NumLock scancodes. At least our BIOS, Linux and Windows handle the 2802 * NumLock LED well. 2803 */ 2804 if ( guGuestNumLockAdaptionCnt 2805 && (gfGuestNumLockPressed ^ !!(SDL_GetModState() & KMOD_NUM))) 2806 { 2807 guGuestNumLockAdaptionCnt--; 2808 gKeyboard->PutScancode(0x45); 2809 gKeyboard->PutScancode(0x45 | 0x80); 2798 if (ev->type != SDL_KEYDOWN) 2799 { 2800 /* 2801 * Some keyboards (e.g. the one of mine T60) don't send a NumLock scan code on every 2802 * press of the key. Both the guest and the host should agree on the NumLock state. 2803 * If they differ, we try to alter the guest NumLock state by sending the NumLock key 2804 * scancode. We will get a feedback through the KBD_CMD_SET_LEDS command if the guest 2805 * tries to set/clear the NumLock LED. If a (silly) guest doesn't change the LED, don't 2806 * bother him with NumLock scancodes. At least our BIOS, Linux and Windows handle the 2807 * NumLock LED well. 2808 */ 2809 if ( guGuestNumLockAdaptionCnt 2810 && (gfGuestNumLockPressed ^ !!(SDL_GetModState() & KMOD_NUM))) 2811 { 2812 guGuestNumLockAdaptionCnt--; 2813 gKeyboard->PutScancode(0x45); 2814 gKeyboard->PutScancode(0x45 | 0x80); 2815 } 2816 #if 0 /* For some reason SDL_GetModState() does not return KMOD_CAPS correctly */ 2817 if ( guGuestCapsLockAdaptionCnt 2818 && (gfGuestCapsLockPressed ^ !!(SDL_GetModState() & KMOD_CAPS))) 2819 { 2820 guGuestCapsLockAdaptionCnt--; 2821 gKeyboard->PutScancode(0x3a); 2822 gKeyboard->PutScancode(0x3a | 0x80); 2823 } 2824 #endif 2810 2825 } 2811 2826 -
trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h
r245 r255 200 200 bool mfCapsLock; 201 201 long muNumLockAdaptionCnt; 202 long muCapsLockAdaptionCnt; 202 203 203 204 QTimer *resize_hint_timer; -
trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp
r245 r255 198 198 { 199 199 public: 200 ModifierKeyChangeEvent(bool fNumLock, bool f ScrollLock, bool fCapsLock) :200 ModifierKeyChangeEvent(bool fNumLock, bool fCapsLock, bool fScrollLock) : 201 201 QEvent ((QEvent::Type) VBoxDefs::ModifierKeyChangeEventType), 202 mfNumLock(fNumLock), mf ScrollLock(fScrollLock), mfCapsLock(fCapsLock) {}202 mfNumLock(fNumLock), mfCapsLock(fCapsLock), mfScrollLock(fScrollLock) {} 203 203 bool NumLock() const { return mfNumLock; } 204 bool CapsLock() const { return mfCapsLock; } 204 205 bool ScrollLock() const { return mfScrollLock; } 205 bool CapsLock() const { return mfCapsLock; }206 206 private: 207 bool mfNumLock, mf ScrollLock, mfCapsLock;207 bool mfNumLock, mfCapsLock, mfScrollLock; 208 208 }; 209 209 … … 292 292 } 293 293 294 STDMETHOD(OnKeyboardLedsChange)(BOOL fNumLock, BOOL f ScrollLock, BOOL fCapsLock)294 STDMETHOD(OnKeyboardLedsChange)(BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock) 295 295 { 296 296 QApplication::postEvent ( 297 view, new ModifierKeyChangeEvent (fNumLock, f ScrollLock, fCapsLock));297 view, new ModifierKeyChangeEvent (fNumLock, fCapsLock, fScrollLock)); 298 298 return S_OK; 299 299 } … … 350 350 , autoresize_guest (false) 351 351 , muNumLockAdaptionCnt (2) 352 , muCapsLockAdaptionCnt (2) 352 353 , mode (rm) 353 354 { … … 784 785 if (me->NumLock() != mfNumLock) 785 786 muNumLockAdaptionCnt = 2; 787 if (me->CapsLock() != mfCapsLock) 788 muCapsLockAdaptionCnt = 2; 786 789 mfNumLock = me->NumLock(); 790 mfCapsLock = me->CapsLock(); 787 791 mfScrollLock = me->ScrollLock(); 788 mfCapsLock = me->CapsLock();789 792 return true; 790 793 } … … 1289 1292 void VBoxConsoleView::FixModifierState(LONG *codes, uint *count) 1290 1293 { 1291 unsigned uKeyMaskNum = 0, uKeyMaskCaps = 0, uKeyMaskScroll = 0;1292 1293 1294 #if defined(Q_WS_X11) 1294 1295 … … 1296 1297 int iDummy3, iDummy4, iDummy5, iDummy6; 1297 1298 unsigned uMask; 1299 unsigned uKeyMaskNum = 0, uKeyMaskCaps = 0, uKeyMaskScroll = 0; 1298 1300 1299 1301 uKeyMaskCaps = LockMask; … … 1321 1323 codes[(*count)++] = 0x45 | 0x80; 1322 1324 } 1325 if (muCapsLockAdaptionCnt && (mfCapsLock ^ !!(uMask & uKeyMaskCaps))) 1326 { 1327 muCapsLockAdaptionCnt--; 1328 codes[(*count)++] = 0x3a; 1329 codes[(*count)++] = 0x3a | 0x80; 1330 } 1323 1331 1324 1332 #elif defined(Q_WS_WIN32) … … 1329 1337 codes[(*count)++] = 0x45; 1330 1338 codes[(*count)++] = 0x45 | 0x80; 1339 } 1340 if (muCapsLockAdaptionCnt && (mfCapsLock ^ !!(GetKeyState(VK_CAPITAL)))) 1341 { 1342 muCapsLockAdaptionCnt--; 1343 codes[(*count)++] = 0x3a; 1344 codes[(*count)++] = 0x3a | 0x80; 1331 1345 } 1332 1346 … … 1388 1402 else 1389 1403 { 1404 if (flags & KeyPressed) 1405 { 1406 // Check if the guest has the same view on the modifier keys (NumLock, 1407 // CapsLock, ScrollLock) as the X server. If not, send KeyPress events 1408 // to synchronize the state. 1409 FixModifierState (codes, &count); 1410 } 1411 1390 1412 // process the scancode and update the table of pressed keys 1391 1413 uint8_t what_pressed = IsKeyPressed; … … 1415 1437 else 1416 1438 keys_pressed [scan] &= ~IsKbdCaptured; 1417 1418 // Check if the guest has the same view on the modifier keys (NumLock,1419 // CapsLock, ScrollLock) as the X server. If not, send KeyPress events1420 // to synchronize the state.1421 FixModifierState (codes, &count);1422 1423 1439 } 1424 1440 } -
trunk/src/VBox/Main/include/DisplayImpl.h
r132 r255 97 97 } 98 98 99 STDMETHOD(OnKeyboardLedsChange)(BOOL fNumLock, BOOL f ScrollLock, BOOL fCapsLock)99 STDMETHOD(OnKeyboardLedsChange)(BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock) 100 100 { 101 101 return S_OK;
Note:
See TracChangeset
for help on using the changeset viewer.