public override void Update(GameTime gameTime) { base.Update(gameTime); KeyboardState kState = Keyboard.GetState(); if (kState.IsKeyPressed(_oldKeyState, Keys.Q)) { if (OnPlayingFinished != null) { OnPlayingFinished(this, new EventArgs()); } } else if (kState.IsKeyPressed(_oldKeyState, Keys.OemSemicolon)) { Score = Score - 100; if (Score < 0) { Score = 0; } SetNextStage(); } else if (kState.IsKeyPressed(_oldKeyState, Keys.R)) { OnHeroLifeFired(this, new EventArgs()); } _oldKeyState = kState; }
protected override void Update(GameTime gameTime) { base.Update(gameTime); // update keyboard state keyboardState = keyboardManager.GetState(); // if Esc is pressed - quit program if (keyboardState.IsKeyPressed(Keys.Escape)) { Exit(); return; } // numer keys (NOT numpad ones) have name like D0, D1, etc... // associate available modes each with its key for (int i = 0; i < availableModes.Count; i++) { var key = (Keys)Enum.Parse(typeof(Keys), "D" + i); if (keyboardState.IsKeyPressed(key)) { ApplyMode(availableModes[i]); return; } } }
/// <summary> Handle <paramref name="keyboard"/> input for a camera </summary> /// <param name="keyboard">The <see cref="KeyboardState"/> to read the input from</param> public void HandleKeyboardInput(KeyboardState keyboard) { if (keyboard.IsKeyPressed(Keys.F1)) { Camera.Config.DebugInfo = !Camera.Config.DebugInfo; } if (keyboard.IsKeyPressed(Keys.F2)) { Camera.Config.DrawBVHTraversal = !Camera.Config.DrawBVHTraversal; } if (keyboard.IsKeyDown(Keys.Space)) { Camera.Move(Camera.Up); } if (keyboard.IsKeyDown(Keys.LeftShift)) { Camera.Move(Camera.Down); } if (keyboard.IsKeyDown(Keys.W)) { Camera.Move(Camera.Front); } if (keyboard.IsKeyDown(Keys.S)) { Camera.Move(Camera.Back); } if (keyboard.IsKeyDown(Keys.A)) { Camera.Move(Camera.Left); } if (keyboard.IsKeyDown(Keys.D)) { Camera.Move(Camera.Right); } if (keyboard.IsKeyPressed(Keys.KeyPadAdd)) { Camera.FOV *= 1.1f; } if (keyboard.IsKeyPressed(Keys.KeyPadSubtract)) { Camera.FOV *= 0.9f; } if (keyboard.IsKeyDown(Keys.Left)) { Camera.Turn(Camera.Left); } if (keyboard.IsKeyDown(Keys.Right)) { Camera.Turn(Camera.Right); } if (keyboard.IsKeyDown(Keys.Up)) { Camera.Turn(Camera.Up); } if (keyboard.IsKeyDown(Keys.Down)) { Camera.Turn(Camera.Down); } }
public override void Update() { turbo = !turbo; state.Update(); DATA = 0; if (state.IsKeyPressed(A)) { DATA |= 1; } if (state.IsKeyPressed(B)) { DATA |= 2; } if (state.IsKeyPressed(TurboA) && turbo) { DATA |= 1; } if (state.IsKeyPressed(TurboB) && turbo) { DATA |= 2; } if (state.IsKeyPressed(Select)) { DATA |= 4; } if (state.IsKeyPressed(Start)) { DATA |= 8; } if (state.IsKeyPressed(Up)) { DATA |= 0x10; } if (state.IsKeyPressed(Down)) { DATA |= 0x20; } if (state.IsKeyPressed(Left)) { DATA |= 0x40; } if (state.IsKeyPressed(Right)) { DATA |= 0x80; } }
public override async void Update(GameTime gameTime) { KeyboardState keyboardState = keyboard.GetState(); // Switch visibility if (keyboardState.IsKeyPressed(Keys.T)) { Visible = !Visible; } if (Visible) { if (keyboardState.IsKeyPressed(Keys.Down)) { if (keyboardState.IsKeyDown(Keys.Shift)) { for (int i = 0; i < 10; i++) { Down(); } } else { Down(); } } if (keyboardState.IsKeyPressed(Keys.Up)) { if (keyboardState.IsKeyDown(Keys.Shift)) { for (int i = 0; i < 10; i++) { Up(); } } else { Up(); } } if (keyboardState.IsKeyPressed(Keys.Left)) { Previous(); } if (keyboardState.IsKeyPressed(Keys.Right)) { Next(); } } base.Update(gameTime); }
protected override void Update(GameTime gameTime) { base.Update(gameTime); // Get the current state of the keyboard keyboardState = keyboard.GetState(); // Get the current state of the mouse mouseState = mouse.GetState(); IsMouseVisible = true; // Check if Escape key has been pressed to exit if (keyboardState.IsKeyPressed(Keys.Escape)) { Exit(); } // Count total execution time in seconds time = (float)gameTime.TotalGameTime.TotalSeconds; // Game screens update switch (gameScreen) { case GameScreen.LOGO: logoScreen.Update(keyboardState); break; case GameScreen.TITLE: titleScreen.Update(keyboardState); break; case GameScreen.GAMEPLAY: gameplayScreen.Update(keyboardState); break; case GameScreen.ENDING: endingScreen.Update(keyboardState); break; default: break; } }
public void Update(KeyboardState keyboardState) { framesCounter++; if (keyboardState.IsKeyPressed(Keys.Enter)) { BaseGame.gameScreen = GameScreen.TITLE; } if (framesCounter <= 120) { logoColor.A++; } if ((framesCounter > 120) && (framesCounter <= 240)) { logoColor.A = logoColor.A; } if ((framesCounter > 240) && (framesCounter <= 360)) { logoColor.A--; } if (framesCounter > 360) { BaseGame.gameScreen = GameScreen.TITLE; } }
public void OnUpdate(double deltaTime) { AXProfiler.Capture(() => { if (KeyboardState.IsKeyPressed(AXKey.J)) { _cameraPosition.X -= _cameraSpeed * (float)deltaTime; } if (KeyboardState.IsKeyPressed(AXKey.L)) { _cameraPosition.X += _cameraSpeed * (float)deltaTime; } if (KeyboardState.IsKeyPressed(AXKey.I)) { _cameraPosition.Y += _cameraSpeed * (float)deltaTime; } if (KeyboardState.IsKeyPressed(AXKey.K)) { _cameraPosition.Y -= _cameraSpeed * (float)deltaTime; } Camera.Position = _cameraPosition; }); }
protected override void Update(GameTime gameTime) { keyboardState = keyboardManager.GetState(); mouseState = mouseManager.GetState(); // Handle base.Update base.Update(gameTime); //Update game objects lightsource.Update(gameTime); model.Update(gameTime, lightsource.getLightDirection()); water.Update(gameTime, lightsource.getLightDirection()); camera.Update(gameTime); //Enable/disable cursor control of the camera if (keyboardState.IsKeyPressed(Keys.Space)) { if (enableCursor == true) { enableCursor = false; } else { enableCursor = true; } } //Exit the game if (keyboardState.IsKeyDown(Keys.Escape)) { this.Exit(); this.Dispose(); } }
private void UpdateGameStart(KeyboardState kState, GameTime gameTime) { if (kState.IsKeyPressed(_oldKeyState, Keys.Enter, Keys.Space, Keys.D0, Keys.D1, Keys.D2, Keys.D3, Keys.D4, Keys.D5, Keys.D6, Keys.D7, Keys.D8, Keys.D9)) { _displayMode = DisplayModeEnum.Splash; string value = Encoding.UTF8.GetString(new[] { (byte)kState.GetPressedKeys()[0] }, 0, 1); int newRange; int range = int.TryParse(value, out newRange) ? newRange : Game.Range; if (OnPlayingStarted != null) { OnPlayingStarted(this, new PlayingStartedEventArgs { Range = range }); } return; } _splashInterval = _splashInterval - gameTime.ElapsedGameTime; if (_splashInterval.Ticks < 0) { _displayMode = DisplayModeEnum.Splash; } }
protected override void OnUpdateFrame(FrameEventArgs args) { if (KeyboardState.IsKeyPressed(OpenTK.Windowing.GraphicsLibraryFramework.Keys.Escape)) { this.Close(); return; } base.OnUpdateFrame(args); }
/// <summary> /// Update method /// </summary> /// <param name="gameTime"></param> protected override void Update(TimeSpan gameTime) { KeyboardState currentKeyboardState = this.input.KeyboardState; if (currentKeyboardState.IsConnected) { if (currentKeyboardState.IsKeyPressed(Keys.Q) && lastKeyboardState.IsKeyReleased(Keys.Q)) { this.ThrowProjectile(); } if (currentKeyboardState.IsKeyPressed(Keys.A)) { this.revoluteJoint2D.MotorSpeed = 1; } else if (currentKeyboardState.IsKeyPressed(Keys.D)) { this.revoluteJoint2D.MotorSpeed = -1; } else { this.revoluteJoint2D.MotorSpeed = 0; } if (currentKeyboardState.IsKeyPressed(Keys.W)) { this.Force += 10; } else if (currentKeyboardState.IsKeyPressed(Keys.S)) { this.Force -= 10; if (this.Force < 0) { this.Force = 0; } } this.lastKeyboardState = currentKeyboardState; } }
public static bool nonePressed(this KeyboardState state, List <Keys> keys) { foreach (Keys key in keys) { if (state.IsKeyPressed(key)) { return(false); } } return(true); }
public static bool GetBindKeyPressed(string bind) { List <bool> Keys = new List <bool>(); Keys Key; foreach (var key in _binds[bind]) { Keys.Add(KeyboardState.IsKeyPressed(key)); } return(!Keys.Contains(false)); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { KeyboardState state = Keyboard.GetState(); if (state.IsKeyPressed(_oldKeyState, Keys.F12)) { _graphics.ToggleFullScreen(); _graphics.ApplyChanges(); } else if (state.IsKeyPressed(_oldKeyState, Keys.F10)) { MapBank++; if (MapBank > Maps.Banks.Count - 1) { MapBank = 0; } OnRoomPlayingFinished(this, null); _room.Score = 0; } base.Update(gameTime); _oldKeyState = state; }
protected override void Update(GameTime gameTime) { base.Update(gameTime); // handle input var keyboardState = _keyboardManager.GetState(); if (_previousKeyboardState.IsKeyPressed(Keys.Escape)) { Exit(); } if (keyboardState.IsKeyPressed(Keys.T)) { _isBorderEnabled = !_isBorderEnabled; _residencyManager.SetBorderMode(_isBorderEnabled); _residencyManager.Reset(); } var time = (float)gameTime.ElapsedGameTime.TotalSeconds; if (keyboardState.IsKeyDown(Keys.A)) { _camera.Left(time); } if (keyboardState.IsKeyDown(Keys.D)) { _camera.Right(time); } if (keyboardState.IsKeyDown(Keys.W)) { _camera.Up(time); } if (keyboardState.IsKeyDown(Keys.S)) { _camera.Down(time); } if (keyboardState.IsKeyDown(Keys.Q)) { _camera.ZoomIn(time); } if (keyboardState.IsKeyDown(Keys.E)) { _camera.ZoomOut(time); } _previousKeyboardState = keyboardState; }
private void UpdateSplash(KeyboardState kState, GameTime gameTime) { if (kState.IsKeyPressed(_oldKeyState, Keys.Enter, Keys.Space, Keys.Escape, Keys.D0, Keys.D1, Keys.D2, Keys.D3, Keys.D4, Keys.D5, Keys.D6, Keys.D7)) { _displayMode = DisplayModeEnum.GameStart; _splashInterval = new TimeSpan(Game.GameSpeedScaleFactor * 40); } _splashInterval = _splashInterval - gameTime.ElapsedGameTime; if (_splashInterval.Ticks < 0) { Game.BackColor = (Game.BackColor == BackColorEnum.White ? BackColorEnum.Black : BackColorEnum.White); _splashInterval = new TimeSpan(Game.GameSpeedScaleFactor * 20); } }
/** * <summary> * Calculates the position for the mouse this frame * </summary> */ private void CalculateMousePosition() { Vector2 position = Vector2.Zero; Vector2 mouse = WaveServices.Input.MouseState.Position; cam.Unproject(ref mouse, out position); if (currentKeyboard.IsKeyPressed(Keys.A)) { Trace.WriteLine(cam.UsedVirtualScreen.BottomEdge); Trace.WriteLine(cam.UsedVirtualScreen.LeftEdge); Trace.WriteLine(cam.UsedVirtualScreen.RightEdge); Trace.WriteLine(cam.UsedVirtualScreen.TopEdge); Trace.WriteLine(mouse); Trace.WriteLine(position); } currentMousePosition = position; }
private void InternalGetJoyState() { //int numberOfKeys; //FIXME: This is SDL-centric for the time being KeyboardState state = new KeyboardState(true); joypad1_state = 0; if (state.IsKeyPressed(Key.Z)) { joypad1_state |= (byte)Button.ButtonA; } if (state.IsKeyPressed(Key.X)) { joypad1_state |= (byte)Button.ButtonB; } if (state.IsKeyPressed(Key.A)) { joypad1_state |= (byte)Button.ButtonSelect; } if (state.IsKeyPressed(Key.S)) { joypad1_state |= (byte)Button.ButtonStart; } if (state.IsKeyPressed(Key.UpArrow)) { joypad1_state |= (byte)Button.ButtonUp; } else if (state.IsKeyPressed(Key.DownArrow)) { joypad1_state |= (byte)Button.ButtonDown; } if (state.IsKeyPressed(Key.LeftArrow)) { joypad1_state |= (byte)Button.ButtonLeft; } else if (state.IsKeyPressed(Key.RightArrow)) { joypad1_state |= (byte)Button.ButtonRight; } }
private void UpdateVelocity(TimeSpan gameTime, KeyboardState keyboardState) { var velocity = Vector3.Zero; var multiplier = 2f; if (keyboardState.IsKeyPressed(Keys.W) || keyboardState.IsKeyPressed(Keys.Up)) { velocity += transform.WorldTransform.Forward; } if (keyboardState.IsKeyPressed(Keys.S) || keyboardState.IsKeyPressed(Keys.Down)) { velocity += transform.WorldTransform.Backward; } if (keyboardState.IsKeyPressed(Keys.A) || keyboardState.IsKeyPressed(Keys.Left)) { velocity += transform.WorldTransform.Left; } if (keyboardState.IsKeyPressed(Keys.D) || keyboardState.IsKeyPressed(Keys.Right)) { velocity += transform.WorldTransform.Right; } if (keyboardState.IsKeyPressed(Keys.Shift)) { multiplier = 2f; } if (velocity != Vector3.Zero) { this.currentVelocity = Vector3.SmoothStep(this.currentVelocity, this.maxVelocity, 0.2f); } velocity *= this.currentVelocity * multiplier; characterController.SetVelocity(velocity); }
public static bool KeyTouched(this KeyboardState keyboardState, ref KeyboardState lastKeyboardStatus, ref Keys key, ref TimeSpan gameTime, ref TimeSpan pressedTime) { var keyPressedInCurrentState = keyboardState.IsKeyPressed(key); var keyPressedInlastState = lastKeyboardStatus.IsKeyPressed(key); var keyTouched = false; if (!keyPressedInlastState && keyPressedInCurrentState) { pressedTime = TimeSpan.Zero; } else if (keyPressedInlastState && keyPressedInCurrentState) { pressedTime += gameTime; } else if (keyPressedInlastState && !keyPressedInCurrentState && pressedTime < KeyDetectionMaxTime) { keyTouched = true; } return(keyTouched); }
public void Update(KeyboardState keyState) { framesCounter++; /*if ((parpadeo == false) && (framesCounter >= 30)) * { * framesCounter = 0; * enterColor.A = 0; * parpadeo = !parpadeo; * } * if ((parpadeo == true) && (framesCounter >= 30)) * { * framesCounter = 0; * enterColor.A = 255; * parpadeo = !parpadeo; * }*/ if (keyState.IsKeyPressed(Keys.Enter)) { BaseGame.gameScreen = GameScreen.GAMEPLAY; } }
public override void Update(GameTime gameTime) { if (Visible) { KeyboardState kState = Keyboard.GetState(); if (kState.IsKeyPressed(_oldKeyboardStateState, Keys.Left, Keys.NumPad4)) { Direction = DirectionEnum.Left; } else if (kState.IsKeyPressed(_oldKeyboardStateState, Keys.Down, Keys.NumPad5)) { Direction = DirectionEnum.Down; } else if (kState.IsKeyPressed(_oldKeyboardStateState, Keys.Right, Keys.NumPad6)) { Direction = DirectionEnum.Right; } else if (kState.IsKeyPressed(_oldKeyboardStateState, Keys.Up, Keys.NumPad8)) { Direction = DirectionEnum.Up; } if (!_bullet.IsActive) { if (kState.IsKeyPressed(_oldKeyboardStateState, Keys.Z, Keys.NumPad7)) { _shootStage = ShootStageEnum.Preparation; _shootDirection = DirectionEnum.Left; } else if (kState.IsKeyPressed(_oldKeyboardStateState, Keys.X, Keys.NumPad9)) { _shootStage = ShootStageEnum.Preparation; _shootDirection = DirectionEnum.Right; } } _oldKeyboardStateState = kState; } else { Direction = DirectionEnum.None; } base.Update(gameTime); }
public static bool IsKeyPressed(Keys key) { return(state.IsKeyPressed(key)); }
public bool IsKeyPressed(Key key) { return(_nativeKeyboard.IsKeyPressed((Keys)key)); }
private bool KeyPressed(Keys key) { return(_keyboardState.IsKeyPressed(key)); }
/// <summary> /// Update method /// </summary> /// <param name="gameTime">game time</param> protected override void Update(TimeSpan gameTime) { this.input = WaveServices.Input; KeyboardState currentKeyboardState = this.input.KeyboardState; if (currentKeyboardState.IsConnected) { if (currentKeyboardState.IsKeyPressed(Keys.O) && this.lastKeyboardState.IsKeyReleased(Keys.O)) { this.RenderManager.DebugLines = !this.RenderManager.DebugLines; } this.lastKeyboardState = currentKeyboardState; } if (this.input.TouchPanelState.IsConnected) { this.touchState = this.input.TouchPanelState; if (this.touchState.Count > 0 && this.mouseJoint == null) { this.TouchPosition = this.touchState[0].Position; this.vsm.ToVirtualPosition(ref this.TouchPosition); foreach (Entity entity in this.Owner.Scene.EntityManager.FindAllByTag("Draggable")) { Collider2D collider = entity.FindComponent <Collider2D>(false); if (collider != null) { if (collider.Contain(TouchPosition)) { RigidBody2D rigidBody = entity.FindComponent <RigidBody2D>(); if (rigidBody != null) { if (rigidBody.PhysicBodyType == WaveEngine.Common.Physics2D.RigidBodyType2D.Dynamic) { this.ConnectedEntity = entity; //Create Joint this.mouseJoint = new MouseJoint2D() { Target = this.TouchPosition, }; this.ConnectedEntity.AddComponent(mouseJoint); break; } } } } } } if (this.touchState.Count == 0 && this.mouseJoint != null) { if (!this.ConnectedEntity.IsDisposed) { this.ConnectedEntity.RemoveComponent(this.mouseJoint); } this.mouseJoint = null; } if (this.mouseJoint != null) { this.TouchPosition = this.touchState[0].Position; this.vsm.ToVirtualPosition(ref this.TouchPosition); this.mouseJoint.Target = this.TouchPosition; } } }
void Update_Input() { keyboardState = keyboardManager.GetState(); mouseState = mouseManager.GetState(); // if Esc is pressed - quit program if (keyboardState.IsKeyPressed(Keys.Escape)) { Exit(); return; } if (keyboardState.IsKeyPressed(Keys.K)) { tiles[3].PlayDelegate(); } if (keyboardState.IsKeyPressed(Keys.J)) { tiles[3].StopDelegate(); } if (keyboardState.IsKeyPressed(Keys.O)) { tiles[4].PlayDelegate(); } if (keyboardState.IsKeyPressed(Keys.P)) { tiles[4].StopDelegate(); } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% int mouseWheelOffset = mouseState.WheelDelta - lastWheelDelta; if (mouseWheelOffset != 0) { int multiply = 10; if (keyboardState.IsKeyDown(Keys.Control)) { multiply = 1; } if (keyboardState.IsKeyDown(Keys.Shift)) { multiply = 100; } config.cameraControl.ExposureTime += multiply * mouseWheelOffset; } //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% // info tiles if (keyboardState.IsKeyPressed(Keys.F1)) { config.hud.helpMenu ^= true; hmd.EnableHSWDisplaySDKRender(true); hmd.DismissHSWDisplay(); // not functional } if (keyboardState.IsKeyPressed(Keys.F2)) { config.hud.toolStrip ^= true; } if (keyboardState.IsKeyPressed(Keys.F3)) { config.hud.timeStrip ^= true; } if (keyboardState.IsKeyPressed(Keys.F5)) { ra.angleType = e_valueType.wantedValue; } if (keyboardState.IsKeyPressed(Keys.F6)) { ra.angleType = e_valueType.sentValue; } if (keyboardState.IsKeyPressed(Keys.F7)) { ra.angleType = e_valueType.seenValue; } if (keyboardState.IsKeyPressed(Keys.F8)) { config.roboticArmPostureOnCameraCapture ^= true; } if (keyboardState.IsKeyPressed(Keys.M) && keyboardState.IsKeyDown(Keys.Control)) { //config.READ_dataFromMotors ^= true; // toggle config.player.ResetPositionAndBodyYaw(); config.WRITE_dataToMotors ^= true; } else if (keyboardState.IsKeyPressed(Keys.M) && keyboardState.IsKeyDown(Keys.Shift)) { //config.READ_dataFromMotors ^= true; // toggle config.READ_dataFromMotors ^= true; } else if (keyboardState.IsKeyPressed(Keys.M)) { config.motorSpeedControl ^= true; } if (keyboardState.IsKeyPressed(Keys.R) && keyboardState.IsKeyDown(Keys.Control)) { config.player.ResetPosition(); } else if (keyboardState.IsKeyPressed(Keys.R) && keyboardState.IsKeyDown(Keys.Shift)) { config.player.ResetBodyYaw(); } else if (keyboardState.IsKeyPressed(Keys.R)) { config.player.ResetPositionAndBodyYaw(); } if (keyboardState.IsKeyPressed(Keys.F)) { config.draw.RoboticArm ^= true; ra.draw = config.draw.RoboticArm; } if (keyboardState.IsKeyPressed(Keys.C) && keyboardState.IsKeyDown(Keys.Shift)) { config.ReadCameraStream ^= true; if (config.ReadCameraStream) { START_streaming(); } else { STOP_streaming(); } } if (keyboardState.IsKeyPressed(Keys.U)) { if (textureConversionAlgorithm == e_textureConversionAlgorithm.unsafeConversion_pointerForLoop) { // last textureConversionAlgorithm = 0; } else { textureConversionAlgorithm++; } } if (keyboardState.IsKeyPressed(Keys.D1) && keyboardState.IsKeyDown(Keys.Shift)) { config.player.PositionLock = e_positionLock.cameraSensor; } if (keyboardState.IsKeyPressed(Keys.D2) && keyboardState.IsKeyDown(Keys.Shift)) { config.player.PositionLock = e_positionLock.desk; } if (keyboardState.IsKeyPressed(Keys.D3) && keyboardState.IsKeyDown(Keys.Shift)) { config.player.PositionLock = e_positionLock.overDesk; } if (keyboardState.IsKeyPressed(Keys.Tab)) { config.player.PositionLockActive ^= true; } if (keyboardState.IsKeyPressed(Keys.D1)) { config.cameraArtificialDelay = false; lock (queuePixelData_locker) { que.Clear(); } } if (keyboardState.IsKeyPressed(Keys.D2)) { config.cameraArtificialDelay = true; lock (queuePixelData_locker) { que.Clear(); } config.cameraFrameQueueLength = config.cameraFrameQueueLengthList[0]; } if (keyboardState.IsKeyPressed(Keys.D3)) { config.cameraArtificialDelay = true; lock (queuePixelData_locker) { que.Clear(); } config.cameraFrameQueueLength = config.cameraFrameQueueLengthList[1]; } if (keyboardState.IsKeyPressed(Keys.D4)) { config.cameraArtificialDelay = true; lock (queuePixelData_locker) { que.Clear(); } config.cameraFrameQueueLength = config.cameraFrameQueueLengthList[2]; } if (keyboardState.IsKeyPressed(Keys.D5)) { config.cameraArtificialDelay = true; lock (queuePixelData_locker) { que.Clear(); } config.cameraFrameQueueLength = config.cameraFrameQueueLengthList[3]; } if (keyboardState.IsKeyPressed(Keys.D6)) { config.cameraArtificialDelay = true; lock (queuePixelData_locker) { que.Clear(); } config.cameraFrameQueueLength = config.cameraFrameQueueLengthList[4]; } if (keyboardState.IsKeyPressed(Keys.X)) { measurementStart = DateTime.Now; } HUD.AppendLine(string.Format( "W{0}|A{1}|S{2}", keyboardState.IsKeyDown(Keys.W), keyboardState.IsKeyDown(Keys.A), keyboardState.IsKeyDown(Keys.S) )); config.player.FrameTime = gameTime.ElapsedGameTime.Milliseconds; config.player.MoveForward(keyboardState.IsKeyDown(Keys.W)); config.player.MoveSideStep(keyboardState.IsKeyDown(Keys.A), false); config.player.MoveBackward(keyboardState.IsKeyDown(Keys.S)); config.player.MoveSideStep(keyboardState.IsKeyDown(Keys.D), true); config.player.MoveUpward(keyboardState.IsKeyDown(Keys.E)); config.player.MoveDownward(keyboardState.IsKeyDown(Keys.Q)); config.player.SetupSpeed(keyboardState.IsKeyDown(Keys.Shift), keyboardState.IsKeyDown(Keys.Control)); if (keyboardState.IsKeyPressed(Keys.J) && keyboardState.IsKeyDown(Keys.Control)) { config.draw.SkySurface ^= true; } List <Keys> keys = new List <Keys>(); keyboardState.GetDownKeys(keys); //foreach (var key in keys) // sb.AppendFormat("Key: {0}, Code: {1}\n", key, (int)key); // numer keys (NOT numpad ones) have name like D0, D1, etc... // associate available modes each with its key //for (int i = 0; i < availableModes.Count; i++) //{ // var key = (Keys)Enum.Parse(typeof(Keys), "D" + i); // if (keyboardState.IsKeyPressed(key)) // { // ApplyMode(availableModes[i]); // return; // } //} lastWheelDelta = mouseState.WheelDelta; }
public bool IsKeyPressed(KeyboardState keyboard, MouseState mouse) { return(keys.TrueForAll((key) => keyboard.IsKeyPressed(key)) && mouseEnum.TrueForAll(m => IsKeyPressed(mouse, m))); }
public bool IsKeyPressed(MKeys key) { return(_keyboardState.IsKeyPressed((Keys)key)); }