private void ReadBufferedData() { BufferedDataCollection buffData = new BufferedDataCollection(); try { keyboard.Poll(); buffData = keyboard.GetBufferedData(); } catch (NotBufferedException ex) { Logging.Logger.AddWarning("Chyba pri vyberu bufferovanych dat " + ex.ToString()); return; } catch (InputException ex) { Logging.Logger.AddWarning("CHYBA V INPUTU!\n" + ex.ToString()); try { FreeDirectInput(); InitInputDevices(); buffData = keyboard.GetBufferedData(); } catch (InputException iex) { Logging.Logger.AddError("CHYBA V INPUTU!\n" + iex.ToString()); return; } } if (buffData == null || buffData.Count == 0) { return; } foreach (BufferedData data in buffData) { if ((data.Data & 0x80) != 0) //pressed keys { switch (data.Offset) { case (int)DXKey.W: this.bufferedActions.Add(Action.MoveForwardStart); break; case (int)DXKey.S: this.bufferedActions.Add(Action.MoveBackwardStart); break; case (int)DXKey.A: this.bufferedActions.Add(Action.MoveLeftStart); break; case (int)DXKey.D: this.bufferedActions.Add(Action.MoveRightStart); break; } } else //released keys { switch (data.Offset) { case 17: this.bufferedActions.Add(Action.MoveForwardStop); break; case 31: this.bufferedActions.Add(Action.MoveBackwardStop); break; case 30: this.bufferedActions.Add(Action.MoveLeftStop); break; case 32: this.bufferedActions.Add(Action.MoveRightStop); break; case 1: this.bufferedActions.Add(Action.Exit); break; case 0x16: this.bufferedActions.Add(Action.InvertMouse); break; case 0x29: this.bufferedActions.Add(Action.ShowConsole); break; case 0x1C: this.bufferedActions.Add(Action.ChangeFillMode); break; case 0x21: this.bufferedActions.Add(Action.Action3); break; } } } }