openxr_action_map.cpp 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603
  1. /**************************************************************************/
  2. /* openxr_action_map.cpp */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #include "openxr_action_map.h"
  31. void OpenXRActionMap::_bind_methods() {
  32. ClassDB::bind_method(D_METHOD("set_action_sets", "action_sets"), &OpenXRActionMap::set_action_sets);
  33. ClassDB::bind_method(D_METHOD("get_action_sets"), &OpenXRActionMap::get_action_sets);
  34. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "action_sets", PROPERTY_HINT_RESOURCE_TYPE, "OpenXRActionSet", PROPERTY_USAGE_NO_EDITOR), "set_action_sets", "get_action_sets");
  35. ClassDB::bind_method(D_METHOD("get_action_set_count"), &OpenXRActionMap::get_action_set_count);
  36. ClassDB::bind_method(D_METHOD("find_action_set", "name"), &OpenXRActionMap::find_action_set);
  37. ClassDB::bind_method(D_METHOD("get_action_set", "idx"), &OpenXRActionMap::get_action_set);
  38. ClassDB::bind_method(D_METHOD("add_action_set", "action_set"), &OpenXRActionMap::add_action_set);
  39. ClassDB::bind_method(D_METHOD("remove_action_set", "action_set"), &OpenXRActionMap::remove_action_set);
  40. ClassDB::bind_method(D_METHOD("set_interaction_profiles", "interaction_profiles"), &OpenXRActionMap::set_interaction_profiles);
  41. ClassDB::bind_method(D_METHOD("get_interaction_profiles"), &OpenXRActionMap::get_interaction_profiles);
  42. ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "interaction_profiles", PROPERTY_HINT_RESOURCE_TYPE, "OpenXRInteractionProfile", PROPERTY_USAGE_NO_EDITOR), "set_interaction_profiles", "get_interaction_profiles");
  43. ClassDB::bind_method(D_METHOD("get_interaction_profile_count"), &OpenXRActionMap::get_interaction_profile_count);
  44. ClassDB::bind_method(D_METHOD("find_interaction_profile", "name"), &OpenXRActionMap::find_interaction_profile);
  45. ClassDB::bind_method(D_METHOD("get_interaction_profile", "idx"), &OpenXRActionMap::get_interaction_profile);
  46. ClassDB::bind_method(D_METHOD("add_interaction_profile", "interaction_profile"), &OpenXRActionMap::add_interaction_profile);
  47. ClassDB::bind_method(D_METHOD("remove_interaction_profile", "interaction_profile"), &OpenXRActionMap::remove_interaction_profile);
  48. ClassDB::bind_method(D_METHOD("create_default_action_sets"), &OpenXRActionMap::create_default_action_sets);
  49. }
  50. void OpenXRActionMap::set_action_sets(Array p_action_sets) {
  51. action_sets.clear();
  52. for (int i = 0; i < p_action_sets.size(); i++) {
  53. Ref<OpenXRActionSet> action_set = p_action_sets[i];
  54. if (action_set.is_valid() && !action_sets.has(action_set)) {
  55. action_sets.push_back(action_set);
  56. }
  57. }
  58. }
  59. Array OpenXRActionMap::get_action_sets() const {
  60. return action_sets;
  61. }
  62. int OpenXRActionMap::get_action_set_count() const {
  63. return action_sets.size();
  64. }
  65. Ref<OpenXRActionSet> OpenXRActionMap::find_action_set(String p_name) const {
  66. for (int i = 0; i < action_sets.size(); i++) {
  67. Ref<OpenXRActionSet> action_set = action_sets[i];
  68. if (action_set->get_name() == p_name) {
  69. return action_set;
  70. }
  71. }
  72. return Ref<OpenXRActionSet>();
  73. }
  74. Ref<OpenXRActionSet> OpenXRActionMap::get_action_set(int p_idx) const {
  75. ERR_FAIL_INDEX_V(p_idx, action_sets.size(), Ref<OpenXRActionSet>());
  76. return action_sets[p_idx];
  77. }
  78. void OpenXRActionMap::add_action_set(Ref<OpenXRActionSet> p_action_set) {
  79. ERR_FAIL_COND(p_action_set.is_null());
  80. if (!action_sets.has(p_action_set)) {
  81. action_sets.push_back(p_action_set);
  82. emit_changed();
  83. }
  84. }
  85. void OpenXRActionMap::remove_action_set(Ref<OpenXRActionSet> p_action_set) {
  86. int idx = action_sets.find(p_action_set);
  87. if (idx != -1) {
  88. action_sets.remove_at(idx);
  89. emit_changed();
  90. }
  91. }
  92. void OpenXRActionMap::set_interaction_profiles(Array p_interaction_profiles) {
  93. interaction_profiles.clear();
  94. for (int i = 0; i < p_interaction_profiles.size(); i++) {
  95. Ref<OpenXRInteractionProfile> interaction_profile = p_interaction_profiles[i];
  96. if (interaction_profile.is_valid() && !interaction_profiles.has(interaction_profile)) {
  97. interaction_profiles.push_back(interaction_profile);
  98. }
  99. }
  100. }
  101. Array OpenXRActionMap::get_interaction_profiles() const {
  102. return interaction_profiles;
  103. }
  104. int OpenXRActionMap::get_interaction_profile_count() const {
  105. return interaction_profiles.size();
  106. }
  107. Ref<OpenXRInteractionProfile> OpenXRActionMap::find_interaction_profile(String p_path) const {
  108. for (int i = 0; i < interaction_profiles.size(); i++) {
  109. Ref<OpenXRInteractionProfile> interaction_profile = interaction_profiles[i];
  110. if (interaction_profile->get_interaction_profile_path() == p_path) {
  111. return interaction_profile;
  112. }
  113. }
  114. return Ref<OpenXRInteractionProfile>();
  115. }
  116. Ref<OpenXRInteractionProfile> OpenXRActionMap::get_interaction_profile(int p_idx) const {
  117. ERR_FAIL_INDEX_V(p_idx, interaction_profiles.size(), Ref<OpenXRInteractionProfile>());
  118. return interaction_profiles[p_idx];
  119. }
  120. void OpenXRActionMap::add_interaction_profile(Ref<OpenXRInteractionProfile> p_interaction_profile) {
  121. ERR_FAIL_COND(p_interaction_profile.is_null());
  122. if (!interaction_profiles.has(p_interaction_profile)) {
  123. interaction_profiles.push_back(p_interaction_profile);
  124. emit_changed();
  125. }
  126. }
  127. void OpenXRActionMap::remove_interaction_profile(Ref<OpenXRInteractionProfile> p_interaction_profile) {
  128. int idx = interaction_profiles.find(p_interaction_profile);
  129. if (idx != -1) {
  130. interaction_profiles.remove_at(idx);
  131. emit_changed();
  132. }
  133. }
  134. void OpenXRActionMap::create_default_action_sets() {
  135. // Note:
  136. // - if you make changes here make sure to delete your default_action_map.tres file of it will load an old version.
  137. // - our palm pose is only available if the relevant extension is supported,
  138. // we still want it to be part of our action map as we may deploy the same game to platforms that do and don't support it.
  139. // - the same applies for interaction profiles that are only supported if the relevant extension is supported.
  140. // Create our Godot action set.
  141. Ref<OpenXRActionSet> action_set = OpenXRActionSet::new_action_set("godot", "Godot action set");
  142. add_action_set(action_set);
  143. // Create our actions.
  144. Ref<OpenXRAction> trigger = action_set->add_new_action("trigger", "Trigger", OpenXRAction::OPENXR_ACTION_FLOAT, "/user/hand/left,/user/hand/right");
  145. Ref<OpenXRAction> trigger_click = action_set->add_new_action("trigger_click", "Trigger click", OpenXRAction::OPENXR_ACTION_BOOL, "/user/hand/left,/user/hand/right");
  146. Ref<OpenXRAction> trigger_touch = action_set->add_new_action("trigger_touch", "Trigger touching", OpenXRAction::OPENXR_ACTION_BOOL, "/user/hand/left,/user/hand/right");
  147. Ref<OpenXRAction> grip = action_set->add_new_action("grip", "Grip", OpenXRAction::OPENXR_ACTION_FLOAT, "/user/hand/left,/user/hand/right");
  148. Ref<OpenXRAction> grip_click = action_set->add_new_action("grip_click", "Grip click", OpenXRAction::OPENXR_ACTION_BOOL, "/user/hand/left,/user/hand/right");
  149. Ref<OpenXRAction> grip_force = action_set->add_new_action("grip_force", "Grip force", OpenXRAction::OPENXR_ACTION_FLOAT, "/user/hand/left,/user/hand/right");
  150. Ref<OpenXRAction> primary = action_set->add_new_action("primary", "Primary joystick/thumbstick/trackpad", OpenXRAction::OPENXR_ACTION_VECTOR2, "/user/hand/left,/user/hand/right");
  151. Ref<OpenXRAction> primary_click = action_set->add_new_action("primary_click", "Primary joystick/thumbstick/trackpad click", OpenXRAction::OPENXR_ACTION_BOOL, "/user/hand/left,/user/hand/right");
  152. Ref<OpenXRAction> primary_touch = action_set->add_new_action("primary_touch", "Primary joystick/thumbstick/trackpad touching", OpenXRAction::OPENXR_ACTION_BOOL, "/user/hand/left,/user/hand/right");
  153. Ref<OpenXRAction> secondary = action_set->add_new_action("secondary", "Secondary joystick/thumbstick/trackpad", OpenXRAction::OPENXR_ACTION_VECTOR2, "/user/hand/left,/user/hand/right");
  154. Ref<OpenXRAction> secondary_click = action_set->add_new_action("secondary_click", "Secondary joystick/thumbstick/trackpad click", OpenXRAction::OPENXR_ACTION_BOOL, "/user/hand/left,/user/hand/right");
  155. Ref<OpenXRAction> secondary_touch = action_set->add_new_action("secondary_touch", "Secondary joystick/thumbstick/trackpad touching", OpenXRAction::OPENXR_ACTION_BOOL, "/user/hand/left,/user/hand/right");
  156. Ref<OpenXRAction> menu_button = action_set->add_new_action("menu_button", "Menu button", OpenXRAction::OPENXR_ACTION_BOOL, "/user/hand/left,/user/hand/right");
  157. Ref<OpenXRAction> select_button = action_set->add_new_action("select_button", "Select button", OpenXRAction::OPENXR_ACTION_BOOL, "/user/hand/left,/user/hand/right");
  158. Ref<OpenXRAction> ax_button = action_set->add_new_action("ax_button", "A/X button", OpenXRAction::OPENXR_ACTION_BOOL, "/user/hand/left,/user/hand/right");
  159. Ref<OpenXRAction> ax_touch = action_set->add_new_action("ax_touch", "A/X touching", OpenXRAction::OPENXR_ACTION_BOOL, "/user/hand/left,/user/hand/right");
  160. Ref<OpenXRAction> by_button = action_set->add_new_action("by_button", "B/Y button", OpenXRAction::OPENXR_ACTION_BOOL, "/user/hand/left,/user/hand/right");
  161. Ref<OpenXRAction> by_touch = action_set->add_new_action("by_touch", "B/Y touching", OpenXRAction::OPENXR_ACTION_BOOL, "/user/hand/left,/user/hand/right");
  162. Ref<OpenXRAction> default_pose = action_set->add_new_action("default_pose", "Default pose", OpenXRAction::OPENXR_ACTION_POSE,
  163. "/user/hand/left,"
  164. "/user/hand/right,"
  165. // "/user/vive_tracker_htcx/role/handheld_object," <-- getting errors on this one.
  166. "/user/vive_tracker_htcx/role/left_foot,"
  167. "/user/vive_tracker_htcx/role/right_foot,"
  168. "/user/vive_tracker_htcx/role/left_shoulder,"
  169. "/user/vive_tracker_htcx/role/right_shoulder,"
  170. "/user/vive_tracker_htcx/role/left_elbow,"
  171. "/user/vive_tracker_htcx/role/right_elbow,"
  172. "/user/vive_tracker_htcx/role/left_knee,"
  173. "/user/vive_tracker_htcx/role/right_knee,"
  174. "/user/vive_tracker_htcx/role/waist,"
  175. "/user/vive_tracker_htcx/role/chest,"
  176. "/user/vive_tracker_htcx/role/camera,"
  177. "/user/vive_tracker_htcx/role/keyboard,"
  178. "/user/eyes_ext");
  179. Ref<OpenXRAction> aim_pose = action_set->add_new_action("aim_pose", "Aim pose", OpenXRAction::OPENXR_ACTION_POSE, "/user/hand/left,/user/hand/right");
  180. Ref<OpenXRAction> grip_pose = action_set->add_new_action("grip_pose", "Grip pose", OpenXRAction::OPENXR_ACTION_POSE, "/user/hand/left,/user/hand/right");
  181. Ref<OpenXRAction> palm_pose = action_set->add_new_action("palm_pose", "Palm pose", OpenXRAction::OPENXR_ACTION_POSE, "/user/hand/left,/user/hand/right");
  182. Ref<OpenXRAction> haptic = action_set->add_new_action("haptic", "Haptic", OpenXRAction::OPENXR_ACTION_HAPTIC,
  183. "/user/hand/left,"
  184. "/user/hand/right,"
  185. // "/user/vive_tracker_htcx/role/handheld_object," <-- getting errors on this one.
  186. "/user/vive_tracker_htcx/role/left_foot,"
  187. "/user/vive_tracker_htcx/role/right_foot,"
  188. "/user/vive_tracker_htcx/role/left_shoulder,"
  189. "/user/vive_tracker_htcx/role/right_shoulder,"
  190. "/user/vive_tracker_htcx/role/left_elbow,"
  191. "/user/vive_tracker_htcx/role/right_elbow,"
  192. "/user/vive_tracker_htcx/role/left_knee,"
  193. "/user/vive_tracker_htcx/role/right_knee,"
  194. "/user/vive_tracker_htcx/role/waist,"
  195. "/user/vive_tracker_htcx/role/chest,"
  196. "/user/vive_tracker_htcx/role/camera,"
  197. "/user/vive_tracker_htcx/role/keyboard");
  198. // Create our interaction profiles.
  199. Ref<OpenXRInteractionProfile> profile = OpenXRInteractionProfile::new_profile("/interaction_profiles/khr/simple_controller");
  200. profile->add_new_binding(default_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  201. profile->add_new_binding(aim_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  202. profile->add_new_binding(grip_pose, "/user/hand/left/input/grip/pose,/user/hand/right/input/grip/pose");
  203. profile->add_new_binding(palm_pose, "/user/hand/left/input/palm_ext/pose,/user/hand/right/input/palm_ext/pose");
  204. profile->add_new_binding(menu_button, "/user/hand/left/input/menu/click,/user/hand/right/input/menu/click");
  205. profile->add_new_binding(select_button, "/user/hand/left/input/select/click,/user/hand/right/input/select/click");
  206. // generic has no support for triggers, grip, A/B buttons, nor joystick/trackpad inputs.
  207. profile->add_new_binding(haptic, "/user/hand/left/output/haptic,/user/hand/right/output/haptic");
  208. add_interaction_profile(profile);
  209. // Create our Vive controller profile.
  210. profile = OpenXRInteractionProfile::new_profile("/interaction_profiles/htc/vive_controller");
  211. profile->add_new_binding(default_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  212. profile->add_new_binding(aim_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  213. profile->add_new_binding(grip_pose, "/user/hand/left/input/grip/pose,/user/hand/right/input/grip/pose");
  214. profile->add_new_binding(palm_pose, "/user/hand/left/input/palm_ext/pose,/user/hand/right/input/palm_ext/pose");
  215. profile->add_new_binding(menu_button, "/user/hand/left/input/menu/click,/user/hand/right/input/menu/click");
  216. profile->add_new_binding(select_button, "/user/hand/left/input/system/click,/user/hand/right/input/system/click");
  217. // wmr controller has no a/b/x/y buttons.
  218. profile->add_new_binding(trigger, "/user/hand/left/input/trigger/value,/user/hand/right/input/trigger/value");
  219. profile->add_new_binding(trigger_click, "/user/hand/left/input/trigger/click,/user/hand/right/input/trigger/click");
  220. profile->add_new_binding(grip, "/user/hand/left/input/squeeze/click,/user/hand/right/input/squeeze/click"); // OpenXR will convert bool to float.
  221. profile->add_new_binding(grip_click, "/user/hand/left/input/squeeze/click,/user/hand/right/input/squeeze/click");
  222. // primary on our vive controller is our trackpad.
  223. profile->add_new_binding(primary, "/user/hand/left/input/trackpad,/user/hand/right/input/trackpad");
  224. profile->add_new_binding(primary_click, "/user/hand/left/input/trackpad/click,/user/hand/right/input/trackpad/click");
  225. profile->add_new_binding(primary_touch, "/user/hand/left/input/trackpad/touch,/user/hand/right/input/trackpad/touch");
  226. // vive controllers have no secondary input.
  227. profile->add_new_binding(haptic, "/user/hand/left/output/haptic,/user/hand/right/output/haptic");
  228. add_interaction_profile(profile);
  229. // Create our WMR controller profile.
  230. profile = OpenXRInteractionProfile::new_profile("/interaction_profiles/microsoft/motion_controller");
  231. profile->add_new_binding(default_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  232. profile->add_new_binding(aim_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  233. profile->add_new_binding(grip_pose, "/user/hand/left/input/grip/pose,/user/hand/right/input/grip/pose");
  234. profile->add_new_binding(palm_pose, "/user/hand/left/input/palm_ext/pose,/user/hand/right/input/palm_ext/pose");
  235. // wmr controllers have no select button we can use.
  236. profile->add_new_binding(menu_button, "/user/hand/left/input/menu/click,/user/hand/right/input/menu/click");
  237. // wmr controller has no a/b/x/y buttons.
  238. profile->add_new_binding(trigger, "/user/hand/left/input/trigger/value,/user/hand/right/input/trigger/value");
  239. profile->add_new_binding(trigger_click, "/user/hand/left/input/trigger/value,/user/hand/right/input/trigger/value"); // OpenXR will convert float to bool.
  240. profile->add_new_binding(grip, "/user/hand/left/input/squeeze/click,/user/hand/right/input/squeeze/click"); // OpenXR will convert bool to float.
  241. profile->add_new_binding(grip_click, "/user/hand/left/input/squeeze/click,/user/hand/right/input/squeeze/click");
  242. // primary on our wmr controller is our thumbstick, no touch.
  243. profile->add_new_binding(primary, "/user/hand/left/input/thumbstick,/user/hand/right/input/thumbstick");
  244. profile->add_new_binding(primary_click, "/user/hand/left/input/thumbstick/click,/user/hand/right/input/thumbstick/click");
  245. // secondary on our wmr controller is our trackpad.
  246. profile->add_new_binding(secondary, "/user/hand/left/input/trackpad,/user/hand/right/input/trackpad");
  247. profile->add_new_binding(secondary_click, "/user/hand/left/input/trackpad/click,/user/hand/right/input/trackpad/click");
  248. profile->add_new_binding(secondary_touch, "/user/hand/left/input/trackpad/touch,/user/hand/right/input/trackpad/touch");
  249. profile->add_new_binding(haptic, "/user/hand/left/output/haptic,/user/hand/right/output/haptic");
  250. add_interaction_profile(profile);
  251. // Create our Meta touch controller profile.
  252. profile = OpenXRInteractionProfile::new_profile("/interaction_profiles/oculus/touch_controller");
  253. profile->add_new_binding(default_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  254. profile->add_new_binding(aim_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  255. profile->add_new_binding(grip_pose, "/user/hand/left/input/grip/pose,/user/hand/right/input/grip/pose");
  256. profile->add_new_binding(palm_pose, "/user/hand/left/input/palm_ext/pose,/user/hand/right/input/palm_ext/pose");
  257. // touch controllers have no select button we can use.
  258. profile->add_new_binding(menu_button, "/user/hand/left/input/menu/click,/user/hand/right/input/system/click"); // right hand system click may not be available.
  259. profile->add_new_binding(ax_button, "/user/hand/left/input/x/click,/user/hand/right/input/a/click"); // x on left hand, a on right hand.
  260. profile->add_new_binding(ax_touch, "/user/hand/left/input/x/touch,/user/hand/right/input/a/touch");
  261. profile->add_new_binding(by_button, "/user/hand/left/input/y/click,/user/hand/right/input/b/click"); // y on left hand, b on right hand.
  262. profile->add_new_binding(by_touch, "/user/hand/left/input/y/touch,/user/hand/right/input/b/touch");
  263. profile->add_new_binding(trigger, "/user/hand/left/input/trigger/value,/user/hand/right/input/trigger/value");
  264. profile->add_new_binding(trigger_click, "/user/hand/left/input/trigger/value,/user/hand/right/input/trigger/value"); // should be converted to boolean.
  265. profile->add_new_binding(trigger_touch, "/user/hand/left/input/trigger/touch,/user/hand/right/input/trigger/touch");
  266. profile->add_new_binding(grip, "/user/hand/left/input/squeeze/value,/user/hand/right/input/squeeze/value"); // should be converted to boolean.
  267. profile->add_new_binding(grip_click, "/user/hand/left/input/squeeze/value,/user/hand/right/input/squeeze/value");
  268. // primary on our touch controller is our thumbstick.
  269. profile->add_new_binding(primary, "/user/hand/left/input/thumbstick,/user/hand/right/input/thumbstick");
  270. profile->add_new_binding(primary_click, "/user/hand/left/input/thumbstick/click,/user/hand/right/input/thumbstick/click");
  271. profile->add_new_binding(primary_touch, "/user/hand/left/input/thumbstick/touch,/user/hand/right/input/thumbstick/touch");
  272. // touch controller has no secondary input.
  273. profile->add_new_binding(haptic, "/user/hand/left/output/haptic,/user/hand/right/output/haptic");
  274. add_interaction_profile(profile);
  275. // Create our Pico 4 controller profile.
  276. profile = OpenXRInteractionProfile::new_profile("/interaction_profiles/bytedance/pico4_controller");
  277. profile->add_new_binding(default_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  278. profile->add_new_binding(aim_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  279. profile->add_new_binding(grip_pose, "/user/hand/left/input/grip/pose,/user/hand/right/input/grip/pose");
  280. profile->add_new_binding(palm_pose, "/user/hand/left/input/palm_ext/pose,/user/hand/right/input/palm_ext/pose");
  281. profile->add_new_binding(select_button, "/user/hand/left/input/system/click,/user/hand/right/input/system/click"); // system click may not be available.
  282. profile->add_new_binding(menu_button, "/user/hand/left/input/menu/click");
  283. profile->add_new_binding(ax_button, "/user/hand/left/input/x/click,/user/hand/right/input/a/click"); // x on left hand, a on right hand.
  284. profile->add_new_binding(ax_touch, "/user/hand/left/input/x/touch,/user/hand/right/input/a/touch");
  285. profile->add_new_binding(by_button, "/user/hand/left/input/y/click,/user/hand/right/input/b/click"); // y on left hand, b on right hand.
  286. profile->add_new_binding(by_touch, "/user/hand/left/input/y/touch,/user/hand/right/input/b/touch");
  287. profile->add_new_binding(trigger, "/user/hand/left/input/trigger/value,/user/hand/right/input/trigger/value");
  288. profile->add_new_binding(trigger_click, "/user/hand/left/input/trigger/value,/user/hand/right/input/trigger/value"); // should be converted to boolean.
  289. profile->add_new_binding(trigger_touch, "/user/hand/left/input/trigger/touch,/user/hand/right/input/trigger/touch");
  290. profile->add_new_binding(grip, "/user/hand/left/input/squeeze/value,/user/hand/right/input/squeeze/value"); // should be converted to boolean.
  291. profile->add_new_binding(grip_click, "/user/hand/left/input/squeeze/value,/user/hand/right/input/squeeze/value");
  292. // primary on our pico controller is our thumbstick.
  293. profile->add_new_binding(primary, "/user/hand/left/input/thumbstick,/user/hand/right/input/thumbstick");
  294. profile->add_new_binding(primary_click, "/user/hand/left/input/thumbstick/click,/user/hand/right/input/thumbstick/click");
  295. profile->add_new_binding(primary_touch, "/user/hand/left/input/thumbstick/touch,/user/hand/right/input/thumbstick/touch");
  296. // pico controller has no secondary input.
  297. profile->add_new_binding(haptic, "/user/hand/left/output/haptic,/user/hand/right/output/haptic");
  298. add_interaction_profile(profile);
  299. // Create our Valve index controller profile.
  300. profile = OpenXRInteractionProfile::new_profile("/interaction_profiles/valve/index_controller");
  301. profile->add_new_binding(default_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  302. profile->add_new_binding(aim_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  303. profile->add_new_binding(grip_pose, "/user/hand/left/input/grip/pose,/user/hand/right/input/grip/pose");
  304. profile->add_new_binding(palm_pose, "/user/hand/left/input/palm_ext/pose,/user/hand/right/input/palm_ext/pose");
  305. // index controllers have no select button we can use.
  306. profile->add_new_binding(menu_button, "/user/hand/left/input/system/click,/user/hand/right/input/system/click");
  307. profile->add_new_binding(ax_button, "/user/hand/left/input/a/click,/user/hand/right/input/a/click"); // a on both controllers.
  308. profile->add_new_binding(ax_touch, "/user/hand/left/input/a/touch,/user/hand/right/input/a/touch");
  309. profile->add_new_binding(by_button, "/user/hand/left/input/b/click,/user/hand/right/input/b/click"); // b on both controllers.
  310. profile->add_new_binding(by_touch, "/user/hand/left/input/b/touch,/user/hand/right/input/b/touch");
  311. profile->add_new_binding(trigger, "/user/hand/left/input/trigger/value,/user/hand/right/input/trigger/value");
  312. profile->add_new_binding(trigger_click, "/user/hand/left/input/trigger/click,/user/hand/right/input/trigger/click");
  313. profile->add_new_binding(trigger_touch, "/user/hand/left/input/trigger/touch,/user/hand/right/input/trigger/touch");
  314. profile->add_new_binding(grip, "/user/hand/left/input/squeeze/value,/user/hand/right/input/squeeze/value");
  315. profile->add_new_binding(grip_click, "/user/hand/left/input/squeeze/value,/user/hand/right/input/squeeze/value"); // this should do a float to bool conversion.
  316. profile->add_new_binding(grip_force, "/user/hand/left/input/squeeze/force,/user/hand/right/input/squeeze/force"); // grip force seems to be unique to the Valve Index.
  317. // primary on our index controller is our thumbstick.
  318. profile->add_new_binding(primary, "/user/hand/left/input/thumbstick,/user/hand/right/input/thumbstick");
  319. profile->add_new_binding(primary_click, "/user/hand/left/input/thumbstick/click,/user/hand/right/input/thumbstick/click");
  320. profile->add_new_binding(primary_touch, "/user/hand/left/input/thumbstick/touch,/user/hand/right/input/thumbstick/touch");
  321. // secondary on our index controller is our trackpad.
  322. profile->add_new_binding(secondary, "/user/hand/left/input/trackpad,/user/hand/right/input/trackpad");
  323. profile->add_new_binding(secondary_click, "/user/hand/left/input/trackpad/force,/user/hand/right/input/trackpad/force"); // not sure if this will work but doesn't seem to support click...
  324. profile->add_new_binding(secondary_touch, "/user/hand/left/input/trackpad/touch,/user/hand/right/input/trackpad/touch");
  325. profile->add_new_binding(haptic, "/user/hand/left/output/haptic,/user/hand/right/output/haptic");
  326. add_interaction_profile(profile);
  327. // Create our HP MR controller profile.
  328. profile = OpenXRInteractionProfile::new_profile("/interaction_profiles/hp/mixed_reality_controller");
  329. profile->add_new_binding(default_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  330. profile->add_new_binding(aim_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  331. profile->add_new_binding(grip_pose, "/user/hand/left/input/grip/pose,/user/hand/right/input/grip/pose");
  332. profile->add_new_binding(palm_pose, "/user/hand/left/input/palm_ext/pose,/user/hand/right/input/palm_ext/pose");
  333. // hpmr controllers have no select button we can use.
  334. profile->add_new_binding(menu_button, "/user/hand/left/input/menu/click,/user/hand/right/input/menu/click");
  335. // hpmr controllers only register click, not touch, on our a/b/x/y buttons.
  336. profile->add_new_binding(ax_button, "/user/hand/left/input/x/click,/user/hand/right/input/a/click"); // x on left hand, a on right hand.
  337. profile->add_new_binding(by_button, "/user/hand/left/input/y/click,/user/hand/right/input/b/click"); // y on left hand, b on right hand.
  338. profile->add_new_binding(trigger, "/user/hand/left/input/trigger/value,/user/hand/right/input/trigger/value");
  339. profile->add_new_binding(trigger_click, "/user/hand/left/input/trigger/value,/user/hand/right/input/trigger/value");
  340. profile->add_new_binding(grip, "/user/hand/left/input/squeeze/value,/user/hand/right/input/squeeze/value");
  341. profile->add_new_binding(grip_click, "/user/hand/left/input/squeeze/value,/user/hand/right/input/squeeze/value");
  342. // primary on our hpmr controller is our thumbstick.
  343. profile->add_new_binding(primary, "/user/hand/left/input/thumbstick,/user/hand/right/input/thumbstick");
  344. profile->add_new_binding(primary_click, "/user/hand/left/input/thumbstick/click,/user/hand/right/input/thumbstick/click");
  345. // No secondary on our hpmr controller.
  346. profile->add_new_binding(haptic, "/user/hand/left/output/haptic,/user/hand/right/output/haptic");
  347. add_interaction_profile(profile);
  348. // Create our Samsung Odyssey controller profile,
  349. // Note that this controller is only identified specifically on WMR, on SteamVR this is identified as a normal WMR controller.
  350. profile = OpenXRInteractionProfile::new_profile("/interaction_profiles/samsung/odyssey_controller");
  351. profile->add_new_binding(default_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  352. profile->add_new_binding(aim_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  353. profile->add_new_binding(grip_pose, "/user/hand/left/input/grip/pose,/user/hand/right/input/grip/pose");
  354. profile->add_new_binding(palm_pose, "/user/hand/left/input/palm_ext/pose,/user/hand/right/input/palm_ext/pose");
  355. // Odyssey controllers have no select button we can use.
  356. profile->add_new_binding(menu_button, "/user/hand/left/input/menu/click,/user/hand/right/input/menu/click");
  357. // Odyssey controller has no a/b/x/y buttons.
  358. profile->add_new_binding(trigger, "/user/hand/left/input/trigger/value,/user/hand/right/input/trigger/value");
  359. profile->add_new_binding(trigger_click, "/user/hand/left/input/trigger/value,/user/hand/right/input/trigger/value");
  360. profile->add_new_binding(grip, "/user/hand/left/input/squeeze/click,/user/hand/right/input/squeeze/click");
  361. profile->add_new_binding(grip_click, "/user/hand/left/input/squeeze/click,/user/hand/right/input/squeeze/click");
  362. // primary on our Odyssey controller is our thumbstick, no touch.
  363. profile->add_new_binding(primary, "/user/hand/left/input/thumbstick,/user/hand/right/input/thumbstick");
  364. profile->add_new_binding(primary_click, "/user/hand/left/input/thumbstick/click,/user/hand/right/input/thumbstick/click");
  365. // secondary on our Odyssey controller is our trackpad.
  366. profile->add_new_binding(secondary, "/user/hand/left/input/trackpad,/user/hand/right/input/trackpad");
  367. profile->add_new_binding(secondary_click, "/user/hand/left/input/trackpad/click,/user/hand/right/input/trackpad/click");
  368. profile->add_new_binding(secondary_touch, "/user/hand/left/input/trackpad/touch,/user/hand/right/input/trackpad/touch");
  369. profile->add_new_binding(haptic, "/user/hand/left/output/haptic,/user/hand/right/output/haptic");
  370. add_interaction_profile(profile);
  371. // Create our Vive Cosmos controller.
  372. profile = OpenXRInteractionProfile::new_profile("/interaction_profiles/htc/vive_cosmos_controller");
  373. profile->add_new_binding(default_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  374. profile->add_new_binding(aim_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  375. profile->add_new_binding(grip_pose, "/user/hand/left/input/grip/pose,/user/hand/right/input/grip/pose");
  376. profile->add_new_binding(palm_pose, "/user/hand/left/input/palm_ext/pose,/user/hand/right/input/palm_ext/pose");
  377. profile->add_new_binding(menu_button, "/user/hand/left/input/menu/click");
  378. profile->add_new_binding(select_button, "/user/hand/right/input/system/click"); // we'll map system to select.
  379. profile->add_new_binding(ax_button, "/user/hand/left/input/x/click,/user/hand/right/input/a/click"); // x on left hand, a on right hand.
  380. profile->add_new_binding(by_button, "/user/hand/left/input/y/click,/user/hand/right/input/b/click"); // y on left hand, b on right hand.
  381. profile->add_new_binding(trigger, "/user/hand/left/input/trigger/value,/user/hand/right/input/trigger/value");
  382. profile->add_new_binding(trigger_click, "/user/hand/left/input/trigger/click,/user/hand/right/input/trigger/click");
  383. profile->add_new_binding(grip, "/user/hand/left/input/squeeze/click,/user/hand/right/input/squeeze/click");
  384. profile->add_new_binding(grip_click, "/user/hand/left/input/squeeze/click,/user/hand/right/input/squeeze/click");
  385. // primary on our Cosmos controller is our thumbstick.
  386. profile->add_new_binding(primary, "/user/hand/left/input/thumbstick,/user/hand/right/input/thumbstick");
  387. profile->add_new_binding(primary_click, "/user/hand/left/input/thumbstick/click,/user/hand/right/input/thumbstick/click");
  388. profile->add_new_binding(primary_touch, "/user/hand/left/input/thumbstick/touch,/user/hand/right/input/thumbstick/touch");
  389. // No secondary on our cosmos controller.
  390. profile->add_new_binding(haptic, "/user/hand/left/output/haptic,/user/hand/right/output/haptic");
  391. add_interaction_profile(profile);
  392. // Create our Vive Focus 3 controller.
  393. // Note, Vive Focus 3 currently is not yet supported as a stand alone device
  394. // however HTC currently has a beta OpenXR runtime in testing we may support in the near future.
  395. profile = OpenXRInteractionProfile::new_profile("/interaction_profiles/htc/vive_focus3_controller");
  396. profile->add_new_binding(default_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  397. profile->add_new_binding(aim_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  398. profile->add_new_binding(grip_pose, "/user/hand/left/input/grip/pose,/user/hand/right/input/grip/pose");
  399. profile->add_new_binding(palm_pose, "/user/hand/left/input/palm_ext/pose,/user/hand/right/input/palm_ext/pose");
  400. profile->add_new_binding(menu_button, "/user/hand/left/input/menu/click");
  401. profile->add_new_binding(select_button, "/user/hand/right/input/system/click"); // we'll map system to select.
  402. profile->add_new_binding(ax_button, "/user/hand/left/input/x/click,/user/hand/right/input/a/click"); // x on left hand, a on right hand.
  403. profile->add_new_binding(by_button, "/user/hand/left/input/y/click,/user/hand/right/input/b/click"); // y on left hand, b on right hand.
  404. profile->add_new_binding(trigger, "/user/hand/left/input/trigger/value,/user/hand/right/input/trigger/value");
  405. profile->add_new_binding(trigger_click, "/user/hand/left/input/trigger/click,/user/hand/right/input/trigger/click");
  406. profile->add_new_binding(trigger_touch, "/user/hand/left/input/trigger/touch,/user/hand/right/input/trigger/touch");
  407. profile->add_new_binding(grip, "/user/hand/left/input/squeeze/click,/user/hand/right/input/squeeze/click");
  408. profile->add_new_binding(grip_click, "/user/hand/left/input/squeeze/click,/user/hand/right/input/squeeze/click");
  409. // primary on our Focus 3 controller is our thumbstick.
  410. profile->add_new_binding(primary, "/user/hand/left/input/thumbstick,/user/hand/right/input/thumbstick");
  411. profile->add_new_binding(primary_click, "/user/hand/left/input/thumbstick/click,/user/hand/right/input/thumbstick/click");
  412. profile->add_new_binding(primary_touch, "/user/hand/left/input/thumbstick/touch,/user/hand/right/input/thumbstick/touch");
  413. // We only have a thumb rest.
  414. profile->add_new_binding(secondary_touch, "/user/hand/left/input/thumbrest/touch,/user/hand/right/input/thumbrest/touch");
  415. profile->add_new_binding(haptic, "/user/hand/left/output/haptic,/user/hand/right/output/haptic");
  416. add_interaction_profile(profile);
  417. // Create our Huawei controller.
  418. profile = OpenXRInteractionProfile::new_profile("/interaction_profiles/huawei/controller");
  419. profile->add_new_binding(default_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  420. profile->add_new_binding(aim_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  421. profile->add_new_binding(grip_pose, "/user/hand/left/input/grip/pose,/user/hand/right/input/grip/pose");
  422. profile->add_new_binding(palm_pose, "/user/hand/left/input/palm_ext/pose,/user/hand/right/input/palm_ext/pose");
  423. profile->add_new_binding(menu_button, "/user/hand/left/input/home/click,/user/hand/right/input/home/click");
  424. profile->add_new_binding(trigger, "/user/hand/left/input/trigger/value,/user/hand/right/input/trigger/value");
  425. profile->add_new_binding(trigger_click, "/user/hand/left/input/trigger/click,/user/hand/right/input/trigger/click");
  426. // primary on our Huawei controller is our trackpad.
  427. profile->add_new_binding(primary, "/user/hand/left/input/trackpad,/user/hand/right/input/trackpad");
  428. profile->add_new_binding(primary_click, "/user/hand/left/input/trackpad/click,/user/hand/right/input/trackpad/click");
  429. profile->add_new_binding(primary_touch, "/user/hand/left/input/trackpad/touch,/user/hand/right/input/trackpad/touch");
  430. profile->add_new_binding(haptic, "/user/hand/left/output/haptic,/user/hand/right/output/haptic");
  431. add_interaction_profile(profile);
  432. // Create our HTC Vive tracker profile.
  433. profile = OpenXRInteractionProfile::new_profile("/interaction_profiles/htc/vive_tracker_htcx");
  434. profile->add_new_binding(default_pose,
  435. // "/user/vive_tracker_htcx/role/handheld_object/input/grip/pose," <-- getting errors on this one.
  436. "/user/vive_tracker_htcx/role/left_foot/input/grip/pose,"
  437. "/user/vive_tracker_htcx/role/right_foot/input/grip/pose,"
  438. "/user/vive_tracker_htcx/role/left_shoulder/input/grip/pose,"
  439. "/user/vive_tracker_htcx/role/right_shoulder/input/grip/pose,"
  440. "/user/vive_tracker_htcx/role/left_elbow/input/grip/pose,"
  441. "/user/vive_tracker_htcx/role/right_elbow/input/grip/pose,"
  442. "/user/vive_tracker_htcx/role/left_knee/input/grip/pose,"
  443. "/user/vive_tracker_htcx/role/right_knee/input/grip/pose,"
  444. "/user/vive_tracker_htcx/role/waist/input/grip/pose,"
  445. "/user/vive_tracker_htcx/role/chest/input/grip/pose,"
  446. "/user/vive_tracker_htcx/role/camera/input/grip/pose,"
  447. "/user/vive_tracker_htcx/role/keyboard/input/grip/pose");
  448. profile->add_new_binding(haptic,
  449. // "/user/vive_tracker_htcx/role/handheld_object/output/haptic," <-- getting errors on this one.
  450. "/user/vive_tracker_htcx/role/left_foot/output/haptic,"
  451. "/user/vive_tracker_htcx/role/right_foot/output/haptic,"
  452. "/user/vive_tracker_htcx/role/left_shoulder/output/haptic,"
  453. "/user/vive_tracker_htcx/role/right_shoulder/output/haptic,"
  454. "/user/vive_tracker_htcx/role/left_elbow/output/haptic,"
  455. "/user/vive_tracker_htcx/role/right_elbow/output/haptic,"
  456. "/user/vive_tracker_htcx/role/left_knee/output/haptic,"
  457. "/user/vive_tracker_htcx/role/right_knee/output/haptic,"
  458. "/user/vive_tracker_htcx/role/waist/output/haptic,"
  459. "/user/vive_tracker_htcx/role/chest/output/haptic,"
  460. "/user/vive_tracker_htcx/role/camera/output/haptic,"
  461. "/user/vive_tracker_htcx/role/keyboard/output/haptic");
  462. add_interaction_profile(profile);
  463. // Create our eye gaze interaction profile.
  464. profile = OpenXRInteractionProfile::new_profile("/interaction_profiles/ext/eye_gaze_interaction");
  465. profile->add_new_binding(default_pose, "/user/eyes_ext/input/gaze_ext/pose");
  466. add_interaction_profile(profile);
  467. // Create our hand interaction profile.
  468. profile = OpenXRInteractionProfile::new_profile("/interaction_profiles/ext/hand_interaction_ext");
  469. profile->add_new_binding(default_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  470. profile->add_new_binding(aim_pose, "/user/hand/left/input/aim/pose,/user/hand/right/input/aim/pose");
  471. profile->add_new_binding(grip_pose, "/user/hand/left/input/grip/pose,/user/hand/right/input/grip/pose");
  472. profile->add_new_binding(palm_pose, "/user/hand/left/input/palm_ext/pose,/user/hand/right/input/palm_ext/pose");
  473. // Use pinch as primary.
  474. profile->add_new_binding(primary, "/user/hand/left/input/pinch_ext/value,/user/hand/right/input/pinch_ext/value");
  475. profile->add_new_binding(primary_click, "/user/hand/left/input/pinch_ext/ready_ext,/user/hand/right/input/pinch_ext/ready_ext");
  476. // Use activation as secondary.
  477. profile->add_new_binding(secondary, "/user/hand/left/input/aim_activate_ext/value,/user/hand/right/input/aim_activate_ext/value");
  478. profile->add_new_binding(secondary_click, "/user/hand/left/input/aim_activate_ext/ready_ext,/user/hand/right/input/aim_activate_ext/ready_ext");
  479. // We link grasp to our grip.
  480. profile->add_new_binding(grip, "/user/hand/left/input/grasp_ext/value,/user/hand/right/input/grasp_ext/value");
  481. profile->add_new_binding(grip_click, "/user/hand/left/input/grasp_ext/ready_ext,/user/hand/right/input/grasp_ext/ready_ext");
  482. add_interaction_profile(profile);
  483. }
  484. void OpenXRActionMap::create_editor_action_sets() {
  485. // TODO implement
  486. }
  487. Ref<OpenXRAction> OpenXRActionMap::get_action(const String p_path) const {
  488. PackedStringArray paths = p_path.split("/", false);
  489. ERR_FAIL_COND_V(paths.size() != 2, Ref<OpenXRAction>());
  490. Ref<OpenXRActionSet> action_set = find_action_set(paths[0]);
  491. if (action_set.is_valid()) {
  492. return action_set->get_action(paths[1]);
  493. }
  494. return Ref<OpenXRAction>();
  495. }
  496. void OpenXRActionMap::remove_action(const String p_path, bool p_remove_interaction_profiles) {
  497. Ref<OpenXRAction> action = get_action(p_path);
  498. if (action.is_valid()) {
  499. for (int i = 0; i < interaction_profiles.size(); i++) {
  500. Ref<OpenXRInteractionProfile> interaction_profile = interaction_profiles[i];
  501. if (p_remove_interaction_profiles) {
  502. // Remove any bindings for this action
  503. interaction_profile->remove_binding_for_action(action);
  504. } else {
  505. ERR_FAIL_COND(interaction_profile->has_binding_for_action(action));
  506. }
  507. }
  508. OpenXRActionSet *action_set = action->get_action_set();
  509. if (action_set != nullptr) {
  510. // Remove the action from this action set
  511. action_set->remove_action(action);
  512. }
  513. }
  514. }
  515. PackedStringArray OpenXRActionMap::get_top_level_paths(const Ref<OpenXRAction> p_action) {
  516. PackedStringArray arr;
  517. for (int i = 0; i < interaction_profiles.size(); i++) {
  518. Ref<OpenXRInteractionProfile> ip = interaction_profiles[i];
  519. const OpenXRInteractionProfileMetadata::InteractionProfile *profile = OpenXRInteractionProfileMetadata::get_singleton()->get_profile(ip->get_interaction_profile_path());
  520. if (profile != nullptr) {
  521. Vector<Ref<OpenXRIPBinding>> bindings = ip->get_bindings_for_action(p_action);
  522. for (const Ref<OpenXRIPBinding> &binding : bindings) {
  523. String binding_path = binding->get_binding_path();
  524. const OpenXRInteractionProfileMetadata::IOPath *io_path = profile->get_io_path(binding_path);
  525. if (io_path != nullptr) {
  526. String top_path = io_path->top_level_path;
  527. if (!arr.has(top_path)) {
  528. arr.push_back(top_path);
  529. }
  530. }
  531. }
  532. }
  533. }
  534. // print_line("Toplevel paths for", p_action->get_name_with_set(), "are", arr);
  535. return arr;
  536. }
  537. OpenXRActionMap::~OpenXRActionMap() {
  538. action_sets.clear();
  539. interaction_profiles.clear();
  540. }