sdlGetCameraPermissionState function
Query if camera access has been approved by the user.
Cameras will not function between when the device is opened by the app and when the user permits access to the hardware. On some platforms, this presents as a popup dialog where the user has to explicitly approve access; on others the approval might be implicit and not alert the user at all.
This function can be used to check the status of that approval. It will return 0 if still waiting for user response, 1 if the camera is approved for use, and -1 if the user denied access.
Instead of polling with this function, you can wait for a SDL_EVENT_CAMERA_DEVICE_APPROVED (or SDL_EVENT_CAMERA_DEVICE_DENIED) event in the standard SDL event loop, which is guaranteed to be sent once when permission to use the camera is decided.
If a camera is declined, there's nothing to be done but call SDL_CloseCamera() to dispose of it.
\param camera the opened camera device to query. \returns -1 if user denied access to the camera, 1 if user approved access, 0 if no decision has been made yet.
\threadsafety It is safe to call this function from any thread.
\since This function is available since SDL 3.1.3.
\sa SDL_OpenCamera \sa SDL_CloseCamera
extern SDL_DECLSPEC int SDLCALL SDL_GetCameraPermissionState(SDL_Camera *camera)
Implementation
int sdlGetCameraPermissionState(Pointer<SdlCamera> camera) {
final sdlGetCameraPermissionStateLookupFunction = libSdl3.lookupFunction<
Int32 Function(Pointer<SdlCamera> camera),
int Function(Pointer<SdlCamera> camera)>('SDL_GetCameraPermissionState');
return sdlGetCameraPermissionStateLookupFunction(camera);
}