From 4c243235309dd52fd5bb4469065fedcf417fb7b9 Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sun, 29 Dec 2019 17:34:43 +0100 Subject: [PATCH] Fix Game Boy Camera support in macOS Mojave and newer --- Cocoa/Document.m | 17 +++++++++++++++++ Cocoa/Info.plist | 4 ++++ 2 files changed, 21 insertions(+) diff --git a/Cocoa/Document.m b/Cocoa/Document.m index a520d62..85dd728 100644 --- a/Cocoa/Document.m +++ b/Cocoa/Document.m @@ -1171,6 +1171,23 @@ static void audioCallback(GB_gameboy_t *gb, GB_sample_t *sample) dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ @try { if (!cameraSession) { + if (@available(macOS 10.14, *)) { + switch ([AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo]) { + case AVAuthorizationStatusAuthorized: + break; + case AVAuthorizationStatusNotDetermined: { + [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) { + [self cameraRequestUpdate]; + }]; + return; + } + case AVAuthorizationStatusDenied: + case AVAuthorizationStatusRestricted: + GB_camera_updated(&gb); + return; + } + } + NSError *error; AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType: AVMediaTypeVideo]; AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice: device error: &error]; diff --git a/Cocoa/Info.plist b/Cocoa/Info.plist index dd801cb..d86b9fd 100644 --- a/Cocoa/Info.plist +++ b/Cocoa/Info.plist @@ -2,6 +2,8 @@ + CFBundleDisplayName + SameBoy CFBundleDevelopmentRegion en CFBundleDocumentTypes @@ -116,6 +118,8 @@ + NSCameraUsageDescription + SameBoy needs to access your camera to emulate the Game Boy Camera NSSupportsAutomaticGraphicsSwitching