Skip to content

Commit 353c871

Browse files
committed
Add support for Android XR devices to the Godot XR Editor
1 parent bd2ca13 commit 353c871

File tree

8 files changed

+63
-20
lines changed

8 files changed

+63
-20
lines changed

platform/android/java/app/config.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ext.versions = [
1515
// Also update 'platform/android/detect.py#get_ndk_version()' when this is updated.
1616
ndkVersion : '28.1.13356709',
1717
splashscreenVersion: '1.0.1',
18-
openxrVendorsVersion: '4.1.1-stable',
18+
openxrVendorsVersion: '4.2.0-stable',
1919
junitVersion : '1.3.0',
2020
espressoCoreVersion: '3.7.0',
2121
kotlinTestVersion : '1.3.11',

platform/android/java/editor/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ dependencies {
203203
implementation "androidx.constraintlayout:constraintlayout:2.2.1"
204204
implementation "org.bouncycastle:bcprov-jdk15to18:1.78"
205205

206+
// Android XR dependencies
207+
androidImplementation "org.godotengine:godot-openxr-vendors-androidxr:$versions.openxrVendorsVersion"
206208
// Meta dependencies
207209
horizonosImplementation "org.godotengine:godot-openxr-vendors-meta:$versions.openxrVendorsVersion"
208210
// Pico dependencies
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools">
3+
4+
<uses-feature
5+
android:name="android.software.xr.api.openxr"
6+
android:required="false" />
7+
8+
<!-- 6dof motion controllers -->
9+
<uses-feature android:name="android.hardware.xr.input.controller" android:required="false" />
10+
11+
<!-- Eye tracking -->
12+
<uses-feature android:name="android.hardware.xr.input.eye_tracking" android:required="false" />
13+
<uses-permission android:name="android.permission.EYE_TRACKING_FINE" />
14+
15+
<!-- Hand tracking -->
16+
<uses-feature android:name="android.hardware.xr.input.hand_tracking" android:required="false" />
17+
<uses-permission android:name="android.permission.HAND_TRACKING" />
18+
19+
<application>
20+
<uses-native-library android:name="libopenxr.google.so" android:required="false" />
21+
22+
<property
23+
android:name="android.window.PROPERTY_XR_BOUNDARY_TYPE_RECOMMENDED"
24+
android:value="XR_BOUNDARY_TYPE_NO_RECOMMENDATION" />
25+
26+
<activity
27+
android:name=".GodotXRGame"
28+
android:exported="false"
29+
tools:node="merge">
30+
<intent-filter>
31+
<action android:name="android.intent.action.MAIN" />
32+
33+
<category android:name="android.intent.category.DEFAULT" />
34+
<category android:name="org.khronos.openxr.intent.category.IMMERSIVE_HMD" />
35+
</intent-filter>
36+
<property
37+
android:name="android.window.PROPERTY_XR_ACTIVITY_START_MODE"
38+
android:value="XR_ACTIVITY_START_MODE_FULL_SPACE_UNMANAGED" />
39+
</activity>
40+
</application>
41+
42+
</manifest>

platform/android/java/editor/src/android/java/org/godotengine/editor/GodotEditor.kt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,16 @@ package org.godotengine.editor
3333
/**
3434
* Primary window of the Godot Editor.
3535
*
36-
* This is the implementation of the editor used when running on regular Android devices.
36+
* This is the implementation of the editor used when running on Android devices.
3737
*/
38-
open class GodotEditor : BaseGodotEditor()
38+
open class GodotEditor : BaseGodotEditor() {
39+
40+
override fun getXRRuntimePermissions(): MutableSet<String> {
41+
val xrRuntimePermissions = super.getXRRuntimePermissions()
42+
43+
xrRuntimePermissions.add("android.permission.EYE_TRACKING_FINE")
44+
xrRuntimePermissions.add("android.permission.HAND_TRACKING")
45+
46+
return xrRuntimePermissions
47+
}
48+
}

platform/android/java/editor/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@
115115
android:configChanges="layoutDirection|locale|orientation|keyboardHidden|screenSize|smallestScreenSize|density|keyboard|navigation|screenLayout|uiMode"
116116
android:process=":GodotXRGame"
117117
android:launchMode="singleTask"
118+
android:taskAffinity=":xr"
118119
android:icon="@mipmap/ic_play_window"
119120
android:label="@string/godot_game_activity_name"
120121
android:exported="false"

platform/android/java/editor/src/main/java/org/godotengine/editor/BaseGodotEditor.kt

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,7 @@ import org.godotengine.godot.error.Error
6969
import org.godotengine.godot.utils.DialogUtils
7070
import org.godotengine.godot.utils.PermissionsUtil
7171
import org.godotengine.godot.utils.ProcessPhoenix
72-
import org.godotengine.godot.utils.isNativeXRDevice
73-
import org.godotengine.godot.xr.HybridMode
74-
import org.godotengine.godot.xr.getHybridAppLaunchMode
75-
import org.godotengine.godot.xr.HYBRID_APP_PANEL_CATEGORY
76-
import org.godotengine.godot.xr.HYBRID_APP_IMMERSIVE_CATEGORY
72+
import org.godotengine.openxr.vendors.utils.*
7773
import kotlin.math.min
7874

7975
/**
@@ -743,12 +739,8 @@ abstract class BaseGodotEditor : GodotActivity(), GameMenuFragment.GameMenuListe
743739
return isNativeXRDevice(applicationContext)
744740
}
745741

746-
if (featureTag == "horizonos") {
747-
return BuildConfig.FLAVOR == "horizonos"
748-
}
749-
750-
if (featureTag == "picoos") {
751-
return BuildConfig.FLAVOR == "picoos"
742+
if (featureTag == BuildConfig.FLAVOR) {
743+
return true
752744
}
753745

754746
return super.supportsFeature(featureTag)

platform/android/java/editor/src/main/java/org/godotengine/editor/BaseGodotGame.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ import org.godotengine.godot.GodotLib
3838
import org.godotengine.godot.editor.utils.GameMenuUtils
3939
import org.godotengine.godot.utils.PermissionsUtil
4040
import org.godotengine.godot.utils.ProcessPhoenix
41-
import org.godotengine.godot.xr.HYBRID_APP_FEATURE
42-
import org.godotengine.godot.xr.isHybridAppEnabled
41+
import org.godotengine.openxr.vendors.utils.*
4342

4443
/**
4544
* Base class for the Godot play windows.

platform/android/java/editor/src/main/java/org/godotengine/editor/GodotGame.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,8 @@ import org.godotengine.editor.embed.GameMenuFragment
4343
import org.godotengine.godot.GodotLib
4444
import org.godotengine.godot.editor.utils.GameMenuUtils
4545
import org.godotengine.godot.utils.ProcessPhoenix
46-
import org.godotengine.godot.utils.isHorizonOSDevice
47-
import org.godotengine.godot.utils.isNativeXRDevice
48-
import org.godotengine.godot.xr.HYBRID_APP_PANEL_FEATURE
4946
import org.godotengine.godot.xr.XRMode
50-
import org.godotengine.godot.xr.isHybridAppEnabled
47+
import org.godotengine.openxr.vendors.utils.*
5148

5249
/**
5350
* Drives the 'run project' window of the Godot Editor.

0 commit comments

Comments
 (0)