public override void TriggerControllerHaptics(float seconds) { if (!IndexIsValid()) { return; } SteamVR_Input_ActionSet_TiltBrush tb = SteamVR_Actions.TiltBrush; SteamVR_Input_Sources index = TrackedPose.inputSource; float durationSeconds = seconds * m_HapticsDurationScale; tb.Haptic[index].Execute(0.0f, durationSeconds, 1.0f, m_HapticsAmplitudeScale); }
public override float GetScrollXDelta() { if (!IndexIsValid()) { return(0); } SteamVR_Input_ActionSet_TiltBrush tb = SteamVR_Actions.TiltBrush; SteamVR_Input_Sources index = TrackedPose.inputSource; // If thumbstick is bound, use that. Otherwise, look at pad movement. // NOTE: Not all thumbsticks detect touch, which is why we don't reference it here. if (tb.RI_Thumbstick[index].active) { float value = tb.RI_Thumbstick[index].axis.x; if (Mathf.Abs(value) < kThumbstickDeadzone) { return(0f); } else { return(value); } } if (tb.RI_PadDirectional[index].active && tb.RI_PadTouch[index].active) { // If we weren't active last frame, return 0 and set ourselves up for success next frame. if (!tb.RI_PadTouch[index].lastState) { return(0.0f); } // This clamping alleviates bounce-back effect as finger slides off the capacitive touch pad. Vector2 range = App.VrSdk.VrControls.TouchpadActivationRange; float xCurr = tb.RI_PadDirectional[index].axis.x; float xPrev = tb.RI_PadDirectional[index].lastAxis.x; xCurr = Mathf.Clamp(xCurr, range.x, range.y); xPrev = Mathf.Clamp(xPrev, range.x, range.y); return(kInputScrollScalar * (xCurr - xPrev)); } return(0.0f); }
public override float GetScrollYDelta() { if (!IndexIsValid()) { return(0); } SteamVR_Input_ActionSet_TiltBrush tb = SteamVR_Actions.TiltBrush; SteamVR_Input_Sources index = TrackedPose.inputSource; // If thumbstick is bound, use that. Otherwise, look at pad movement. if (tb.RI_Thumbstick[index].active && tb.RI_ThumbstickTouch[index].active) { if (tb.RI_ThumbstickTouch[index].state) { Vector2 range = App.VrSdk.VrControls.TouchpadActivationRange; return(Mathf.Clamp(tb.RI_Thumbstick[index].axis.y, range.x, range.y)); } } if (tb.RI_PadDirectional[index].active && tb.RI_PadTouch[index].active) { // If we weren't active last frame, return 0 and set ourselves up for success next frame. if (!tb.RI_PadTouch[index].lastState) { return(0.0f); } // This clamping alleviates bounce-back effect as finger slides off the capacitive touch pad. Vector2 range = App.VrSdk.VrControls.TouchpadActivationRange; float yCurr = tb.RI_PadDirectional[index].axis.y; float yPrev = tb.RI_PadDirectional[index].lastAxis.y; yCurr = Mathf.Clamp(yCurr, range.x, range.y); yPrev = Mathf.Clamp(yPrev, range.x, range.y); return(kInputScrollScalar * (yCurr - yPrev)); } return(0.0f); }
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); }