/// <summary> /// Override to set up inputs for the left and right controllers in a single def on 3DOF. /// </summary> protected override void Initialize() { loadedButtonDefs = TBInput.LoadButtonDefs(GetDefaultDefs(), fileName); if (TBCore.GetActiveHeadset() == VRHeadset.GearVR) { _instance.model = VRController.GearVRController; } loadedButtonDefs.Add(new TBInput.ButtonDef <OVRInput.RawButton>() { rawButton = OVRInput.RawButton.LTouchpad, virtualButtons = loadedButtonDefs[0].virtualButtons, name = "Touchpad Left", supportsTouch = true, supportsAxis2D = true }); loadedButtonDefs.Add(new TBInput.ButtonDef <OVRInput.RawButton>() { rawButton = OVRInput.RawButton.LIndexTrigger, virtualButtons = loadedButtonDefs[1].virtualButtons, name = "Trigger Left", supportsTouch = false, supportsAxis2D = false }); lookupTable = TBInput.NewLookupTableFromDefs(loadedButtonDefs); loaded = true; }
public override TBInput.Mobile3DOFHandedness Get3DOFHandedness() { if (TBCore.UsingEditorMode() || TBCore.GetActivePlatform() == VRPlatform.OculusPC) { if (TBSettings.GetControlSettings().handedness3DOF == TBSettings.TBHardwareHandedness.Left) { return(TBInput.Mobile3DOFHandedness.Left); } else { return(TBInput.Mobile3DOFHandedness.Right); } } else { if (OVRInput.IsControllerConnected(OVRInput.Controller.LTrackedRemote)) { return(TBInput.Mobile3DOFHandedness.Left); } else if (OVRInput.IsControllerConnected(OVRInput.Controller.RTrackedRemote)) { return(TBInput.Mobile3DOFHandedness.Right); } else { return(TBInput.Mobile3DOFHandedness.Center); } } }
public override void Initialize() { _serviceIDs = TBDataManager.DeserializeFromFile <OculusServiceIDs>(TBSettings.settingsFolder + TBOculusService.serviceFilename, TBDataManager.PathType.ResourcesFolder); switch (TBCore.GetActivePlatform()) { case VRPlatform.OculusMobile: switch (TButt.Settings.TBOculusSettings.GetOculusDeviceFamily()) { case Settings.TBOculusSettings.OculusDeviceFamily.GearVR: case Settings.TBOculusSettings.OculusDeviceFamily.Go: Core.AsyncInitialize(_serviceIDs.oculusMobile_ID).OnComplete((Message msg) => ContinueSetup(msg)); break; default: Core.AsyncInitialize(_serviceIDs.oculusQuest_ID).OnComplete((Message msg) => ContinueSetup(msg));; break; } break; case VRPlatform.OculusPC: Core.AsyncInitialize(_serviceIDs.oculusPC_ID).OnComplete((Message msg) => ContinueSetup(msg)); break; default: Debug.LogError("Attempted to initialize Oculus Platform service while running on a non-Oculus platform. This shouldn't happen and will probably cause you to be sad."); break; } }
/// <summary> /// Needed for generating a controller type compatible with Oculus SDK calls. /// </summary> /// <param name="controller"></param> /// <returns></returns> public static OVRInput.Controller GetOculusControllerID(TBInput.Controller controller) { if (controller == TBInput.Controller.Active) { controller = TBInput.GetActiveController(); } switch (controller) { case TBInput.Controller.LHandController: return(OVRInput.Controller.LTouch); case TBInput.Controller.RHandController: return(OVRInput.Controller.RTouch); case TBInput.Controller.Mobile3DOFController: if (TBCore.UsingEditorMode() || TBCore.GetActivePlatform() == VRPlatform.OculusPC) { if (TBSettings.GetControlSettings().handedness3DOF == TBSettings.TBHardwareHandedness.Left) { return(OVRInput.Controller.LTouch); } else { return(OVRInput.Controller.RTouch); } } else { if (OVRInput.IsControllerConnected(OVRInput.Controller.LTrackedRemote)) { return(OVRInput.Controller.LTrackedRemote); } else { return(OVRInput.Controller.RTrackedRemote); } } case TBInput.Controller.ClickRemote: if (TBCore.GetActivePlatform() == VRPlatform.OculusMobile) { return(OVRInput.Controller.Touchpad); } else { return(OVRInput.Controller.Remote); } case TBInput.Controller.Gamepad: return(OVRInput.Controller.Gamepad); } TBLogging.LogError("Controller type " + controller + " has no match for Oculus."); return(OVRInput.Controller.None); }
protected override void Load3DOFControllers() { if (TBCore.GetActivePlatform() == VRPlatform.Daydream) { controller_3DOF = TBController_Google_Daydream.instance; } else { base.Load3DOFControllers(); } }
public override void Initialize() { if (TBCore.GetActivePlatform() == VRPlatform.Daydream) { if (TBCore.instance.gameObject.GetComponent <GvrControllerInput>() == null) { TBCore.instance.gameObject.AddComponent <GvrControllerInput>(); } } base.Initialize(); }
public override VRController GetModel() { switch (TBCore.GetActiveHeadset()) { case VRHeadset.OculusGo: case VRHeadset.MiVRStandalone: return(VRController.OculusGoController); default: return(VRController.GearVRController); } }
protected virtual void PrintStartupResults() { TBLogging.LogMessage("TButt settings initialized. Diagnostics Report (click to view) \n" + "------------------------------------------------------------------------------------- \n" + "SystemInfo DeviceModel: " + SystemInfo.deviceModel + "\n" + "Device Name: " + SystemInfo.deviceName + "\n" + "Unity XR Device: " + UnityEngine.XR.XRSettings.loadedDeviceName + "\n" + "Unity XR Device Model: " + UnityEngine.XR.XRDevice.model + "\n" + "TButt Platform: " + TBCore.GetActivePlatform() + "\n" + "TButt HMD: " + TBCore.GetActiveHeadset() + "\n" + "Configured Renderscale: " + _displaySettings.renderscale + ", Actual Renderscale: " + UnityEngine.XR.XRSettings.eyeTextureResolutionScale + "\n" + "Configured Refresh Rate: " + _displaySettings.refreshRate + ", Actual Refresh Rate: " + UnityEngine.XR.XRDevice.refreshRate + "\n" + "Configured TBQuality Level: " + _displaySettings.qualityLevel); }
void Start() { if (controllerHand == ControllerHand.LeftController) { controller = TBInput.Controller.LHandController; } else { controller = TBInput.Controller.RHandController; } defaultMaterial = renderer.material; if (TBCore.GetActiveHeadset() == VRHeadset.HTCVive) { useTouchpadInsteadOfJoystick = true; } }
protected override void LoadClickRemotes() { if (TBCore.UsingEditorMode() || (TBCore.GetActivePlatform() == VRPlatform.OculusPC)) // Oculus Remote is only supported click remote when in the editor or on PC builds. { controller_ClickRemote = TBController_Oculus_Remote.instance; #if UNITY_ANDROID TBLogging.LogMessage("Using Oculus Remote instead of Gear VR Touchpad when running Gear VR builds in the editor."); #endif } else if (TBCore.GetActivePlatform() == VRPlatform.OculusMobile) // Use Gear VR Touchpad when in Android builds { switch (Settings.TBOculusSettings.GetOculusDeviceFamily()) { case Settings.TBOculusSettings.OculusDeviceFamily.GearVR: case Settings.TBOculusSettings.OculusDeviceFamily.Unknown: controller_ClickRemote = TBController_Oculus_GearVRTouchpad.instance; break; } } }
protected override void LoadHandControllers() { switch (TBCore.GetActiveHeadset()) { case VRHeadset.OculusRift: controller_LHand = TBController_SteamVR_OculusTouchLeft.instance; controller_RHand = TBController_SteamVR_OculusTouchRight.instance; break; case VRHeadset.WindowsMR: controller_LHand = TBController_SteamVR_WindowsMixedRealityLeft.instance; controller_RHand = TBController_SteamVR_WindowsMixedRealityRight.instance; break; default: controller_LHand = TBController_SteamVR_ViveControllerLeft.instance; controller_RHand = TBController_SteamVR_ViveControllerRight.instance; break; } }
protected override void Load3DOFControllers() { // 3DOF Controller emulation in the editor. if (TBCore.UsingEditorMode() && TBSettings.GetControlSettings().emulate3DOFArmModel) { if (TBSettings.GetControlSettings().handedness3DOF == TBSettings.TBHardwareHandedness.Left) { switch (TBCore.GetActiveHeadset()) { case VRHeadset.OculusRift: controller_3DOF = TBController_SteamVR_OculusTouchLeft.instance; break; case VRHeadset.WindowsMR: controller_3DOF = TBController_SteamVR_WindowsMixedRealityLeft.instance; break; default: controller_3DOF = TBController_SteamVR_ViveControllerLeft.instance; break; } } else { switch (TBCore.GetActiveHeadset()) { case VRHeadset.OculusRift: controller_3DOF = TBController_SteamVR_OculusTouchRight.instance; break; case VRHeadset.WindowsMR: controller_3DOF = TBController_SteamVR_WindowsMixedRealityRight.instance; break; default: controller_3DOF = TBController_SteamVR_ViveControllerRight.instance; break; } } } }
protected override void LoadHandControllers() { _numHapticSamples = (int)(320 / TBSettings.GetRefreshRate()) + 1; // Oculus Touch haptics update at 320hz. _leftRumble = new OVRHapticsClip(_numHapticSamples); _rightRumble = new OVRHapticsClip(_numHapticSamples); if (TBCore.GetActivePlatform() == VRPlatform.OculusMobile) { switch (Settings.TBOculusSettings.GetOculusDeviceFamily()) { case Settings.TBOculusSettings.OculusDeviceFamily.Quest: controller_LHand = TBController_Oculus_QuestLeft.instance; controller_RHand = TBController_Oculus_QuestRight.instance; break; default: Debug.LogWarning("Attempted to load hand controllers, but none are defined for " + Settings.TBOculusSettings.GetOculusDeviceFamily()); break; } } else { switch (TBCore.GetActiveHeadset()) { case VRHeadset.HTCVive: controller_LHand = TBController_Oculus_ViveControllerLeft.instance; controller_RHand = TBController_Oculus_ViveControllerRight.instance; break; default: // Currently, the only supported hand controller on PC is Oculus Touch. controller_LHand = TBController_Oculus_TouchLeft.instance; controller_RHand = TBController_Oculus_TouchRight.instance; break; } } }
protected override void Load3DOFControllers() { if (!TBCore.UsingEditorMode() && (TBCore.GetActivePlatform() == VRPlatform.OculusMobile)) // Prevents 3DOF controller from initializing when on PC unless we're in the editor. { controller_3DOF = TBController_Oculus_GearVRController.instance; } else if (TBCore.UsingEditorMode() || (TBCore.GetActivePlatform() == VRPlatform.OculusPC)) { if (TBSettings.GetControlSettings().handedness3DOF == TBSettings.TBHardwareHandedness.Left) { controller_3DOF = TBController_Oculus_TouchLeft.instance; } else { controller_3DOF = TBController_Oculus_TouchRight.instance; } TBLogging.LogMessage("Emulating 3DOF Controller with Oculus Touch controller with " + TBSettings.GetControlSettings().handedness3DOF + " handedness."); } else { base.Load3DOFControllers(); } }
protected virtual void LoadGamepads() { TBLogging.LogMessage("Gamepads are not defined for " + TBCore.GetActivePlatform() + ". Skipping..."); }
public virtual bool ResolveTouch(T button, TBInput.Controller controller) { TBLogging.LogMessage(TBCore.GetActivePlatform() + " does not have any inputs that support GetTouch"); return(false); }
public virtual float ResolveAxis1D(T button, TBInput.Controller controller) { TBLogging.LogMessage(TBCore.GetActivePlatform() + " does not have any inputs that support GetAxis1D"); return(0); }
public virtual Vector2 ResolveAxis2D(T button, TBInput.Controller controller) { TBLogging.LogMessage(TBCore.GetActivePlatform() + " does not have any inputs that support GetAxis2D"); return(Vector2.zero); }
protected virtual void LoadClickRemotes() { TBLogging.LogMessage("Click Remotes are not defined for " + TBCore.GetActivePlatform() + ". Skipping..."); }
public virtual Vector3 ResolveRawPosition(TBInput.Controller controller) { TBLogging.LogMessage(TBCore.GetActivePlatform() + " does not have any inputs that support GetRawPosition"); return(Vector3.zero); }
public virtual Quaternion ResolveRawRotation(TBInput.Controller controller) { TBLogging.LogMessage(TBCore.GetActivePlatform() + " does not have any inputs that support GetRawRotation"); return(Quaternion.identity); }
protected virtual void SetRefreshRate() { TBLogging.LogMessage("Custom refresh rate assignment not available (or not implemented) for " + TBCore.GetActivePlatform() + "."); }
protected virtual void Load3DOFControllers() { TBLogging.LogMessage("3DOF Controllers are not defined for " + TBCore.GetActivePlatform() + ". Skipping..."); }