mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
adding input monitoring priviledge detect for mac
This commit is contained in:
34
src/platform/macos.mm
Normal file
34
src/platform/macos.mm
Normal file
@@ -0,0 +1,34 @@
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <IOKit/hidsystem/IOHIDLib.h>
|
||||
|
||||
extern "C" bool InputMonitoringAuthStatus(bool prompt) {
|
||||
if (@available(macos 10.15, *)) {
|
||||
IOHIDAccessType theType = IOHIDCheckAccess(kIOHIDRequestTypeListenEvent);
|
||||
NSLog(@"IOHIDCheckAccess = %d", theType);
|
||||
switch (theType) {
|
||||
case kIOHIDAccessTypeGranted:
|
||||
return true;
|
||||
break;
|
||||
case kIOHIDAccessTypeDenied: {
|
||||
if (prompt) {
|
||||
NSString *urlString = @"x-apple.systempreferences:com.apple.preference.security?Privacy_ListenEvent";
|
||||
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:urlString]];
|
||||
}
|
||||
break;
|
||||
}
|
||||
case kIOHIDAccessTypeUnknown: {
|
||||
if (prompt) {
|
||||
bool result = IOHIDRequestAccess(kIOHIDRequestTypeListenEvent);
|
||||
NSLog(@"IOHIDRequestAccess result = %d", result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user