summaryrefslogtreecommitdiffstats
path: root/modules/openxr
diff options
context:
space:
mode:
authorBastiaan Olij <mux213@gmail.com>2023-03-13 12:26:10 +1100
committerBastiaan Olij <mux213@gmail.com>2023-03-15 13:11:48 +1100
commite31c2e42774f0b56608662f239a32f7734513a99 (patch)
tree78b91f39cd216580746724b5ffdb7751d0ea1074 /modules/openxr
parent550a7798510810d238b733a54f69da71b2a2d152 (diff)
downloadredot-engine-e31c2e42774f0b56608662f239a32f7734513a99.tar.gz
Add a get_system_info method to XRInterface
Diffstat (limited to 'modules/openxr')
-rw-r--r--modules/openxr/openxr_api.cpp7
-rw-r--r--modules/openxr/openxr_api.h6
-rw-r--r--modules/openxr/openxr_interface.cpp11
-rw-r--r--modules/openxr/openxr_interface.h1
4 files changed, 24 insertions, 1 deletions
diff --git a/modules/openxr/openxr_api.cpp b/modules/openxr/openxr_api.cpp
index ddb3114b59..8509571012 100644
--- a/modules/openxr/openxr_api.cpp
+++ b/modules/openxr/openxr_api.cpp
@@ -385,8 +385,13 @@ bool OpenXRAPI::create_instance() {
if (XR_FAILED(result)) {
// not fatal probably
print_line("OpenXR: Failed to get XR instance properties [", get_error_string(result), "]");
+
+ runtime_name = "";
+ runtime_version = "";
} else {
- print_line("OpenXR: Running on OpenXR runtime: ", instanceProps.runtimeName, " ", OpenXRUtil::make_xr_version_string(instanceProps.runtimeVersion));
+ runtime_name = instanceProps.runtimeName;
+ runtime_version = OpenXRUtil::make_xr_version_string(instanceProps.runtimeVersion);
+ print_line("OpenXR: Running on OpenXR runtime: ", runtime_name, " ", runtime_version);
}
for (OpenXRExtensionWrapper *wrapper : registered_extension_wrappers) {
diff --git a/modules/openxr/openxr_api.h b/modules/openxr/openxr_api.h
index 8c642c4ff4..c8bef5d420 100644
--- a/modules/openxr/openxr_api.h
+++ b/modules/openxr/openxr_api.h
@@ -95,6 +95,10 @@ private:
uint32_t num_swapchain_formats = 0;
int64_t *supported_swapchain_formats = nullptr;
+ // system info
+ String runtime_name;
+ String runtime_version;
+
// configuration
XrFormFactor form_factor = XR_FORM_FACTOR_HEAD_MOUNTED_DISPLAY;
XrViewConfigurationType view_configuration = XR_VIEW_CONFIGURATION_TYPE_PRIMARY_STEREO;
@@ -294,6 +298,8 @@ public:
XrInstance get_instance() const { return instance; };
XrSystemId get_system_id() const { return system_id; };
XrSession get_session() const { return session; };
+ String get_runtime_name() const { return runtime_name; };
+ String get_runtime_version() const { return runtime_version; };
// helper method to convert an XrPosef to a Transform3D
Transform3D transform_from_pose(const XrPosef &p_pose);
diff --git a/modules/openxr/openxr_interface.cpp b/modules/openxr/openxr_interface.cpp
index 51de9b913a..27344c9da7 100644
--- a/modules/openxr/openxr_interface.cpp
+++ b/modules/openxr/openxr_interface.cpp
@@ -583,6 +583,17 @@ void OpenXRInterface::uninitialize() {
initialized = false;
}
+Dictionary OpenXRInterface::get_system_info() {
+ Dictionary dict;
+
+ if (openxr_api) {
+ dict[SNAME("XRRuntimeName")] = openxr_api->get_runtime_name();
+ dict[SNAME("XRRuntimeVersion")] = openxr_api->get_runtime_version();
+ }
+
+ return dict;
+}
+
bool OpenXRInterface::supports_play_area_mode(XRInterface::PlayAreaMode p_mode) {
return false;
}
diff --git a/modules/openxr/openxr_interface.h b/modules/openxr/openxr_interface.h
index 40ee95f02f..de758a8c2d 100644
--- a/modules/openxr/openxr_interface.h
+++ b/modules/openxr/openxr_interface.h
@@ -112,6 +112,7 @@ public:
virtual bool is_initialized() const override;
virtual bool initialize() override;
virtual void uninitialize() override;
+ virtual Dictionary get_system_info() override;
virtual void trigger_haptic_pulse(const String &p_action_name, const StringName &p_tracker_name, double p_frequency, double p_amplitude, double p_duration_sec, double p_delay_sec = 0) override;