本文整理汇总了C#中KeyboardState类的典型用法代码示例。如果您正苦于以下问题:C# KeyboardState类的具体用法?C# KeyboardState怎么用?C# KeyboardState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
KeyboardState类属于命名空间,在下文中一共展示了KeyboardState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
protected override void Update(TimeSpan gameTime)
{
input = WaveServices.Input;
if (input.KeyboardState.IsConnected)
{
keyboardState = input.KeyboardState;
if (keyboardState.W == ButtonState.Pressed)
{
MoveCamera(ref forward);
}
if (keyboardState.S == ButtonState.Pressed)
{
MoveCamera(ref back);
}
if (keyboardState.A == ButtonState.Pressed)
{
MoveCamera(ref left);
}
if (keyboardState.D == ButtonState.Pressed)
{
MoveCamera(ref right);
}
}
var rotationMatrix = (Matrix.CreateRotationX(MathHelper.ToRadians(45.0f)) * Matrix.CreateRotationY(MathHelper.ToRadians(30.0f)));
Vector3 transformedReference = Vector3.Transform(Vector3.Down, rotationMatrix);
Vector3 cameraLookat = Camera.Position + transformedReference;
var width = WaveServices.Platform.ScreenWidth / 24;
var height = WaveServices.Platform.ScreenHeight / 24;
//camera.Projection = Matrix.CreateOrthographic(width, height, camera.NearPlane, camera.FarPlane);
Camera.LookAt = cameraLookat;
}
示例2: Keyboard
public Keyboard()
{
var directInput = new DirectInput();
mKeyboard = new SlimDX.DirectInput.Keyboard(directInput);
mKeyboard.Acquire();
mState = new KeyboardState();
}
示例3: Move
//Methods from IMovable
public void Move(KeyboardState keyBoardState)
{
keyBoardState = Keyboard.GetState();
this.Velocity = Vector2.Zero;
if (keyBoardState.IsKeyDown(Keys.Up))
{
this.velocity.Y = -movementSpeed.Y;
}
if (keyBoardState.IsKeyDown(Keys.Left))
{
this.velocity.X = -movementSpeed.X;
}
if (keyBoardState.IsKeyDown(Keys.Down))
{
this.velocity.Y = movementSpeed.Y;
}
if (keyBoardState.IsKeyDown(Keys.Right))
{
this.velocity.X = movementSpeed.X;
}
this.Position += this.velocity;
}
示例4: Update
/// <summary>
/// Update Method
/// </summary>
/// <param name="gameTime"></param>
protected override void Update(TimeSpan gameTime)
{
this.input = WaveServices.Input;
// if (this.input.KeyboardState.IsConnected)
{
this.keyboardState = this.input.KeyboardState;
if (revoluteJoint != null)
{
// A, D, S Keyboard Control (left, right, stop motor)
if (this.keyboardState.A == ButtonState.Pressed)
{
if (revoluteJoint.MotorSpeed + motorSpeed <= maxSpeed)
{
revoluteJoint.MotorSpeed += motorSpeed;
}
}
else if (this.keyboardState.D == ButtonState.Pressed)
{
if (revoluteJoint.MotorSpeed - motorSpeed >= -maxSpeed)
{
revoluteJoint.MotorSpeed -= motorSpeed;
}
}
else if (this.keyboardState.S == ButtonState.Pressed)
{
revoluteJoint.MotorSpeed = 0.0f;
}
}
}
}
示例5: Update
/// <summary>
/// Allows this instance to execute custom logic during its <c>Update</c>.
/// </summary>
/// <param name="gameTime">The game time.</param>
/// <remarks>
/// This method will not be executed if it are not <c>Active</c>.
/// </remarks>
protected override void Update(TimeSpan gameTime)
{
inputService = WaveServices.Input;
if (inputService.KeyboardState.IsConnected)
{
// Key F1
if (inputService.KeyboardState.F1 == ButtonState.Pressed &&
beforeKeyboardState.F1 != ButtonState.Pressed)
{
this.diagnostics = !this.diagnostics;
WaveServices.ScreenContextManager.SetDiagnosticsActive(this.diagnostics);
}
// Key F3
if (inputService.KeyboardState.F3 == ButtonState.Pressed &&
beforeKeyboardState.F3 != ButtonState.Pressed)
{
this.debugLines = !this.debugLines;
this.Scene.RenderManager.DebugLines = this.debugLines;
}
}
beforeKeyboardState = inputService.KeyboardState;
}
示例6: HandleInput
public void HandleInput(MouseState mouseState, KeyboardState keyboardState)
{
KeyboardState = keyboardState;
if (MouseOverRenderArea && mouseState.LeftButton == ButtonState.Pressed)
{
if (!MouseDragging)
{
MouseDragging = true;
MousePreviousPosition = new Vector2(mouseState.X, mouseState.Y);
}
var mouseNewCoords = new Vector2(mouseState.X, mouseState.Y);
MouseDelta.X = mouseNewCoords.X - MousePreviousPosition.X;
MouseDelta.Y = mouseNewCoords.Y - MousePreviousPosition.Y;
MousePreviousPosition = mouseNewCoords;
}
if (!MouseOverRenderArea || mouseState.LeftButton == ButtonState.Released)
{
MouseDragging = false;
}
}
示例7: KeyboardInputProcessor
public KeyboardInputProcessor()
{
_previousKeyboardState = new KeyboardState();
_currentKeyboardState = new KeyboardState();
KeyDictionary = new KeyDictionary();
}
示例8: Update
public void Update(KeyboardState keyboardState)
{
_previousKeyboardState = _currentKeyboardState;
_currentKeyboardState = keyboardState;
KeyDictionary.Update(keyboardState);
}
示例9: Poll
/// <summary>
/// Check input device without check Floor Height
/// </summary>
public void Poll()
{
KeyState = KeyBoardDevice.GetCurrentKeyboardState();
KeyBoardJOBs();
MState = MouseDevice.CurrentMouseState;
MouseJOBs();
}
示例10: KeyboardMapBuilder
internal KeyboardMapBuilder(IVirtualKeyboard virtualKeyboard)
{
_virtualKeyboard = virtualKeyboard;
_keyboard = _virtualKeyboard.KeyboardState;
_lookedForOem1ModifierVirtualKey = _keyboard.Oem1ModifierVirtualKey.HasValue;
_lookedForOem2ModifierVirtualKey = _keyboard.Oem2ModifierVirtualKey.HasValue;
_possibleModifierVirtualKey = new Lazy<List<uint>>(GetPossibleVirtualKeyModifiers);
}
示例11: Poll
/// <summary>
/// Check input device with check Floor Height
/// </summary>
/// <param name="vFloor"></param>
public void Poll(ref Microsoft.DirectX.Direct3D.CustomVertex.PositionTextured[] vFloor)
{
_vFloor = vFloor;
KeyState = KeyBoardDevice.GetCurrentKeyboardState();
KeyBoardJOBs();
MState = MouseDevice.CurrentMouseState;
MouseJOBs();
}
示例12: Keyboard
internal Keyboard(DKeyboard keyboard)
{
System.Diagnostics.Debug.Assert(keyboard != null);
_dKeyboard = keyboard;
_inputState = KeyboardInput.CreateEmpty();
_lastPressedKeys = new List<Key>();
(_timer = new GameTimer()).Start();
_currentDirectInputState = new KeyboardState();
}
示例13: InputKeyBoard_KeyEvent
void InputKeyBoard_KeyEvent(KeyboardState keyNewState, KeyboardState keyOldState)
{
if (keyNewState.IsKeyDown(Keys.Escape) && keyOldState.IsKeyUp(Keys.Escape)) game.Exit();
if (keyNewState.IsKeyDown(Keys.Up) && keyOldState.IsKeyUp(Keys.Up)) game.Window.Title = "Up";
if (keyNewState.IsKeyDown(Keys.Down) && keyOldState.IsKeyUp(Keys.Down)) game.Window.Title = "Down";
if (keyNewState.IsKeyDown(Keys.Left) && keyOldState.IsKeyUp(Keys.Left)) game.Window.Title = "Left";
if (keyNewState.IsKeyDown(Keys.Right) && keyOldState.IsKeyUp(Keys.Right)) game.Window.Title = "Right";
}
示例14: Update
protected override void Update(TimeSpan gameTime)
{
this.input = WaveServices.Input;
if (this.input.KeyboardState.IsConnected)
{
this.keyboardState = this.input.KeyboardState;
RigidBody2D rigidBody = Owner.FindComponent<RigidBody2D>();
if (rigidBody != null)
{
// W, A, S, D applies Directional Linear Impulses
Vector2 result = Vector2.Zero;
if (keyboardState.A == ButtonState.Pressed)
{
result += leftDirection;
}
if (keyboardState.D == ButtonState.Pressed)
{
result -= leftDirection;
}
if (keyboardState.W == ButtonState.Pressed)
{
result += topDirection;
}
if (keyboardState.S == ButtonState.Pressed)
{
result -= topDirection;
}
// Apply Linear Impulse
if (result != Vector2.Zero)
{
rigidBody.ApplyLinearImpulse(result);
}
// Left and Right arrow applies angular impulse
if (keyboardState.Left == ButtonState.Pressed)
{
rigidBody.ApplyAngularImpulse(-angularImpulse);
}
else if (keyboardState.Right == ButtonState.Pressed)
{
rigidBody.ApplyAngularImpulse(angularImpulse);
}
// J and K applies Torque
if (keyboardState.J == ButtonState.Pressed)
{
rigidBody.ApplyTorque(torque);
}
else if (keyboardState.K == ButtonState.Pressed)
{
rigidBody.ApplyTorque(-torque);
}
}
}
}
示例15: InputSystem
public InputSystem()
{
CurrentKeyboardState = new KeyboardState();
PreviousKeyboardState = new KeyboardState();
CurrentGamepadState = new GamePadState();
PreviousGamepadState = new GamePadState();
CurrentMouseState = new MouseState();
PreviousMouseState = new MouseState();
}