示例#1
0
 protected void InvokeButtonReleased(EControllerID controllerID, EInputButton inputButton)
 {
     if (ButtonReleased != null)
     {
         ButtonReleased.Invoke(controllerID, inputButton);
     }
 }
示例#2
0
 private void OnKeyRelease(KeyInfo info)
 {
     if (keyMappings.ContainsKey(info.KeyCode) && ButtonReleased != null)
     {
         ButtonReleased.Invoke(keyMappings[info.KeyCode]);
     }
 }
示例#3
0
 private void OnButtonRelease(int buttonId)
 {
     ButtonReleased?.Invoke(this, new ButtonPressedEventArgs()
     {
         ButtonId = buttonId, Device = null
     });
 }
示例#4
0
 public void ResetSwitch()
 {
     if (!isSwitch || pressedCount > 0)
     {
         return;
     }
     ButtonReleased.Invoke();
 }
示例#5
0
 private void OnTriggerExit2D(Collider2D other)
 {
     if (--pressedCount != 0 || isSwitch)
     {
         return;
     }
     ButtonReleased.Invoke();
     anim.SetBool("pressed", false);
 }
示例#6
0
 private void _buttonPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs args)
 {
     if (args.Edge == GpioPinEdge.FallingEdge)
     {
         ButtonPressed?.Invoke(this, DateTime.Now);
     }
     else
     {
         ButtonReleased?.Invoke(this, DateTime.Now);
     }
 }
示例#7
0
 private void InDevOnNoteOn(NoteOnMessage msg)
 {
     if (msg.Velocity == 0)
     {
         ButtonReleased?.Invoke(new ButtonReleasedEventArgs(PitchToButton(msg.Pitch)));
     }
     else
     {
         ButtonPressed?.Invoke(new ButtonPressedEventArgs(PitchToButton(msg.Pitch)));
     }
 }
示例#8
0
 private void Pin_ValueChanged(object sender, GpioPinValueChangedEventArgs e)
 {
     if (e.Edge == GpioPinEdge.RisingEdge)
     {
         ButtonPressed?.Invoke();
     }
     else
     {
         ButtonReleased?.Invoke();
     }
 }
示例#9
0
        protected virtual void OnKeyReleased(KeyCode key)
        {
            if (m_keyToControllerInput.TryGetValue(key, out ControllerInput input))
            {
                var  list    = m_buttons[input];
                bool wasDown = list.Count > 0;

                list.Remove(key);
                if (wasDown && list.Count == 0)
                {
                    ButtonReleased?.Invoke(input);
                }
            }
        }
示例#10
0
        private void OnButtonReleased(uint index)
        {
            if (m_buttonToControllerInput.TryGetValue((int)index, out ControllerInput input))
            {
                var  list    = m_buttons[input];
                bool wasDown = list.Count > 0;

                list.Remove(index);
                if (wasDown && list.Count == 0)
                {
                    ButtonReleased?.Invoke(input);
                }
            }
        }
示例#11
0
        internal void HandleInputEvent(uint buttonIndex, uint newState)
        {
            var info = new ButtonInfo()
            {
                DeviceIndex = DeviceIndex,
                Button      = buttonIndex,
            };

            buttonStates[buttonIndex] = newState;
            if (newState == 1)
            {
                ButtonPressed?.Invoke(buttonIndex);
                Host.ButtonPressed(info);
            }
            else
            {
                ButtonReleased?.Invoke(buttonIndex);
                Host.ButtonReleased(info);
            }
        }
示例#12
0
        /// <summary>
        /// Event listner for timer in controller
        /// </summary>
        /// <param name="sender">Event invoker</param>
        /// <param name="e">Event arguments</param>
        internal void TimerOnElapsed(object sender, ElapsedEventArgs e)
        {
            if (IsButtonPressed && !lastButtonState_)
            {
                buttonTimer_.Reset();
                buttonTimer_.Start();
                ButtonPressed?.Invoke(this, EventArgs.Empty);
            }
            else if (!IsButtonPressed && lastButtonState_)
            {
                buttonTimer_.Stop();

                ButtonReleased?.Invoke(this,
                                       new ButtonReleasedEventArgs(buttonTimer_.Elapsed.TotalMilliseconds < parent_.HoldMinTime
                                                                                          ? ButtonState.Clicked
                                                                                          : ButtonState.Holded));
            }

            lastButtonState_ = IsButtonPressed;
        }
示例#13
0
        public CallButtonService(ILogger <CallButtonService> logger, HubConnection hubConnection)
        {
            _logger = logger;

            _hubConnection = hubConnection;

            _hubConnection.Closed += async(exception) =>
            {
                if (exception != null)
                {
                    _logger.LogError(exception, "Connection unexpectedly.");

                    await Task.Delay(new Random().Next(0, 5) * 1000).ConfigureAwait(false);

                    try
                    {
                        await _hubConnection.StartAsync().ConfigureAwait(false);

                        _logger.LogInformation("Connection restarted.");
                    }
                    catch (Exception exc)
                    {
                        _logger.LogError(exc, "Failed to restart connection.");
                    }
                }
            };

            pressedSubscription = _hubConnection.On <string>("ButtonPressed", _ =>
            {
                ButtonPressed?.Invoke(this, EventArgs.Empty);
            });

            releasedSubscription = _hubConnection.On <string>("ButtonReleased", _ =>
            {
                ButtonReleased?.Invoke(this, EventArgs.Empty);
            });
        }
示例#14
0
 /// <summary>
 /// Raises the <see cref="ButtonReleased"/> event.
 /// </summary>
 /// <param name="window">The window in which the input event took place.</param>
 /// <param name="button">The mouse button that was released.</param>
 protected virtual void OnButtonReleased(IUltravioletWindow window, MouseButton button) =>
 ButtonReleased?.Invoke(window, this, button);
示例#15
0
 private void OnButtonReleased(Buttons button)
 {
     ButtonReleased?.Invoke(this,
                            new GamepadButtonEventArgs(button));
 }
 /// <summary>
 /// Raises the <see cref="ButtonReleased"/> event.
 /// </summary>
 /// <param name="window">The window that raised the event.</param>
 /// <param name="scancode">The <see cref="Scancode"/> that represents the button that was released.</param>
 protected virtual void OnButtonReleased(IUltravioletWindow window, Scancode scancode) =>
 ButtonReleased?.Invoke(window, this, scancode);
示例#17
0
 /// <summary>
 /// Raises the <see cref="ButtonReleased"/> event.
 /// </summary>
 /// <param name="button">The <see cref="GamePadButton"/> value that represents the button that was pressed.</param>
 protected virtual void OnButtonReleased(GamePadButton button) =>
 ButtonReleased?.Invoke(this, button);
示例#18
0
 protected virtual void OnButtonReleased(JoystickEventArgs e)
 {
     ButtonReleased?.Invoke(this, e);
 }