mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-28 15:53:55 -04:00
device: Do not enumerate keyboard/mouse devices on macOS by default
This causes an annoying "this app would like to receive keystrokes from any application" alert to be shown Enable iokit-scan-mouse-devices or iokit-scan-keyboard-devices to restore the old behavior
This commit is contained in:
parent
d66ef59ecc
commit
38bea01dab
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user