Ejemplo n.º 1
0
        /// <summary>
        /// Handler invoked on mouse click (left) event.
        /// </summary>
        /// <param name="x">X coordinate.</param>
        /// <param name="y">Y coordinate.</param>
        /// <param name="down">If set to <c>true</c> mouse button is down.</param>
        protected override void OnMouseClickedLeft(int x, int y, bool down)
        {
            if (down)
            {
                IsDepressed             = true;
                InputHandler.MouseFocus = this;
                if (Pressed != null)
                {
                    Pressed.Invoke(this, EventArgs.Empty);
                }
                base.OnMouseClickedLeft(x, y, true);                //not original
            }
            else
            {
                if (IsHovered && m_Depressed)
                {
                    OnClicked(x, y);
                }

                IsDepressed             = false;
                InputHandler.MouseFocus = null;
                if (Released != null)
                {
                    Released.Invoke(this, EventArgs.Empty);
                }
            }

            Redraw();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handler invoked on mouse click (left) event.
        /// </summary>
        /// <param name="x">X coordinate.</param>
        /// <param name="y">Y coordinate.</param>
        /// <param name="down">If set to <c>true</c> mouse button is down.</param>
        protected override void OnMouseClickedLeft(int x, int y, bool down)
        {
            if (null == m_Target)
            {
                return;
            }

            if (down)
            {
                m_Held    = true;
                m_HoldPos = m_Target.CanvasPosToLocal(new Point(x, y));
                InputHandler.MouseFocus = this;
                if (Pressed != null)
                {
                    Pressed.Invoke(this, EventArgs.Empty);
                }
            }
            else
            {
                m_Held = false;
                InputHandler.MouseFocus = null;

                if (Released != null)
                {
                    Released.Invoke(this, EventArgs.Empty);
                }
            }
        }
Ejemplo n.º 3
0
        private void ReleaseObject()
        {
            // Make sure there’s a fixed joint attached to the controller.
            if (GetComponent <FixedJoint>())
            {
                // Remove the connection to the object held by the joint and destroy the joint.
                GetComponent <FixedJoint>().connectedBody = null;
                Destroy(GetComponent <FixedJoint>());
                // Add the speed and rotation of the controller when the player releases the object, so the result is a realistic arc.
                var held_rigidbody = HeldObject.GetComponent <Rigidbody>();
                held_rigidbody.velocity        = Controller.velocity;
                held_rigidbody.angularVelocity = Controller.angularVelocity;
            }
            // Destroy the grabbed marker on the held object
            //Destroy(HeldObjectGrabMarker);
            //HeldObjectGrabMarker = null;
            // Remove the reference to the formerly attached object.
            var was_held = HeldObject;

            HeldObject = null;
            Released.Invoke(this, new GrabEventArgs()
            {
                ControllerDevice = Controller,
                GameObject       = was_held
            });
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Handler invoked on mouse click (left) event.
        /// </summary>
        /// <param name="x">X coordinate.</param>
        /// <param name="y">Y coordinate.</param>
        /// <param name="down">If set to <c>true</c> mouse button is down.</param>
        protected override void OnMouseClickedLeft(int x, int y, bool down)
        {
            //base.OnMouseClickedLeft(x, y, down);
            if (down)
            {
                IsDepressed = true;
                InputHandler.Instance.MouseFocus = this;
                if (Pressed != null)
                {
                    Pressed.Invoke(this);
                }
            }
            else
            {
                if (IsHovered && m_Depressed)
                {
                    OnClicked();
                }

                IsDepressed = false;
                InputHandler.Instance.MouseFocus = null;
                if (Released != null)
                {
                    Released.Invoke(this);
                }
            }

            Redraw();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Handler invoked on mouse click (left) event.
        /// </summary>
        /// <param name="x">X coordinate.</param>
        /// <param name="y">Y coordinate.</param>
        /// <param name="down">If set to <c>true</c> mouse button is down.</param>
        protected override void OnMouseClickedLeft(int x, int y, bool down)
        {
            //base.OnMouseClickedLeft(x, y, down);
            if (down)
            {
                IsDepressed             = true;
                InputHandler.MouseFocus = this;
                if (Pressed != null)
                {
                    Pressed.Invoke(this, EventArgs.Empty);
                }
            }
            else
            {
                if (IsHovered && m_Depressed && this.GetCanvas().GetControlAt(x, y) == this)
                {
                    OnClicked(x, y);
                }

                IsDepressed             = false;
                InputHandler.MouseFocus = null;
                if (Released != null)
                {
                    Released.Invoke(this, EventArgs.Empty);
                }
            }

            Redraw();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Handler invoked on mouse click (left) event.
        /// </summary>
        /// <param name="x">X coordinate.</param>
        /// <param name="y">Y coordinate.</param>
        /// <param name="down">If set to <c>true</c> mouse button is down.</param>
        protected override void onMouseClickedLeft(int x, int y, bool down)
        {
            //base.onMouseClickedLeft(x, y, down);
            if (down)
            {
                IsDepressed             = true;
                InputHandler.MouseFocus = this;
                if (Pressed != null)
                {
                    Pressed.Invoke(this, EventArgs.Empty);
                }
            }
            else
            {
                if (IsHovered && depressed)
                {
                    onClicked(x, y);
                }

                IsDepressed             = false;
                InputHandler.MouseFocus = null;
                if (Released != null)
                {
                    Released.Invoke(this, EventArgs.Empty);
                }
            }

            Redraw();
        }
Ejemplo n.º 7
0
 private void OnRelease()
 {
     Manager.OnAnyButtonRelease();
     state = ButtonState.Ready;
     if (InteractionStyle == ButtonInteractionStyles.ToggleButton)
     {
         Toggled = !Toggled;
     }
     Released?.Invoke(this, EventArgs.Empty);
 }
        public void ConsumeKeyDown(KeyboardKeyEventArgs obj)
        {
            if (obj.IsRepeat || !KeyMap.TryGetValue(obj.Key, out var value))
            {
                return;
            }

            ButtonStates[value] = ButtonState.Released;
            Released?.Invoke(this, value);
        }
Ejemplo n.º 9
0
        private void HandleButtonReleased()
        {
            ulong interruptTime = Pi.Timing.Milliseconds;

            if (interruptTime - _releasedLastInterrupt <= InterruptTime)
            {
                return;
            }
            _releasedLastInterrupt = interruptTime;
            Released?.Invoke(this, new EventArgs());
        }
Ejemplo n.º 10
0
        private void HandleButtonReleased()
        {
            ulong interruptTime = WiringPi.Millis();

            if (interruptTime - _releasedLastInterrupt <= InterruptTime)
            {
                return;
            }
            _releasedLastInterrupt = interruptTime;
            Released?.Invoke(this, EventArgs.Empty);
        }
Ejemplo n.º 11
0
 private void DispatchState(object sender, BinaryStateChangedEventArgs e)
 {
     if (e.NewState == BinaryState.High)
     {
         Pressed?.Invoke(this, EventArgs.Empty);
     }
     else if (e.NewState == BinaryState.Low)
     {
         Released?.Invoke(this, EventArgs.Empty);
     }
 }
Ejemplo n.º 12
0
        private void ZReleaseToken(cTrace.cContext pParentContext)
        {
            var lContext = pParentContext.NewMethod(nameof(cExclusiveAccess), nameof(ZReleaseToken), mName, mInstance);

            if (mDisposed)
            {
                throw new ObjectDisposedException(nameof(cExclusiveAccess));
            }
            mToken = null;
            Released?.Invoke(lContext);
            mExclusiveSemaphoreSlim.Release();
        }
Ejemplo n.º 13
0
        public virtual void Release(IBinder targetBinder)
        {
            if (this.Items.Contains(targetBinder))
            {
                this.Items.Remove(targetBinder);

                targetBinder.Release(this);

                // Raise
                Released?.Invoke(this, targetBinder);
            }
        }
Ejemplo n.º 14
0
 private void Slider_PointerReleased(object sender, PointerRoutedEventArgs e)
 {
     Slider.ReleasePointerCapture(e.Pointer);
     pointerCaptured = false;
     Released?.Invoke(this, new SliderEventArgs {
         Distance = Distance
     });
     if (this.ResetOnRelease)
     {
         centerSlider.Begin();
     }
 }
Ejemplo n.º 15
0
 private void Knob_PointerReleased(object sender, PointerRoutedEventArgs e)
 {
     Knob.ReleasePointerCapture(e.Pointer);
     pointerCaptured = false;
     Released?.Invoke(this, new JoypadEventArgs {
         Angle = Angle, Distance = Distance
     });
     if (!this.DisableResetOnRelease)
     {
         centerKnob.Begin();
     }
 }
Ejemplo n.º 16
0
        public void Release()
        {
            if (IsConnected)
            {
                IsConnected = false;

                Output = null;
                Input  = null;

                OnRelease();
                Released?.Invoke(this, null);
            }
        }
Ejemplo n.º 17
0
        public virtual void OnReleased(Mouse.Button button)
        {
            if (IsPressed && button == Mouse.Button.Left)
            {
                Focused = true;
                OnClicked();
            }

            IsPressed = false;
            Released?.Invoke(this, button);

            StyleChanged = true;
        }
Ejemplo n.º 18
0
        /// <summary>
        ///     Отпустить шайбу
        /// </summary>
        public void Release()
        {
            Releasing?.Invoke(null, null);

            _inHand                = false;
            _playerTransform       = null;
            _targetJoint.enabled   = false;
            _rigidbody.constraints = RigidbodyConstraints2D.None;

            gameObject.layer = _puckLayer;

            Released?.Invoke(null, null);
        }
Ejemplo n.º 19
0
        /// <inheritdoc />
        protected override void DataAvailable(object sender, DataAvailableEventArgs <EvEvent> e)
        {
            var data = e.Data;

            var eventType = (TouchscreenEventType)data.Type;

            switch (eventType)
            {
            case TouchscreenEventType.Syn:
            {
                switch (Fingers[_slot].Status)
                {
                case FingerStatus.Down:
                    Pressed?.Invoke(this, Fingers[_slot]);
                    break;

                case FingerStatus.Up:
                    Released?.Invoke(this, Fingers[_slot]);
                    break;

                case FingerStatus.Moving:
                    Moved?.Invoke(this, Fingers[_slot]);
                    break;

                case FingerStatus.Untracked:
                    break;

                default:
                    throw new ArgumentOutOfRangeException("Status", Fingers[_slot].Status,
                                                          Fingers[_slot].Status.GetType().Name);
                }

                Fingers[_slot].Status = Fingers[_slot].Status switch
                {
                    FingerStatus.Up => FingerStatus.Untracked,
                    FingerStatus.Down => FingerStatus.Moving,
                    _ => Fingers[_slot].Status
                };

                _slot = 0;
                break;
            }

            case TouchscreenEventType.Absolute:
                ProcessAbsoluteTouch((TouchscreenEventAbsCode)data.Code, data.Value);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(eventType), eventType, eventType.GetType().Name);
            }
        }
Ejemplo n.º 20
0
        protected override void OnReleased(HVRGrabbable grabbable)
        {
            if (_appQuitting)
            {
                return;
            }

            base.OnReleased(grabbable);

            Released.Invoke(this, grabbable);

            if (grabbable.BeingDestroyed)
            {
                return;
            }

            CleanupRigidBody(grabbable);

            grabbable.ResetToNonTrigger();
            grabbable.transform.parent = _previousParent;

            if (ScaleGrabbable)
            {
                grabbable.transform.localScale = _previousScale;
            }

            _previousParent = null;

            if (AudioReleasedOverride)
            {
                SFXPlayer.Instance.PlaySFX(AudioReleasedOverride, transform.position);
            }
            else if (grabbable.Socketable.UnsocketedClip)
            {
                SFXPlayer.Instance.PlaySFX(grabbable.Socketable.UnsocketedClip, transform.position);
            }
            else if (AudioReleasedFallback)
            {
                SFXPlayer.Instance.PlaySFX(AudioReleasedFallback, transform.position);
            }

            CheckAutoSpawn();

            if (GrabTimeout > .00001f)
            {
                StartCoroutine(GrabTimeoutRoutine(grabbable));
            }
        }
Ejemplo n.º 21
0
        private void Callback(object _, PinValueChangedEventArgs pinValueChangedEventArgs)
        {
            switch (pinValueChangedEventArgs.ChangeType)
            {
            case PinEventTypes.Rising:
                IsPressed = false;
                Released?.Invoke(this, EventArgs.Empty);
                break;

            case PinEventTypes.Falling:
                IsPressed = true;
                Pressed?.Invoke(this, EventArgs.Empty);
                break;
            }
            PressedChanged?.Invoke(this, IsPressed);
        }
Ejemplo n.º 22
0
 private void onMouseUp(object sender, MouseButtonEventArgs e)
 {
     if (e.Button == Mouse.Button.Left && _state == InteractableState.Down)
     {
         if (inputEngine.Mouse.CurrentWindow == Window && e.X >= GlobalX + _hitBox.X && e.X <= GlobalX + _hitBox.X + _hitBox.Width && e.Y >= GlobalY + _hitBox.Y && e.Y <= GlobalY + _hitBox.Y + _hitBox.Height)
         {
             _state = InteractableState.Hover;
             Released?.Invoke(this, EventArgs.Empty);
         }
         else
         {
             _state = InteractableState.Normal;
             ReleasedOutside?.Invoke(this, EventArgs.Empty);
         }
     }
 }
Ejemplo n.º 23
0
 private void Update()
 {
     if (Touched)
     {
         if (_timeTouched < _triggerTime &&
             _timeTouched + Time.deltaTime >= _triggerTime)
         {
             Pressed?.Invoke(this);
         }
         _timeTouched += Time.deltaTime;
     }
     else
     {
         if (_timeTouched >= _triggerTime)
         {
             _timeTouched = 0;
             Released?.Invoke(this);
         }
     }
 }
Ejemplo n.º 24
0
        protected override void DataAvailable(object sender, DataAvailableEventArgs <EvEvent> e)
        {
            var data = e.Data;

            var eventType = (KeyboardEventType)data.Type;

            switch (eventType)
            {
            case KeyboardEventType.Syn:
            case KeyboardEventType.Msc:
            case KeyboardEventType.Led:
                break;

            case KeyboardEventType.Key:
            {
                var key   = (KeyboardKey)data.Code;
                var state = (ButtonState)data.Value;

                switch (state)
                {
                case ButtonState.Released:
                    Released?.Invoke(this, new KeyEventArgs(key));
                    break;

                case ButtonState.Pressed:
                case ButtonState.Repeat:
                    Pressed?.Invoke(this, new KeyPressEventArgs(key, state == ButtonState.Repeat));
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(state), state, state.GetType().Name);
                }

                break;
            }

            default:
                throw new ArgumentOutOfRangeException(nameof(eventType), eventType, eventType.GetType().Name);
            }
        }
Ejemplo n.º 25
0
 /// <summary>
 /// 启用UI。
 /// </summary>
 public void Start( )
 {
     PreEvent();
     UIEvent();
     Click      += ClickEvent;
     RightClick += RightClickEvent;
     Pressed    += PressedEvent;
     Released   += ReleasedEvent;
     if (ModHelper.MouseInRectangle(uiRectangle))
     {
         if (!canUseItem)
         {
             Main.LocalPlayer.mouseInterface = true;
         }
         if (Main.mouseLeft && Main.mouseLeftRelease)
         {
             Click.Invoke();
         }
         if (Main.mouseRight && Main.mouseRightRelease)
         {
             RightClick.Invoke();
         }
         else if (Main.mouseLeft)
         {
             Pressed.Invoke();
         }
         else if (Main.mouseLeftRelease)
         {
             Released.Invoke();
         }
     }
     Click      -= ClickEvent;
     RightClick -= RightClickEvent;
     Pressed    -= PressedEvent;
     Released   -= ReleasedEvent;
     Draw(Main.spriteBatch);
     PostEvent();
 }
Ejemplo n.º 26
0
        /// <inheritdoc />
        protected override void DataAvailable(object sender, DataAvailableEventArgs <EvEvent> e)
        {
            var data = e.Data;

            var eventType = (PhysicalButtonEventType)data.Type;

            switch (eventType)
            {
            case PhysicalButtonEventType.Syn:
                break;

            case PhysicalButtonEventType.Key:
                var button      = (PhysicalButton)data.Code;
                var buttonState = (ButtonState)data.Value;

                ButtonStates[button] = ButtonState.Pressed;

                switch (buttonState)
                {
                case ButtonState.Released:
                    Released?.Invoke(null, button);
                    break;

                case ButtonState.Pressed:
                    Pressed?.Invoke(null, button);
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(buttonState), buttonState,
                                                          buttonState.GetType().Name);
                }

                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(eventType), eventType, eventType.GetType().Name);
            }
        }
Ejemplo n.º 27
0
 private void onMouseUp(object sender, MouseButtonEventArgs e)
 {
     if (e.Button == Mouse.Button.Left && _state == InteractableState.Down)
     {
         if (inputEngine.Mouse.CurrentWindow == Window && e.X >= GlobalX + _hitBox.X && e.X <= GlobalX + _hitBox.X + _hitBox.Width && e.Y >= GlobalY + _hitBox.Y && e.Y <= GlobalY + _hitBox.Y + _hitBox.Height)
         {
             /*bool update = false;
              * if (_hitBox.X == X && _hitBox.Y == Y && _hitBox.Width == Width && _hitBox.Height == Height) {
              *      update = true;
              * }*/
             Texture = (_hoverTexture != null) ? atlas.GetTexture(_hoverTexture) : atlas.GetTexture(_normalTexture);
             //if (update) {
             _hitBox.X      = 0.0d;
             _hitBox.Y      = 0.0d;
             _hitBox.Width  = Width;
             _hitBox.Height = Height;
             //}
             _state = InteractableState.Hover;
             Released?.Invoke(this, EventArgs.Empty);
         }
         else
         {
             /*bool update = false;
              * if (_hitBox.X == X && _hitBox.Y == Y && _hitBox.Width == Width && _hitBox.Height == Height) {
              *      update = true;
              * }*/
             Texture = atlas.GetTexture(_normalTexture);
             //if (update) {
             _hitBox.X      = 0.0d;
             _hitBox.Y      = 0.0d;
             _hitBox.Width  = Width;
             _hitBox.Height = Height;
             //}
             _state = InteractableState.Normal;
             ReleasedOutside?.Invoke(this, EventArgs.Empty);
         }
     }
 }
Ejemplo n.º 28
0
        private void OnPinChanged(object sender, PinValueChangedEventArgs pinValueChangedEventArgs)
        {
            var value = gpioController.Read(InPinNumber);

            var duration = DateTime.Now - triggerTimestamp;

            if (duration.TotalMilliseconds < InterruptTime)
            {
                return;
            }

            if (value == PinValue.Low)
            {
                triggerTimestamp = DateTime.Now;

                Released?.Invoke(this, EventArgs.Empty);
            }
            else if (value == PinValue.High)
            {
                triggerTimestamp = DateTime.Now;

                Pressed?.Invoke(this, EventArgs.Empty);
            }
        }
Ejemplo n.º 29
0
 /// <summary>
 /// Raises the Released event.
 /// </summary>
 private void OnReleased() =>
 Released?.Invoke(this);
Ejemplo n.º 30
0
 public void PropagateUpReleased() =>
 Released?.Invoke(this, EventArgs.Empty);