Monado OpenXR Runtime
Loading...
Searching...
No Matches
oxr_session_attached_actions.h
Go to the documentation of this file.
1// Copyright 2018-2024, Collabora, Ltd.
2// Copyright 2023-2026, NVIDIA CORPORATION.
3// SPDX-License-Identifier: BSL-1.0
4/*!
5 * @file
6 * @brief Holds per session attached actions.
7 * @ingroup oxr_main
8 */
9
10#pragma once
11
12#include "os/os_threading.h"
13
15#include "oxr_extension_support.h"
16
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
22
23/*!
24 * Per-session map of action key to action attachment.
25 *
26 * This is stored on the session (not on the action context) and tracks
27 * all action attachments from all action contexts. State-get and lookup
28 * functions (e.g. xrGetActionStateBoolean, haptics, pose) resolve an action
29 * by act_key only; they do not need to know which context the action came
30 * from. That way, a future extension that adds multiple action contexts
31 * per session can keep feeding this single map, and those functions will
32 * not need to change.
33 *
34 * @ingroup oxr_main
35 */
37{
38 /*!
39 * A map of action key to action attachment.
40 *
41 * The action attachments are actually owned by the action set
42 * attachments, which are owned by the session action context.
43 *
44 * If non-null, this means an action context (default or otherwise)
45 * action sets have been attached to the owning session, since this map
46 * points to @p oxr_action_attachment members of
47 * @ref oxr_session_action_context::act_set_attachments elements.
48 */
50
51 struct os_mutex mutex;
52};
53
54
55/*!
56 * Initialize the attached actions for a session.
57 *
58 * @public @memberof oxr_session_attached_actions
59 */
60XRT_NONNULL_ALL XrResult
61oxr_session_attached_actions_init(struct oxr_session_attached_actions *attached);
62
63/*!
64 * Finalize and cleanup the attached actions.
65 *
66 * @public @memberof oxr_session_attached_actions
67 */
68XRT_NONNULL_ALL void
69oxr_session_attached_actions_fini(struct oxr_session_attached_actions *attached);
70
71/*!
72 * Add a single action attachment to the map (thread-safe).
73 *
74 * @public @memberof oxr_session_attached_actions
75 */
76XRT_NONNULL_ALL XrResult
77oxr_session_attached_actions_add_action_attachment(struct oxr_session_attached_actions *attached,
78 struct oxr_action_attachment *act_attachment);
79
80/*!
81 * Remove a single action attachment from the map (thread-safe).
82 *
83 * @public @memberof oxr_session_attached_actions
84 */
85XRT_NONNULL_ALL void
86oxr_session_attached_actions_remove_action_attachment(struct oxr_session_attached_actions *attached,
87 struct oxr_action_attachment *act_attachment);
88
89/*!
90 * Find an action attachment by action key (thread-safe).
91 *
92 * @public @memberof oxr_session_attached_actions
93 */
94XRT_NONNULL_ALL void
95oxr_session_attached_actions_find(struct oxr_session_attached_actions *attached,
96 uint32_t act_key,
97 struct oxr_action_attachment **out_act_attached);
98
99
100#ifdef __cplusplus
101}
102#endif
Wrapper around OS threading native functions.
Forward declarations for OpenXR state tracker structs.
A wrapper around a native mutex.
Definition os_threading.h:69
Data associated with an Action that has been attached to a Session.
Definition oxr_objects.h:1707
Per-session map of action key to action attachment.
Definition oxr_session_attached_actions.h:37
struct u_hashmap_int * act_attachments_by_key
A map of action key to action attachment.
Definition oxr_session_attached_actions.h:49
A simple uint64_t key to a void pointer hashmap.
Definition u_hashmap.cpp:24