diff --git a/panda/src/device/ioKitInputDeviceManager.cxx b/panda/src/device/ioKitInputDeviceManager.cxx index 3f1c807469..aa8d67301c 100644 --- a/panda/src/device/ioKitInputDeviceManager.cxx +++ b/panda/src/device/ioKitInputDeviceManager.cxx @@ -16,6 +16,18 @@ #if defined(__APPLE__) && !defined(CPPPARSER) +static ConfigVariableBool iokit_scan_mouse_devices +("iokit-scan-mouse-devices", false, + PRC_DESC("Set this to true to enable capturing raw mouse data via IOKit on " + "macOS. This is disabled by default because newer macOS versions " + "will prompt the user explicitly for permissions when this is on.")); + +static ConfigVariableBool iokit_scan_keyboard_devices +("iokit-scan-keyboard-devices", false, + PRC_DESC("Set this to true to enable capturing raw keyboard data via IOKit on " + "macOS. This is disabled by default because newer macOS versions " + "will prompt the user explicitly for permissions when this is on.")); + /** * Initializes the input device manager by scanning which devices are currently * connected and setting up any platform-dependent structures necessary for @@ -34,15 +46,22 @@ IOKitInputDeviceManager() { int page = kHIDPage_GenericDesktop; int usages[] = {kHIDUsage_GD_GamePad, kHIDUsage_GD_Joystick, - kHIDUsage_GD_Mouse, - kHIDUsage_GD_Keyboard, - kHIDUsage_GD_MultiAxisController, 0}; - int *usage = usages; + kHIDUsage_GD_MultiAxisController, + 0, 0, 0}; + + int num_usages = 3; + if (iokit_scan_mouse_devices) { + usages[num_usages++] = kHIDUsage_GD_Mouse; + } + if (iokit_scan_keyboard_devices) { + usages[num_usages++] = kHIDUsage_GD_Keyboard; + } // This giant mess is necessary to create an array of match dictionaries // that will match the devices we're interested in. CFMutableArrayRef match = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks); nassertv(match); + int *usage = usages; while (*usage) { CFMutableDictionaryRef dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); CFNumberRef page_ref = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page);