protected virtual void UpdateButtonState(InteractionSourcePressType button, InteractionSourceState state) { switch (button) { case InteractionSourcePressType.Grasp: prevButtonState.Grasped = currentButtonState.Grasped; currentButtonState.Grasped = state.grasped; break; case InteractionSourcePressType.Menu: prevButtonState.MenuPressed = currentButtonState.MenuPressed; currentButtonState.MenuPressed = state.menuPressed; break; case InteractionSourcePressType.Touchpad: prevButtonState.TouchpadPressed = currentButtonState.TouchpadPressed; currentButtonState.TouchpadPressed = state.touchpadPressed; break; case InteractionSourcePressType.Thumbstick: prevButtonState.ThumbstickPressed = currentButtonState.ThumbstickPressed; currentButtonState.ThumbstickPressed = state.thumbstickPressed; break; } StartCoroutine(UpdateButtonStateAfterNextFrame(button)); }
public void RaiseSourceDown(IInputSource source, uint sourceId, InteractionSourcePressType pressType, object tag = null) { // Create input event inputEventData.Initialize(source, sourceId, tag, pressType); // Pass handler through HandleEvent to perform modal/fallback logic HandleEvent(inputEventData, OnSourceDownEventHandler); // UI events if (ShouldSendUnityUiEvents && (pressType == InteractionSourcePressType.Select)) { PointerInputEventData pointerInputEventData = FocusManager.Instance.BorrowPointerEventData(); pointerInputEventData.InputSource = source; pointerInputEventData.SourceId = sourceId; pointerInputEventData.eligibleForClick = true; pointerInputEventData.delta = Vector2.zero; pointerInputEventData.dragging = false; pointerInputEventData.useDragThreshold = true; pointerInputEventData.pressPosition = pointerInputEventData.position; pointerInputEventData.pointerPressRaycast = pointerInputEventData.pointerCurrentRaycast; HandleEvent(pointerInputEventData, ExecuteEvents.pointerDownHandler); } }
void UpdatePressed(InteractionSourcePressType pressType, InteractionSourceState state) { switch (pressType) { case InteractionSourcePressType.Select: _currentState.SelectPressed = state.selectPressed; Debug.Log("Select state:" + state.selectPressed); break; case InteractionSourcePressType.Grasp: _currentState.GraspPressed = state.grasped; break; case InteractionSourcePressType.Menu: _currentState.MenuPressed = state.menuPressed; break; case InteractionSourcePressType.Touchpad: _currentState.TouchPadPressed = state.touchpadPressed; break; case InteractionSourcePressType.Thumbstick: _currentState.ThumbstickPressed = state.thumbstickPressed; break; } }
public void RaiseInputPositionChanged(IInputSource source, uint sourceId, InteractionSourcePressType pressType, Vector2 position, object tag = null) { // Create input event inputPositionEventData.Initialize(source, sourceId, tag, pressType, position); // Pass handler through HandleEvent to perform modal/fallback logic HandleEvent(inputPositionEventData, OnInputPositionChangedEventHandler); }
public bool GetTouchUp(InteractionSourcePressType button) { switch (button) { case InteractionSourcePressType.Touchpad: return(prevButtonState.TouchpadTouched == true && currentButtonState.TouchpadTouched == false); } return(false); }
public bool GetTouch(InteractionSourcePressType button) { switch (button) { case InteractionSourcePressType.Touchpad: return(currentButtonState.TouchpadTouched); } return(false); }
public float GetPressAmount(InteractionSourcePressType button) { switch (button) { case InteractionSourcePressType.Select: return(currentButtonState.SelectPressedAmount); } return(0); }
public void RaiseInputClicked(IInputSource source, uint sourceId, InteractionSourcePressType pressType, int tapCount, object tag = null) { // Create input event sourceClickedEventData.Initialize(source, sourceId, tag, pressType, tapCount); // Pass handler through HandleEvent to perform modal/fallback logic HandleEvent(sourceClickedEventData, OnInputClickedEventHandler); // NOTE: In Unity UI, a "click" happens on every pointer up, so we have SourceUp call the pointerClickHandler. }
public Vector2 GetAxis(InteractionSourcePressType button) { switch (button) { case InteractionSourcePressType.Select: return(new Vector2(currentButtonState.SelectPressedAmount, 0f)); case InteractionSourcePressType.Touchpad: return(currentButtonState.TouchpadPosition); case InteractionSourcePressType.Thumbstick: return(currentButtonState.ThumbstickPosition); } return(Vector2.zero); }
private bool EventIsRelevant(InteractionSourceState state, InteractionSourcePressType pressType) { if (pressType == this.PressType) { if (Handedness == InteractionSourceHandedness.Unknown || Handedness == state.source.handedness) { var grabbable = GetComponent <BaseGrabbable>(); if (grabbable != null && grabbable.GrabState == GrabStateEnum.Single) { return(true); } } } return(false); }
public void RaiseSourceUp(IInputSource source, uint sourceId, InteractionSourcePressType pressType, object tag = null) { // Create input event inputEventData.Initialize(source, sourceId, tag, pressType); // Pass handler through HandleEvent to perform modal/fallback logic HandleEvent(inputEventData, OnSourceUpEventHandler); // UI events if (ShouldSendUnityUiEvents && (pressType == InteractionSourcePressType.Select)) { PointerInputEventData pointerInputEventData = FocusManager.Instance.BorrowPointerEventData(); pointerInputEventData.InputSource = source; pointerInputEventData.SourceId = sourceId; HandleEvent(pointerInputEventData, ExecuteEvents.pointerUpHandler); HandleEvent(pointerInputEventData, ExecuteEvents.pointerClickHandler); } }
public bool GetPressUp(InteractionSourcePressType button) { switch (button) { case InteractionSourcePressType.Select: return(prevButtonState.SelectPressed == true && currentButtonState.SelectPressed == false); case InteractionSourcePressType.Grasp: return(prevButtonState.Grasped == true && currentButtonState.Grasped == false); case InteractionSourcePressType.Menu: return(prevButtonState.MenuPressed == true && currentButtonState.MenuPressed == false); case InteractionSourcePressType.Touchpad: return(prevButtonState.TouchpadPressed == true && currentButtonState.TouchpadPressed == false); case InteractionSourcePressType.Thumbstick: return(prevButtonState.ThumbstickPressed == true && currentButtonState.ThumbstickPressed == false); } return(false); }
protected virtual IEnumerator UpdateButtonStateAfterNextFrame(InteractionSourcePressType button) { yield return(new WaitForEndOfFrame()); switch (button) { case InteractionSourcePressType.Grasp: prevButtonState.Grasped = currentButtonState.Grasped; break; case InteractionSourcePressType.Menu: prevButtonState.MenuPressed = currentButtonState.MenuPressed; break; case InteractionSourcePressType.Touchpad: prevButtonState.TouchpadPressed = currentButtonState.TouchpadPressed; break; case InteractionSourcePressType.Thumbstick: prevButtonState.ThumbstickPressed = currentButtonState.ThumbstickPressed; break; } }
public InteractionSourceReleasedEventArgs(InteractionSourceState state, InteractionSourcePressType pressType) : this() { this.state = state; this.pressType = pressType; }
private static void OnSourceEvent(InteractionManager.EventType eventType, InteractionSourceState state, InteractionSourcePressType pressType) { /* * switch (eventType) * { * case InteractionManager.EventType.SourceDetected: * { * InteractionManager.SourceEventHandler interactionSourceDetectedLegacy = InteractionManager.InteractionSourceDetectedLegacy; * if (interactionSourceDetectedLegacy != null) * { * interactionSourceDetectedLegacy(state); * } * Action<InteractionSourceDetectedEventArgs> interactionSourceDetected = InteractionManager.InteractionSourceDetected; * if (interactionSourceDetected != null) * { * interactionSourceDetected(new InteractionSourceDetectedEventArgs(state)); * } * break; * } * case InteractionManager.EventType.SourceLost: * { * InteractionManager.SourceEventHandler interactionSourceLostLegacy = InteractionManager.InteractionSourceLostLegacy; * if (interactionSourceLostLegacy != null) * { * interactionSourceLostLegacy(state); * } * Action<InteractionSourceLostEventArgs> interactionSourceLost = InteractionManager.InteractionSourceLost; * if (interactionSourceLost != null) * { * interactionSourceLost(new InteractionSourceLostEventArgs(state)); * } * break; * } * case InteractionManager.EventType.SourceUpdated: * { * InteractionManager.SourceEventHandler interactionSourceUpdatedLegacy = InteractionManager.InteractionSourceUpdatedLegacy; * if (interactionSourceUpdatedLegacy != null) * { * interactionSourceUpdatedLegacy(state); * } * Action<InteractionSourceUpdatedEventArgs> interactionSourceUpdated = InteractionManager.InteractionSourceUpdated; * if (interactionSourceUpdated != null) * { * interactionSourceUpdated(new InteractionSourceUpdatedEventArgs(state)); * } * break; * } * case InteractionManager.EventType.SourcePressed: * { * InteractionManager.SourceEventHandler interactionSourcePressedLegacy = InteractionManager.InteractionSourcePressedLegacy; * if (interactionSourcePressedLegacy != null) * { * interactionSourcePressedLegacy(state); * } * Action<InteractionSourcePressedEventArgs> interactionSourcePressed = InteractionManager.InteractionSourcePressed; * if (interactionSourcePressed != null) * { * interactionSourcePressed(new InteractionSourcePressedEventArgs(state, pressType)); * } * break; * } * case InteractionManager.EventType.SourceReleased: * { * InteractionManager.SourceEventHandler interactionSourceReleasedLegacy = InteractionManager.InteractionSourceReleasedLegacy; * if (interactionSourceReleasedLegacy != null) * { * interactionSourceReleasedLegacy(state); * } * Action<InteractionSourceReleasedEventArgs> interactionSourceReleased = InteractionManager.InteractionSourceReleased; * if (interactionSourceReleased != null) * { * interactionSourceReleased(new InteractionSourceReleasedEventArgs(state, pressType)); * } * break; * } * default: * throw new ArgumentException("OnSourceEvent: Invalid EventType"); * } */ }
private static void OnSourceEvent(InteractionManager.EventType eventType, InteractionSourceState state, InteractionSourcePressType pressType) { switch (eventType) { case InteractionManager.EventType.SourceDetected: { InteractionManager.SourceEventHandler interactionSourceDetectedLegacy = InteractionManager.InteractionSourceDetectedLegacy; if (interactionSourceDetectedLegacy != null) { interactionSourceDetectedLegacy(state); } Action <InteractionSourceDetectedEventArgs> interactionSourceDetected = InteractionManager.InteractionSourceDetected; if (interactionSourceDetected != null) { interactionSourceDetected(new InteractionSourceDetectedEventArgs(state)); } break; } case InteractionManager.EventType.SourceLost: { InteractionManager.SourceEventHandler interactionSourceLostLegacy = InteractionManager.InteractionSourceLostLegacy; if (interactionSourceLostLegacy != null) { interactionSourceLostLegacy(state); } Action <InteractionSourceLostEventArgs> interactionSourceLost = InteractionManager.InteractionSourceLost; if (interactionSourceLost != null) { interactionSourceLost(new InteractionSourceLostEventArgs(state)); } break; } case InteractionManager.EventType.SourceUpdated: { InteractionManager.SourceEventHandler interactionSourceUpdatedLegacy = InteractionManager.InteractionSourceUpdatedLegacy; if (interactionSourceUpdatedLegacy != null) { interactionSourceUpdatedLegacy(state); } Action <InteractionSourceUpdatedEventArgs> interactionSourceUpdated = InteractionManager.InteractionSourceUpdated; if (interactionSourceUpdated != null) { interactionSourceUpdated(new InteractionSourceUpdatedEventArgs(state)); } break; } case InteractionManager.EventType.SourcePressed: { InteractionManager.SourceEventHandler interactionSourcePressedLegacy = InteractionManager.InteractionSourcePressedLegacy; if (interactionSourcePressedLegacy != null) { interactionSourcePressedLegacy(state); } Action <InteractionSourcePressedEventArgs> interactionSourcePressed = InteractionManager.InteractionSourcePressed; if (interactionSourcePressed != null) { interactionSourcePressed(new InteractionSourcePressedEventArgs(state, pressType)); } break; } case InteractionManager.EventType.SourceReleased: { InteractionManager.SourceEventHandler interactionSourceReleasedLegacy = InteractionManager.InteractionSourceReleasedLegacy; if (interactionSourceReleasedLegacy != null) { interactionSourceReleasedLegacy(state); } Action <InteractionSourceReleasedEventArgs> interactionSourceReleased = InteractionManager.InteractionSourceReleased; if (interactionSourceReleased != null) { interactionSourceReleased(new InteractionSourceReleasedEventArgs(state, pressType)); } break; } default: throw new ArgumentException("OnSourceEvent: Invalid EventType"); } }
public SourceButtonEventArgs(IInputSource inputSource, uint sourceId, InteractionSourcePressType buttonType) : base(inputSource, sourceId) { ButtonType = buttonType; }
public void Initialize(IInputSource inputSource, uint sourceId, InteractionSourcePressType pressType, Vector2 position, object tag = null) { Initialize(inputSource, sourceId, tag, pressType); Position = position; }
private static void OnSourceEvent(EventType eventType, ref InteractionSourceState state, InteractionSourcePressType pressType) { switch (eventType) { case EventType.SourceDetected: { var deprecatedEventHandler = InteractionSourceDetectedLegacy; if (deprecatedEventHandler != null) { deprecatedEventHandler(state); } var eventHandler = InteractionSourceDetected; if (eventHandler != null) { eventHandler(new InteractionSourceDetectedEventArgs(state)); } } break; case EventType.SourceLost: { var deprecatedEventHandler = InteractionSourceLostLegacy; if (deprecatedEventHandler != null) { deprecatedEventHandler(state); } var eventHandler = InteractionSourceLost; if (eventHandler != null) { eventHandler(new InteractionSourceLostEventArgs(state)); } } break; case EventType.SourceUpdated: { var deprecatedEventHandler = InteractionSourceUpdatedLegacy; if (deprecatedEventHandler != null) { deprecatedEventHandler(state); } var eventHandler = InteractionSourceUpdated; if (eventHandler != null) { eventHandler(new InteractionSourceUpdatedEventArgs(state)); } } break; case EventType.SourcePressed: { var deprecatedEventHandler = InteractionSourcePressedLegacy; if (deprecatedEventHandler != null) { deprecatedEventHandler(state); } var eventHandler = InteractionSourcePressed; if (eventHandler != null) { eventHandler(new InteractionSourcePressedEventArgs(state, pressType)); } } break; case EventType.SourceReleased: { var deprecatedEventHandler = InteractionSourceReleasedLegacy; if (deprecatedEventHandler != null) { deprecatedEventHandler(state); } var eventHandler = InteractionSourceReleased; if (eventHandler != null) { eventHandler(new InteractionSourceReleasedEventArgs(state, pressType)); } } break; default: throw new ArgumentException("OnSourceEvent: Invalid EventType"); } }
public InteractionSourcePressedEventArgs(InteractionSourceState state, InteractionSourcePressType pressType) { this = default(InteractionSourcePressedEventArgs); this.state = state; this.pressType = pressType; }
public void Initialize(IInputSource inputSource, uint sourceId, object tag, InteractionSourcePressType pressType, int tapCount) { Initialize(inputSource, sourceId, tag, pressType); TapCount = tapCount; }
public void Initialize(IInputSource inputSource, uint sourceId, object tag, InteractionSourcePressType pressType) { BaseInitialize(inputSource, sourceId, tag); PressType = pressType; }