Game Development Community

gui input maps

by Dan Pascal · in Torque X 2D · 07/16/2009 (3:34 pm) · 7 replies

Is the GUI input map the same as the PlayerManager.Instance.GetPlayer.InputMap()?

I bind a button to a command in my mainplay gui class to spawn the player:

InputMap.BindCommand(gamepadId, (int)XGamePadDevice.GamePadObjects.A, null, SpawnPlayer);

That works, but when the player spawns and goes thru it's MovementComponent onRegister input setup, it keeps the "A" button attached to the SpawnPlayer command. Although all the other binding work.

?

#1
07/17/2009 (2:27 pm)
I'm not sure if this is related, but have you tried Scott Zarnke's fix for rebinding controls on a player control object? It sounds like it might be a similar problem where you lose movement controls but the buttons still work.

Solution for setting Player ControlObject to same object

Brian
#2
07/17/2009 (5:32 pm)
In your MovementComponent's OnRegister method, are you then binding A to anything? If not, and you simply want to have A no longer bound to anything, see this thread I just wrote.
#3
07/17/2009 (6:25 pm)
I just tried the the solution Brian mentioned, didn't work
(thanks though)

@Scott: I am binding it to somethingelse in the MovementComponent, shooting.

#4
07/17/2009 (6:39 pm)
I would have thought that binding a particular combination of deviceNumber, objectId, and modifier to something new would get rid of the old binding...

So, when you bind to shooting, that's not working at all, but the SpawnPlayer is still called instead, is that correct?

Would you please post your code in the MovementComponent OnRegister method?
#5
07/17/2009 (7:03 pm)
that is correct

static public void _SetupInputMap(TorqueObject player, int playerIndex, String gamePad, String keyboard)
        {
            // Set player as the controllable object
            PlayerManager.Instance.GetPlayer(playerIndex).ControlObject = player;

            // Get input map for this player and configure it
            inputMap = PlayerManager.Instance.GetPlayer(playerIndex).InputMap;

            int gamepadId = InputManager.Instance.FindDevice(gamePad);
            if (gamepadId >= 0)
            {
                inputMap.BindMove(gamepadId, (int)XGamePadDevice.GamePadObjects.LeftThumbX, MoveMapTypes.StickAnalogHorizontal, 0);
                inputMap.BindMove(gamepadId, (int)XGamePadDevice.GamePadObjects.LeftThumbY, MoveMapTypes.StickAnalogVertical, 0);
                inputMap.BindMove(gamepadId, (int)XGamePadDevice.GamePadObjects.RightThumbX, MoveMapTypes.StickAnalogHorizontal, 1);
                inputMap.BindMove(gamepadId, (int)XGamePadDevice.GamePadObjects.RightThumbY, MoveMapTypes.StickAnalogVertical, 1);

                inputMap.BindAction(gamepadId, (int)XGamePadDevice.GamePadObjects.Back, MovementComponent._OnBackButton);
               
                inputMap.BindMove(gamepadId, (int)XGamePadDevice.GamePadObjects.A, MoveMapTypes.Button, 0);
                inputMap.BindMove(gamepadId, (int)XGamePadDevice.GamePadObjects.RightShoulder, MoveMapTypes.Button, 1);
                
                PlayerManager.Instance.GetPlayer(playerIndex).InputMap.BindCommand(gamepadId, (int)XGamePadDevice.GamePadObjects.B, null, Game.pauseScene);
                PlayerManager.Instance.GetPlayer(playerIndex).InputMap.BindCommand(gamepadId, (int)XGamePadDevice.GamePadObjects.Y, null, Game.unpauseScene);
            }
#6
07/17/2009 (7:29 pm)
Check the return value of BindMove for A in your _SetupInputMap method above. It should return true if it Set the new Input Node.

What class is your mainplay gui? Nevermind, all GUI's derive from GUIControl which has an InputMap inside it.

Also, now that I think about it, the InputMap stored in each GUI object is separate from the ones stored in the PlayerManager. So while you are mapping the A button to the button move for the MovementComponent, there is still an input map in the main play gui that also has A mapped to the Spawn method, so that one would need to be unbound, or use a different control for shooting. Why the shooting one doesn't happen, I'm not sure. You are handling it in the ProcessTick method of MovementComponent, right?
#7
07/18/2009 (8:09 am)
jumping to this thread
http://www.garagegames.com/community/forums/viewthread/97325