Game Development Community

Keyboard mapping?

by Drethon · in Torque Game Engine · 09/16/2008 (3:04 pm) · 3 replies

I'm having a hard time reading through the new documentation (what happened to the old documentation, I thought that was easier to read...) and am starting to actually work with Torque.

I'm trying to figure out how keyboard(and mouse) mapping works. I found the mapping of the mouse button one in config.cs to the function mouseFire, in default.bind.cs is the function mouseFire that increments mvTriggerCount0. I can't find mvTriggerCount0 referenced anywhere else in Torque, either engine or script.

#1
09/16/2008 (11:45 pm)
Hello Drethon the mvTriggerCount is used by the MoveManager. You can take a look at gameConnectionMoves.cc it defines many movement variables:

void MoveManager::init()
{
   Con::addVariable("mvForwardAction", TypeF32, &mForwardAction);
   Con::addVariable("mvBackwardAction", TypeF32, &mBackwardAction);
   Con::addVariable("mvUpAction", TypeF32, &mUpAction);
   Con::addVariable("mvDownAction", TypeF32, &mDownAction);
   Con::addVariable("mvLeftAction", TypeF32, &mLeftAction);
   Con::addVariable("mvRightAction", TypeF32, &mRightAction);

   Con::addVariable("mvFreeLook", TypeBool, &mFreeLook);
   Con::addVariable("mvPitch", TypeF32, &mPitch);
   Con::addVariable("mvYaw", TypeF32, &mYaw);
   Con::addVariable("mvRoll", TypeF32, &mRoll);
   Con::addVariable("mvPitchUpSpeed", TypeF32, &mPitchUpSpeed);
   Con::addVariable("mvPitchDownSpeed", TypeF32, &mPitchDownSpeed);
   Con::addVariable("mvYawLeftSpeed", TypeF32, &mYawLeftSpeed);
   Con::addVariable("mvYawRightSpeed", TypeF32, &mYawRightSpeed);
   Con::addVariable("mvRollLeftSpeed", TypeF32, &mRollLeftSpeed);
   Con::addVariable("mvRollRightSpeed", TypeF32, &mRollRightSpeed);

   for(U32 i = 0; i < MaxTriggerKeys; i++)
   {
      char varName[256];
      dSprintf(varName, sizeof(varName), "mvTriggerCount%d", i);
      Con::addVariable(varName, TypeS32, &mTriggerCount[i]);
   }
}
#2
09/17/2008 (5:06 am)
So mvTriggerCount0 in the script is actually an array index that translates to mvTriggerCount[0] in the code?

Edit: Ah, wove my way through the documentation and found it is. Once step closer to understanding TGE, thanks!
#3
09/17/2008 (9:39 am)
Ok, I do have another question now. I'm trying to fully connect the mouse click and the fire events but I think I'm missing the connection between the call from shapeBase to the script function onTrigger and the stateTransitionOnTriggerDown that causes an item to fire.

Edit: Ah, I think I took the wrong path. It looks like the Player processTick calls updateMove which calls setImageTriggerState and eventually calls setImageState which then calls the script callback for the mounted image? Essentially it looks like the graphics update calls the actual fire command.