1616
1717package com.example.xr.arcore
1818
19+ import android.app.Activity
1920import androidx.activity.ComponentActivity
2021import androidx.lifecycle.lifecycleScope
2122import androidx.xr.arcore.Hand
@@ -30,6 +31,7 @@ import androidx.xr.runtime.math.Quaternion
3031import androidx.xr.runtime.math.Vector3
3132import androidx.xr.scenecore.GltfModelEntity
3233import androidx.xr.scenecore.scene
34+ import kotlinx.coroutines.flow.Flow
3335import kotlinx.coroutines.launch
3436
3537@Suppress(" RestrictedApi" ) // b/416288516 - session.config and session.configure() are incorrectly restricted
@@ -65,6 +67,16 @@ fun ComponentActivity.collectHands(session: Session) {
6567 }
6668}
6769
70+ fun secondaryHandDetection (activity : Activity , session : Session ) {
71+ fun detectGesture (handState : Flow <Hand .State >) {}
72+ // [START androidxr_arcore_hand_handedness]
73+ val handedness = Hand .getHandedness(activity.contentResolver)
74+ val secondaryHand = if (handedness == Hand .Handedness .LEFT ) Hand .right(session) else Hand .left(session)
75+ val handState = secondaryHand?.state ? : return
76+ detectGesture(handState)
77+ // [END androidxr_arcore_hand_handedness]
78+ }
79+
6880fun ComponentActivity.renderPlanetAtHandPalm (leftHandState : Hand .State ) {
6981 val session: Session = null !!
7082 val palmEntity: GltfModelEntity = null !!
0 commit comments