Monado OpenXR Runtime
android_lifecycle_callbacks.h
Go to the documentation of this file.
1// Copyright 2021-2024, Collabora, Ltd.
2// SPDX-License-Identifier: BSL-1.0
3/*!
4 * @file
5 * @brief An implementation of a callback collection for the Android lifecycle.
6 * @author Rylie Pavlik <rylie.pavlik@collabora.com>
7 * @ingroup aux_android
8 */
9
10#pragma once
11
12#include <xrt/xrt_config_os.h>
13#include <xrt/xrt_android.h>
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19struct xrt_instance_android;
20
21/*!
22 * @class android_lifecycle_callbacks
23 * @brief An object handling a collection of callbacks for the Android lifecycle.
24 */
26
27/*!
28 * Create an @ref android_lifecycle_callbacks object.
29 *
30 * @param xinst_android The instance that will be passed to all callbacks.
31 *
32 * @public @memberof android_lifecycle_callbacks
33 */
35android_lifecycle_callbacks_create(struct xrt_instance_android *xinst_android);
36
37/*!
38 * Destroy an @ref android_lifecycle_callbacks object.
39 * @public @memberof android_lifecycle_callbacks
40 */
41void
43
44/*!
45 * Register a lifecycle event callback.
46 *
47 * @param alc Pointer to self
48 * @param callback Function pointer for callback
49 * @param event_mask bitwise-OR of one or more values from @ref xrt_android_lifecycle_event
50 * @param userdata An opaque pointer for use by the callback. Whatever you pass here will be passed to the
51 * callback when invoked.
52 *
53 * @return 0 on success, <0 on error.
54 * @public @memberof android_lifecycle_callbacks
55 */
56int
59 enum xrt_android_lifecycle_event event_mask,
60 void *userdata);
61
62/*!
63 * Remove a lifecycle event callback that matches the supplied parameters.
64 *
65 * @param alc Pointer to self
66 * @param callback Function pointer for callback
67 * @param event_mask bitwise-OR of one or more values from @ref xrt_android_lifecycle_event
68 * @param userdata An opaque pointer for use by the callback, must match the one originally supplied
69 *
70 * @return number of callbacks removed (typically 1) on success, <0 on error.
71 * @public @memberof android_lifecycle_callbacks
72 */
73int
76 enum xrt_android_lifecycle_event event_mask,
77 void *userdata);
78
79#ifdef __cplusplus
80} // extern "C"
81#endif
An object handling a collection of callbacks for the Android lifecycle.
Definition: android_lifecycle_callbacks.cpp:30
struct android_lifecycle_callbacks * android_lifecycle_callbacks_create(struct xrt_instance_android *xinst_android)
Create an android_lifecycle_callbacks object.
Definition: android_lifecycle_callbacks.cpp:161
int android_lifecycle_callbacks_register_callback(struct android_lifecycle_callbacks *alc, xrt_android_lifecycle_event_handler_t callback, enum xrt_android_lifecycle_event event_mask, void *userdata)
Register a lifecycle event callback.
Definition: android_lifecycle_callbacks.cpp:125
void android_lifecycle_callbacks_destroy(struct android_lifecycle_callbacks **ptr_callbacks)
Destroy an android_lifecycle_callbacks object.
Definition: android_lifecycle_callbacks.cpp:193
int android_lifecycle_callbacks_remove_callback(struct android_lifecycle_callbacks *alc, xrt_android_lifecycle_event_handler_t callback, enum xrt_android_lifecycle_event event_mask, void *userdata)
Remove a lifecycle event callback that matches the supplied parameters.
Definition: android_lifecycle_callbacks.cpp:138
Header holding Android-specific details.
bool(* xrt_android_lifecycle_event_handler_t)(struct xrt_instance_android *xinst_android, enum xrt_android_lifecycle_event event, void *userdata)
A callback type for a handler of Android lifecycle events.
Definition: xrt_android.h:46
xrt_android_lifecycle_event
Distinguishes the possible Android lifecycle events from each other.
Definition: xrt_android.h:32
Auto detect OS and certain features.