void Input_GamepadConnected(object sender, GamepadEventArgs e)
 {
     if (controller != null)
     {
         controller.ControllingPlayer = e.Player;
     }
 }
Beispiel #2
0
        /// <summary>
        /// 输入手柄消息
        /// </summary>
        /// <param name="msg">消息</param>
        private void OnGamepadMessage(GamepadEventArgs args)
        {
            switch (args.Msg.GetMessageType())
            {
            case MessageType.Keyboard:
                MessageKeyboard kb = args.Msg as MessageKeyboard;

                //Debug.Log($"Keyboard  Hid:{kb.Hid} KeyCode:{kb.KeyCode} State:{kb.State}");
                singlePool.Cache(kb.KeyCode, kb.State);
                multiPool.Cache(kb.KeyCode, kb.State);
                break;

            case MessageType.Rocker:
                MessageRocker r = args.Msg as MessageRocker;
                if (Rockers.TryGetValue(r.Hid, out IRocker rocker))
                {
                    rocker.SetMessage(args.Msg);
                }

                //Debug.Log($"Rocker  Hid:{r.Hid} KeyCode:{r.KeyCode} State:{r.State}");

                singlePool.Cache(r.KeyCode, r.State);
                multiPool.Cache(r.KeyCode, r.State);
                break;

            case MessageType.Gyro:
                MessageGyro g = args.Msg as MessageGyro;
                if (Gyros.TryGetValue(g.Hid, out IGyro gyro))
                {
                    gyro.SetMessage(args.Msg);
                }
                break;
            }
        }
 void Input_GamepadDisconnected(object sender, GamepadEventArgs e)
 {
     if (e.Player.HasValue)
     {
         if (controller.ControllingPlayer.HasValue &&
             controller.ControllingPlayer.Value == e.Player.Value)
         {
             controller.ControllingPlayer = null;
         }
     }
 }
Beispiel #4
0
        private void StateChanged(object sender, XboxControllerStateChangedEventArgs e)
        {
            _gamepadState = Map(e.CurrentInputState);

            var args = new GamepadEventArgs {
                Gamepad = _gamepadState
            };

            // Fire event
            GamepadStateChanged?.Invoke(this, args);
            ProcessButtonsChangeEvents(_gamepadState, _previousState);

            _previousState = _gamepadState;
        }
        private void OnButtonsChanged(object sender, GamepadEventArgs e)
        {
            if (e.Buttons.Count > 0)
            {
                GamepadDeviveName = string.Format(@"{0}", e.DeviceName);

                var sb = new StringBuilder();
                e.Buttons.ForEach(btn => sb.AppendFormat("{0} ", btn));
                PressedButtons = sb.ToString();
            }
            else
            {
                GamepadDeviveName = "";
                PressedButtons    = "";
            }
        }
 private void GamepadService_GamepadStateChanged(object sender, GamepadEventArgs e)
 {
     _mainViewModel.GamepadViewModel.GamepadModel = e.GamepadModel;
 }
Beispiel #7
0
 private void OnDisconnect(object sender, GamepadEventArgs evt)
 {
     Text = "Device " + evt.DeviceID + " is not connected.";
 }
Beispiel #8
0
 public virtual void OnLeftStickMove(GamepadEventArgs e)
 {
     LeftStickMove(this, e);
 }
Beispiel #9
0
 public virtual void OnRightStickMove(GamepadEventArgs e)
 {
     RightStickMove(this, e);
 }
Beispiel #10
0
 public virtual void OnTriggerUp(GamepadEventArgs e)
 {
     TriggerUp(this, e);
 }
Beispiel #11
0
 public virtual void OnButtonPressed(GamepadEventArgs e)
 {
     ButtonPressed(this, e);
 }
Beispiel #12
0
 public virtual void OnButtonUp(GamepadEventArgs e)
 {
     ButtonUp(this, e);
 }
 private void OnDisconnect(object sender, GamepadEventArgs evt)
 {
     Connected = false;
     OnDisconnected?.Invoke(this, evt);
 }
 private void OnConnect(object sender, GamepadEventArgs evt)
 {
     Connected = true;
     DeviceId  = evt.DeviceID;
     OnConnected?.Invoke(this, evt);
 }