VirtualBox

Changeset 49090 in vbox for trunk/src/VBox/Frontends


Ignore:
Timestamp:
Oct 14, 2013 6:33:39 PM (11 years ago)
Author:
vboxsync
Message:

OS X host: leds sync: resync last affected HID device with the guest state at the point where Carbon input callback is issued; now all things should in sync.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/DarwinKeyboard.cpp

    r49049 r49090  
    311311    IOHIDDeviceRef    pDevice;              /** A reference to IOKit HID device */
    312312    VBoxLedState_t    LED;                  /** LED states */
    313     CFMutableArrayRef pStorageArray;        /** A reference to array where VBoxKbdState_t instance is stored */
     313    void             *pParentContainer;     /** A pointer to a VBoxHidsState_t instance where VBoxKbdState_t instance is stored */
    314314    CFIndex           idxPosition;          /** Position in global storage (used to simplify CFArray navigation when removing detached device) */
    315315} VBoxKbdState_t;
     
    14761476    {
    14771477        Log2(("carbon event: caps=%s, num=%s\n", VBOX_BOOL_TO_STR_STATE(fCaps), VBOX_BOOL_TO_STR_STATE(fNum)));
    1478         if (g_LastTouchedState)
    1479         {
    1480             g_LastTouchedState->LED.fCapsLockOn = fCaps;
    1481             g_LastTouchedState->LED.fNumLockOn  = fNum;
     1478
     1479        VBoxKbdState_t  *pKbd = g_LastTouchedState;
     1480        if (pKbd)
     1481        {
     1482            pKbd->LED.fCapsLockOn = fCaps;
     1483            pKbd->LED.fNumLockOn  = fNum;
     1484
     1485            /* Silently resync last touched KBD device */
     1486            VBoxHidsState_t *pHidState = (VBoxHidsState_t *)pKbd->pParentContainer;
     1487            if (pHidState)
     1488            {
     1489                CFDictionaryRef elementMatchingDict = darwinQueryLedElementMatchingDictionary();
     1490                if (elementMatchingDict)
     1491                {
     1492                    (void)darwinSetDeviceLedsState(pKbd->pDevice, elementMatchingDict, pHidState->guestState.fNumLockOn,
     1493                        pHidState->guestState.fCapsLockOn, pHidState->guestState.fScrollLockOn);
     1494
     1495                    CFRelease(elementMatchingDict);
     1496                }
     1497            }
    14821498
    14831499            /* Forget device */
     
    14951511    (void)unused1;
    14961512
    1497     VBoxKbdState_t *pKbd = (VBoxKbdState_t *)pData;
    1498 
    1499     AssertReturnVoid(pKbd);
    1500     AssertReturnVoid(pKbd->pStorageArray);
     1513    VBoxKbdState_t  *pKbd      = (VBoxKbdState_t  *)pData;                  AssertReturnVoid(pKbd);
     1514    VBoxHidsState_t *pHidState = (VBoxHidsState_t *)pKbd->pParentContainer; AssertReturnVoid(pHidState);
     1515
     1516    AssertReturnVoid(pHidState->pDeviceCollection);
    15011517
    15021518    Log2(("Forget KBD %d\n", (int)pKbd->idxPosition));
    1503     CFArrayRemoveValueAtIndex(pKbd->pStorageArray, pKbd->idxPosition);
     1519    CFArrayRemoveValueAtIndex(pHidState->pDeviceCollection, pKbd->idxPosition);
    15041520    free(pKbd);
    15051521}
     
    15351551            {
    15361552                pKbd->pDevice = pDevice;
    1537                 pKbd->pStorageArray = pHidState->pDeviceCollection;
     1553                pKbd->pParentContainer = (void *)pHidState;
    15381554                pKbd->idxPosition = CFArrayGetCount(pHidState->pDeviceCollection);
    15391555
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