private void CallBackEvent(JoyButtonEvent evt) { if (this.mCallBackFunction != null) { this.mCallBackFunction.Invoke(mBtnCode, evt, this.mArrowDir); } }
private void ResetToInit() { this.mArrowDir = JoyButtonDir.Center; this.mHasNotifyedEvent = JoyButtonEvent.None; this.mTouchStartTime = 0; this.UpdateArrowDir(); this.mControlTransform.anchoredPosition = Vector2.zero; this.mPress.SetActive(false); }
void Update() { if (this.IsTouched) { float PressDelta = Time.time - this.mTouchStartTime; if (PressDelta > this.mPressNotiInterval && this.mHasNotifyedEvent == JoyButtonEvent.None) { //通知长按事件 this.mHasNotifyedEvent = JoyButtonEvent.Holding; this.CallBackEvent(JoyButtonEvent.Holding); } } }
public void ProcessJoystickEvent(JoyButtonEvent ev) { int id = ev.Which; if (IsJoystickInstanceValid(id)) { int index = sdl_instanceid_to_joysticks[id]; JoystickDevice<Sdl2JoystickDetails> joystick = (JoystickDevice<Sdl2JoystickDetails>)joysticks[index]; joystick.SetButton(ev.Button, ev.State == State.Pressed); joystick.Details.PacketNumber = Math.Max(0, unchecked(joystick.Details.PacketNumber + 1)); } else { Debug.Print("[SDL2] Invalid joystick id {0} in {1}", id, ev.Type); } }
public void OnUiJoyButtonEvent(JoyButtonCode buttonCode, JoyButtonEvent evt, JoyButtonDir dir) { JoyButtonResponseData data = new JoyButtonResponseData(); data.mCode = buttonCode; data.mEvent = evt; data.mDir = dir; data.mIsGrounded = this.mIsGrounded; if (data.mCode == JoyButtonCode.Jump && data.mEvent == JoyButtonEvent.Touched) { this.CallJump(); } else { this.CallAttack(data); } }
//////////////////////////////////////////////////////////// /// <summary> /// Construct the joystick button arguments from a joystick button event /// </summary> /// <param name="e">Joystick button event</param> //////////////////////////////////////////////////////////// public JoyButtonEventArgs(JoyButtonEvent e) { JoystickId = e.JoystickId; Button = e.Button; }