Removed unnecessary IsButtonValid method
authorStefanos A <stapostol@gmail.com>
Mon, 23 Dec 2013 00:50:13 +0000 (01:50 +0100)
committerthefiddler <stapostol@gmail.com>
Tue, 24 Dec 2013 16:18:02 +0000 (17:18 +0100)
Source/OpenTK/Input/GamePad.cs
Source/OpenTK/Input/GamePadState.cs

index 7a2fc0664e2b426c339f7e7f35f8c2a9475babf9..a0a63f49b6f8ea0cabdc654d63c20162686c19d0 100644 (file)
@@ -35,7 +35,6 @@ namespace OpenTK.Input
     public class GamePad
     {
         internal const int MaxAxisCount = 10;
-        internal const int MaxButtonCount = 16; // if this grows over 32 then GamePadState.buttons must be modified
         internal const int MaxDPadCount = 2;
 
         static readonly IGamePadDriver driver =
index b0501f6c5c12aad61c50947099156aaad56254a3..ceec371fe465eab890ffcbbcffb72093d763e204 100644 (file)
@@ -129,23 +129,13 @@ namespace OpenTK.Input
 
         internal void SetButton(Buttons button, bool pressed)
         {
-            if (IsButtonValid(button))
+            if (pressed)
             {
-                int index = (int)button;
-
-                Buttons mask = (Buttons)(1 << index);
-                if (pressed)
-                {
-                    buttons |= mask;
-                }
-                else
-                {
-                    buttons &= ~mask;
-                }
+                buttons |= button;
             }
             else
             {
-                throw new ArgumentOutOfRangeException("button");
+                buttons &= ~button;
             }
         }
 
@@ -164,12 +154,6 @@ namespace OpenTK.Input
             return index >= 0 && index < GamePad.MaxAxisCount;
         }
 
-        bool IsButtonValid(Buttons button)
-        {
-            int index = (int)button;
-            return index >= 0 && index < GamePad.MaxButtonCount;
-        }
-
         bool IsDPadValid(int index)
         {
             return index >= 0 && index < GamePad.MaxDPadCount;