Monado OpenXR Runtime
oxr_subaction.h
Go to the documentation of this file.
1 // Copyright 2020, Collabora, Ltd.
2 // SPDX-License-Identifier: BSL-1.0
3 /*!
4  * @file
5  * @brief Provides a utility macro for dealing with subaction paths
6  * @author Rylie Pavlik <rylie.pavlik@collabora.com>
7  * @ingroup oxr_input
8  */
9 
10 #pragma once
11 
12 /*!
13  * Expansion macro (x-macro) that calls the macro you pass with the shorthand
14  * name of each valid subaction path.
15  *
16  * Use to generate code that checks each subaction path in sequence, etc.
17  *
18  * If you also want the bogus subaction path of just plain `/user`, then see
19  * OXR_FOR_EACH_SUBACTION_PATH()
20  *
21  * @note Keep this synchronized with OXR_ACTION_GET_FILLER!
22  */
23 #define OXR_FOR_EACH_VALID_SUBACTION_PATH(_) \
24  _(left) \
25  _(right) \
26  _(head) \
27  _(gamepad) \
28  _(eyes)
29 
30 
31 /*!
32  * Expansion macro (x-macro) that calls the macro you pass with the shorthand
33  * name of each subaction path, including just bare `user`.
34  *
35  * Use to generate code that checks each subaction path in sequence, etc.
36  *
37  * @note Keep this synchronized with OXR_ACTION_GET_FILLER!
38  */
39 #define OXR_FOR_EACH_SUBACTION_PATH(_) \
40  OXR_FOR_EACH_VALID_SUBACTION_PATH(_) \
41  _(user)
42 
43 /*!
44  * Expansion macro (x-macro) that calls the macro you pass for each valid
45  * subaction path, with the shorthand name of each subaction path, the same
46  * name capitalized, and the corresponding path string.
47  *
48  * If you also want the bogus subaction path of just plain `/user`, then see
49  * OXR_FOR_EACH_SUBACTION_PATH_DETAILED()
50  *
51  * Use to generate code that checks each subaction path in sequence, etc.
52  *
53  * Most of the time you can just use OXR_FOR_EACH_VALID_SUBACTION_PATH() or
54  * OXR_FOR_EACH_SUBACTION_PATH()
55  */
56 #define OXR_FOR_EACH_VALID_SUBACTION_PATH_DETAILED(_) \
57  _(left, LEFT, "/user/hand/left") \
58  _(right, RIGHT, "/user/hand/right") \
59  _(head, HEAD, "/user/head") \
60  _(gamepad, GAMEPAD, "/user/gamepad") \
61  _(eyes, EYES, "/user/eyes_ext")
62 
63 /*!
64  * Expansion macro (x-macro) that calls the macro you pass for each subaction
65  * path (including the bare `/user`), with the shorthand name of each subaction
66  * path, the same name capitalized, and the corresponding path string.
67  *
68  * Use to generate code that checks each subaction path in sequence, etc.
69  *
70  * Most of the time you can just use OXR_FOR_EACH_VALID_SUBACTION_PATH() or
71  * OXR_FOR_EACH_SUBACTION_PATH()
72  */
73 #define OXR_FOR_EACH_SUBACTION_PATH_DETAILED(_) \
74  OXR_FOR_EACH_VALID_SUBACTION_PATH_DETAILED(_) \
75  _(user, USER, "/user")