using System; using System.Collections.Generic; using System.Text; namespace OpenTK.Input { /// /// Encapsulates the state of a Keyboard device. /// public struct KeyboardState : IEquatable { #region Fields const int NumKeys = ((int)Key.LastKey + 16) / 32; unsafe fixed int Keys[NumKeys]; #endregion #region Constructors #endregion #region Public Members /// /// Gets a indicating whether this key is down. /// /// The to check. public bool IsKeyDown(Key key) { return ReadBit((int)key) != 0; } /// /// Gets a indicating whether this key is up. /// /// The to check. public bool IsKeyUp(Key key) { return ReadBit((int)key) == 0; } #endregion #region Internal Members internal int ReadBit(int offset) { return 0; //unsafe { return (Keys[(offset / 32)] & (1 << (offset % 32))); } } internal enum BitValue { Zero = 0, One = 1 } internal void WriteBit(int offset, BitValue bit) { // Todo: this is completely broken. //unsafe { Keys[offset / 32] = Keys[offset / 32] ^ (~(int)bit << (offset % 32)); } } #endregion #region IEquatable Members /// /// Compares two KeyboardState instances. /// /// The instance to compare two. /// True, if both instances are equal; false otherwise. public bool Equals(KeyboardState other) { throw new NotImplementedException(); } #endregion } }