VirtualBox

Changeset 47675 in vbox for trunk


Ignore:
Timestamp:
Aug 12, 2013 3:12:34 PM (11 years ago)
Author:
vboxsync
Message:

UsbKbd: Report LED state changes.

File:
1 edited

Legend:

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

    r47316 r47675  
    861861
    862862/**
     863 * Handles a SET_REPORT request sent to the default control pipe. Note
     864 * that unrecognized requests are ignored without reporting an error.
     865 */
     866static void usbHidSetReport(PUSBHID pThis, PVUSBURB pUrb)
     867{
     868    PVUSBSETUP pSetup = (PVUSBSETUP)&pUrb->abData[0];
     869    Assert(pSetup->bRequest == HID_REQ_SET_REPORT);
     870
     871    /* The LED report is the 3rd report, ID 0 (-> wValue 0x200). */
     872    if (pSetup->wIndex == 0 && pSetup->wLength == 1 && pSetup->wValue == 0x200)
     873    {
     874        PDMKEYBLEDS enmLeds = PDMKEYBLEDS_NONE;
     875        uint8_t     u8LEDs = pUrb->abData[sizeof(*pSetup)];
     876        LogFlowFunc(("Setting keybooard LEDs to u8LEDs=%02X\n", u8LEDs));
     877
     878        /* Translate LED state to PDM format and send upstream. */
     879        if (u8LEDs & 0x01)
     880            enmLeds = (PDMKEYBLEDS)(enmLeds | PDMKEYBLEDS_NUMLOCK);
     881        if (u8LEDs & 0x02)
     882            enmLeds = (PDMKEYBLEDS)(enmLeds | PDMKEYBLEDS_CAPSLOCK);
     883        if (u8LEDs & 0x04)
     884            enmLeds = (PDMKEYBLEDS)(enmLeds | PDMKEYBLEDS_SCROLLLOCK);
     885
     886        pThis->Lun0.pDrv->pfnLedStatusChange(pThis->Lun0.pDrv, enmLeds);
     887    }
     888}
     889
     890/**
    863891 * Sends a state report to the host if there is a pending URB.
    864892 */
     
    12551283                        pUrb->abData[sizeof(*pSetup)] = pThis->bIdle;
    12561284                        return usbHidCompleteOk(pThis, pUrb, 1);
     1285                    }
     1286                    break;
     1287                }
     1288                break;
     1289            }
     1290            case HID_REQ_SET_REPORT:
     1291            {
     1292                switch (pSetup->bmRequestType)
     1293                {
     1294                    case VUSB_TO_INTERFACE | VUSB_REQ_CLASS | VUSB_DIR_TO_DEVICE:
     1295                    {
     1296                        Log(("usbHid: SET_REPORT wValue=%#x wIndex=%#x wLength=%#x\n", pSetup->wValue, pSetup->wIndex, pSetup->wLength));
     1297                        usbHidSetReport(pThis, pUrb);
     1298                        return usbHidCompleteOk(pThis, pUrb, 0);
    12571299                    }
    12581300                    break;
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