summaryrefslogtreecommitdiff
path: root/modules/openxr/extensions
diff options
context:
space:
mode:
authorBastiaan Olij <mux213@gmail.com>2022-03-09 19:09:25 +1100
committerBastiaan Olij <mux213@gmail.com>2022-06-16 16:52:13 +1000
commit95f75b232fde3d55e6042819986a7ca71de62d3f (patch)
tree99e946d79eaa2cb54e147d3341be4c2932b3995a /modules/openxr/extensions
parent9ddf13e7addd26de56e16af64946751de291112d (diff)
Adding HTC tracker support
Diffstat (limited to 'modules/openxr/extensions')
-rw-r--r--modules/openxr/extensions/openxr_htc_vive_tracker_extension.cpp67
-rw-r--r--modules/openxr/extensions/openxr_htc_vive_tracker_extension.h52
2 files changed, 119 insertions, 0 deletions
diff --git a/modules/openxr/extensions/openxr_htc_vive_tracker_extension.cpp b/modules/openxr/extensions/openxr_htc_vive_tracker_extension.cpp
new file mode 100644
index 0000000000..302acf4e30
--- /dev/null
+++ b/modules/openxr/extensions/openxr_htc_vive_tracker_extension.cpp
@@ -0,0 +1,67 @@
+/*************************************************************************/
+/* openxr_htc_vive_tracker_extension.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "openxr_htc_vive_tracker_extension.h"
+#include "core/string/print_string.h"
+
+OpenXRHTCViveTrackerExtension *OpenXRHTCViveTrackerExtension::singleton = nullptr;
+
+OpenXRHTCViveTrackerExtension *OpenXRHTCViveTrackerExtension::get_singleton() {
+ return singleton;
+}
+
+OpenXRHTCViveTrackerExtension::OpenXRHTCViveTrackerExtension(OpenXRAPI *p_openxr_api) :
+ OpenXRExtensionWrapper(p_openxr_api) {
+ singleton = this;
+
+ request_extensions[XR_HTCX_VIVE_TRACKER_INTERACTION_EXTENSION_NAME] = &available;
+}
+
+OpenXRHTCViveTrackerExtension::~OpenXRHTCViveTrackerExtension() {
+ singleton = nullptr;
+}
+
+bool OpenXRHTCViveTrackerExtension::is_available() {
+ return available;
+}
+
+bool OpenXRHTCViveTrackerExtension::on_event_polled(const XrEventDataBuffer &event) {
+ switch (event.type) {
+ case XR_TYPE_EVENT_DATA_VIVE_TRACKER_CONNECTED_HTCX: {
+ // Investigate if we need to do more here
+ print_verbose("OpenXR EVENT: VIVE tracker connected");
+
+ return true;
+ } break;
+ default: {
+ return false;
+ } break;
+ }
+}
diff --git a/modules/openxr/extensions/openxr_htc_vive_tracker_extension.h b/modules/openxr/extensions/openxr_htc_vive_tracker_extension.h
new file mode 100644
index 0000000000..7670bc074b
--- /dev/null
+++ b/modules/openxr/extensions/openxr_htc_vive_tracker_extension.h
@@ -0,0 +1,52 @@
+/*************************************************************************/
+/* openxr_htc_vive_tracker_extension.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* https://godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef OPENXR_HTC_VIVE_TRACKER_EXTENSION_H
+#define OPENXR_HTC_VIVE_TRACKER_EXTENSION_H
+
+#include "openxr_extension_wrapper.h"
+
+class OpenXRHTCViveTrackerExtension : public OpenXRExtensionWrapper {
+public:
+ static OpenXRHTCViveTrackerExtension *get_singleton();
+
+ OpenXRHTCViveTrackerExtension(OpenXRAPI *p_openxr_api);
+ virtual ~OpenXRHTCViveTrackerExtension() override;
+
+ bool is_available();
+ virtual bool on_event_polled(const XrEventDataBuffer &event) override;
+
+private:
+ static OpenXRHTCViveTrackerExtension *singleton;
+
+ bool available = false;
+};
+
+#endif // !OPENXR_HTC_VIVE_TRACKER_EXTENSION_H