private void OnDPadPress(object sender, GamepadDPadEventArgs args) { ButtonConfig currentButton = GetCurrentButton(args.Buttons); if (lastDPadButton == null) { if (currentButton != null) { OnButtonDown?.Invoke(this, new GamepadHelperEventArgs(currentButton)); } lastDPadButton = currentButton; } else { if (lastDPadButton != currentButton) { if (lastDPadButton != null) { OnButtonUp?.Invoke(this, new GamepadHelperEventArgs(lastDPadButton)); } if (currentButton != null) { OnButtonDown?.Invoke(this, new GamepadHelperEventArgs(currentButton)); } lastDPadButton = currentButton; } } }
public void Update() { for (Axis i = Axis.MoveHorizontal; i <= Axis.Shoot; i++) { float value = Input.GetAxisRaw(string.Format("{0} {1}", Controller, i.ToString())); OnCurrentAxis?.Invoke(i, value, this); //Keyboard uses mouse for rotation if (controller == ControllerType.Keyboard && i == Axis.MoveVertical) { break; } } for (Action i = Action.Start; i <= Action.Heal; i++) { //Joysticks shoots with triggers (axis) if (controller != ControllerType.Keyboard && i == Action.Shoot) { continue; } string s = string.Format("{0} {1}", Controller, i.ToString()); if (Input.GetButtonDown(s)) { OnButtonDown?.Invoke(i, this); } if (Input.GetButtonUp(s)) { OnButtonUp?.Invoke(i, this); } } }
private void OnEnable() { state = gameObject.AddComponent <ButtonState>(); effect = Instantiate(buttonEffect, transform); effect.GetComponent <ParticleSystem>().Stop(); // タップ判定 var eventTrigger = GetComponent <ObservableEventTrigger>(); eventTrigger.OnPointerDownAsObservable() .Subscribe((_) => OnButtonDown.Invoke(this, state.Index)); eventTrigger .OnPointerUpAsObservable() .Subscribe(_ => OnButtonUp.Invoke(this, state.Index)); // キーボード判定 this.UpdateAsObservable() .Where(_ => Input.GetKeyDown(keys[state.Index])) .Subscribe(_ => OnButtonDown.Invoke(this, state.Index)); this.UpdateAsObservable() .Where(_ => Input.GetKeyUp(keys[state.Index])) .Subscribe(_ => OnButtonUp.Invoke(this, state.Index)); OnButtonDown += ButtonController_OnButtonDown; OnButtonUp += ButtonController_OnButtonUp; }
public void OnPointerDown(PointerEventData eventData) { IsPressDown = true; if (OnButtonDown != null) { OnButtonDown.Invoke(); } }
protected override void ButtonDownFeedback(PointerEventData eventData) { if (buttonMovementCoroutine != null) { StopCoroutine(buttonMovementCoroutine); } buttonMovementCoroutine = StartCoroutine(transform.LerpLocal(pressPos, 0.6f, curvesPreset.EaseOut)); // Hover in sound // Hover in effect OnButtonDown?.Invoke(buttonType); }
private void OnTriggerPress(object sender, GamepadTriggerEventArgs args) { ButtonConfig currentButton = args.Trigger == GamepadTriggers.Left ? profile.LT : profile.RT; if (args.Value > 0) { OnButtonDown?.Invoke(this, new GamepadHelperEventArgs(currentButton)); } else { OnButtonUp?.Invoke(this, new GamepadHelperEventArgs(currentButton)); } }
private void OnButtonPress(object sender, GamepadButtonEventArgs args) { ButtonConfig currentButton = GetCurrentButton(args.Button); if (currentButton != null && args.IsPressed) { OnButtonDown?.Invoke(this, new GamepadHelperEventArgs(currentButton)); } else { OnButtonUp?.Invoke(this, new GamepadHelperEventArgs(currentButton)); } }
private void FireMouseEvents() { foreach (MouseButton button in ButtonList) { if (button == MouseButton.LEFT) { // Button is held down if (CurrentMouseState.LeftButton == ButtonState.Pressed) { OnButtonDown?.Invoke(this, new MouseEventArgs(button, CurrentMouseState, PrevMouseState)); } // Button is pressed once if (PrevMouseState.LeftButton == ButtonState.Released && CurrentMouseState.LeftButton == ButtonState.Pressed) { OnButtonPressed?.Invoke(this, new MouseEventArgs(button, CurrentMouseState, PrevMouseState)); } // Button is just released once if (PrevMouseState.LeftButton == ButtonState.Pressed && CurrentMouseState.LeftButton == ButtonState.Released) { OnButtonUp?.Invoke(this, new MouseEventArgs(button, CurrentMouseState, PrevMouseState)); } } else if (button == MouseButton.RIGHT) { // Button is held down if (CurrentMouseState.RightButton == ButtonState.Pressed) { OnButtonDown?.Invoke(this, new MouseEventArgs(button, CurrentMouseState, PrevMouseState)); } // Button is pressed once if (PrevMouseState.RightButton == ButtonState.Released && CurrentMouseState.RightButton == ButtonState.Pressed) { OnButtonPressed?.Invoke(this, new MouseEventArgs(button, CurrentMouseState, PrevMouseState)); } // Button is just released if (PrevMouseState.RightButton == ButtonState.Pressed && CurrentMouseState.RightButton == ButtonState.Released) { OnButtonUp?.Invoke(this, new MouseEventArgs(button, CurrentMouseState, PrevMouseState)); } } } }
public void CheckInput() { if (Input.GetButtonDown(ButtonName)) { OnButtonDown?.Invoke(); } if (Input.GetButtonUp(ButtonName)) { OnButtonUp?.Invoke(); } if (Input.GetButton(ButtonName)) { OnButton?.Invoke(); } }
private void Update() { OVRInput.Update(); foreach (OVRInput.Button button in buttons) { if (inputStates[button] && OVRInput.Get(button)) { inputStates[button] = false; OnButtonDown?.Invoke(button); } else if (!inputStates[button] && !OVRInput.Get(button)) { inputStates[button] = true; OnButtonUp?.Invoke(button); } } }
private void UpdateTimer_Elapsed(object sender, ElapsedEventArgs e) { LogiLcdUpdate( ); foreach (Button btn in Enum.GetValues(typeof(Button))) { var state = IsButtonPressed(btn); if (state && !buttonState [( int )btn]) { OnButtonDown.Invoke(btn); } buttonState [( int )btn] = state; } IsConnected = LogiLcdIsConnected(LOGI_LCD_TYPE_COLOR); updateTimer.Start( ); }
internal void InitGamePadHandlers() { _gamePadHandlers = new GamePadHandler[MaxGamePads]; for (int i = 0; i < MaxGamePads; i++) { var handle = _gamePadHandlers[i] = new GamePadHandler(i); // Redirect Events. handle.OnConnection += () => OnConnection?.Invoke(handle); handle.OnDisconnect += () => OnDisconnected?.Invoke(handle); handle.OnButtonDown += (button, value) => OnButtonDown?.Invoke(handle, button, value); handle.OnButtonUp += (button, value) => OnButtonUp?.Invoke(handle, button, value); handle.OnButtonPressed += (button, value) => OnButtonPressed?.Invoke(handle, button, value); handle.OnButtonClicked += (button, value) => OnButtonClicked?.Invoke(handle, button, value); handle.OnButtonReleased += (button, value) => OnButtonReleased?.Invoke(handle, button, value); } }
public override void HandleState(XRController controller) { if (controller.inputDevice.IsPressed(button, out bool pressed, controller.axisToPressThreshold)) { if (previousPress != pressed) { previousPress = pressed; if (pressed) { OnButtonDown?.Invoke(controller); } else { OnButtonUp?.Invoke(controller); } } } }
private void Init() { dir = selectedType.Equals(ButtonType.Left) ? -1 : +1; var DownEntry = new EventTrigger.Entry(); DownEntry.eventID = EventTriggerType.PointerDown; DownEntry.callback.AddListener((data) => OnButtonDown?.Invoke(dir, true)); var UpEntry = new EventTrigger.Entry(); UpEntry.eventID = EventTriggerType.PointerUp; UpEntry.callback.AddListener((data) => OnButtonUp?.Invoke(false)); button = GetComponent <EventTrigger>(); button.triggers.Add(DownEntry); button.triggers.Add(UpEntry); }
public void Update() { var currentButtons = GamePadButtonsHelper.GetPressedButtons(0); previousUpdateButtons.Except(currentButtons).ToList().ForEach(button => OnButtonUp?.Invoke(0, new GamePadButtonEventArgs(button))); currentButtons.Except(previousUpdateButtons).ToList().ForEach(button => OnButtonDown?.Invoke(0, new GamePadButtonEventArgs(button))); previousUpdateButtons.Clear(); previousUpdateButtons.AddRange(currentButtons); var currentDPadButtons = GamePadButtonsHelper.GetPressedDPadButtons(0); previousUpdateDPadButtons.Except(currentDPadButtons).ToList().ForEach(button => OnButtonUp?.Invoke(0, new GamePadButtonEventArgs(button))); currentDPadButtons.Except(previousUpdateDPadButtons).ToList().ForEach(button => OnButtonDown?.Invoke(0, new GamePadButtonEventArgs(button))); previousUpdateDPadButtons.Clear(); previousUpdateDPadButtons.AddRange(currentDPadButtons); }
/// <summary> /// Handles incoming HID reports. /// </summary> /// <param name="report">The input report.</param> private void OnReport(HidReport report) { if (!device.IsConnected) { Console.WriteLine("But device not connected?"); return; } if (report.Data.Length != 16) { Console.WriteLine("Unknown input"); return; } lock (lastInput) { InputMessage input = new InputMessage(report.Data); for (int i = 0; i < 15; i++) { bool keyPressed = input.IsButtonPressed(i); if (keyPressed != lastInput.IsButtonPressed(i)) { if (keyPressed) { Console.WriteLine("Press: {0}", i); OnButtonDown?.Invoke(i); } else { Console.WriteLine("Release: {0}", i); OnButtonUp?.Invoke(i); } } } lastInput = input; } device.ReadReport(OnReport); }
void Read(SerialPort port) { while (readPorts) { try { var msg = port.ReadLine(); if (msg.StartsWith("btn1.down")) { var args = new ButtonEventArgs("btn1", ButtonState.Down); OnButtonDown?.Invoke(this, args); OnButtonChange?.Invoke(this, args); } else if (msg.StartsWith("btn1.up")) { var args = new ButtonEventArgs("btn1", ButtonState.Up); OnButtonUp?.Invoke(this, args); OnButtonChange?.Invoke(this, args); } } catch (TimeoutException e) { } } }
public static void InvokeEvents() { if (OnLeftButtonDown != null && IsButtonDown(MouseButton.Left)) { OnLeftButtonDown.Invoke(currentState); } if (OnLeftButtonPressed != null && IsButtonPressed(MouseButton.Left)) { OnLeftButtonPressed.Invoke(currentState); } if (OnLeftButtonReleased != null && IsButtonReleased(MouseButton.Left)) { OnLeftButtonReleased.Invoke(currentState); } if (OnRightButtonDown != null && IsButtonDown(MouseButton.Right)) { OnRightButtonDown.Invoke(currentState); } if (OnRightButtonPressed != null && IsButtonPressed(MouseButton.Right)) { OnRightButtonPressed.Invoke(currentState); } if (OnRightButtonReleased != null && IsButtonReleased(MouseButton.Right)) { OnRightButtonReleased.Invoke(currentState); } if (OnMiddleButtonDown != null && IsButtonDown(MouseButton.Middle)) { OnMiddleButtonDown.Invoke(currentState); } if (OnMiddleButtonPressed != null && IsButtonPressed(MouseButton.Middle)) { OnMiddleButtonPressed.Invoke(currentState); } if (OnMiddleButtonReleased != null && IsButtonReleased(MouseButton.Middle)) { OnMiddleButtonReleased.Invoke(currentState); } if (OnXButton1Down != null && IsButtonDown(MouseButton.XButton1)) { OnXButton1Down.Invoke(currentState); } if (OnXButton1Pressed != null && IsButtonPressed(MouseButton.XButton1)) { OnXButton1Pressed.Invoke(currentState); } if (OnXButton1Released != null && IsButtonReleased(MouseButton.XButton1)) { OnXButton1Released.Invoke(currentState); } if (OnXButton2Down != null && IsButtonDown(MouseButton.XButton2)) { OnXButton2Down.Invoke(currentState); } if (OnXButton2Pressed != null && IsButtonPressed(MouseButton.XButton2)) { OnXButton2Pressed.Invoke(currentState); } if (OnXButton2Released != null && IsButtonReleased(MouseButton.XButton2)) { OnXButton2Released.Invoke(currentState); } if (OnButtonDown != null && IsButtonDown(MouseButton.Any)) { OnButtonDown.Invoke(currentState, GetDownButtons()); } if (OnButtonPressed != null && IsButtonPressed(MouseButton.Any)) { OnButtonPressed.Invoke(currentState, GetPressedButtons()); } if (OnButtonReleased != null && IsButtonReleased(MouseButton.Any)) { OnButtonReleased.Invoke(currentState, GetReleasedButtons()); } if (OnMouseWheelUp != null && IsMouseWheelUp()) { OnMouseWheelUp.Invoke(currentState); } if (OnMouseWheelDown != null && IsMouseWheelDown()) { OnMouseWheelDown.Invoke(currentState); } if (OnMouseMove != null && IsMouseMoving()) { OnMouseMove.Invoke(currentState, GetMoveDirection()); } }
public override void OnPressed() { base.OnPressed(); OnButtonDown?.Invoke(this, null); }
public void TriggerOnButtonDown() { OnButtonDown?.Invoke(); }
void Update() { var name = Number.ToString(); var LeftStickH = (InputMap.LeftStick.Inversion.Horizontal ? -1 : 1) * Input.GetAxis($"{name}{InputMap.LeftStick.Horizontal}"); var LeftStickV = (InputMap.LeftStick.Inversion.Vertical ? -1 : 1) * Input.GetAxis($"{name}{InputMap.LeftStick.Vertical}"); if (LeftStickH != 0 || LeftStickV != 0) { OnLeftStick?.Invoke(LeftStickH, LeftStickV); } var RightStickH = (InputMap.RightStick.Inversion.Horizontal ? -1 : 1) * Input.GetAxis($"{name}{InputMap.RightStick.Horizontal}"); var RightStickV = (InputMap.RightStick.Inversion.Vertical ? -1 : 1) * Input.GetAxis($"{name}{InputMap.RightStick.Vertical}"); if (RightStickH != 0 || RightStickV != 0) { OnRightStick?.Invoke(RightStickH, RightStickV); } var DPadH = (InputMap.DPadAxes.Inversion.Horizontal ? -1 : 1) * Input.GetAxis($"{name}{InputMap.DPadAxes.Horizontal}"); var DPadV = (InputMap.DPadAxes.Inversion.Vertical ? -1 : 1) * Input.GetAxis($"{name}{InputMap.DPadAxes.Vertical}"); if (DPadH != 0 || DPadV != 0) { OnDPad?.Invoke(DPadH, DPadV); } var L2Analog = Input.GetAxis($"{name}{InputMap.L2Analog}"); if (L2Analog != 0) { OnLeftTrigger?.Invoke(L2Analog); } var R2Analog = Input.GetAxis($"{name}{InputMap.R2Analog}"); if (R2Analog != 0) { OnRightTrigger?.Invoke(R2Analog); } if (Input.GetButtonDown($"{name}{InputMap.DPadButtons.Left}")) { OnButtonDown?.Invoke(Button.DPadLeft); } if (Input.GetButtonDown($"{name}{InputMap.DPadButtons.Down}")) { OnButtonDown?.Invoke(Button.DPadDown); } if (Input.GetButtonDown($"{name}{InputMap.DPadButtons.Right}")) { OnButtonDown?.Invoke(Button.DPadRight); } if (Input.GetButtonDown($"{name}{InputMap.DPadButtons.Up}")) { OnButtonDown?.Invoke(Button.DPadUp); } if (Input.GetButtonDown($"{name}{InputMap.L1}")) { OnButtonDown?.Invoke(Button.L1); } if (Input.GetButtonDown($"{name}{InputMap.R1}")) { OnButtonDown?.Invoke(Button.R1); } if (Input.GetButtonDown($"{name}{InputMap.L2}")) { OnButtonDown?.Invoke(Button.L2); } if (Input.GetButtonDown($"{name}{InputMap.R2}")) { OnButtonDown?.Invoke(Button.R2); } if (Input.GetButtonDown($"{name}{InputMap.LeftStick.Press}")) { OnButtonDown?.Invoke(Button.L3); } if (Input.GetButtonDown($"{name}{InputMap.RightStick.Press}")) { OnButtonDown?.Invoke(Button.R3); } if (Input.GetButtonDown($"{name}{InputMap.ButtonLeft}")) { OnButtonDown?.Invoke(Button.ButtonLeft); } if (Input.GetButtonDown($"{name}{InputMap.ButtonBottom}")) { OnButtonDown?.Invoke(Button.ButtonBottom); } if (Input.GetButtonDown($"{name}{InputMap.ButtonRight}")) { OnButtonDown?.Invoke(Button.ButtonRight); } if (Input.GetButtonDown($"{name}{InputMap.ButtonTop}")) { OnButtonDown?.Invoke(Button.ButtonTop); } if (Input.GetButtonDown($"{name}{InputMap.Start}")) { OnButtonDown?.Invoke(Button.Start); } if (Input.GetButtonDown($"{name}{InputMap.Select}")) { OnButtonDown?.Invoke(Button.Select); } if (Input.GetButtonDown($"{name}{InputMap.Extra1}")) { OnButtonDown?.Invoke(Button.Extra1); } if (Input.GetButtonDown($"{name}{InputMap.Extra2}")) { OnButtonDown?.Invoke(Button.Extra2); } if (Input.GetButtonDown($"{name}{InputMap.Extra3}")) { OnButtonDown?.Invoke(Button.Extra3); } if (Input.GetButtonDown($"{name}{InputMap.Extra4}")) { OnButtonDown?.Invoke(Button.Extra4); } if (Input.GetButtonDown($"{name}{InputMap.Extra5}")) { OnButtonDown?.Invoke(Button.Extra5); } if (Input.GetButtonDown($"{name}{InputMap.Extra6}")) { OnButtonDown?.Invoke(Button.Extra6); } if (Input.GetButtonDown($"{name}{InputMap.Extra7}")) { OnButtonDown?.Invoke(Button.Extra7); } if (Input.GetButtonDown($"{name}{InputMap.Extra8}")) { OnButtonDown?.Invoke(Button.Extra8); } if (Input.GetButtonDown($"{name}{InputMap.Extra9}")) { OnButtonDown?.Invoke(Button.Extra9); } if (Input.GetButtonDown($"{name}{InputMap.Extra10}")) { OnButtonDown?.Invoke(Button.Extra10); } }
public void GetButtonDown() { OnButtonDown?.Invoke(Input.GetButton(AxisManager.FIREBALL_ATTACK)); }
public void GetButtonDown() { OnButtonDown?.Invoke(Input.GetButton(AxisManager.BLOCK)); }
public void GetButtonDown() { OnButtonDown?.Invoke(Input.GetButton(AxisManager.SWORD_ATTACK)); }
public void InvokeDownEvent(XRController controller) { previousPress = true; OnButtonDown?.Invoke(controller); }