Jump to content

Stop Left-Over Gamepad Input


Recommended Posts

Okeedokee, here's a funny little thing I found. If you exit a level whilst still having the gamepad stick in movement, the input locks and is remembered when you start a new mission the movement input restarts.

How to test in default Torque:

1) Have a gamepad (durrrr)

2) Load a mission and start moving.

3) Keep pressure on the thumbstick and exit using the Back button on gamepad, or Esc/select quit/yes with mouse (keep that thumbstick in move position)

4) At Main Menu release gamepad

5) Start new mission

6) See player start moving from leftover input


in scripts/client/default.bind.cs, add this new function (anywhere is fine)

//to stop movement being left over, after death or end of mission
function gamePadEnd()
   $mvYawLeftSpeed = 0;
   $mvYawRightSpeed = 0;
   $mvPitchUpSpeed = 0;
   $mvPitchDownSpeed = 0;
   $mvRightAction = 0;
   $mvLeftAction = 0;
   $mvForwardAction = 0;
   $mvBackwardAction = 0;


In scripts/server/gameCore.cs, add this at the bottom of onMissionEnded

function GameCore::onMissionEnded(%game)
   //echo (%game @"\c4 -> "@ %game.class @" -> GameCore::onMissionEnded");
   // Called by endMission(), right before the mission is destroyed
   // Normally the game should be ended first before the next
   // mission is loaded, this is here in case loadMission has been
   // called directly.  The mission will be ended if the server
   // is destroyed, so we only need to cleanup here.
   $Game::Running = false;
   $Game::Cycling = false;
//new from here
   echo("c\4End any left over gamepad input");
   gamePadEnd();//in default.bind.cs


You could probably also include a var to see if there is a gamepad connected or even cycle through gamepad inputs to see if any are still active, but this works fine.

Link to comment
Share on other sites

Not a bad workaround :)

Still, feels like a bug in the input in general if we consider that the other keybinds don't have a similar sticking effect. Something we'll have to double-check on.

I know with the SDL stuff the core input handling is different(and we're still reviewing the gamepad side) so that may well be a non-issue when we get it all wrapped up, but this is definitely useful for people still rocking the windows platform layer.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...