From 0875cbd9285ed51c12948fc418c5baf6d6b23ea1 Mon Sep 17 00:00:00 2001 From: Stefanos A Date: Mon, 23 Dec 2013 01:50:13 +0100 Subject: [PATCH] Removed unnecessary IsButtonValid method --- Source/OpenTK/Input/GamePad.cs | 1 - Source/OpenTK/Input/GamePadState.cs | 22 +++------------------- 2 files changed, 3 insertions(+), 20 deletions(-) diff --git a/Source/OpenTK/Input/GamePad.cs b/Source/OpenTK/Input/GamePad.cs index 7a2fc066..a0a63f49 100644 --- a/Source/OpenTK/Input/GamePad.cs +++ b/Source/OpenTK/Input/GamePad.cs @@ -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 = diff --git a/Source/OpenTK/Input/GamePadState.cs b/Source/OpenTK/Input/GamePadState.cs index b0501f6c..ceec371f 100644 --- a/Source/OpenTK/Input/GamePadState.cs +++ b/Source/OpenTK/Input/GamePadState.cs @@ -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;