I'd to fail so many good games because of this... so let's see if I can help understanding and solving the problem.
First of all, a little background info. The Guitar controllers have a bad habit: they feed a continuous value to the Right ThumbStick and the Left Trigger. This characteristic causes your game to behave in a very strange way or to be not responsive.
Since Rock Band and Guitar Hero those controllers are widespread and people have them always plugged in so we cannot ignore this issue: it’s not simply because of the Evil Checklist, it’s mostly because you’ll lose a lot of conversions for your potential customer will think that your game is broken!
Let’s assume you have the usual class members:
| private GamePadState[] lastGamePadState = new GamePadState[4]; |
| private GamePadState[] currentGamePadState = new GamePadState[4]; |
Now all we need is to add this simple method to our input manager:
| public static bool IsAcceptablePad(PlayerIndex index) |
| { |
| return (currentGamePadState[(int)index].IsConnected && |
| GamePad.GetCapabilities(index).GamePadType != GamePadType.Guitar && |
| GamePad.GetCapabilities(index).GamePadType != GamePadType.AlternateGuitar); |
| } |
So now all you have to do is to add the result of this method to your code when checking the state of a button, for instance:
| public static bool IsButtonPressedA(PlayerIndex? index, out PlayerIndex ActivePlayer) |
| { |
| PlayerIndex idx; |
| if (index.HasValue) |
| { |
| idx = (PlayerIndex)index.Value; |
| ActivePlayer = idx; |
| return (IsAcceptablePad(idx) && |
| inputManager.currentGamePadState[(int)idx].Buttons.A == ButtonState.Pressed && |
| inputManager.lastGamePadState[(int)idx].Buttons.A == ButtonState.Released); |
| } |
| else |
| { |
| return IsButtonPressedA(PlayerIndex.One, out ActivePlayer) || |
| IsButtonPressedA(PlayerIndex.Two, out ActivePlayer) || |
| IsButtonPressedA(PlayerIndex.Three, out ActivePlayer) || |
| IsButtonPressedA(PlayerIndex.Four, out ActivePlayer); |
| } |
| } |
That’s it folks!
Cheers,
Pino