VirtualBox

Changeset 255 in vbox


Ignore:
Timestamp:
Jan 23, 2007 9:33:50 PM (18 years ago)
Author:
vboxsync
Message:

same magic with caps lock

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/pdm.h

    r161 r255  
    593593    /** Num Lock */
    594594    PDMKEYBLEDS_NUMLOCK          = 0x0001,
     595    /** Caps Lock */
     596    PDMKEYBLEDS_CAPSLOCK         = 0x0002,
    595597    /** Scroll Lock */
    596     PDMKEYBLEDS_SCROLLLOCK       = 0x0002,
    597     /** Caps Lock */
    598     PDMKEYBLEDS_CAPSLOCK         = 0x0004
     598    PDMKEYBLEDS_SCROLLLOCK       = 0x0004
    599599} PDMKEYBLEDS;
    600600
  • trunk/src/VBox/Frontends/VBoxSDL/VBoxSDL.cpp

    r153 r255  
    166166static BOOL gfGuestScrollLockPressed = FALSE;
    167167static int  guGuestNumLockAdaptionCnt = 2;
     168static int  guGuestCapsLockAdaptionCnt = 2;
    168169
    169170/** modifier keypress status (scancode as index) */
     
    462463    }
    463464
    464     STDMETHOD(OnKeyboardLedsChange)(BOOL fNumLock, BOOL fScrollLock, BOOL fCapsLock)
     465    STDMETHOD(OnKeyboardLedsChange)(BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock)
    465466    {
    466467        /* Don't bother the guest with NumLock scancodes if he doesn't set the NumLock LED */
    467468        if (gfGuestNumLockPressed != fNumLock)
    468469            guGuestNumLockAdaptionCnt = 2;
     470        if (gfGuestCapsLockPressed != fCapsLock)
     471            guGuestCapsLockAdaptionCnt = 2;
    469472        gfGuestNumLockPressed    = fNumLock;
     473        gfGuestCapsLockPressed   = fCapsLock;
    470474        gfGuestScrollLockPressed = fScrollLock;
    471         gfGuestCapsLockPressed   = fCapsLock;
    472475        return S_OK;
    473476    }
     
    27932796    }
    27942797
    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
    28102825    }
    28112826
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h

    r245 r255  
    200200    bool mfCapsLock;
    201201    long muNumLockAdaptionCnt;
     202    long muCapsLockAdaptionCnt;
    202203
    203204    QTimer *resize_hint_timer;
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp

    r245 r255  
    198198{
    199199public:
    200     ModifierKeyChangeEvent(bool fNumLock, bool fScrollLock, bool fCapsLock) :
     200    ModifierKeyChangeEvent(bool fNumLock, bool fCapsLock, bool fScrollLock) :
    201201        QEvent ((QEvent::Type) VBoxDefs::ModifierKeyChangeEventType),
    202         mfNumLock(fNumLock), mfScrollLock(fScrollLock), mfCapsLock(fCapsLock) {}
     202        mfNumLock(fNumLock), mfCapsLock(fCapsLock), mfScrollLock(fScrollLock) {}
    203203    bool NumLock()    const { return mfNumLock; }
     204    bool CapsLock()   const { return mfCapsLock; }
    204205    bool ScrollLock() const { return mfScrollLock; }
    205     bool CapsLock()   const { return mfCapsLock; }
    206206private:
    207     bool mfNumLock, mfScrollLock, mfCapsLock;
     207    bool mfNumLock, mfCapsLock, mfScrollLock;
    208208};
    209209
     
    292292    }
    293293
    294     STDMETHOD(OnKeyboardLedsChange)(BOOL fNumLock, BOOL fScrollLock, BOOL fCapsLock)
     294    STDMETHOD(OnKeyboardLedsChange)(BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock)
    295295    {
    296296        QApplication::postEvent (
    297             view, new ModifierKeyChangeEvent (fNumLock, fScrollLock, fCapsLock));
     297            view, new ModifierKeyChangeEvent (fNumLock, fCapsLock, fScrollLock));
    298298        return S_OK;
    299299    }
     
    350350    , autoresize_guest (false)
    351351    , muNumLockAdaptionCnt (2)
     352    , muCapsLockAdaptionCnt (2)
    352353    , mode (rm)
    353354{
     
    784785                if (me->NumLock() != mfNumLock)
    785786                    muNumLockAdaptionCnt = 2;
     787                if (me->CapsLock() != mfCapsLock)
     788                    muCapsLockAdaptionCnt = 2;
    786789                mfNumLock    = me->NumLock();
     790                mfCapsLock   = me->CapsLock();
    787791                mfScrollLock = me->ScrollLock();
    788                 mfCapsLock   = me->CapsLock();
    789792                return true;
    790793            }
     
    12891292void VBoxConsoleView::FixModifierState(LONG *codes, uint *count)
    12901293{
    1291     unsigned uKeyMaskNum = 0, uKeyMaskCaps = 0, uKeyMaskScroll = 0;
    1292 
    12931294#if defined(Q_WS_X11)
    12941295
     
    12961297    int      iDummy3, iDummy4, iDummy5, iDummy6;
    12971298    unsigned uMask;
     1299    unsigned uKeyMaskNum = 0, uKeyMaskCaps = 0, uKeyMaskScroll = 0;
    12981300
    12991301    uKeyMaskCaps          = LockMask;
     
    13211323        codes[(*count)++] = 0x45 | 0x80;
    13221324    }
     1325    if (muCapsLockAdaptionCnt && (mfCapsLock ^ !!(uMask & uKeyMaskCaps)))
     1326    {
     1327        muCapsLockAdaptionCnt--;
     1328        codes[(*count)++] = 0x3a;
     1329        codes[(*count)++] = 0x3a | 0x80;
     1330    }
    13231331
    13241332#elif defined(Q_WS_WIN32)
     
    13291337        codes[(*count)++] = 0x45;
    13301338        codes[(*count)++] = 0x45 | 0x80;
     1339    }
     1340    if (muCapsLockAdaptionCnt && (mfCapsLock ^ !!(GetKeyState(VK_CAPITAL))))
     1341    {
     1342        muCapsLockAdaptionCnt--;
     1343        codes[(*count)++] = 0x3a;
     1344        codes[(*count)++] = 0x3a | 0x80;
    13311345    }
    13321346
     
    13881402        else
    13891403        {
     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
    13901412            // process the scancode and update the table of pressed keys
    13911413            uint8_t what_pressed = IsKeyPressed;
     
    14151437            else
    14161438                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 events
    1420             // to synchronize the state.
    1421             FixModifierState (codes, &count);
    1422            
    14231439        }
    14241440    }
  • trunk/src/VBox/Main/include/DisplayImpl.h

    r132 r255  
    9797    }
    9898
    99     STDMETHOD(OnKeyboardLedsChange)(BOOL fNumLock, BOOL fScrollLock, BOOL fCapsLock)
     99    STDMETHOD(OnKeyboardLedsChange)(BOOL fNumLock, BOOL fCapsLock, BOOL fScrollLock)
    100100    {
    101101        return S_OK;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette