public void RemovePressedKeyByIndex(int index) { PressedKeys.RemoveAt(index); }
static public void InputUpdater() { var running = true; var threadLimiterWatch = new Stopwatch(); threadLimiterWatch.Start(); while (running) { Thread.Yield(); if (threadLimiterWatch.ElapsedMilliseconds >= 1) { threadLimiterWatch.Restart(); try { KeyboardState = Keyboard.GetState(); MouseState = Mouse.GetState(); if (KeyboardState.GetPressedKeys().Count() > 0) { foreach (Keys key in KeyboardState.GetPressedKeys()) { if (!PressedKeys.Contains(key)) { PressActions.Enqueue(new KeyValuePair <double, Keys>(AudioManager.GetTime(), key)); PressedKeys.Add(key); if (key == Keys.CapsLock) { CapsLock = !CapsLock; Caps = CapsLock; } if (key == Keys.LeftShift || key == Keys.RightShift) { Caps = !CapsLock; } } } } for (int i = 0; i < PressedKeys.Count; i++) { Keys key = PressedKeys[i]; if (!KeyboardState.IsKeyDown(key)) { // Used if LN handling //keyboardReleases.Enqueue(new KeyValuePair<double, Keys>(time, key)); PressedKeys.RemoveAt(i); i--; if (key == Keys.LeftShift || key == Keys.RightShift) { Caps = CapsLock; } } } if (LastMouseClick.Value == 0 && MouseState.LeftButton == ButtonState.Pressed) { LastMouseClick.Key = MouseState; LastMouseClick.Value = 1; } else if (LastMouseClick.Value == 1 && MouseState.LeftButton == ButtonState.Released) { LastMouseClick.Key = MouseState; LastMouseClick.Value = 2; } } catch { } } } }