VirtualBox

Changeset 95427 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jun 29, 2022 1:13:38 PM (3 years ago)
Author:
vboxsync
Message:

UsbKbd: Reshuffled code to avoid assertion.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Input/UsbKbd.cpp

    r93115 r95427  
    11941194
    11951195    iKeyCode = usbHidToInternalCode(idUsage);
    1196     AssertReturn(iKeyCode > 0 && iKeyCode <= VBOX_USB_MAX_USAGE_CODE, VERR_INTERNAL_ERROR);
     1196    AssertReturn((iKeyCode > 0 && iKeyCode <= VBOX_USB_MAX_USAGE_CODE) || (idUsage & PDMIKBDPORT_RELEASE_KEYS), VERR_INTERNAL_ERROR);
    11971197
    11981198    RTCritSectEnter(&pThis->CritSect);
    11991199
    1200     LogFlowFunc(("key %s: %08X (iKeyCode 0x%x)\n", fKeyDown ? "down" : "up", idUsage, iKeyCode));
    1201 
    1202     /*
    1203      * Due to host key repeat, we can get key events for keys which are
    1204      * already depressed. Drop those right here.
    1205      */
    1206     if (fKeyDown && pThis->abDepressedKeys[iKeyCode])
    1207         fHaveEvent = false;
    1208 
    1209     /* If there is already a pending event, we won't accept a new one yet. */
    1210     if (pIf->fHasPendingChanges && fHaveEvent)
    1211     {
    1212         rc = VERR_TRY_AGAIN;
    1213     }
    1214     else if (fHaveEvent)
    1215     {
    1216         if (RT_LIKELY(!(idUsage & PDMIKBDPORT_RELEASE_KEYS)))
     1200    if (RT_LIKELY(!(idUsage & PDMIKBDPORT_RELEASE_KEYS)))
     1201    {
     1202        LogFlowFunc(("key %s: %08X (iKeyCode 0x%x)\n", fKeyDown ? "down" : "up", idUsage, iKeyCode));
     1203
     1204        /*
     1205         * Due to host key repeat, we can get key events for keys which are
     1206         * already depressed. Drop those right here.
     1207         */
     1208        if (fKeyDown && pThis->abDepressedKeys[iKeyCode])
     1209            fHaveEvent = false;
     1210
     1211        /* If there is already a pending event, we won't accept a new one yet. */
     1212        if (pIf->fHasPendingChanges && fHaveEvent)
     1213        {
     1214            rc = VERR_TRY_AGAIN;
     1215        }
     1216        else if (fHaveEvent)
    12171217        {
    12181218            /* Regular key event - update keyboard state. */
     
    12211221            else
    12221222                pThis->abDepressedKeys[iKeyCode] = 0;
     1223
     1224            /*
     1225             * Try sending a report. Note that we already decided to consume the
     1226             * event regardless of whether a URB is available or not. If it's not,
     1227             * we will simply not accept any further events.
     1228             */
     1229            usbHidSendReport(pThis, pIf);
    12231230        }
    1224         else
    1225         {
    1226             /* Clear all currently depressed keys. */
    1227             RT_ZERO(pThis->abDepressedKeys);
    1228         }
    1229 
    1230         /*
    1231          * Try sending a report. Note that we already decided to consume the
    1232          * event regardless of whether a URB is available or not. If it's not,
    1233          * we will simply not accept any further events.
    1234          */
    1235         usbHidSendReport(pThis, pIf);
     1231    }
     1232    else
     1233    {
     1234        LogFlowFunc(("Release all keys.\n"));
     1235
     1236        /* Clear all currently depressed keys. */
     1237        RT_ZERO(pThis->abDepressedKeys);
    12361238    }
    12371239
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