private void init() { zInputToBooleanAction.Add("JoyMenu", SteamVR_Actions.valheim_ToggleMenu); zInputToBooleanAction.Add("Inventory", SteamVR_Actions.valheim_ToggleInventory); zInputToBooleanAction.Add("Jump", SteamVR_Actions.valheim_Jump); zInputToBooleanAction.Add("Use", SteamVR_Actions.valheim_Use); zInputToBooleanAction.Add("Sit", SteamVR_Actions.valheim_Sit); zInputToBooleanAction.Add("Map", SteamVR_Actions.valheim_ToggleMap); // These placement commands re-use some of the normal game inputs zInputToBooleanAction.Add("BuildMenu", SteamVR_Actions.laserPointers_RightClick); zInputToBooleanAction.Add("JoyPlace", SteamVR_Actions.laserPointers_LeftClick); zInputToBooleanAction.Add("Remove", SteamVR_Actions.valheim_Jump); contextScroll = SteamVR_Actions.valheim_ContextScroll; walk = SteamVR_Actions.valheim_Walk; pitchAndYaw = SteamVR_Actions.valheim_PitchAndYaw; poseL = SteamVR_Actions.valheim_PoseL; poseR = SteamVR_Actions.valheim_PoseR; initIgnoredZInputs(); }
private void MoveMethod(SteamVR_Action_Vector2 fromAction, SteamVR_Input_Sources fromSource, Vector2 axis, Vector2 delta) { _inputs = new Vector3(axis.x, 0, axis.y); }
private void Position(SteamVR_Action_Vector2 fromAction, SteamVR_Input_Sources fromSource, Vector2 axis, Vector2 delta) { radialMenu.SetTouchPosition(axis); }
private void Position(SteamVR_Action_Vector2 fromAction, SteamVR_Input_Sources fromSource, Vector2 axis, Vector2 delta) { print(axis); }
public Vector2 GetAxis2D(SteamVR_Action_Vector2 axis2D) { return(axis2D.GetAxis(handType)); }
void Update() { if (actionSetChanged) { switch (currentActionSet.GetShortName()) { case "MySet": currentActionSet.Activate(currentSource, 0, false); pose.poseAction = SteamVR_Input.GetAction <SteamVR_Action_Pose>("MySet", "Pose", false, false); gripClickAction = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("MySet", "GripClick", false, false); triggerPullAction = SteamVR_Input.GetAction <SteamVR_Action_Single>("MySet", "Teleport", false, false); joyStickAction = SteamVR_Input.GetAction <SteamVR_Action_Vector2>("MySet", "Move", false, false); break; case "Sword": currentActionSet.Activate(currentSource, 0, false); pose.poseAction = SteamVR_Input.GetAction <SteamVR_Action_Pose>("Sword", "Pose", false, false); //gripClickAction = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("Sword", "InitiateSlash", false, false); triggerClickAction = SteamVR_Input.GetAction <SteamVR_Action_Boolean>("Sword", "InitiateSlash", false, false); joyStickAction = SteamVR_Input.GetAction <SteamVR_Action_Vector2>("Sword", "Move", false, false); break; default: break; } actionSetChanged = false; } gripClick = gripClickAction.GetStateDown(currentSource); triggerClickUp = triggerClickAction.GetStateUp(currentSource); triggerValue = triggerPullAction.GetAxis(currentSource); triggerClick = triggerClickAction.GetLastStateDown(currentSource); detach = detachAction.GetStateDown(currentSource); moveValue = joyStickAction.GetAxis(currentSource); //INITIATESLASH CODE ---------------------------------------------------------------------------------------------------------------------------------- if (triggerClick && attached && currentActionSet.GetShortName().Equals("Sword")) { slashParticles = currentlyAttachedObject.GetComponent <ParticleSystem>(); ParticleSystem.EmissionModule emiss = slashParticles.emission; emiss.rateOverDistance = 200f; } if (triggerClickUp && attached && currentActionSet.GetShortName().Equals("Sword")) { slashParticles = currentlyAttachedObject.GetComponent <ParticleSystem>(); ParticleSystem.EmissionModule emiss = slashParticles.emission; emiss.rateOverDistance = 0f; } //OBJECT DETACH CODE --------------------------------------------------------------------------------------------------------------------------------- if (attached && detach && hover.closestHoverObj != null) { //Grab a reference to the current closestHoverObject that is obtained by running Hover() in Hover.cs try { ObjectInteraction detachCall = hover.closestHoverObj.GetComponent <ObjectInteraction>(); attached = detachCall.DetachObjectFromController(); currentActionSet.Deactivate(currentSource); currentActionSet = SteamVR_Input.GetActionSet("MySet"); currentlyAttachedObject = null; actionSetChanged = true; } catch (NullReferenceException) { Debug.LogWarning("detachCall Hand is null in OculusInput.cs"); return; } } //OBJECT ATTACH CODE --------------------------------------------------------------------------------------------------------------------------------- if (gripClick && hover.closestHoverObj != null && !attached) { try { ObjectInteraction attachCall = hover.closestHoverObj.GetComponent <ObjectInteraction>(); attached = attachCall.AttachObjectToController(this.gameObject, hover.hoverPoint); currentlyAttachedObject = hover.closestHoverObj; currentActionSet.Deactivate(currentSource); currentActionSet = SteamVR_Input.GetActionSet("Sword"); //CHANGE THIS LATER WHEN WE HAVE MORE THAN ONE ITEM TO PICK UP actionSetChanged = true; } catch (NullReferenceException) { Debug.LogWarning("attachCall Right Hand is null in OculusInput.cs"); return; } } //TRIGGER PRESS CODE --------------------------------------------------------------------------------------------------------------------------------- if (triggerValue > 0.1f) { int layerMask = (1 << 9); if (Physics.Raycast(transform.position, transform.forward - transform.up, out RaycastHit hit, 50f, layerMask)) { teleTarget.transform.position = hit.point; Debug.DrawRay(transform.position, (transform.forward - transform.up) * 100f, Color.blue, 5f); } } if (triggerValue > 0.75f && pressFlag)//Teleport using raycast { print("Teleport"); Debug.DrawRay(transform.position, transform.forward * 100f, Color.red); if (Physics.Raycast(transform.position, transform.forward - transform.up, out RaycastHit hit, 100f)) { cameraRig.transform.position = hit.point; } pressFlag = false; } if (triggerValue < 0.1f)//Must release or almost release trigger before teleporting again { pressFlag = true; } //JOYSTICK MOVEMENT CODE --------------------------------------------------------------------------------------------------------------------------------- if (moveValue.y > 0.1f || moveValue.y < -0.1f) {//Forward and Backward Vector3 controllerMove = new Vector3(((transform.forward - transform.up).normalized).x, 0f, (((transform.forward - transform.up).normalized).z)); cameraRig.transform.Translate(controllerMove * moveValue.y); } if (moveValue.x > 0.1f || moveValue.x < -0.1f) {//Right and Left Vector3 controllerMove = new Vector3(transform.right.x, 0f, transform.right.z); cameraRig.transform.Translate(controllerMove * moveValue.x); } }
private void OnTouchpadChanged(SteamVR_Action_Vector2 _action, SteamVR_Input_Sources _source, Vector2 _axis, Vector2 _delta) => onTouchpadAxisChanged.Invoke(GenerateArgs());
public void SetTouchPosition(SteamVR_Action_Vector2 fromAction, SteamVR_Input_Sources fromSource, Vector2 axis, Vector2 delta) { touchPosition = axis; }
public void OnChangeResize(SteamVR_Action_Vector2 fromAction, SteamVR_Input_Sources fromSource, Vector2 axis, Vector2 delta) { markerSystem.OnChangeResize(axis); }
public void OnChangeMovePlayer(SteamVR_Action_Vector2 fromAction, SteamVR_Input_Sources fromSource, Vector2 axis, Vector2 delta) { last_vector_move = axis; }
private void AxisTest(SteamVR_Action_Vector2 action, SteamVR_Input_Sources source, Vector2 axis, Vector2 delta) { }
private void MoveBody_OnUpdate(SteamVR_Action_Vector2 fromAction, SteamVR_Input_Sources fromSource, Vector2 axis, Vector2 delta) { movement.x = axis.x; movement.z = axis.y; }
private void Controller_onAxis(SteamVR_Action_Vector2 fromAction, SteamVR_Input_Sources fromSource, Vector2 axis, Vector2 delta) { Debug.Log($"User is touching point {axis.x}, {axis.y} : {delta.x}, {delta.y}"); }
private SteamVR_Action_Boolean touchPadTap; //if the touch pad is being touched void Start() { rb = this.gameObject.GetComponent <Rigidbody>(); touchPadAction = SteamVR_Input._default.inActions.TouchpadTouch; touchPadTap = SteamVR_Input._default.inActions.TouchpadTap; }
private void Awake() { clickMove = SteamVR_Actions.MovementSet.ClickMove; clickAxis = SteamVR_Actions.MovementSet.ClickAxis; }
private void OnTrackpadChange(SteamVR_Action_Vector2 fromaction, SteamVR_Input_Sources fromsource, Vector2 axis, Vector2 delta) { Debug.Log("Controller Movement. " + axis.ToString() + " | " + delta.ToString()); }
void Awake() { radial = SteamVR_Actions._default.WheelTouch; }
/* * @brief: function runs at a fixed rate of 1 / fixed time step */ void FixedUpdate() { if (global.startup) { return; } // Will only use VR Controller input if the control toggle from brachIOplexus is disabled if (!global.controlToggle) { // clears buffer clearRotationArray(); // Gets current values from the actions single = (SteamVR_Action_Single)trigger; // Gets a float 0 to 1 boolean = (SteamVR_Action_Boolean)push; // Gets a bool (if button is pressed or not) vector2 = (SteamVR_Action_Vector2)joystick; // Get a 2-D vector (0 to 1) // Determines if the end effectors should open or not // Will need to be expanded for future end effectors (only created for chopsticks) // if both triggers are pressed OR if neither triggers are pressed, don't move if (single.GetAxis(Left) != 0 && single.GetAxis(Right) != 0 || (single.GetAxis(Left) == 0 && single.GetAxis(Right) == 0)) { global.SteamVRControl[4] = 0; } else if (single.GetAxis(Left) != 0 && single.GetAxis(Right) == 0) { global.SteamVRControl[4] = single.GetAxis(Left); } else if (single.GetAxis(Left) == 0 && single.GetAxis(Right) != 0) { global.SteamVRControl[4] = -1 * single.GetAxis(Right); } // Checks if the controllers are from the VIVE if (SteamVR.instance.hmd_ModelNumber == "VIVE_Pro MV") { // Checks first if the trackpad is pressed down if (boolean.GetState(Left)) { // Gets values from the Left trackpad leftJoy = vector2.GetAxis(Left); // Only fills array if the value is above the threshold global.SteamVRControl[0] = Math.Abs(leftJoy.x) >= 0.15 ? -1 * leftJoy.x : 0; global.SteamVRControl[1] = Math.Abs(leftJoy.y) >= 0.15 ? -1 * leftJoy.y : 0; } // Checks first if the trackpad is pressed down if (boolean.GetState(Right)) { // Gets value from Right trackpad rightJoy = vector2.GetAxis(Right); // Only fills array if tyhe value is above the threshold global.SteamVRControl[2] = Math.Abs(rightJoy.x) >= 0.15 ? -1 * rightJoy.x : 0; global.SteamVRControl[3] = Math.Abs(rightJoy.y) >= 0.15 ? -1 * rightJoy.y : 0; } } else { // Gets values from the Left trackpad leftJoy = vector2.GetAxis(Left); // Only fills array if the value is above the threshold global.SteamVRControl[0] = Math.Abs(leftJoy.x) >= 0.15 ? -1 * leftJoy.x : 0; global.SteamVRControl[1] = Math.Abs(leftJoy.y) >= 0.15 ? -1 * leftJoy.y : 0; // Gets value from Right trackpad rightJoy = vector2.GetAxis(Right); // Only fills array if tyhe value is above the threshold global.SteamVRControl[2] = Math.Abs(rightJoy.x) >= 0.15 ? -1 * rightJoy.x : 0; global.SteamVRControl[3] = Math.Abs(rightJoy.y) >= 0.15 ? -1 * rightJoy.y : 0; } } }
private void OnPositionChanged(SteamVR_Action_Vector2 fromAction, SteamVR_Input_Sources fromSource, Vector2 axis, Vector2 delta) => positionEvent.Invoke(fromAction, fromSource, axis, delta);
public override void Initialize(ActionCanvasBase actionCanvasBase) { base.Initialize(actionCanvasBase); actionAxis = SteamVR_Input.GetAction <SteamVR_Action_Vector2>(actionName + "Axis"); }
public Vector2 getTrackPadPosRight() { SteamVR_Action_Vector2 trackpadPos = SteamVR_Input._default.inActions.TouchpadPos; return(trackpadPos.GetAxis(rightHand.GetComponent <Hand>().handType)); }
/// <summary> /// Returns the axis of a given SteamVR 2D action. /// </summary> protected Vector2 CheckSteamVR2DAxis(SteamVR_Action_Vector2 action) { return(action.GetAxis(GetSteamVRInputSource())); }
private void OnWarpAction(SteamVR_Action_Vector2 fromAction, SteamVR_Input_Sources fromSource, Vector2 axis, Vector2 delta) { warpRaw += axis.y * sensitivity; }
public Vector2 getTrackpadPosition() { SteamVR_Action_Vector2 trackpadPos = SteamVR_Actions._default.touchpadPos; return(trackpadPos.GetAxis(hand.handType)); }
public Vector2 getTrackPadPos() { SteamVR_Action_Vector2 trackpadPos = SteamVR_Actions._default.touchpos; return(trackpadPos.GetAxis(SteamVR_Input_Sources.LeftHand)); }
protected override void FillMetadata(HandAnchor anchor, ref XRNodeState xRNode) { //base.UpdateHandNodeState(hand, ref xRNode); float thumb = 0f, index = 0f, middle = 0f; //psotion && rotation xRNode.TryGetPosition(out anchor.position); xRNode.TryGetRotation(out anchor.rotation); var inputSource = SteamVR_Input_Sources.LeftHand; string skeletonHandName = "SkeletonLeftHand"; if (anchor.type == NodeType.RightHand) { inputSource = SteamVR_Input_Sources.RightHand; skeletonHandName = "skeletonRightHand"; } //SteamVR_Action_Boolean key_MenuKey = SteamVR_Input.GetBooleanAction("MenuKey"); //SteamVR_Action_Boolean key_SystemKey = SteamVR_Input.GetBooleanAction("SystemKey"); //trigger SteamVR_Action_Boolean triggerPressed = SteamVR_Input.GetBooleanAction("Trigger"); //SteamVR_Action_Single triggerTouchValue = SteamVR_Input.GetSingleAction("triggerTouchValue"); anchor.triggerPressed = triggerPressed.GetState(inputSource); anchor.triggerTouchValue = Mathf.Lerp(anchor.triggerTouchValue, anchor.triggerPressed ? 1f : 0f, Time.deltaTime * 5); index = anchor.triggerTouchValue; //grip SteamVR_Action_Boolean gripPressed = SteamVR_Input.GetBooleanAction("SideTrigger"); //SteamVR_Action_Single gripTouchValue = SteamVR_Input.GetSingleAction("gripTouchValue"); anchor.gripPressed = gripPressed.GetState(inputSource); anchor.gripTouchValue = Mathf.Lerp(anchor.gripTouchValue, anchor.gripPressed ? 1f : 0f, Time.deltaTime * 5); middle = anchor.gripTouchValue; //primary2DAxis SteamVR_Action_Vector2 primary2DAxis = SteamVR_Input.GetVector2Action("ThumbStick"); SteamVR_Action_Boolean primary2DAxisClick = SteamVR_Input.GetBooleanAction("PadDown"); anchor.primary2DAxis = primary2DAxis.GetAxis(inputSource); anchor.primary2DAxisTouch = anchor.primary2DAxis.sqrMagnitude > 0.02f; anchor.primary2DAxisPressed = primary2DAxisClick.GetState(inputSource); thumb = Mathf.Max(thumb, (anchor.primary2DAxisPressed || anchor.primary2DAxisTouch) ? 1f : 0f); thumb = Mathf.Max(thumb, anchor.primary2DAxis.sqrMagnitude > 0.1f ? 1f : 0f); //primary SteamVR_Action_Boolean primaryPressed = SteamVR_Input.GetBooleanAction("BKey"); anchor.primaryPressed = primaryPressed.GetState(inputSource); anchor.primaryTouchValue = (anchor.primaryPressed) ? 1f : 0f; thumb = Mathf.Max(thumb, anchor.primaryTouchValue); //secondary SteamVR_Action_Boolean secondaryPressed = SteamVR_Input.GetBooleanAction("AKey"); anchor.secondaryPressed = secondaryPressed.GetState(inputSource); anchor.secondaryTouchValue = (anchor.secondaryPressed) ? 1f : 0f; thumb = Mathf.Max(thumb, anchor.secondaryTouchValue); //fingers var skeletonHand = SteamVR_Input.GetAction <SteamVR_Action_Skeleton>(skeletonHandName); if (skeletonHand.poseIsValid) { anchor.handPoseChanged = skeletonHand.poseChanged; anchor.fingerCurls[0] = skeletonHand.thumbCurl; anchor.fingerCurls[1] = skeletonHand.indexCurl; anchor.fingerCurls[2] = skeletonHand.middleCurl; anchor.fingerCurls[3] = skeletonHand.ringCurl; anchor.fingerCurls[4] = skeletonHand.pinkyCurl; } else { anchor.handPoseChanged = true; anchor.fingerCurls[0] = thumb; anchor.fingerCurls[1] = index; anchor.fingerCurls[2] = middle; anchor.fingerCurls[3] = middle; anchor.fingerCurls[4] = middle; } }
//in order to use trackpadpos and trackpadtouch, you need to bind your controller input with custom names as TouchPad and TouchPos static public Vector2 getTrackPadPos(Hand hand) { SteamVR_Action_Vector2 trackpadPos = SteamVR_Input._default.inActions.TouchPos; return(trackpadPos.GetAxis(hand.handType)); }
public void AnalAxis(SteamVR_Action_Vector2 fromAction, SteamVR_Input_Sources fromSource, Vector2 tAxis, Vector2 tDelta) { cITA.AnalAxis(tAxis); }
internal VectorInput(SteamVR_Action_Vector2 vectorAction, int xAxisID, int yAxisID) { this.vectorAction = vectorAction; this.xAxisID = xAxisID; this.yAxisID = yAxisID; }
public Vector2 Axis(SteamVR_Action_Vector2 action) { return(m_currentFrame ? action[m_index].axis : action[m_index].lastAxis); }