2019-12-04 18:16:38 +00:00
|
|
|
|
using Microsoft.Xna.Framework.Input;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
2020-01-08 22:56:57 +00:00
|
|
|
|
namespace SemiColinGames {
|
2019-12-04 18:16:38 +00:00
|
|
|
|
public class KeyboardInput {
|
|
|
|
|
private KeyboardState oldState = Keyboard.GetState();
|
|
|
|
|
private List<Keys> newKeysDown = new List<Keys>();
|
|
|
|
|
|
|
|
|
|
public void Update() {
|
|
|
|
|
KeyboardState newState = Keyboard.GetState();
|
|
|
|
|
newKeysDown.Clear();
|
|
|
|
|
foreach (Keys k in newState.GetPressedKeys()) {
|
|
|
|
|
if (!oldState.IsKeyDown(k)) {
|
|
|
|
|
newKeysDown.Add(k);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
oldState = newState;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Keys> NewKeysDown() {
|
|
|
|
|
return newKeysDown;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|