/// <summary> /// If the GamePad is being used, set it as the control device /// </summary> public void CheckActiveGamePad() { if (mode != Control_Mode.GamePad && gps.IsConnected) { //Get the newest gamepad state if (gps.PacketNumber != prevGps.PacketNumber) { //Set the control mode to gamepad mode = Control_Mode.GamePad; } } }
/// <summary> /// If the Keyboard is being used, set it as the control device /// </summary> public void CheckActiveKBM() { if (mode != Control_Mode.KBM) { //Check if the keyboard is being used if (kbs.GetPressedKeys().Length > 0) { //Set the control mode to keyboard+mouse mode = Control_Mode.KBM; } else if (ms.Position != prevMs.Position) { mode = Control_Mode.KBM; } } }
/// <summary> /// Singleton Constructor /// </summary> private ControlManager() { controls = new List <Control>(); alternateControls = new List <Control>(); mode = Control_Mode.KBM; //Current states gps = GamePad.GetState(PlayerIndex.One, GamePadDeadZone.Circular); kbs = Keyboard.GetState(); ms = Mouse.GetState(); //Previous states prevGps = GamePad.GetState(PlayerIndex.One, GamePadDeadZone.Circular); prevKbs = Keyboard.GetState(); prevMs = Mouse.GetState(); prevPrevMs = Mouse.GetState(); ReadControlFile(); }