Changeset 49012 in vbox
- Timestamp:
- Oct 9, 2013 3:36:39 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 89754
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/platform/darwin/DarwinKeyboard.cpp
r48978 r49012 22 22 *******************************************************************************/ 23 23 #define LOG_GROUP LOG_GROUP_GUI 24 //#define VBOX_WITH_KBD_LEDS_SYNC24 #define VBOX_WITH_KBD_LEDS_SYNC 25 25 26 26 #include "DarwinKeyboard.h" … … 292 292 #ifdef VBOX_WITH_KBD_LEDS_SYNC 293 293 /* HID LEDs synchronization data: LED states. */ 294 typedef struct VBox HidLeds_t {294 typedef struct VBoxKbdState_t { 295 295 bool fNumLockOn; 296 296 bool fCapsLockOn; 297 297 bool fScrollLockOn; 298 } VBoxHidLeds_t; 298 bool fAttached; 299 } VBoxKbdState_t; 299 300 300 301 /* HID LEDs synchronization data: IOKit specific data. */ … … 302 303 IOHIDManagerRef hidManagerRef; 303 304 IOHIDDeviceRef *hidDevicesCollection; 304 VBox HidLeds_t *hidLedsCollection;305 VBoxKbdState_t *hidLedsCollection; 305 306 CFIndex cDevices; 306 307 CFMachPortRef pTapRef; … … 309 310 310 311 /* A *sync* between IOKit and Carbon callbacks. */ 311 static VBox HidLeds_t *g_LastTouchedState;312 static VBoxKbdState_t *g_LastTouchedState; 312 313 #endif // !VBOX_WITH_KBD_LEDS_SYNC 313 314 … … 1379 1380 } 1380 1381 1382 static void darwinHidRemovalCallback(void *pData, IOReturn unused, void *unused1) 1383 { 1384 (void)unused; 1385 (void)unused1; 1386 1387 VBoxKbdState_t *pState = (VBoxKbdState_t *)pData; 1388 1389 if (pState) 1390 { 1391 pState->fAttached = false; 1392 } 1393 } 1394 1381 1395 /** IOKit key press callback. Triggered before Carbon callback. */ 1382 1396 static void darwinHidInputCallback(void *pData, IOReturn unused, void *unused1, IOHIDValueRef valueRef) … … 1395 1409 { 1396 1410 Log2(("A modifier key has been pressed\n")); 1397 g_LastTouchedState = (VBox HidLeds_t *)pData;1411 g_LastTouchedState = (VBoxKbdState_t *)pData; 1398 1412 } 1399 1413 … … 1557 1571 if (hidsState->hidDevicesCollection) 1558 1572 { 1559 hidsState->hidLedsCollection = (VBox HidLeds_t *)malloc((size_t)hidsState->cDevices * sizeof(VBoxHidLeds_t));1573 hidsState->hidLedsCollection = (VBoxKbdState_t *)malloc((size_t)hidsState->cDevices * sizeof(VBoxKbdState_t)); 1560 1574 if (hidsState->hidLedsCollection) 1561 1575 { … … 1585 1599 } 1586 1600 1601 /* Mark a device as currently attached. If device will be removed (physically) 1602 * before current state is applied (by DarwinHidDevicesApplyAndReleaseLedsState()), we mark 1603 * it as detached one in a removal callback. We cannot access device which was detached 1604 * because IOKit released the resources and this will trigger a SEGFAULT. */ 1605 hidsState->hidLedsCollection[i].fAttached = true; 1606 1607 /* Register per-device removal callback */ 1608 IOHIDDeviceRegisterRemovalCallback(hidsState->hidDevicesCollection[i], darwinHidRemovalCallback, (void *)&hidsState->hidLedsCollection[i]); 1609 1587 1610 /* Register per-device input callback */ 1588 1611 IOHIDDeviceRegisterInputValueCallback(hidsState->hidDevicesCollection[i], darwinHidInputCallback, (void *)&hidsState->hidLedsCollection[i]); … … 1657 1680 { 1658 1681 /* Cycle through supported devices only. */ 1659 if (IOHIDDeviceConformsTo(hidsState->hidDevicesCollection[i], kHIDPage_GenericDesktop, kHIDUsage_GD_Keyboard) 1682 if (hidsState->hidLedsCollection[i].fAttached 1683 && IOHIDDeviceConformsTo(hidsState->hidDevicesCollection[i], kHIDPage_GenericDesktop, kHIDUsage_GD_Keyboard) 1660 1684 && darwinHidDeviceSupported(hidsState->hidDevicesCollection[i])) 1661 1685 {
Note:
See TracChangeset
for help on using the changeset viewer.