Xbox LIVE Indie Games
Sort Discussions: Previous Discussion Next Discussion
Page 1 of 1 (16 posts)

HOW TO avoid your game being failed because of the Guitar controller

Last post 12/4/2010 8:58 PM by PouncingKitten Games. 15 replies.
  • 10/14/2009 3:47 PM

    HOW TO avoid your game being failed because of the Guitar controller

    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




  • 10/14/2009 4:06 PM In reply to

    Re: HOW TO avoid your game being failed because of the Guitar controller

    It might be better to put this on the wiki.  Then push to have a link added to the evil checklist under the multiple controller support fail point.  That way programmers that are actively working through the evil checklist have all the fixes to the evil checklist in one place.
  • 10/14/2009 4:17 PM In reply to

    Re: HOW TO avoid your game being failed because of the Guitar controller

    This is only a problem in 2 situations I have seen:
    1. At the 'Press start' screen people check the triggers/thumbsticks as well as (start) and (A). SImple fix - just check (start) and (A)
    2. Instead of having a (press start) screen they poll ALL controllers during the game and the game relies on triggers/thumsticks. Simple fix - have a press start screen - thats why its in the best practises.

    Feel free to fail games as you find them..

    Also I tweaked the Evil checklist - it already had some words about guitar issues but I added a link to this thread.

  • 10/14/2009 4:18 PM In reply to

    Re: HOW TO avoid your game being failed because of the Guitar controller

    Unless of course you don't mind if someone is playing your game with the guitar ;)  Really if you're checking for an obvious button press like "A" or "Start" there's really no need for this. It's when you do things like check for ANY button press that this becomes an issue. I personally would just encourage developers to be more observant but not to exclude guitar controllers.
  • 10/14/2009 4:21 PM In reply to

    Re: HOW TO avoid your game being failed because of the Guitar controller

    Thanks for this information.  I've been trying to work around this issue, but am unable to test my code since I do not have access to a guitar controller.

    A couple questions:

    PinoEire:
    The Guitar controllers have a bad habit: they feed a continuous value to the Left ThumbStick and the Left Trigger.


    The MSDN  Button Mapping Between Different Controllers and the Xbox 360 Gamepad page says that the Left ThumbStick X-axis, Y-Axis, and button are not used by the guitar controller.  I took this to mean that they would return 0.0f or false.  Is this incorrect?  Do you see non-zero values from the Left ThumbStick X-axis and Y-axis?

    My current workaround is to screen thumbstick inputs from guitar, alternate guitar, and wheel devices in the Input Update method like this:

            public void Update(GameTime gameTime)  
            {  
                totalRealTime = gameTime.TotalRealTime;  
                repeatDelta =   
                    (float)(totalRealTime.TotalSeconds - repeatStart.TotalSeconds);  
     
                for (int i = 0; i < MaxInputs; i++)  
                {  
                    LastKeyboardStates[i] = CurrentKeyboardStates[i];  
                    LastGamePadStates[i] = CurrentGamePadStates[i];  
                    LastLeftStickDirections[i] = CurrentLeftStickDirections[i];  
                    LastRightStickDirections[i] = CurrentRightStickDirections[i];  
     
                    CurrentKeyboardStates[i] = Keyboard.GetState((PlayerIndex)i);  
                    CurrentGamePadStates[i] = GamePad.GetState((PlayerIndex)i);  
     
                    GamePadType padType =  
                        GamePad.GetCapabilities((PlayerIndex)i).GamePadType;  
                    if (padType != GamePadType.Wheel)  
                    {  
                        CurrentLeftStickDirections[i] =  
                            LeftThumbStickDirection((PlayerIndex)i);  
                    }  
                    if (padType != GamePadType.AlternateGuitar &&  
                        padType != GamePadType.Guitar &&  
                        padType != GamePadType.Wheel)  
                    {  
                        CurrentRightStickDirections[i] =  
                            RightThumbStickDirection((PlayerIndex)i);  
                    }  
     
                    // Keep track of whether a gamepad has ever been  
                    // connected, so we can detect if it is unplugged.  
                    if (CurrentGamePadStates[i].IsConnected)  
                    {  
                        GamePadWasConnected[i] = true;  
                    }  
                }  
            } 

    The idea is to allow use of the "well behaved" inputs from all controllers while blocking the problematic inputs from a few controller types.

    Do you think that this approach will work?
  • 10/14/2009 4:22 PM In reply to

    Re: HOW TO avoid your game being failed because of the Guitar controller

    Yes its the 'right' thumstick.... or is there a profiel way of flipping them for left handed folk?
  • 10/14/2009 4:23 PM In reply to

    Re: HOW TO avoid your game being failed because of the Guitar controller

    Steve Roe:
    The idea is to allow use of the "well behaved" inputs from all controllers while blocking the problematic inputs from a few controller types.

    Do you think that this approach will work?


    I wouldn't make it that complex... detect the controller by having a 'press start' screen that only looks for (start) and (A). Then from that point on only read that controller. If they are dumb enough to start your game with the guitar they deserve everything they get ;-)
  • 10/14/2009 4:29 PM In reply to

    Re: HOW TO avoid your game being failed because of the Guitar controller

    The ZMan:
    Steve Roe:
    The idea is to allow use of the "well behaved" inputs from all controllers while blocking the problematic inputs from a few controller types.

    Do you think that this approach will work?


    I wouldn't make it that complex... detect the controller by having a 'press start' screen that only looks for (start) and (A). Then from that point on only read that controller. If they are dumb enough to start your game with the guitar they deserve everything they get ;-)


    That's how most of the game modes work.  There is one "shared controller" game mode that allows multiple people to play with one or more controllers, so a group of people with one controller could play the game.  The easy way to implement that was to accept input from all controllers.  It seemed like a good idea at the time ...
  • 10/14/2009 4:43 PM In reply to

    Re: HOW TO avoid your game being failed because of the Guitar controller

    Steve Roe:
    The MSDN  Button Mapping Between Different Controllers and the Xbox 360 Gamepad page says that the Left ThumbStick X-axis, Y-Axis, and button are not used by the guitar controller.  I took this to mean that they would return 0.0f or false.  Is this incorrect?  Do you see non-zero values from the Left ThumbStick X-axis and Y-axis?
    Hi,

    I've mixed left and right, I'll edit the original post! I've checked the Guitars behaviour (using different models) using the Input Reporter sample. This is what is common to the models I tested (leaving the guitar in its default state, not using it):

    Thumbsticks.Right.X = -1
    Thumbsticks.Right.Y = 1
    Triggers.Left = 0.658

    Cheers,
    Pino
  • 12/2/2010 12:55 PM In reply to

    Re: HOW TO avoid your game being failed because of the Guitar controller

    sorry for bringing the thread back from the dead, but i have a question.

    You have a spashscreen and the user trys to play the game with the guitar, but the game is not playable, ie racing game and you can't accelerate!

    Is this a fail?
  • 12/2/2010 1:08 PM In reply to

    Re: HOW TO avoid your game being failed because of the Guitar controller

    If a players tries to start a game with a guitar controller and can't play the game - so be it. There is no requirement to support additional controller types in your game beyond the standard Xbox controller. Just make sure they can get back to a screen where they can choose a different controller.

    Guitar controllers are different than normal controllers because in their default untouched (no player input) state they provide input values. As long as these input values don't prevent the player from playing the game using normal controllers there is no reason to fail.
  • 12/4/2010 5:16 AM In reply to

    Re: HOW TO avoid your game being failed because of the Guitar controller

    How does continual input mess up any game?
  • 12/4/2010 5:02 PM In reply to

    Re: HOW TO avoid your game being failed because of the Guitar controller

    If, for example, you are doing a "lazy" check for the first controller to provide input, so that you can make it the active one, that would pick up an unused wired guitar controller.
  • 12/4/2010 8:14 PM In reply to

    Re: HOW TO avoid your game being failed because of the Guitar controller

    Is the input from the guitar thumbstick input, or more than this?

    EDIT: It's "Right ThumbStick and the Left Trigger" as the OP said, but is that all?
  • 12/4/2010 8:16 PM In reply to

    Re: HOW TO avoid your game being failed because of the Guitar controller

    Matthew Doucette:
    Is the input from the guitar thumbstick input, or more than this?

    EDIT: It's "Right ThumbStick and the Left Trigger" as the OP said, but is that all?


    I think thats right.
  • 12/4/2010 8:58 PM In reply to

    Re: HOW TO avoid your game being failed because of the Guitar controller

    I've seen some weird behavior from those touchpad-like buttons on the newer guitars too, though I don't remember what button(s) those were mapping to.
Page 1 of 1 (16 posts) Previous Discussion Next Discussion