From 219ceacc7a5cda32f0d33a35b5a4907cc0ae8621 Mon Sep 17 00:00:00 2001 From: James Turner Date: Mon, 24 Feb 2020 11:32:57 +0000 Subject: [PATCH] macOS Catalina device filtering --- src/Input/FGMacOSXEventInput.cxx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Input/FGMacOSXEventInput.cxx b/src/Input/FGMacOSXEventInput.cxx index b8dc29eee..d7f6a33f4 100644 --- a/src/Input/FGMacOSXEventInput.cxx +++ b/src/Input/FGMacOSXEventInput.cxx @@ -252,8 +252,21 @@ void FGMacOSXEventInputPrivate::matchedDevice(IOHIDDeviceRef device) std::string manufacturer = getDeviceStringProperty(device, CFSTR(kIOHIDManufacturerKey)); std::string serial = getDeviceStringProperty(device, CFSTR(kIOHIDSerialNumberKey)); +// filter out keyboard and mouse devices : this is especially important for +// Catalina TCC hardening to avoid secuirty alerts + int usagePage, usage; + getDeviceIntProperty(device, CFSTR(kIOHIDPrimaryUsagePageKey), usagePage); + getDeviceIntProperty(device, CFSTR(kIOHIDPrimaryUsageKey), usage); + + if (usagePage == kHIDPage_GenericDesktop) { + if ((usage == kHIDUsage_GD_Keyboard) || (usage == kHIDUsage_GD_Mouse)) { + SG_LOG(SG_INPUT, SG_INFO, "MacOSX-EventInput: skipping device:" << productName << "( from " << manufacturer << ") becuase it is a keyboard or mouse"); + return; + } + } + SG_LOG(SG_INPUT, SG_DEBUG, "MacOSX-EventInput: matched device:" << productName << "( from " << manufacturer << ")"); - + // allocate a Mac input device, and add to the base class to see if we have // a config