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 Update() { if (TBSettings.GetControlSettings().supportsHandControllers) { UpdateHandControllers(); } }
public virtual void Initialize() { emptyLookupTable = new TBInput.ButtonLookupTable <T>(); _activeController = GetActiveController(); // Load supported input types. if (TBSettings.GetControlSettings().supportsHandControllers) { LoadHandControllers(); } if (TBSettings.GetControlSettings().supports3DOFControllers) { Load3DOFControllers(); } if (TBSettings.GetControlSettings().supportsClickRemote) { LoadClickRemotes(); } if (TBSettings.GetControlSettings().supportsGamepad) { LoadGamepads(); } TBCore.Events.OnSystemMenu += RefreshInput; }
protected override void OnStartup(StartupEventArgs e) { logger.Debug("Template Builder starting up."); if (AppDomain.CurrentDomain.SetupInformation .ActivationArguments?.ActivationData != null && AppDomain.CurrentDomain.SetupInformation .ActivationArguments.ActivationData.Length > 0) { TBSettings.StartUpFilePath = ""; try { string fname = AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0]; // It comes in as a URI; this helps to convert it to a path. Uri uri = new Uri(fname); string startUpFilePath = uri.LocalPath; logger.Debug("StartUp file path: {0}", startUpFilePath); TBSettings.StartUpFilePath = startUpFilePath; } catch (Exception) { logger.Error("Couldn't process startup arguments as a path."); } TBSettings.Save(); } else { TBSettings.StartUpFilePath = ""; TBSettings.Save(); logger.Debug("No startup arguments passed."); } base.OnStartup(e); }
/// <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 OnDestroy() { base.OnDestroy(); if (TBSettings.GetControlSettings().supportsGamepad) { TBCore.OnUpdate -= TBXInput.instance.Update; TBCore.OnFixedUpdate -= TBXInput.instance.FixedUpdate; } }
public override void Initialize() { base.Initialize(); if (TBSettings.GetControlSettings().supportsGamepad) { TBXInput.instance.Initialize(); TBCore.OnUpdate += TBXInput.instance.Update; TBCore.OnFixedUpdate += TBXInput.instance.FixedUpdate; _useXInputWrapper = true; } }
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(); } }