private IEnumerator BackExit() { float elapsed = 0; bool handBackIn = false; while (elapsed < 1 && !handBackIn) { yield return(null); elapsed += Time.deltaTime; if (_handInTrigger != null && _handInTrigger == _handThatExitedWhileHeld) { handBackIn = true; } } if (!handBackIn) { _pointerData.Reset(); _pointerData.pointerCurrentRaycast = new RaycastResult(); _pressState = PressState.Released; _pointerData.IsCanceled = true; _raycaster.ProcessHandEvent(_pointerData, false, true); _handThatExitedWhileHeld = null; } }
public void OnKeyUp(UIKeyboardEventArgs e) { if (keyPressState.Count == 99) { keyPressState = new PressState(); TimerHelper.Stop(); return; } string a = e.Key.ToLower(); if (a.Contains("arrow")) { MoveDirection CurrDirection = StringToDirection(a.Replace("arrow", null)); //if (keyPressState.Direction == MoveDirection.undefined) //{ if (!e.CtrlKey) { SelectNeightbourCell(CurrDirection); } //} //else //{ // if (CurrDirection == keyPressState.Direction && keyPressState.Count > 0) // { // SelectNeightbourCell(CurrDirection); // } //} } }
private void UpdatePressStateAndFireEvents() { //Determine how the hand is interacting with the EventVolume. //When the hand is past the down trigger, the user is pressing. This is like the user pressing the left mouse button down. //Once the user is pressing, if the hand returns past the up trigger, the press has been released. This is like the user releasing the left mouse button. //Once the user is pressing, if the hand does not pass the up trigger, the press becomes a hold. This is like the user holding down the left mouse button. if (_pressState == PressState.None) { //plane click if (_pointerData.FrontDistance < _downTriggerOffset * transform.lossyScale.z) { _pressState = PressState.Pressed; } } else if (_pressState == PressState.Pressed) { _pressState = PressState.Held; } else if (_pressState == PressState.Held && _pointerData.FrontDistance > ((_downTriggerOffset * transform.lossyScale.z) + (_upTriggerOffset * transform.lossyScale.z))) { _pressState = PressState.Released; } else if (_pressState == PressState.Released) { _pressState = PressState.None; } if (_pressStateEvent != null) { _pressStateEvent.Invoke(_pressState); } }
private void InvokePressAction(PressState ps) { if (_onPressAction != null) { _onPressAction.Invoke(gameObject, ps); } }
/// <summary> /// Update the cursor's position and visual state /// </summary> /// <param name="eventData"></param> /// <param name="pressState"></param> public void UpdateCursor(MetaHandEventData eventData, PressState pressState) { float ringScale = _ringPanelProximityScale.Evaluate(eventData.DownDistance); _ring.transform.position = eventData.ProjectedPanelPosition; _ring.transform.localPosition = new Vector3(_ring.transform.localPosition.x, _ring.transform.localPosition.y, 0); _ring.transform.localScale = Vector3.one * ringScale; _ring.Alpha = _ringPanelProximityAlpha.Evaluate(eventData.DownDistance); _ring2.transform.position = eventData.ProjectedPanelPosition; _ring2.transform.localPosition = new Vector3(_ring2.transform.localPosition.x, _ring2.transform.localPosition.y, 0); _ring2.transform.localScale = Vector3.one * (ringScale + _ring2.Thickness); _ring2.Alpha = _ring.Alpha; _fill.transform.position = eventData.ProjectedPanelPosition; _fill.transform.localPosition = new Vector3(_fill.transform.localPosition.x, _fill.transform.localPosition.y, 0); _fill.Alpha = eventData.DownDistance < 0 ? _ring.Alpha * FillAlpha : FillAlpha; _fillOutline.transform.position = eventData.ProjectedPanelPosition; _fillOutline.Alpha = eventData.DownDistance < 0 ? _ring.Alpha * FillOutlineAlpha : FillOutlineAlpha; _hoverPower = Mathf.SmoothDamp(_hoverPower, (_isHovering ? 1 : 0), ref _hoverPowerVelocity, HoverEffectSeconds); _dot.transform.position = eventData.ProjectedPanelPosition; _dot.transform.localPosition = new Vector3(_dot.transform.localPosition.x, _dot.transform.localPosition.y, 0); _dot.transform.localScale = Vector3.one * (_fullDotScale * Mathf.Lerp(DotUnhoveredScale, 1, _hoverPower)); float dotAlpha = Mathf.Lerp(DotUnhoveredAlpha, 1, _hoverPower); _dot.Alpha = eventData.DownDistance < 0 ? _ring.Alpha * dotAlpha : dotAlpha; if (_isHovering && pressState == PressState.Pressed) { _canvasPressIndicator.PlayAnimation(eventData.ProjectedPanelPosition); } }
/// <summary> /// Override this message to handle key events internally. /// </summary> /// <param name="key">Integer value of the key affected</param> /// <param name="pressed">True if the key is currently being pressed; false if released</param> /// <param name="handled">true if the event is handled. Set to true if handled.</param> /// <remarks> /// If the return Key (key == 10) is pressed or released the button is switched to /// <see cref="PressState.Pressed"/> and <see cref="PressState.Normal"/> state. /// On release the <see cref="Control.Tap"/> event is fired. /// </remarks> protected override void KeyboardKeyMessage(char key, bool pressed, ref bool handled) { if (key == 10) { handled = true; if (pressed) { if (_state != PressState.Pressed) { _state = PressState.Pressed; Invalidate(); } } else { if (_state == PressState.Pressed) { _state = PressState.Normal; Invalidate(); OnTap(this, new point(Left, Top)); } } } base.KeyboardKeyMessage(key, pressed, ref handled); }
// ReSharper disable once RedundantAssignment /// <summary> /// Override this message to handle touch events internally. /// </summary> /// <param name="sender">Object sending the event</param> /// <param name="point">Point on screen touch event is occurring</param> /// <param name="handled">true if the event is handled. Set to true if handled.</param> /// <remarks> /// Switches the button into <see cref="PressState.Pressed"/> state /// </remarks> protected override void TouchDownMessage(object sender, point point, ref bool handled) { _state = PressState.Pressed; Invalidate(); // do NOT set handled to true ! base.TouchDownMessage(sender, point, ref handled); }
/// <summary> /// Creates a new button /// </summary> /// <param name="name">Name of the button</param> /// <param name="text">Content text of the button</param> /// <param name="font">Font to render the content text</param> /// <param name="x">X position relative to it's parent</param> /// <param name="y">Y position relative to it's parent</param> /// <param name="showFocusRect">true if the focus rectangle should be visible; false if not</param> /// <remarks> /// The <see cref="Control.Width"/> and <see cref="Control.Height"/> are calculated automatically to fit the content text. /// </remarks> public Button(string name, string text, Font font, int x, int y, bool showFocusRect = true) : base(name, x, y) { DefaultColors(); _text = text; _font = font; if (!showFocusRect) { _renderStyle &= ~ButtonRenderStyles.ShowFocusRectangle; } _state = PressState.Normal; SetPadding(new Thickness(11, 6, 11, 7)); if (!MeasureControl()) { Invalidate(); } /*// Size button * size sz = FontManager.ComputeExtentEx(_font, _text); * // ReSharper disable DoNotCallOverridableMethodsInConstructor * Width = sz.Width + 22; * Height = sz.Height + 13; * // ReSharper restore DoNotCallOverridableMethodsInConstructor*/ }
/// <summary> /// Override this message to handle button pressed events internally. /// </summary> /// <param name="buttonId">Integer ID corresponding to the affected button</param> /// <param name="handled">true if the event is handled. Set to true if handled.</param> /// <remarks> /// On button id <see cref="ButtonIDs.Select"/> or <see cref="ButtonIDs.Click"/> the button is switched to <see cref="PressState.Pressed"/> state /// </remarks> protected override void ButtonPressedMessage(int buttonId, ref bool handled) { if (buttonId == (int)ButtonIDs.Select || buttonId == (int)ButtonIDs.Click) { _state = PressState.Pressed; Invalidate(); } base.ButtonPressedMessage(buttonId, ref handled); }
void Awake() { state = PressState.Released; Initialize(parts); Initialize(otherParts); index = 0; Roots = new GunPart[] { parts[0], otherParts[0] }; }
/// <summary> /// Override this message to handle touch events internally. /// </summary> /// <param name="sender">Object sending the event</param> /// <param name="point">Point on screen touch event is occurring</param> /// <param name="handled">true if the event is handled. Set to true if handled.</param> /// <remarks> /// Switches the button to <see cref="PressState.Normal"/> state if currently pressed /// </remarks> protected override void TouchUpMessage(object sender, point point, ref bool handled) { if (Touching) { _state = PressState.Normal; Invalidate(); // do NOT set handled to true ! } base.TouchUpMessage(sender, point, ref handled); }
/// <summary> /// Override this message to handle button released events internally. /// </summary> /// <param name="buttonId">Integer ID corresponding to the affected button</param> /// <param name="handled">true if the event is handled. Set to true if handled.</param> /// <remarks> /// On button id <see cref="ButtonIDs.Select"/> or <see cref="ButtonIDs.Click"/> the button is switched back to <see cref="PressState.Normal"/> state /// and the <see cref="Control.Tap"/> event is fired. /// </remarks> protected override void ButtonReleasedMessage(int buttonId, ref bool handled) { if (_state == PressState.Pressed && (buttonId == (int)ButtonIDs.Select || buttonId == (int)ButtonIDs.Click)) { _state = PressState.Normal; Invalidate(); OnTap(this, new point(X, Y)); } base.ButtonReleasedMessage(buttonId, ref handled); }
//刷新按键检查 private void RefreshPressCheck() { if (PCControl) { if (refreshPressState == PressState.Ready) { if (UnityEngine.Input.GetKey(KeyCode.R)) { refreshPressState = PressState.OnPress; } } else if (refreshPressState == PressState.OnPress) { if (!UnityEngine.Input.GetKey(KeyCode.R)) { refreshPressState = PressState.OnClick; if (RefreshHandler != null) { RefreshHandler((int)PressEvent.PressClick); } } } else if (refreshPressState == PressState.OnClick && !UnityEngine.Input.GetKey(KeyCode.R)) { refreshPressState = PressState.Ready; } } else { if (refreshPressState == PressState.Ready) { if (McuInput.GetInstance().GetKey(MCUKeyCode.IN2)) { refreshPressState = PressState.OnPress; } } else if (refreshPressState == PressState.OnPress) { if (!McuInput.GetInstance().GetKey(MCUKeyCode.IN2)) { if (RefreshHandler != null) { RefreshHandler((int)PressEvent.PressClick); } refreshPressState = PressState.OnClick; } } else if (refreshPressState == PressState.OnClick && !McuInput.GetInstance().GetKey(MCUKeyCode.IN2)) { //重置 refreshPressState = PressState.Ready; } } }
private void SetDisplay(bool display) { m_Display = display; Cursor.SetActive(display); // stop click animation when hide cursor if (!display) { CursorAnimator.SetBool(CursorAnimatorClickParmeterName, false); m_PressState = PressState.Notset; } }
void displaymarker() { for (int i = 0; i < 15; i++) { if (!ispaused) { PressState currentstate = tilearray[i][tilecount[i]]; if (Time.time * 1000 - starttime >= currentstate.duepressedtime - 250 + offset && currentstate.isplayed == false) { currentstate.isexceeded = false; tiles[i].SetTrigger("marker"); if (i != convert(i)) { tiles[convert(i)].SetTrigger("note"); } currentstate.isplayed = true; } if (Time.time * 1000 - starttime >= currentstate.duepressedtime + 250 + offset && currentstate.isexceeded == false) { currentstate.isexceeded = true; if (tilecount[i] < tileall[i]) { tilecount[i]++; } } if (i <= 3) { PressState currentdropstate = droparray[i][dropcount[i]]; if (Time.time * 1000 - starttime >= currentdropstate.duepressedtime - 700 + offset && currentdropstate.isplayed == false) { currentdropstate.isexceeded = false; currentdropstate.isplayed = true; drop[i].Enqueue(pool.Instantiate(new Vector3(-1.06f + 0.710f * i, 1.082f, -1f))); } if (Time.time * 1000 - starttime >= currentdropstate.duepressedtime + 250 + offset && currentdropstate.isexceeded == false) { currentdropstate.isexceeded = true; if (dropcount[i] < dropall[i]) { dropcount[i]++; } } } } } }
public void SetAvailable(bool available) { if (m_Available != available) { m_Available = available; if (!m_Available) { SetDisplay(false); m_LastHasInputTime = 0; m_PressState = PressState.Notset; } } }
// Update is called once per frame void Update () { if (m_mode == InputMode.IN_INVENTORY) { return; } if (Input.GetMouseButtonDown (0)) { m_pressState = PressState.FIRST_FRAME_DOWN; m_lastPressVS = Input.mousePosition; m_lastPressVS.x /= Screen.width; m_lastPressVS.y /= Screen.height; m_lastPressWS = GetPlanarCoordForScreenCoord (m_lastPressVS); m_lastDeltaPressVS = Vector3.zero; m_lastDeltaPressWS = Vector3.zero; } else if (Input.GetMouseButton (0)) { m_pressState = PressState.HELD_DOWN; // Store the change in press location Vector3 vsPress = Input.mousePosition; vsPress.x /= Screen.width; vsPress.y /= Screen.height; Vector3 wsPress = GetPlanarCoordForScreenCoord (vsPress); m_lastDeltaPressVS = vsPress - m_lastPressVS; m_lastDeltaPressWS = wsPress - m_lastPressWS; m_lastPressVS = vsPress; m_lastPressWS = wsPress; if (m_mode != InputMode.PAN_CAMERA && m_lastDeltaPressVS.magnitude > m_minPanSpeed) { SetInputMode (InputMode.PAN_CAMERA); } } else if (Input.GetMouseButtonUp (0)) { if (m_mode == InputMode.WAITING) { SetInputMode (InputMode.INTERACT_WORLD); } m_pressState = PressState.FIRST_FRAME_NO_PRESS; } else { if (m_pressState == PressState.FIRST_FRAME_NO_PRESS) { SetInputMode (InputMode.WAITING); m_pressState = PressState.NO_PRESS; } } }
/// <summary> /// Creates a new button /// </summary> /// <param name="name">Name of the button</param> /// <param name="text">Content text of the button</param> /// <param name="font">Font to render the content text</param> /// <param name="x">X position relative to it's parent</param> /// <param name="y">Y position relative to it's parent</param> /// <param name="width">Width of the button in pixel</param> /// <param name="height">Height of the button in pixel</param> /// <param name="showFocusRect">true if the focus rectangle should be visible; false if not</param> public Button(string name, string text, Font font, int x, int y, int width, int height, bool showFocusRect = true) : base(name, x, y, width, height) { DefaultColors(); _text = text; _font = font; if (!showFocusRect) { _renderStyle &= ~ButtonRenderStyles.ShowFocusRectangle; } _state = PressState.Normal; SetPadding(new Thickness(11, 6, 11, 7)); }
/*void OnDragEnd () { * * }*/ void OnPress(bool pressed) { isPressed = pressed; if (pressed) { dragDirection = Vector2.zero; if (timeProgress <= time + manager.config.range_Excellent) { pressState = PressState.excellent; } else if (timeProgress <= time + manager.config.range_Good) { pressState = PressState.good; } else { pressState = PressState.bad; } } else { //drag end //var dragAngle = Vector2.Angle(Vector2.right,dragDirection); var dot = Vector2.Dot(dragDirection, getTransform.right); if (dot > 0.75f) { if (pressState == PressState.excellent) { onExcellent(); } else if (pressState == PressState.good) { onGood(); } else { onBad(); } } else { onBad(); } } }
public override bool Initialize() { currentRotationAngle = 0; recordRotationAngle = 0; rockerState = RockerState.RockerMoveMiddle; startPressState = PressState.Ready; refreshPressState = PressState.Ready; longPressTime = 2.0f; #if UNITY_EDITOR PCControl = true; #else //启动串口 McuInput.GetInstance(); PCControl = false; #endif return(true); }
void Update() { if (state == PressState.Released) { if (Input.GetKeyDown(KeyCode.E) && index != 0) { ChangeIndex(0); } if (Input.GetKeyDown(KeyCode.R) && index != 1) { ChangeIndex(1); } if (Input.GetMouseButtonDown(0)) { if (!Roots[index].IsActive) { return; } pressTime = 0.0f; Roots[index].Start(ComputeAim(), EventArgs.Empty); MoveControl.canSprint = false; state = PressState.Pressed; } } else if (state == PressState.Pressed) { if (Input.GetMouseButton(0)) { pressTime += Time.deltaTime; Roots[index].Update(ComputeAim(), EventArgs.Empty); } if (Input.GetMouseButtonUp(0)) { Roots[index].End(ComputeAim(), EventArgs.Empty); MoveControl.canSprint = true; state = PressState.Released; } } }
public bool IsKey(VirtualKey key, PressState pressState) { switch (pressState) { case PressState.Down: return(CurrentState.KeyStates[(int)key]); case PressState.Up: return(!CurrentState.KeyStates[(int)key]); case PressState.Pressed: return(CurrentState.KeyStates[(int)key] && !PreviousState.KeyStates[(int)key]); case PressState.Released: return(!CurrentState.KeyStates[(int)key] && PreviousState.KeyStates[(int)key]); default: throw new ArgumentOutOfRangeException(); } }
public bool IsMouseButton(MouseButton mouseButton, PressState pressState) { switch (pressState) { case PressState.Down: return(CurrentState.MouseStates[(int)mouseButton]); case PressState.Up: return(!CurrentState.MouseStates[(int)mouseButton]); case PressState.Pressed: return(CurrentState.MouseStates[(int)mouseButton] && !PreviousState.MouseStates[(int)mouseButton]); case PressState.Released: return(!CurrentState.MouseStates[(int)mouseButton] && PreviousState.MouseStates[(int)mouseButton]); default: throw new ArgumentOutOfRangeException(); } }
private void OnTriggerExit(Collider collider) { //Check if the collider represents a hand HandFeature hand = collider.GetComponent <HandFeature>(); //Check if the first hand exited, in case multiple hands are in the EventVolume if (hand != null && _handInTrigger == hand) { _handInTrigger = null; if (_canvasCursor != null) { _canvasCursor.Hide(); } //ReleaseToSeat on EventVolume exit if being held if (_pressState == PressState.Held) { Vector3 localHandPosition = transform.InverseTransformPoint(hand.transform.position); Vector3 localBack = transform.InverseTransformPoint(_collider.bounds.max); if (localHandPosition.z < localBack.z) { _handThatExitedWhileHeld = hand; _pointerData.Reset(); _pointerData.pointerCurrentRaycast = new RaycastResult(); _pressState = PressState.Released; _raycaster.ProcessHandEvent(_pointerData, false, true); } else { StopCoroutine(BackExit()); StartCoroutine(BackExit()); } } } }
void OnPress(bool pressed) { isPressed = pressed; if (pressed) { if (timeProgress <= time + manager.config.range_Excellent) { onExcellent(); pressState = PressState.excellent; } else if (timeProgress <= time + manager.config.range_Good) { onGood(); pressState = PressState.good; } else { onBad(); pressState = PressState.bad; } } }
/// <summary> /// Update is called once per frame /// </summary> public void Update() { //UnityEngine.Debug.Log("SIZE " + Screen.width.ToString() + ", " + Screen.height.ToString()); if (gameStateManagerRef.inGame) { // saves a boolean for init update // when the game first starts if (bottomTouchLimitPos == 0) { // Here, we need to use Screen height, width instead of Screen Resolution // for whatever reason, FLAG currentScreenSize = screenManagerRef.GetScreenSize(); bottomTouchLimitPos = screenManagerRef.GetScreenSize().x - (2 * screenManagerRef.GetScreenSize().x / 3); leftSideTouchLimitPos = (screenManagerRef.GetScreenSize().x / 4); rightSideTouchLimitPos = (3 * screenManagerRef.GetScreenSize().x / 4); //UnityEngine.Debug.Log("RIGHT " + rightSideTouchLimitPos); //UnityEngine.Debug.Log("BOTTOM " + bottomTouchLimitPos); //UnityEngine.Debug.Log("RES " + Screen.width + ", " + Screen.height); } if (GameObject.FindGameObjectWithTag("TearScript")) { tearScript = GameObject.FindGameObjectWithTag("TearScript").GetComponent<Demo_SingleTear>(); } if (GameObject.FindGameObjectWithTag("Player") != null) { playerObject = GameObject.FindGameObjectWithTag("Player"); } } AnimationManager.AnimationDirection currDirection = PlayerScreenSideTouched(); if (currentScreenSize != screenManagerRef.GetScreenSize()) { currentScreenSize = screenManagerRef.GetScreenSize(); ResetResolutionDependents(); } if(Input.GetKey(KeyCode.Escape) || touchController.ReturnTouchType().Equals(TouchType.MULTITOUCH_3)) { if(gameStateManagerRef.inGame) { gameStateManagerRef.PauseGame(); } } if(gameStateManagerRef.inGame) { // this is the only place where the function ReturnPressState // should be called so we can have consistent prev and curr states prevPressState = currPressState; currPressState = ReturnPressState(); if(currDirection != AnimationManager.AnimationDirection.NONE) { //UnityEngine.Debug.Log (currSideTouched); if(!animationManagerRef.GetAnimationDirection().Equals (currDirection)) { animationManagerRef.SetDirection (currDirection); } } // starts the watch if any of the actions keys are pressed if(PlayerMoveHorizontalTriggered(ScreenSide.LEFT) || PlayerMoveHorizontalTriggered(ScreenSide.RIGHT) || currPressState.Equals(PressState.DOWN) || currPressState.Equals(PressState.JUST_PRESSED) || PlayerVerticalMovementTriggered()) { if(keyDownWatch.ElapsedMilliseconds.Equals(0)) { keyDownWatch.Start(); } if (!idleWatch.ElapsedMilliseconds.Equals(0)) { idleWatch.Reset(); idleWatch.Stop(); } } // else reset the watch and start idle timer else { if(!keyDownWatch.ElapsedMilliseconds.Equals(0)) { keyDownWatch.Reset(); keyDownWatch.Stop(); } if(idleWatch.ElapsedMilliseconds.Equals(0)) { idleWatch.Start(); } } if(idleWatch.ElapsedMilliseconds > IDLE_TRIGGER_LIMIT) { if(!animationManagerRef.GetCurrentAnimationType().Equals(AnimationManager.AnimationType.IDLE)) { //UnityEngine.Debug.Log("I'M GETTING HIT 2"); animationManagerRef.TriggerAnimation(AnimationManager.AnimationType.IDLE); } } else if (PlayerVerticalMovementTriggered()) { // trigger jump movement in animation manager if (!animationManagerRef.GetCurrentAnimationType().Equals(AnimationManager.AnimationType.JUMP)) animationManagerRef.TriggerAnimation(AnimationManager.AnimationType.JUMP); } else if(PlayerMoveHorizontalTriggered(GetCurrScreenSide ())) { if(!animationManagerRef.GetCurrentAnimationType().Equals(AnimationManager.AnimationType.WALK)) { animationManagerRef.TriggerAnimation(AnimationManager.AnimationType.WALK); } } //Should trigger for case where player holds both left and right down. else if(PlayerMoveHorizontalTriggered(ScreenSide.LEFT) && PlayerMoveHorizontalTriggered(ScreenSide.RIGHT)) { animationManagerRef.SetDirection (AnimationManager.AnimationDirection.RIGHT); animationManagerRef.TriggerAnimation (AnimationManager.AnimationType.STAND); } else { //UnityEngine.Debug.Log ("Yell at me~!"); animationManagerRef.TriggerAnimation (AnimationManager.AnimationType.STAND); } } }
protected virtual void OnPressState(GpioPressState e) { PressState?.Invoke(this, e); }
public override bool DispatchTouchEvent(MotionEvent ev) { float currentActivityScaleX = viewActivity.ScaleX; if (currentActivityScaleX == 1.0f) { SetScaleDirectionByRawX(ev.RawX); } switch (ev.Action) { case MotionEventActions.Down: lastActionDownX = ev.GetX(); lastActionDownY = ev.GetY(); isInIgnoredView = IsInIgnoredView(ev) && !IsOpened; pressedState = PressState.Down; break; case MotionEventActions.Move: if (isInIgnoredView || IsInDisableDirection(scaleDirection)) { break; } if (pressedState != PressState.Down && pressedState != PressState.MoveHorizontal) { break; } int xOffset = (int)(ev.GetX() - lastActionDownX); int yOffset = (int)(ev.GetY() - lastActionDownY); if (pressedState == PressState.Down) { if (yOffset > 25 || yOffset < -25) { pressedState = PressState.MoveVertical; break; } if (xOffset < -50 || xOffset > 50) { pressedState = PressState.MoveHorizontal; ev.Action = MotionEventActions.Cancel; } } else if (pressedState == PressState.MoveHorizontal) { if (currentActivityScaleX < 0.95) { ShowScrollViewMenu(scrollViewMenu); } float targetScale = GetTargetScale(ev.RawX); if (Use3D) { int angle = scaleDirection == Direction.Left ? -ROTATE_Y_ANGLE : ROTATE_Y_ANGLE; angle *= (int)((1 - targetScale) * 2); viewActivity.RotationY = angle; imageViewShadow.ScaleX = targetScale - shadowAdjustScaleX; imageViewShadow.ScaleY = targetScale - shadowAdjustScaleY; } else { imageViewShadow.ScaleX = targetScale + shadowAdjustScaleX; imageViewShadow.ScaleY = targetScale + shadowAdjustScaleY; } viewActivity.ScaleX = targetScale; viewActivity.ScaleY = targetScale; scrollViewMenu.Alpha = (1 - targetScale) * 2.0f; lastRawX = ev.RawX; return(true); } break; case MotionEventActions.Up: if (isInIgnoredView) { break; } if (pressedState != PressState.MoveHorizontal) { break; } pressedState = PressState.Done; if (IsOpened) { if (currentActivityScaleX > 0.56f) { CloseMenu(); } else { OpenMenu(scaleDirection); } } else { if (currentActivityScaleX < 0.94f) { OpenMenu(scaleDirection); } else { CloseMenu(); } } break; } lastRawX = ev.RawX; return(base.DispatchTouchEvent(ev)); }
protected void Update() { Vector2 axis = new Vector2(Input.GetAxis(XInputAxesName) * CursorMoveSpeed , Input.GetAxis(YInputAxesName) * CursorMoveSpeed); bool hasInput = false; // has input if (axis.sqrMagnitude > Mathf.Epsilon) { hasInput = true; if (!m_Display) { SetDisplay(true); } Vector2 position_CanvasSpace = Cursor.transform.localPosition; // origin in canvas center position_CanvasSpace += axis; position_CanvasSpace.x = Mathf.Clamp(position_CanvasSpace.x, -m_CanvasHalfSize.x, m_CanvasHalfSize.x); position_CanvasSpace.y = Mathf.Clamp(position_CanvasSpace.y, -m_CanvasHalfSize.y, m_CanvasHalfSize.y); Cursor.transform.localPosition = position_CanvasSpace; m_CursorPosition_ScreenSpace = (position_CanvasSpace + m_CanvasHalfSize) // change origin to canvas leftdown * m_CanvasToScreenScale; m_LastHasInputTime = snSystem.GetInstance().GetRealtimeSinceStartup(); } // hide when no input for a long time else if (m_Display) { float currentTime = snSystem.GetInstance().GetRealtimeSinceStartup(); if (currentTime - m_LastHasInputTime >= AutoHideCursorTime) { SetDisplay(false); } } // play click animation if (m_Display) { if (Input.GetButtonUp(SubmitButtonName)) { hasInput = true; m_PressState = PressState.Up; CursorAnimator.SetBool(CursorAnimatorClickParmeterName, true); } else if (Input.GetButton(SubmitButtonName)) { hasInput = true; m_PressState = m_PressState == PressState.Notset ? PressState.Down : PressState.Hold; } else { m_PressState = PressState.Notset; } CursorAnimator.SetBool(CursorAnimatorHoverParmeterName, snSystem.GetInstance().GetInput().EventSystem.IsPointerOverGameObject()); } else { // handle on SetDisplay() } if (hasInput) { m_LastHasInputTime = snSystem.GetInstance().GetRealtimeSinceStartup(); } }
/// <summary> /// Initializes a new instance of the <see cref="InputPacket" /> class. /// </summary> /// <param name="up">The button for moving north.</param> /// <param name="down">The button for moving south.</param> /// <param name="left">The button for moving west.</param> /// <param name="right">The button for moving east.</param> /// <param name="accept">The button used to accept menu choices.</param> /// <param name="cancel">The button used to cancel menu choices.</param> /// <param name="run">The button used to sprint.</param> /// <param name="check">The button used to check objects, talk to people, etc.</param> public InputPacket(PressState up, PressState down, PressState left, PressState right, PressState accept, PressState cancel, PressState run, PressState check) { Up = up; Down = down; Left = left; Right = right; Accept = accept; Cancel = cancel; Run = run; Check = check; }
public void OnKeyDown(KeyboardEventArgs e) { if (e.Repeat && e.ShiftKey) { return; } string a = e.Key.ToLower(); if (a.Contains("arrow")) { MoveDirection CurrDirection = StringToDirection(a.Replace("arrow", null)); if (e.CtrlKey) { SelectCornerCell(CurrDirection); keyPressState = new PressState(); } else if (e.ShiftKey) { keyPressState = new PressState(CurrDirection, 99); TimerHelper.OnTick = TimerOnTick; TimerHelper.Start(1, 1); } else { if (e.Repeat) { //if (CurrDirection == MoveDirection.up || CurrDirection == MoveDirection.down) //{ keyPressState = new PressState(CurrDirection, 99); TimerHelper.OnTick = TimerOnTick2; TimerHelper.Start(1, 1); //} //else //{ // SelectNeightbourCell(CurrDirection); //} //if (keyPressState.Direction == MoveDirection.undefined) //{ // keyPressState = new PressState(CurrDirection, 0); //} //if (CurrDirection == keyPressState.Direction) //{ // keyPressState.Count++; // if (keyPressState.Count > 5) // { // SelectNeightbourCell(CurrDirection); // keyPressState.Count -= 5; // } //} //else //{ // keyPressState = new PressState(CurrDirection, 1); //} } } } else { switch (e.Key.ToLower()) { case "home": SelectCornerCell(MoveDirection.up); break; case "end": SelectCornerCell(MoveDirection.down); break; case "pageup": bvgCell.bvgGrid.VerticalScroll.compBlazorScrollbar.ThumbMove(-(bvgCell.bvgGrid.DisplayedRowsCount - 1) * bvgCell.bvgGrid.bvgSettings.RowHeight); break; case "pagedown": bvgCell.bvgGrid.VerticalScroll.compBlazorScrollbar.ThumbMove((bvgCell.bvgGrid.DisplayedRowsCount - 1) * bvgCell.bvgGrid.bvgSettings.RowHeight); break; default: break; } } }
//确定按键检查 private void MachinePressCheck() { if (PCControl) { if (startPressState == PressState.Ready) { if (UnityEngine.Input.GetKey(KeyCode.Return)) { startPressState = PressState.OnPress; longPressStarTime = Time.time; // if (PressHandler != null) { PressHandler((int)PressEvent.PressBegin); } } } else if (startPressState == PressState.OnPress) { if (Time.time - longPressStarTime > longPressTime) { startPressState = PressState.OnClick; longPressStarTime = Time.time; // if (PressHandler != null) { PressHandler((int)PressEvent.LongPress); } } else if (!UnityEngine.Input.GetKey(KeyCode.Return)) { startPressState = PressState.OnClick; longPressStarTime = Time.time; // if (PressHandler != null) { PressHandler((int)PressEvent.PressEnd); } // if (PressHandler != null) { PressHandler((int)PressEvent.PressClick); } } } else if (startPressState == PressState.OnClick && !UnityEngine.Input.GetKey(KeyCode.Return)) { //重置 startPressState = PressState.Ready; } } else { if (startPressState == PressState.Ready) { if (McuInput.GetInstance().GetKey(MCUKeyCode.IN3)) { startPressState = PressState.OnPress; longPressStarTime = Time.time; if (PressHandler != null) { PressHandler((int)PressEvent.PressBegin); } } } else if (startPressState == PressState.OnPress) { if (Time.time - longPressStarTime > longPressTime) { startPressState = PressState.OnClick; longPressStarTime = Time.time; if (PressHandler != null) { PressHandler((int)PressEvent.LongPress); } } else if (!McuInput.GetInstance().GetKey(MCUKeyCode.IN3)) { startPressState = PressState.OnClick; longPressStarTime = Time.time; if (PressHandler != null) { PressHandler((int)PressEvent.PressEnd); } if (PressHandler != null) { PressHandler((int)PressEvent.PressClick); } } } else if (startPressState == PressState.OnClick && !McuInput.GetInstance().GetKey(MCUKeyCode.IN3)) { startPressState = PressState.Ready; } } }
// Sets global variables needed to determine specific touch controls. Such globals need to be only updated once per // update and nowhere else. private void SetTouchGlobals() { // This is the only place where the function ReturnPressState should be called so we can have consistent prev and curr states. prevPressState = currPressState; currPressState = ReturnPressState(); //UnityEngine.Debug.Log("******************************"); //UnityEngine.Debug.Log("PRESS STATE " + currPressState); //UnityEngine.Debug.Log("PREV " + prevPressState.ToString()); //UnityEngine.Debug.Log("CURR " + currPressState.ToString()); //UnityEngine.Debug.Log("GEST " + touchController.ReturnTouchType()); // Set global boolean for swipe detection. Set here so it is used only once. swipeInputDetected = IsSwipeInput(); //UnityEngine.Debug.Log("H"); //UnityEngine.Debug.Log("SWIPE " + swipeInputDetected); // Boolean used throughout the class to determine if player has initiated jump. We call this once so we dont have // conflicting states New, if vector swipe overrides any call to PlayerVerticalMovementTriggered(). jumpInitiated = PlayerVerticalMovementTriggered(); }
protected virtual void XmIeStyleChange(PressState state) { }