From ca30b85badc3d2b87dc6c814ade211ff0ee5e89b Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Wed, 20 Oct 2010 15:14:26 +0000 Subject: [PATCH] * Input/KeyboardState.cs: Fixed the amount of storage for keyboard keys (the code would allocate one less int than necessary when "number of keys % 32" falls between 1 and 15). Fixed the implementation of the Equals method to compare the two instances (instead of comparing this instance against itself). --- Source/OpenTK/Input/KeyboardState.cs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Source/OpenTK/Input/KeyboardState.cs b/Source/OpenTK/Input/KeyboardState.cs index 9d05a32a..955ef547 100644 --- a/Source/OpenTK/Input/KeyboardState.cs +++ b/Source/OpenTK/Input/KeyboardState.cs @@ -38,13 +38,10 @@ namespace OpenTK.Input { #region Fields - const int NumKeys = ((int)Key.LastKey + 16) / 32; + // Allocate enough ints to store all keyboard keys + const int NumInts = ((int)Key.LastKey + 31) / 32; // The following line triggers bogus CS0214 in gmcs 2.0.1, sigh... - unsafe fixed int Keys[NumKeys]; - - #endregion - - #region Constructors + unsafe fixed int Keys[NumInts]; #endregion @@ -126,9 +123,9 @@ namespace OpenTK.Input unsafe { fixed (int* k1 = Keys) - fixed (int* k2 = Keys) + fixed (int* k2 = other.Keys) { - for (int i = 0; equal && i < NumKeys; i++) + for (int i = 0; equal && i < NumInts; i++) equal &= *(k1 + i) == *(k2 + i); } }