Skip to content

Commit c5e40e1

Browse files
committed
Expose OpenXRAPI methods to get XrAction handles
1 parent aa65940 commit c5e40e1

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

modules/openxr/doc_classes/OpenXRAPIExtension.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@
1717
<link title="XrPosef documentation">https://registry.khronos.org/OpenXR/specs/1.0/man/html/XrPosef.html</link>
1818
</tutorials>
1919
<methods>
20+
<method name="action_get_handle">
21+
<return type="int" />
22+
<param index="0" name="action" type="RID" />
23+
<description>
24+
Returns the corresponding [code]XrAction[/code] OpenXR handle for the given action RID.
25+
</description>
26+
</method>
2027
<method name="begin_debug_label_region">
2128
<return type="void" />
2229
<param index="0" name="label_name" type="String" />
@@ -36,6 +43,14 @@
3643
Marks the end of a debug label region. Removes the latest debug label region added by calling [method begin_debug_label_region].
3744
</description>
3845
</method>
46+
<method name="find_action">
47+
<return type="RID" />
48+
<param index="0" name="name" type="String" />
49+
<param index="1" name="action_set" type="RID" />
50+
<description>
51+
Returns the [RID] corresponding to an [code]Action[/code] of a matching name, optionally limited to a specified action set.
52+
</description>
53+
</method>
3954
<method name="get_error_string">
4055
<return type="String" />
4156
<param index="0" name="result" type="int" />

modules/openxr/openxr_api_extension.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ void OpenXRAPIExtension::_bind_methods() {
5656
ClassDB::bind_method(D_METHOD("get_next_frame_time"), &OpenXRAPIExtension::get_next_frame_time);
5757
ClassDB::bind_method(D_METHOD("can_render"), &OpenXRAPIExtension::can_render);
5858

59+
ClassDB::bind_method(D_METHOD("find_action", "name", "action_set"), &OpenXRAPIExtension::find_action);
60+
ClassDB::bind_method(D_METHOD("action_get_handle", "action"), &OpenXRAPIExtension::action_get_handle);
61+
5962
ClassDB::bind_method(D_METHOD("get_hand_tracker", "hand_index"), &OpenXRAPIExtension::get_hand_tracker);
6063

6164
ClassDB::bind_method(D_METHOD("register_composition_layer_provider", "extension"), &OpenXRAPIExtension::register_composition_layer_provider);
@@ -197,6 +200,17 @@ bool OpenXRAPIExtension::can_render() {
197200
return OpenXRAPI::get_singleton()->can_render();
198201
}
199202

203+
RID OpenXRAPIExtension::find_action(const String &p_name, const RID &p_action_set) {
204+
ERR_FAIL_NULL_V(OpenXRAPI::get_singleton(), RID());
205+
return OpenXRAPI::get_singleton()->find_action(p_name, p_action_set);
206+
}
207+
208+
uint64_t OpenXRAPIExtension::action_get_handle(RID p_action) {
209+
ERR_FAIL_NULL_V(OpenXRAPI::get_singleton(), 0);
210+
XrAction action_hanlde = OpenXRAPI::get_singleton()->action_get_handle(p_action);
211+
return reinterpret_cast<uint64_t>(action_hanlde);
212+
}
213+
200214
uint64_t OpenXRAPIExtension::get_hand_tracker(int p_hand_index) {
201215
ERR_FAIL_NULL_V(OpenXRAPI::get_singleton(), 0);
202216
return (uint64_t)OpenXRAPI::get_singleton()->get_hand_tracker(p_hand_index);

modules/openxr/openxr_api_extension.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ class OpenXRAPIExtension : public RefCounted {
7676
int64_t get_next_frame_time();
7777
bool can_render();
7878

79+
RID find_action(const String &p_name, const RID &p_action_set = RID());
80+
uint64_t action_get_handle(RID p_action);
81+
7982
uint64_t get_hand_tracker(int p_hand_index);
8083

8184
void register_composition_layer_provider(OpenXRExtensionWrapperExtension *p_extension);

0 commit comments

Comments
 (0)