private float PrimaryAxis(InputManager.ControllerName name, GetVrInputHelper helper, SteamVR_Action_Vector2 action) { bool scrollX = App.VrSdk.VrControls.PrimaryScrollDirectionIsX(Behavior.ControllerName); Vector2 axis = helper.Axis(action); return(scrollX ? axis.x : axis.y); }
private bool GetVrInputForFrame(VrInput input, bool currentFrame) { SteamVR_Input_ActionSet_TiltBrush tb = SteamVR_Actions.TiltBrush; var h = new GetVrInputHelper(this, currentFrame); switch (input) { case VrInput.Button01: { return((h.State(tb.RI_PadClick) && PrimaryAxis(Behavior.ControllerName, h, tb.RI_PadDirectional) < 0.0f) || h.State(tb.RI_SecondaryButton)); } case VrInput.Button02: { return((h.State(tb.RI_PadClick) && PrimaryAxis(Behavior.ControllerName, h, tb.RI_PadDirectional) > 0.0f) || h.State(tb.RI_PrimaryButton)); } case VrInput.Button03: return(h.State(tb.RI_MenuButton) || h.State(tb.RI_PrimaryButton)); case VrInput.Button04: return(h.State(tb.RI_PadClick) || h.State(tb.RI_SecondaryButton)); case VrInput.Button05: return((h.State(tb.RI_PadClick) && h.Axis(tb.RI_PadDirectional).y > 0.0f) || h.State(tb.RI_PrimaryButton)); case VrInput.Button06: return((h.State(tb.RI_PadClick) && h.Axis(tb.RI_PadDirectional).y < 0.0f) || h.State(tb.RI_SecondaryButton)); case VrInput.Trigger: { Vector2 triggerRange = App.VrSdk.VrControls.TriggerActivationRange(Behavior.ControllerName); return(h.Axis(tb.RI_Trigger) > triggerRange.x); } case VrInput.Grip: if (h.Active(tb.RI_GripBinary)) { return(h.State(tb.RI_GripBinary)); } else { // Fallback in case nobody's bound RI_GripBinary. RI_GripBinary is preferred, // since it handles hysteresis, is tunable by end-users, etc. // GripActivationRange.x is not a great threshold since it's defined as the minimum // useful value and therefore will be set rather light. Vector2 gripRange = App.VrSdk.VrControls.GripActivationRange; return(h.Axis(tb.RI_GripAnalog) > gripRange.x); } case VrInput.Any: return(false); // TODO case VrInput.Directional: if (h.Active(tb.RI_Thumbstick)) { goto case VrInput.Thumbstick; } else { goto case VrInput.Touchpad; } case VrInput.Thumbstick: return(h.Axis(tb.RI_Thumbstick).sqrMagnitude > 0.0f); case VrInput.Touchpad: return(h.State(tb.RI_PadTouch)); } return(false); }