Game Development Community

Find current key binds C++?

by Tim Hutcheson · in Torque Game Engine · 06/15/2005 (12:37 pm) · 2 replies

Is there a simple way to discover the current key bindings from a C++ method?

I want to populate an array of key and associated console method strings, like {'w',"moveforward"},... at runtime to be sure that the running scripts are using same console methods that I assume. Otherwise there is the possibllity that 'w' key might be bound to "acclerate" of something else, for example

#1
06/15/2005 (12:59 pm)
Looking through the dOxygen stuff online, I found a good starting place for ya:

www.garagegames.com/docs/tge/engine/classActionMap.php#a2

void ActionMap::dumpActionMap ( const char * fileName, const bool append ) const

So you could parse the file to build your array, or you could make a similar ActionMap::dumpToConsoleArrayThingy() function.
#2
06/15/2005 (1:41 pm)
Thanks for the headsup Mark. I executed the following code just before I need the bindings and indeed it has spit them to the console. Thanks.

SimSet* pActionMapSet = Sim::getActiveActionMapSet();
   AssertFatal(pActionMapSet && pActionMapSet->size() != 0,
      "error, no ActiveMapSet or no global action map...");

   for (SimSet::iterator itr = pActionMapSet->end() - 1;
      itr > pActionMapSet->begin(); itr--) {
         ActionMap* pMap = static_cast<ActionMap*>(*itr);
         pMap->dumpActionMap(NULL, false);
      }