/// <summary>
 ///     Raises the TouchpadManipulate event.
 /// </summary>
 /// <param name="sender">
 ///     <see cref="InteractionSourceState" />
 /// </param>
 /// <param name="e">An <see cref="TouchpadManipulateEventArgs" /> that contains the event data. </param>
 public virtual void OnTouchpadManipulate(object sender, TouchpadManipulateEventArgs e)
 {
     if (TouchpadManipulate != null)
     {
         TouchpadManipulate(sender, e);
     }
 }
        private void InteractionSourceUpdated(InteractionSourceUpdatedEventArgs obj)
        {
            MotionControllerState motionControllerState;

            if (_controllers.TryGetValue(obj.state.source.id, out motionControllerState))
            {
                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);

                SetLaserPointer(obj, handedness, controllerPosition, pointerPosition);

                if (obj.state.grasped && !motionControllerState.Grasped)
                {
                    OutputLog("OnGrasped");
                    OnGrasped(obj.state, new EventArgs());
                }
                else if (!obj.state.grasped && motionControllerState.Grasped)
                {
                    OutputLog("OnReleased");
                    OnReleased(obj.state, new EventArgs());
                }
                motionControllerState.Grasped = obj.state.grasped;


                if (obj.state.menuPressed && !motionControllerState.MenuPressed)
                {
                    OutputLog("OnMenuDown");
                    OnMenuDown(obj.state, new EventArgs());
                }
                else if (!obj.state.menuPressed && motionControllerState.MenuPressed)
                {
                    OutputLog("OnMenuUp");
                    OnMenuUp(obj.state, new EventArgs());
                }
                motionControllerState.MenuPressed = obj.state.menuPressed;


                var selectManipulateEventArgs = new SelectManipulateEventArgs(obj.state
                                                                              , obj.state.selectPressed
                                                                              , obj.state.selectPressedAmount
                                                                              , handedness);
                if (obj.state.selectPressed && !motionControllerState.SelectPressed)
                {
                    OutputLog("OnSelectDown");
                    OnSelectDown(obj.state, selectManipulateEventArgs);
                }
                else if (!obj.state.selectPressed && motionControllerState.SelectPressed)
                {
                    OutputLog("OnSelectUp");
                    OnSelectUp(obj.state, selectManipulateEventArgs);
                }
                else if (obj.state.selectPressed && motionControllerState.SelectPressed)
                {
                    OutputLog("OnSelectHold");
                    OnSelectHold(obj.state, selectManipulateEventArgs);
                }
                motionControllerState.SelectPressed = obj.state.selectPressed;

                var thumbstickManipulateEventArgs = new ThumbstickManipulateEventArgs(obj.state
                                                                                      , obj.state.thumbstickPressed
                                                                                      , obj.state.thumbstickPosition
                                                                                      , handedness);
                if (obj.state.thumbstickPressed && !motionControllerState.ThumbstickPressed)
                {
                    OutputLog("OnThumbstickDown");
                    OnThumbstickDown(obj.state, thumbstickManipulateEventArgs);
                }
                else if (!obj.state.thumbstickPressed && motionControllerState.ThumbstickPressed)
                {
                    OutputLog("OnThumbstickUp");
                    OnThumbstickUp(obj.state, thumbstickManipulateEventArgs);
                }

                OnThumbstickManipulate(obj.state, thumbstickManipulateEventArgs);
                motionControllerState.ThumbstickPressed = obj.state.thumbstickPressed;


                var touchpadManipulateEventArgs = new TouchpadManipulateEventArgs(obj.state
                                                                                  , obj.state.touchpadPressed
                                                                                  , obj.state.touchpadTouched
                                                                                  , obj.state.touchpadPosition
                                                                                  , handedness);
                if (obj.state.touchpadPressed && !motionControllerState.TouchpadPressed)
                {
                    OutputLog("OnTouchpadDown");
                    OnTouchpadDown(obj.state, touchpadManipulateEventArgs);
                }
                else if (!obj.state.touchpadPressed && motionControllerState.TouchpadPressed)
                {
                    OutputLog("OnThumbstickUp");
                    OnTouchpadUp(obj.state, touchpadManipulateEventArgs);
                }
                OnTouchpadManipulate(obj.state, touchpadManipulateEventArgs);
                motionControllerState.TouchpadPressed = obj.state.touchpadPressed;

                if (obj.state.touchpadTouched && !motionControllerState.TouchpadTouched)
                {
                    OutputLog("OnTouchpadTouch");
                    OnTouchpadTouch(obj.state, touchpadManipulateEventArgs);
                }
                else if (!obj.state.touchpadTouched && motionControllerState.TouchpadTouched)
                {
                    OutputLog("OnTouchpadUp");
                    OnTouchpadUp(obj.state, touchpadManipulateEventArgs);
                }
                else if (motionControllerState.TouchpadTouched && obj.state.touchpadTouched)
                {
                    OutputLog("OnTouchpadManipulate");
                    OnTouchpadManipulate(obj.state, touchpadManipulateEventArgs);
                }
                motionControllerState.TouchpadTouched = obj.state.touchpadTouched;

                OnMotionControllerManipulate(obj.state, new MotionControllerManipulateEventArgs(obj.state,
                                                                                                pointerPosition
                                                                                                , pointerRotation, controllerPosition
                                                                                                , controllerRotation
                                                                                                , handedness));
            }
        }