VirtualBox

Changeset 48788 in vbox


Ignore:
Timestamp:
Oct 1, 2013 8:09:35 AM (11 years ago)
Author:
vboxsync
Message:

OS X host: leds sync: some KBD devices might freeze after LEDs manipulations, filter out all the devices which were not verified to work reliably with our sync code.

File:
1 edited

Legend:

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

    r48772 r48788  
    4040# include <IOKit/IOCFPlugIn.h>
    4141# include <IOKit/hid/IOHIDUsageTables.h>
    42 # include <IOKit/usb/USB.h>
    4342# include <CoreFoundation/CoreFoundation.h>
    4443#endif
     44# include <IOKit/usb/USB.h>
    4545#include <IOKit/hid/IOHIDLib.h>
    4646#include <ApplicationServices/ApplicationServices.h>
     
    14641464}
    14651465
     1466/** Some keyboard devices might freeze after LEDs manipulation. We filter out such devices here.
     1467 * In the list below, devices which verified to be stable against LEDs manipulation.
     1468 * If you want to add new device, add it here. Currently, we only filter devices by Vendor ID.
     1469 * In future it might make sense to take Product ID into account as well. */
     1470static bool darwinHidDeviceSupported(IOHIDDeviceRef pHidDeviceRef)
     1471{
     1472    bool      fSupported = false;
     1473    CFTypeRef pNumberRef;
     1474    uint32_t  vendorId = 0;
     1475
     1476    pNumberRef = IOHIDDeviceGetProperty(pHidDeviceRef, CFSTR(kIOHIDVendorIDKey));
     1477    if (pNumberRef)
     1478    {
     1479        if (CFGetTypeID(pNumberRef) == CFNumberGetTypeID())
     1480        {
     1481            if (CFNumberGetValue((CFNumberRef)pNumberRef, kCFNumberSInt32Type, &vendorId))
     1482            {
     1483                switch (vendorId)
     1484                {
     1485                    case kIOUSBVendorIDAppleComputer:   /** Apple devices always in the list */
     1486                    case 0x03F0:                        /** Hewlett-Packard (verified with model KU-0316) */
     1487                        fSupported = true;
     1488                        break;
     1489                }
     1490
     1491                Log2(("HID device Vendor ID 0x%X %s in the list of supported devices.\n", vendorId, (fSupported ? "is" : "is not")));
     1492            }
     1493        }
     1494    }
     1495
     1496    return fSupported;
     1497}
     1498
    14661499#endif // !VBOX_WITH_KBD_LEDS_SYNC
    14671500
     
    15081541                                    for (CFIndex i = 0; i < hidsState->cDevices; i++)
    15091542                                    {
    1510                                         if (IOHIDDeviceConformsTo(hidsState->hidDevicesCollection[i], kHIDPage_GenericDesktop, kHIDUsage_GD_Keyboard))
     1543                                        if (IOHIDDeviceConformsTo(hidsState->hidDevicesCollection[i], kHIDPage_GenericDesktop, kHIDUsage_GD_Keyboard)
     1544                                         && darwinHidDeviceSupported(hidsState->hidDevicesCollection[i]))
    15111545                                        {
    15121546                                            rc = darwinGetDeviceLedsState(hidsState->hidDevicesCollection[i],
     
    16041638                }
    16051639
    1606                 IOHIDDeviceRegisterInputValueCallback(hidsState->hidDevicesCollection[i], NULL, NULL);
    1607                 IOHIDDeviceUnscheduleFromRunLoop(hidsState->hidDevicesCollection[i], CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
     1640                /* Only supported devices have subscription to input callbacks. */
     1641                if (darwinHidDeviceSupported(hidsState->hidDevicesCollection[i]))
     1642                {
     1643                    IOHIDDeviceRegisterInputValueCallback(hidsState->hidDevicesCollection[i], NULL, NULL);
     1644                    IOHIDDeviceUnscheduleFromRunLoop(hidsState->hidDevicesCollection[i], CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
     1645                }
    16081646            }
    16091647        }
     
    16771715                            for (CFIndex i = 0; i < cDevices; i++)
    16781716                            {
    1679                                 if (IOHIDDeviceConformsTo(hidDevicesCollection[i], kHIDPage_GenericDesktop, kHIDUsage_GD_Keyboard))
     1717                                if (IOHIDDeviceConformsTo(hidDevicesCollection[i], kHIDPage_GenericDesktop, kHIDUsage_GD_Keyboard)
     1718                                 && darwinHidDeviceSupported(hidDevicesCollection[i]))
    16801719                                {
    16811720                                    rc = darwinSetDeviceLedsState(hidDevicesCollection[i], elementMatchingDict,
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