@@ -610,37 +610,53 @@ class FakeVRDisplay extends VRDisplay {
610610const createVRDisplay = ( ) => new FakeVRDisplay ( ) ;
611611
612612const controllerIDs = {
613- oculusVRIDLeft : 'Oculus Touch (Left)' ,
614- oculusVRIDRight : 'Oculus Touch (Right)' ,
615- oculusMobileVRIDLeft : 'Oculus Touch (Left)' ,
616- oculusMobileVRIDRight : 'Oculus Touch (Right)' ,
617- openVRID : 'OpenVR Gamepad' ,
618- openVRTrackerID : 'OpenVR Tracker'
613+ OculusVRLeft : 'Oculus Touch (Left)' ,
614+ OculusVRRight : 'Oculus Touch (Right)' ,
615+ OculusQuestLeft : 'Oculus Touch (Left)' ,
616+ OculusQuestRight : 'Oculus Touch (Right)' ,
617+ OculusGo : 'Oculus Go' ,
618+ GearVR : 'Gear VR' ,
619+ OpenVR : 'OpenVR Gamepad' ,
620+ OpenVRTrackerID : 'Tracker'
619621} ;
620622
623+ function getControllerID ( vrDisplay , hand ) {
624+ if ( vrDisplay . id === 'OpenVR' ||
625+ vrDisplay . id === 'GearVR' ||
626+ vrDisplay . id === 'OculusGo' ) {
627+ return controllerIDs [ vrDisplay . id ] ;
628+ }
629+ return controllerIDs [ vrDisplay . id + hand . charAt ( 0 ) . toUpperCase ( ) + hand . slice ( 1 ) ] ;
630+ }
631+
621632let gamepads = null ;
622633function getGamepads ( window ) {
623634 const { oculusVRDisplay, openVRDisplay, oculusMobileVrDisplay, magicLeapARDisplay} = window [ symbols . mrDisplaysSymbol ] ;
624- if (
625- GlobalContext . fakeVrDisplayEnabled ||
626- oculusVRDisplay . isPresenting ||
627- openVRDisplay . isPresenting ||
628- oculusMobileVrDisplay . isPresenting ||
629- magicLeapARDisplay . isPresenting
630- ) {
635+ const presentingDisplay =
636+ ( GlobalContext . fakeVrDisplayEnabled && GlobalContext . fakePresentState . fakeVrDisplay ) ||
637+ ( oculusVRDisplay . isPresenting && oculusVRDisplay ) ||
638+ ( openVRDisplay . isPresenting && openVRDisplay ) ||
639+ ( oculusMobileVrDisplay . isPresenting && oculusMobileVrDisplay ) ||
640+ ( magicLeapARDisplay . isPresenting && magicLeapARDisplay ) ;
641+
642+ if ( presentingDisplay ) {
631643 if ( ! gamepads ) {
632- gamepads = Array ( 2 + maxNumTrackers ) ;
644+ const numGamepads = 2 ;
645+ if ( presentingDisplay === openVRDisplay ) {
646+ numGamepads += maxNumTrackers ;
647+ }
648+ gamepads = Array ( numGamepads ) ;
633649 for ( let i = 0 ; i < gamepads . length ; i ++ ) {
634650 let hand , id ;
635651 if ( i === 0 ) {
636652 hand = 'left' ;
637- id = openVRDisplay . isPresenting ? controllerIDs . openVRID : controllerIDs . oculusVRIDLeft ;
653+ id = getControllerID ( presentingDisplay , hand ) ;
638654 } else if ( i === 1 ) {
639655 hand = 'right' ;
640- id = openVRDisplay . isPresenting ? controllerIDs . openVRID : controllerIDs . oculusVRIDRight ;
656+ id = getControllerID ( presentingDisplay , hand ) ;
641657 } else {
642658 hand = null ;
643- id = controllerIDs . openVRTrackerID ;
659+ id = controllerIDs . OpenVRTrackerID ;
644660 }
645661 gamepads [ i ] = new Gamepad ( hand , i , id ) ;
646662 }
0 commit comments