public TkKeyboardState(OpenTK.Input.KeyboardState tkState) { if (tkState.IsAnyKeyDown) { Keys = all_keys.Where(tkState.IsKeyDown); } }
private void handleState(object sender, KeyboardKeyEventArgs e) { var state = e.Keyboard; if (state.Equals(lastState)) { return; } lastState = state; PendingStates.Enqueue(new InputState { Keyboard = new TkKeyboardState(state) }); FrameStatistics.Increment(StatisticsCounterType.KeyEvents); }
public TkKeyboardState(OpenTK.Input.KeyboardState tkState) { List <Key> keys = new List <Key>(); if (tkState.IsAnyKeyDown) { foreach (Key k in Enum.GetValues(typeof(Key))) { if (tkState.IsKeyDown(k)) { keys.Add(k); } } } Keys = keys; }
public override bool Initialize(GameHost host) { host.InputThread.Scheduler.Add(scheduled = new ScheduledDelegate(delegate { var state = host.IsActive ? OpenTK.Input.Keyboard.GetState() : new OpenTK.Input.KeyboardState(); if (state.Equals(lastState)) { return; } lastState = state; PendingStates.Enqueue(new InputState { Keyboard = new TkKeyboardState(state) }); FrameStatistics.Increment(StatisticsCounterType.KeyEvents); }, 0, 0)); return(true); }