public static Type GetTypeFor(EControllersButton buttonInteracting) { switch (buttonInteracting) { case EControllersButton.A_BUTTON: return typeof(AButtonInputCapture); case EControllersButton.B_BUTTON: return typeof(BButtonInputCapture); case EControllersButton.X_BUTTON: return typeof(XButtonInputCapture); case EControllersButton.Y_BUTTON: return typeof(YButtonInputCapture); case EControllersButton.THUMBREST: return typeof(ThumbrestInputCapture); case EControllersButton.BACK_BUTTON: return typeof(GoAndGearVRInputCapture); case EControllersButton.TRIGGER: return typeof(TriggerInputCapture); case EControllersButton.GRIP: return typeof(GripInputCapture); case EControllersButton.MENU: return typeof(MenuInputCapture); case EControllersButton.TOUCHPAD: return typeof(TouchpadInputCapture); default: Debug.LogErrorFormat("<b>[VRSF] :</b> Please Specify valid buttons to use for your ControllersButtonResponseAssigners."); return null; } }
/// <summary> /// Get a type of IComponentData based on a controller button interacting, or EControllersButton /// </summary> /// <param name="buttonInteracting">The requested button on the controller</param> /// <returns>The corresponding Type (or IComponentData) corresponding to the requested button</returns> public static Type GetTypeFor(EControllersButton buttonInteracting) { switch (buttonInteracting) { // basic buttons, on all controller case EControllersButton.TRIGGER: return(typeof(TriggerInputCapture)); case EControllersButton.GRIP: return(typeof(GripInputCapture)); case EControllersButton.MENU: return(typeof(MenuInputCapture)); case EControllersButton.TOUCHPAD: return(typeof(TouchpadInputCapture)); // Oculus Specific buttons case EControllersButton.A_BUTTON: return(typeof(AButtonInputCapture)); case EControllersButton.B_BUTTON: return(typeof(BButtonInputCapture)); case EControllersButton.X_BUTTON: return(typeof(XButtonInputCapture)); case EControllersButton.Y_BUTTON: return(typeof(YButtonInputCapture)); case EControllersButton.THUMBREST: return(typeof(ThumbrestInputCapture)); // Go and GearVR specific buttons case EControllersButton.BACK_BUTTON: return(typeof(GoAndGearVRInputCapture)); default: Debug.LogErrorFormat("<Color=red><b>[VRDF] :</b> Please Specify valid buttons to use for your ControllersButtonResponseAssigners.</Color>"); return(null); } }
private static bool InteractionIsCompatibleWithButton(EControllerInteractionType interactionType, EControllersButton button) { switch (button) { case EControllersButton.THUMBREST: // Only work with Touch Feature and Two Hand Oculus devices return(IsTwoHandOculusDevice() && (interactionType & EControllerInteractionType.TOUCH) == EControllerInteractionType.TOUCH); case EControllersButton.GRIP: switch (VRSF_Components.DeviceLoaded) { // No grip button case EDevice.GEAR_VR: case EDevice.OCULUS_GO: return(false); // Touch and Click supported case EDevice.OCULUS_QUEST: case EDevice.OCULUS_RIFT: case EDevice.OCULUS_RIFT_S: return(true); default: // If the user wanna use the touch feature on a non-Oculus or GearVR device, we display a warning if ((interactionType & EControllerInteractionType.TOUCH) == EControllerInteractionType.TOUCH) { Debug.LogWarning("<b>[VRSF] :</b> Grip Button has only a touch callback on non-Oculus devices."); } return((interactionType & EControllerInteractionType.CLICK) == EControllerInteractionType.CLICK); } case EControllersButton.MENU: switch (VRSF_Components.DeviceLoaded) { // No menu button case EDevice.GEAR_VR: case EDevice.OCULUS_GO: return(false); default: // If the user wanna use the touch feature on a Menu button, we display a warning if ((interactionType & EControllerInteractionType.TOUCH) == EControllerInteractionType.TOUCH) { Debug.LogWarning("<b>[VRSF] :</b> Menu Button has only a Click Callback."); } return((interactionType & EControllerInteractionType.CLICK) == EControllerInteractionType.CLICK); } case EControllersButton.BACK_BUTTON: // Only work with Click Feature and Portable VR return((interactionType & EControllerInteractionType.CLICK) == EControllerInteractionType.CLICK); default: return(true); } }
/// <summary> /// Add the corresponding InteractionType component for the selected button. /// </summary> public static bool AddInteractionType(ref EntityManager entityManager, ref Entity entity, EControllerInteractionType interactionType, EControllersButton button) { // If the button hand wasn't set in editor, we destroy this entity and return. if (interactionType == EControllerInteractionType.NONE || !InteractionIsCompatibleWithButton(interactionType, button)) { Debug.LogError("<b>[VRSF] :</b> Please Specify valid Interaction Types in your ControllersButtonResponseAssigners."); return(false); } else { // set the CBRA Interaction Type component to the entity entityManager.SetComponentData(entity, new ControllersInteractionType { InteractionType = interactionType, HasTouchInteraction = (interactionType & EControllerInteractionType.TOUCH) == EControllerInteractionType.TOUCH, HasClickInteraction = (interactionType & EControllerInteractionType.CLICK) == EControllerInteractionType.CLICK }); return(true); } }
/// <summary> /// Add a StartTouchingEventComp to activate the other systems /// </summary> /// <param name="hasTouchInteraction"></param> /// <param name="baseInput"></param> /// <param name="entity"></param> /// <param name="simulatedButton"></param> private void AddStartTouchingComp(bool hasTouchInteraction, ref BaseInputCapture baseInput, ref Entity entity, EControllersButton simulatedButton) { if (hasTouchInteraction) { EntityManager.AddComponentData(entity, new StartTouchingEventComp { HasWaitedOneFrameBeforeRemoval = false, ButtonInteracting = simulatedButton }); baseInput.IsTouching = true; } }
/// <summary> /// Add a StartClickingEventComp to activate the other systems /// </summary> /// <param name="hasClickInteraction"></param> /// <param name="baseInput"></param> /// <param name="entity"></param> /// <param name="simulatedButton"></param> private void AddStartClickingComp(bool hasClickInteraction, ref BaseInputCapture baseInput, ref Entity entity, EControllersButton simulatedButton) { // if the VRInteractionAuthoring has a Click Interaction set in editor if (hasClickInteraction) { EntityManager.AddComponentData(entity, new StartClickingEventComp { HasWaitedOneFrameBeforeRemoval = false, ButtonInteracting = simulatedButton }); baseInput.IsClicking = true; } }