diff options
| author | Yuri Sizov <11782833+YuriSizov@users.noreply.github.com> | 2023-03-25 15:07:51 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-25 15:07:51 +0100 |
| commit | d20c520d96ec2c119ae00bf87868d0ddf436dc14 (patch) | |
| tree | aec878b59ac6ed5d0740980ace94650f42c5a7ed /modules/openxr | |
| parent | e4e63f976abb264f109725b6524cd8aa38d99ac0 (diff) | |
| parent | e31c2e42774f0b56608662f239a32f7734513a99 (diff) | |
| download | redot-engine-d20c520d96ec2c119ae00bf87868d0ddf436dc14.tar.gz | |
Merge pull request #74848 from BastiaanOlij/add_xr_system_info
Add a get_system_info method to XRInterface
Diffstat (limited to 'modules/openxr')
| -rw-r--r-- | modules/openxr/openxr_api.cpp | 7 | ||||
| -rw-r--r-- | modules/openxr/openxr_api.h | 6 | ||||
| -rw-r--r-- | modules/openxr/openxr_interface.cpp | 11 | ||||
| -rw-r--r-- | modules/openxr/openxr_interface.h | 1 |
4 files changed, 24 insertions, 1 deletions
diff --git a/modules/openxr/openxr_api.cpp b/modules/openxr/openxr_api.cpp index af59fe7dde..4b39a6295c 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; |
