コード例 #1
0
 void Input_GamepadConnected(object sender, GamepadEventArgs e)
 {
     if (controller != null)
     {
         controller.ControllingPlayer = e.Player;
     }
 }
コード例 #2
0
ファイル: MultiInput.cs プロジェクト: zhoulk/ETBrainSecond
        /// <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;
            }
        }
コード例 #3
0
 void Input_GamepadDisconnected(object sender, GamepadEventArgs e)
 {
     if (e.Player.HasValue)
     {
         if (controller.ControllingPlayer.HasValue &&
             controller.ControllingPlayer.Value == e.Player.Value)
         {
             controller.ControllingPlayer = null;
         }
     }
 }
コード例 #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;
        }
コード例 #5
0
        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    = "";
            }
        }
コード例 #6
0
 private void GamepadService_GamepadStateChanged(object sender, GamepadEventArgs e)
 {
     _mainViewModel.GamepadViewModel.GamepadModel = e.GamepadModel;
 }
コード例 #7
0
ファイル: XBoxJoyStick.cs プロジェクト: duchiy/ARJoystick
 private void OnDisconnect(object sender, GamepadEventArgs evt)
 {
     Text = "Device " + evt.DeviceID + " is not connected.";
 }
コード例 #8
0
 public virtual void OnLeftStickMove(GamepadEventArgs e)
 {
     LeftStickMove(this, e);
 }
コード例 #9
0
 public virtual void OnRightStickMove(GamepadEventArgs e)
 {
     RightStickMove(this, e);
 }
コード例 #10
0
 public virtual void OnTriggerUp(GamepadEventArgs e)
 {
     TriggerUp(this, e);
 }
コード例 #11
0
 public virtual void OnButtonPressed(GamepadEventArgs e)
 {
     ButtonPressed(this, e);
 }
コード例 #12
0
 public virtual void OnButtonUp(GamepadEventArgs e)
 {
     ButtonUp(this, e);
 }
コード例 #13
0
 private void OnDisconnect(object sender, GamepadEventArgs evt)
 {
     Connected = false;
     OnDisconnected?.Invoke(this, evt);
 }
コード例 #14
0
 private void OnConnect(object sender, GamepadEventArgs evt)
 {
     Connected = true;
     DeviceId  = evt.DeviceID;
     OnConnected?.Invoke(this, evt);
 }