Skip to content

Commit

Permalink
Update the configuration and launch mechanism for the hybrid app feature
Browse files Browse the repository at this point in the history
  • Loading branch information
m4gr3d committed Mar 10, 2025
1 parent 1f4d075 commit 961f8d0
Show file tree
Hide file tree
Showing 10 changed files with 229 additions and 81 deletions.
2 changes: 1 addition & 1 deletion config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ext {

// Parse the release version from the gradle project properties (e.g: -Prelease_version=<version>)
getReleaseVersion = { ->
final String defaultVersion = "3.1.0-dev-SNAPSHOT"
final String defaultVersion = "4.0.0-dev-SNAPSHOT"

String releaseVersion = project.hasProperty("release_version") ? project.property("release_version") : defaultVersion
if (releaseVersion == null || releaseVersion.isEmpty()) {
Expand Down
23 changes: 18 additions & 5 deletions plugin/src/main/cpp/export/export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,15 @@ Dictionary OpenXREditorExportPlugin::_get_vendor_toggle_option(const String &ven
true);
}

OpenXREditorExportPlugin::HybridType OpenXREditorExportPlugin::_get_hybrid_app_setting_value() const {
return (HybridType)(int)ProjectSettings::get_singleton()->get_setting_with_override("xr/openxr/hybrid_app");
bool OpenXREditorExportPlugin::_is_hybrid_app_enabled() const {
return ProjectSettings::get_singleton()->get_setting_with_override("xr/hybrid_app/enabled");
}

OpenXRHybridApp::HybridMode OpenXREditorExportPlugin::_get_hybrid_app_launch_mode() const {
if (!_is_hybrid_app_enabled()) {
return OpenXRHybridApp::HYBRID_MODE_NONE;
}
return (OpenXRHybridApp::HybridMode)(int)ProjectSettings::get_singleton()->get_setting_with_override("xr/hybrid_app/launch_mode");
}

String OpenXREditorExportPlugin::_get_opening_activity_tag_for_panel_app() const {
Expand Down Expand Up @@ -127,6 +134,12 @@ String OpenXREditorExportPlugin::_get_common_activity_intent_filter_contents() c
<category android:name="android.intent.category.HOME" />
)";
}

if (_is_hybrid_app_enabled()) {
contents += R"(
<category android:name="org.godotengine.xr.hybrid.IMMERSIVE" />
)";
}
return contents;
}

Expand Down Expand Up @@ -198,11 +211,11 @@ Dictionary OpenXREditorExportPlugin::_get_export_options_overrides(const Ref<Edi
return overrides;
}

HybridType hybrid_type = _get_hybrid_app_setting_value();
if (hybrid_type != HYBRID_TYPE_DISABLED) {
OpenXRHybridApp::HybridMode hybrid_launch_mode = _get_hybrid_app_launch_mode();
if (hybrid_launch_mode != OpenXRHybridApp::HYBRID_MODE_NONE) {
// Unless this is a hybrid app that launches as a panel, then we want to force this option on.
// Otherwise, it needs to be off, so that the panel activity can be the one that's launched by default.
overrides["package/show_in_app_library"] = (hybrid_type != HYBRID_TYPE_START_AS_PANEL);
overrides["package/show_in_app_library"] = (hybrid_launch_mode != OpenXRHybridApp::HYBRID_MODE_PANEL);
}

return overrides;
Expand Down
11 changes: 7 additions & 4 deletions plugin/src/main/cpp/export/meta_export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ PackedStringArray MetaEditorExportPlugin::_get_export_features(const Ref<EditorE
}

// Add a feature to indicate that this is a hybrid app.
if (_is_openxr_enabled() && _get_hybrid_app_setting_value() != HYBRID_TYPE_DISABLED) {
if (_is_openxr_enabled() && _is_hybrid_app_enabled()) {
features.append(HYBRID_APP_FEATURE);
}

Expand Down Expand Up @@ -514,17 +514,18 @@ String MetaEditorExportPlugin::_get_android_manifest_application_element_content
contents += " <meta-data android:name=\"com.oculus.ossplash.background\" android:value=\"passthrough-contextual\" />\n";
}

HybridType hybrid_type = _get_hybrid_app_setting_value();
if (hybrid_type != HYBRID_TYPE_DISABLED) {
OpenXRHybridApp::HybridMode hybrid_launch_mode = _get_hybrid_app_launch_mode();
if (hybrid_launch_mode != OpenXRHybridApp::HYBRID_MODE_NONE) {
contents += _get_opening_activity_tag_for_panel_app();

contents +=
" <intent-filter>\n"
" <action android:name=\"android.intent.action.MAIN\" />\n"
" <category android:name=\"android.intent.category.DEFAULT\" />\n"
" <category android:name=\"org.godotengine.xr.hybrid.PANEL\" />\n"
" <category android:name=\"com.oculus.intent.category.2D\" />\n";

if (hybrid_type == HYBRID_TYPE_START_AS_PANEL) {
if (hybrid_launch_mode == OpenXRHybridApp::HYBRID_MODE_PANEL) {
contents += " <category android:name=\"android.intent.category.LAUNCHER\" />\n";
}

Expand All @@ -545,6 +546,8 @@ String MetaEditorExportPlugin::_get_android_manifest_activity_element_contents(c
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.DEFAULT" />
<!-- Enable access to OpenXR on Oculus mobile devices, no-op on other Android
platforms. -->
<category android:name="com.oculus.intent.category.VR" />
Expand Down
11 changes: 4 additions & 7 deletions plugin/src/main/cpp/include/export/export_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

#pragma once

#include "classes/openxr_hybrid_app.h"

#include <godot_cpp/classes/display_server.hpp>
#include <godot_cpp/classes/editor_export_platform.hpp>
#include <godot_cpp/classes/editor_export_plugin.hpp>
Expand Down Expand Up @@ -70,12 +72,6 @@ class OpenXREditorExportPlugin : public EditorExportPlugin {
GDCLASS(OpenXREditorExportPlugin, EditorExportPlugin)

public:
enum HybridType {
HYBRID_TYPE_DISABLED,
HYBRID_TYPE_START_AS_IMMERSIVE,
HYBRID_TYPE_START_AS_PANEL,
};

OpenXREditorExportPlugin();

String _get_name() const override;
Expand Down Expand Up @@ -114,7 +110,8 @@ class OpenXREditorExportPlugin : public EditorExportPlugin {

Dictionary _get_vendor_toggle_option(const String &vendor_name) const;

HybridType _get_hybrid_app_setting_value() const;
bool _is_hybrid_app_enabled() const;
OpenXRHybridApp::HybridMode _get_hybrid_app_launch_mode() const;

String _get_opening_activity_tag_for_panel_app() const;

Expand Down
35 changes: 24 additions & 11 deletions plugin/src/main/cpp/register_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,19 +291,32 @@ void add_plugin_project_settings() {
}

{
String hybrid_app_setting = "xr/openxr/hybrid_app";
if (!project_settings->has_setting(hybrid_app_setting)) {
project_settings->set_setting(hybrid_app_setting, OpenXRHybridApp::HYBRID_MODE_NONE);
String hybrid_app_enabled_setting = "xr/hybrid_app/enabled";
if (!project_settings->has_setting(hybrid_app_enabled_setting)) {
project_settings->set_setting(hybrid_app_enabled_setting, false);
}

project_settings->set_initial_value(hybrid_app_setting, OpenXRHybridApp::HYBRID_MODE_NONE);
project_settings->set_as_basic(hybrid_app_setting, false);
Dictionary property_info;
property_info["name"] = hybrid_app_setting;
property_info["type"] = Variant::Type::INT;
property_info["hint"] = PROPERTY_HINT_ENUM;
property_info["hint_string"] = "Disabled:-1,Start As Immersive:0,Start As Panel:1";
project_settings->add_property_info(property_info);
project_settings->set_initial_value(hybrid_app_enabled_setting, false);
project_settings->set_as_basic(hybrid_app_enabled_setting, true);
Dictionary hybrid_app_enabled_property_info;
hybrid_app_enabled_property_info["name"] = hybrid_app_enabled_setting;
hybrid_app_enabled_property_info["type"] = Variant::Type::BOOL;
hybrid_app_enabled_property_info["hint"] = PROPERTY_HINT_NONE;
project_settings->add_property_info(hybrid_app_enabled_property_info);

String hybrid_app_launch_mode_setting = "xr/hybrid_app/launch_mode";
if (!project_settings->has_setting(hybrid_app_launch_mode_setting)) {
project_settings->set_setting(hybrid_app_launch_mode_setting, OpenXRHybridApp::HYBRID_MODE_IMMERSIVE);
}

project_settings->set_initial_value(hybrid_app_launch_mode_setting, OpenXRHybridApp::HYBRID_MODE_IMMERSIVE);
project_settings->set_as_basic(hybrid_app_launch_mode_setting, true);
Dictionary hybrid_app_launch_mode_property_info;
hybrid_app_launch_mode_property_info["name"] = hybrid_app_launch_mode_setting;
hybrid_app_launch_mode_property_info["type"] = Variant::Type::INT;
hybrid_app_launch_mode_property_info["hint"] = PROPERTY_HINT_ENUM;
hybrid_app_launch_mode_property_info["hint_string"] = "Start As Immersive:0,Start As Panel:1";
project_settings->add_property_info(hybrid_app_launch_mode_property_info);
}
}

Expand Down
Loading

0 comments on commit 961f8d0

Please sign in to comment.