Beispiel #1
0
        public InputMapping()
        {
            if (instance_ == null)
            {
                KeyboardMap   = new Dictionary <InputManager.ActionTypes, Keys>();
                ControllerMap = new Dictionary <InputManager.ActionTypes, Buttons>();

                instance_ = this;
                InputMapping.SetDefaultMapping();
            }
        }
Beispiel #2
0
 public InputManager()
 {
     MouseInput   = new MouseInput();
     keyInput     = new KeyInput();
     mapInstance_ = new InputMapping();
     oldGState    = new Dictionary <PlayerIndex, GamePadState>();
     oldGState.Add(PlayerIndex.One, GamePad.GetState(0));
     oldGState.Add(PlayerIndex.Two, GamePad.GetState(1));
     oldGState.Add(PlayerIndex.Three, GamePad.GetState(2));
     oldGState.Add(PlayerIndex.Four, GamePad.GetState(3));
 }
Beispiel #3
0
        public static bool GetActionHeld(PlayerIndex player, ActionTypes action)
        {
            //if (GetActionDown(player, action))
            //    pressDic[player] |= action;
            //
            bool b = GamePad.GetState(player).IsButtonDown(InputMapping.GetMappedButton(action)) || (Keyboard.GetState().IsKeyDown(InputMapping.GetMappedKey(action)) && player == keyboardPlayerIndex);//(pressDic[player] & action) > 0;

            //
            //if (GetActionUp(player, action))
            //    pressDic[player] &= ~action;

            return(b);
        }
Beispiel #4
0
        public static bool GetActionUp(PlayerIndex player, ActionTypes action)
        {
            GamePadState  currentGState = GamePad.GetState(player);
            KeyboardState currentKState = Keyboard.GetState();

            bool n = currentGState.IsButtonUp(InputMapping.GetMappedButton(action)) ||
                     (currentKState.IsKeyUp(InputMapping.GetMappedKey(action)) && player == keyboardPlayerIndex);

            bool o = oldGState[player].IsButtonDown(InputMapping.GetMappedButton(action)) ||
                     (oldKState.IsKeyDown(InputMapping.GetMappedKey(action)) && player == keyboardPlayerIndex);



            oldGState[player] = currentGState;
            oldKState         = currentKState;
            return(n && o);
        }