Game Development Community

multiple actionMap binds to one function

by Cameron Altenhof-Long · in Torque Game Engine · 10/31/2001 (8:19 pm) · 33 replies

I discovered an anomaly today in the show.bind.cs script provided with the show mod. This script contains commands to bind the various number keys to a single function, each using the scale modifier to pass a different value. Unfortunately, only the last bind works.

In review of the code (sim/actionMap.cc) I found a comment near line 1016 indicating that a decision was made to only allow one bind per function. If possible, can you please shed light on why this decision was made, and what potential problems may occur if multiple binds are allowed per command.

The ability to bind the number keys to a common function passing scaled values seem quite useful, but there must have been a reason that this capability was disabled.

Thank you in advance for your time and feedback on this issue.

Cameron
Page «Previous 1 2
#1
11/01/2001 (12:38 am)
Actually it was implemented this way because we knew Tribes 2 was only going to support one key mapped to a particular function - in retrospect it would have made sense to only have this restriction in the Options GUI script - not make it hard-coded into action map. It's on our list of things to fix.
#2
11/01/2001 (6:47 am)
Thank you very much for the quick response. I was curious if this was a preference decision, or if there were unforeseen problems with having multiple keys map to the same function.
#3
11/01/2001 (9:58 am)
It is actually on my task list to remove that restriction from the code, so we're all on the same page here. :)

--RIck
#4
01/06/2005 (4:45 pm)
I know this is resurrecting an abandoned thread, which is frowned upon, but does anyone know if this has been done? I still see the comment about the single binding. What I want to do is to bind both the arrow keys, and the wasd keys to moving the camera around in my project.
#5
01/11/2005 (11:54 am)
Normally we do frown upon resurrections, but in this case I'm pretty glad you did. This is a good, cheap fix, and I've put it on my todo list to look at it more closely.
#6
01/11/2005 (12:00 pm)
Thanks for the response. I have worked around the issue in my project, by just creating four additional functions that do the same things as the first four, and binding those to the four arrow keys, but it does seem like an unnecessary limitation.
#7
05/08/2005 (11:20 am)
It seems this hasn't been fixed in 1.4 HEAD yet. I'm gonna look at it myself because it annoys me all to hell when switching between using the gamepad and mouse/keyboard.
#8
05/08/2005 (3:16 pm)
Do post your fixes! This would be an excellent candidate for inclusion into 1.4.
#9
05/09/2005 (1:25 am)
Ok... it's a stupid simple change that took me less than a 5 minutes to find, fix, and test. In ActionMap::processBind just comment this sucker out:

// We have decided to only allow one bind per console function, so
   // remove any existing nodes that are bound to the given function:
   /*
   if ( pFnName[0] )
   {
      U32 devMapIndex, nodeIndex;
      while ( findBoundNode( pFnName, devMapIndex, nodeIndex ) )
      {
         dFree( mDeviceMaps[devMapIndex]->nodeMap[nodeIndex].makeConsoleCommand );
         dFree( mDeviceMaps[devMapIndex]->nodeMap[nodeIndex].breakConsoleCommand );
         mDeviceMaps[devMapIndex]->nodeMap.erase( nodeIndex );
      }
   }
  */

Wow... that was easy. Now the harder part... fixing the control mapping GUI. In OptionsDlg.cs within the OptRemapInputCtrl::onInputEvent function make the following change:

%cmd  = $RemapCmd[%this.index];
   %name = $RemapName[%this.index];

   // START ADDED CODE!

   // First remove all other bindings of this command... one
   // binding per command is all that this gui is *designed* for.
   while ( true ) 
   {
      %oldBind = moveMap.getBinding( %cmd );

      if ( %oldBind $= "" )
         break;

      moveMap.unbind( getWord( %oldBind, 0 ), getWord( %oldBind, 1 ) );
   }

   // END ADDED CODE!

   // First check to see if the given action is already mapped:
	%prevMap = moveMap.getCommand( %device, %action );
   if ( %prevMap !$= %cmd )
   {

I guess it wasn't that hard, but it took me longer to come up with an adequate solution. The problem is that to support multiple bindings per command the options dialog needs to be redesigned in a way so that the user can see and change any of the X bindings on each command.

It would be super cool that after I contributed this that someone else would come in and do a redesign of the control mapping dialog to support lets say 3 binds per-command.
#10
06/02/2005 (10:22 pm)
Bump.... hope you saw my fix above Ben.
#11
10/26/2005 (1:21 pm)
Seems that this got lost in the shuffle as it's not in 1.4 RC2. I'll email Ben about it.
#12
10/28/2005 (12:10 pm)
Hi Tom,

Have you notified Ben or others that are working on 1.4?
#13
10/28/2005 (12:44 pm)
Well we've both bump'd this thread up and i've emailed Ben about it just the other day. I hesitate to push the issue too much because i know that he is extremely busy, but i will drop him another note when he is online again.
#14
11/30/2005 (1:32 pm)
Hey guys, does someone know, if this is fixed in the recently released 1.4 version?
#15
11/30/2005 (3:40 pm)
@Markus - I talked to Ben about it and i *think* we came to the conclusion that it was sort of a special case thing and would probably not make it into 1.4 final. Someone needs to check it.
#16
12/01/2005 (3:26 pm)
Thanks for the info Tom.

So this still needs to be a custom engine extension.
No problem.

-- Markus
#17
12/06/2005 (6:45 am)
Um, is this supposed to work in 1.4? Put it in but no change. If i try to bind two commands to the one key it cames up with the same warning (from memory... 'run is already bound to w, do you want to unbind this command?'). Anyone else get this working???
#18
12/12/2005 (2:25 pm)
Thanks for sticking with this 4+ year old bug Tom!
#19
01/12/2006 (11:26 pm)
Tim H., isn't this fix supposed to allow the opposite of what you describe - bind two (different keys / controller buttons / etc. to the same console command?
#20
01/25/2006 (1:55 am)
Wow, glad I found this thread! The fix works perfectly.
Page «Previous 1 2