mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 05:40:04 +00:00 
			
		
		
		
	clang format: add objective c++ formatting
This commit is contained in:
		
							parent
							
								
									940ec70f13
								
							
						
					
					
						commit
						d5a4988f9e
					
				
					 3 changed files with 125 additions and 44 deletions
				
			
		|  | @ -11,57 +11,54 @@ namespace AppleAuthorization { | |||
| 
 | ||||
| static bool authorized = false; | ||||
| 
 | ||||
| enum class AuthMediaType { | ||||
|     Camera, | ||||
|     Microphone | ||||
| }; | ||||
| enum class AuthMediaType { Camera, Microphone }; | ||||
| 
 | ||||
| // Based on https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/requesting_authorization_for_media_capture_on_macos | ||||
| // Based on | ||||
| // https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture/requesting_authorization_for_media_capture_on_macos | ||||
| void CheckAuthorization(AuthMediaType type) { | ||||
|     if (@available(macOS 10.14, *)) { | ||||
|         NSString *media_type; | ||||
|         if(type == AuthMediaType::Camera) { | ||||
|         NSString* media_type; | ||||
|         if (type == AuthMediaType::Camera) { | ||||
|             media_type = AVMediaTypeVideo; | ||||
|         } | ||||
|         else { | ||||
|         } else { | ||||
|             media_type = AVMediaTypeAudio; | ||||
|         } | ||||
| 
 | ||||
|         // Request permission to access the camera and microphone. | ||||
|         switch ([AVCaptureDevice authorizationStatusForMediaType:media_type]) { | ||||
|             case AVAuthorizationStatusAuthorized: | ||||
|                 // The user has previously granted access to the camera. | ||||
|                 authorized = true; | ||||
|                 break; | ||||
|             case AVAuthorizationStatusNotDetermined: | ||||
|             { | ||||
|                 // The app hasn't yet asked the user for camera access. | ||||
|                 [AVCaptureDevice requestAccessForMediaType:media_type completionHandler:^(BOOL) { | ||||
|                     authorized = true; | ||||
|                 }]; | ||||
|                 if(type == AuthMediaType::Camera) { | ||||
|                     LOG_INFO(Frontend, "Camera access requested."); | ||||
|                 } | ||||
|                 break; | ||||
|             } | ||||
|             case AVAuthorizationStatusDenied: | ||||
|             { | ||||
|                 // The user has previously denied access. | ||||
|                 authorized = false; | ||||
|                 if(type == AuthMediaType::Camera) { | ||||
|                     LOG_WARNING(Frontend, "Camera access denied. To change this you may modify the macos system settings for Citra at 'System Preferences -> Security & Privacy -> Camera'"); | ||||
|                 } | ||||
|                 return; | ||||
|             } | ||||
|             case AVAuthorizationStatusRestricted: | ||||
|             { | ||||
|                 // The user can't grant access due to restrictions. | ||||
|                 authorized = false; | ||||
|                 return; | ||||
|         case AVAuthorizationStatusAuthorized: | ||||
|             // The user has previously granted access to the camera. | ||||
|             authorized = true; | ||||
|             break; | ||||
|         case AVAuthorizationStatusNotDetermined: { | ||||
|             // The app hasn't yet asked the user for camera access. | ||||
|             [AVCaptureDevice requestAccessForMediaType:media_type | ||||
|                                      completionHandler:^(BOOL) { | ||||
|                                        authorized = true; | ||||
|                                      }]; | ||||
|             if (type == AuthMediaType::Camera) { | ||||
|                 LOG_INFO(Frontend, "Camera access requested."); | ||||
|             } | ||||
|             break; | ||||
|         } | ||||
|     } | ||||
|     else { | ||||
|         case AVAuthorizationStatusDenied: { | ||||
|             // The user has previously denied access. | ||||
|             authorized = false; | ||||
|             if (type == AuthMediaType::Camera) { | ||||
|                 LOG_WARNING( | ||||
|                     Frontend, | ||||
|                     "Camera access denied. To change this you may modify the macos system settings " | ||||
|                     "for Citra at 'System Preferences -> Security & Privacy -> Camera'"); | ||||
|             } | ||||
|             return; | ||||
|         } | ||||
|         case AVAuthorizationStatusRestricted: { | ||||
|             // The user can't grant access due to restrictions. | ||||
|             authorized = false; | ||||
|             return; | ||||
|         } | ||||
|         } | ||||
|     } else { | ||||
|         authorized = true; | ||||
|     } | ||||
| } | ||||
|  | @ -76,4 +73,4 @@ bool CheckAuthorizationForMicrophone() { | |||
|     return authorized; | ||||
| } | ||||
| 
 | ||||
| } //AppleAuthorization | ||||
| } // AppleAuthorization | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue