private void InteractionSourceUpdated(InteractionSourceUpdatedEventArgs obj) { MotionControllerState motionControllerState; if (_controllers.TryGetValue(obj.state.source.id, out motionControllerState)) { Debug.Log("Event!"); var handedness = obj.state.source.handedness; Vector3 pointerPosition; Vector3 controllerPosition; Quaternion pointerRotation; Quaternion controllerRotation; obj.state.sourcePose.TryGetPosition(out pointerPosition, InteractionSourceNode.Pointer); obj.state.sourcePose.TryGetRotation(out pointerRotation, InteractionSourceNode.Pointer); obj.state.sourcePose.TryGetPosition(out controllerPosition, InteractionSourceNode.Grip); obj.state.sourcePose.TryGetRotation(out controllerRotation, InteractionSourceNode.Grip); _leftLaserPointer.positionCount = 2; _leftLaserPointer.SetPosition(0, pointerPosition); _leftLaserPointer.SetPosition(1, controllerPosition); SetLaserPointer(obj, handedness, controllerPosition, pointerPosition); if (obj.state.grasped && !motionControllerState.Grasped) { Debug.Log("OnGrasped"); OnGrasped(obj.state, new EventArgs()); } else if (!obj.state.grasped && motionControllerState.Grasped) { Debug.Log("OnReleased"); OnReleased(obj.state, new EventArgs()); } motionControllerState.Grasped = obj.state.grasped; if (obj.state.menuPressed && !motionControllerState.MenuPressed) { Debug.Log("OnMenuDown"); OnMenuDown(obj.state, new EventArgs()); } else if (!obj.state.menuPressed && motionControllerState.MenuPressed) { Debug.Log("OnMenuUp"); OnMenuUp(obj.state, new EventArgs()); } motionControllerState.MenuPressed = obj.state.menuPressed; var selectManipilateEventArgs = new SelectManipilateEventArgs(obj.state , obj.state.selectPressed , obj.state.selectPressedAmount , handedness); if (obj.state.selectPressed && !motionControllerState.SelectPressed) { Debug.Log("OnSelectDown"); OnSelectDown(obj.state, selectManipilateEventArgs); } else if (!obj.state.selectPressed && motionControllerState.SelectPressed) { Debug.Log("OnSelectUp"); OnSelectUp(obj.state, selectManipilateEventArgs); } else if (obj.state.selectPressed && motionControllerState.SelectPressed) { Debug.Log("OnSelectHold"); OnSelectHold(obj.state, selectManipilateEventArgs); } motionControllerState.SelectPressed = obj.state.selectPressed; var thumbstickManipilateEventArgs = new ThumbstickManipilateEventArgs(obj.state , obj.state.thumbstickPressed , obj.state.thumbstickPosition , handedness); if (obj.state.thumbstickPressed && !motionControllerState.ThumbstickPressed) { Debug.Log("OnThumbstickDown"); OnThumbstickDown(obj.state, thumbstickManipilateEventArgs); } else if (!obj.state.thumbstickPressed && motionControllerState.ThumbstickPressed) { Debug.Log("OnThumbstickUp"); OnThumbstickUp(obj.state, thumbstickManipilateEventArgs); } else if (motionControllerState.ThumbstickPressed && obj.state.thumbstickPressed) { Debug.Log("OnThumbstickHold"); OnThumbstickHold(obj.state, thumbstickManipilateEventArgs); } motionControllerState.ThumbstickPressed = obj.state.thumbstickPressed; var touchpadManipilateEventArgs = new TouchpadManipilateEventArgs(obj.state , obj.state.touchpadPressed , obj.state.touchpadTouched , obj.state.touchpadPosition , handedness); if (obj.state.touchpadPressed && !motionControllerState.TouchpadPressed) { Debug.Log("OnTouchpadDown"); OnTouchpadDown(obj.state, touchpadManipilateEventArgs); } else if (!obj.state.touchpadPressed && motionControllerState.TouchpadPressed) { Debug.Log("OnThumbstickHold"); OnTouchpadUp(obj.state, touchpadManipilateEventArgs); } else if (motionControllerState.TouchpadPressed && obj.state.touchpadPressed) { Debug.Log("OnTouchpadHold"); OnTouchpadHold(obj.state, touchpadManipilateEventArgs); } motionControllerState.TouchpadPressed = obj.state.touchpadPressed; if (obj.state.touchpadTouched && !motionControllerState.TouchpadTouched) { Debug.Log("OnTouchpadTouch"); OnTouchpadTouch(obj.state, touchpadManipilateEventArgs); } else if (!obj.state.touchpadTouched && motionControllerState.TouchpadTouched) { Debug.Log("OnTouchpadUp"); OnTouchpadUp(obj.state, touchpadManipilateEventArgs); } else if (motionControllerState.TouchpadTouched && obj.state.touchpadTouched) { Debug.Log("OnTouchpadHold"); OnTouchpadHold(obj.state, touchpadManipilateEventArgs); } motionControllerState.TouchpadTouched = obj.state.touchpadTouched; OnMotionControllerManipulate(obj.state, new MotionControllerManipilateEventArgs(obj.state, pointerPosition , pointerRotation, controllerPosition , controllerRotation , handedness)); } }
/// <summary> /// Raises the ThumbstickUp event. /// </summary> /// <param name="sender"> /// <see cref="InteractionSourceState" /> /// </param> /// <param name="e">An <see cref="ThumbstickManipilateEventArgs" /> that contains the event data. </param> public virtual void OnThumbstickUp(object sender, ThumbstickManipilateEventArgs e) { if (ThumbstickUp != null) ThumbstickUp(sender, e); }