Skip to content

Commit

Permalink
Manually request eye tracking permission if it's included in the app …
Browse files Browse the repository at this point in the history
…manifest

This is a follow-up of the changes made in godotengine/godot#87080
  • Loading branch information
m4gr3d committed Jan 12, 2024
1 parent f384632 commit 803b016
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,21 @@

package org.godotengine.openxr.vendors.meta

import android.app.Activity
import android.util.Log
import android.view.View
import org.godotengine.godot.Godot
import org.godotengine.godot.plugin.GodotPlugin
import org.godotengine.godot.utils.PermissionsUtil

/**
* Godot plugin for the Meta OpenXR loader.
*/
class GodotOpenXRMeta(godot: Godot?) : GodotPlugin(godot) {
companion object {
val TAG = GodotOpenXRMeta::class.java.simpleName
private val TAG = GodotOpenXRMeta::class.java.simpleName

private const val EYE_TRACKING_PERMISSION = "com.oculus.permission.EYE_TRACKING"

init {
try {
Expand All @@ -56,12 +61,21 @@ class GodotOpenXRMeta(godot: Godot?) : GodotPlugin(godot) {

override fun getPluginGDExtensionLibrariesPaths() = setOf("res://addons/godotopenxrvendors/meta/plugin.gdextension")

override fun onMainCreate(activity: Activity): View? {
// Request the eye tracking permission if it's included in the manifest
if (PermissionsUtil.hasManifestPermission(activity, EYE_TRACKING_PERMISSION)) {
Log.d(TAG, "Requesting permission '${EYE_TRACKING_PERMISSION}'")
PermissionsUtil.requestPermission(EYE_TRACKING_PERMISSION, activity)
}
return null
}

override fun supportsFeature(featureTag: String): Boolean {
if ("PERMISSION_XR_EXT_eye_gaze_interaction" == featureTag) {
val grantedPermissions = godot?.getGrantedPermissions()
if (grantedPermissions != null) {
for (permission in grantedPermissions) {
if ("com.oculus.permission.EYE_TRACKING" == permission) {
if (EYE_TRACKING_PERMISSION == permission) {
return true
}
}
Expand Down

0 comments on commit 803b016

Please sign in to comment.