Game Development Community

Keyboard Event capturing

by Bryce Bangerter · in Torque Game Builder · 06/27/2006 (2:33 pm) · 2 replies

I posted this question in general originally, but after reading the forum descriptions a bit more closely it seemed I might be better served reposting here.

I'm trying to setup a way in my menu screens for a player to configure the game controls if they do not like the default ones I provide. Now in my gui I could create an action map that links every key on the keyboard to a function call to map that key to a specified game action. But is there an easier/more elegant way to intercept keyboard events and then figure out what key was pressed/released.

#1
06/27/2006 (7:03 pm)
Take a look at the files:

common/gameScripts/options.cs
common/gameScripts/keybindings.cs
common/gui/options.gui

I belive these are the files that handle the keybinding options TGB displays (Edit->Preferences->Keybinding tab)

Using an editor like Torison, you can step though the code to see what it being done.

HTH
#2
06/28/2006 (6:03 pm)
I added
new GuiInputCtrl(RemapGameInput) {
      profile = "GuiInputCtrlProfile";
      horizSizing = "relative";
      vertSizing = "relative";
      position = "0 0";
      extent = "8 8";
      minExtent = "8 8";
      visible = "1";
      helpTag = "0";
to my gui file. Then I added

function RemapGameInput::onInputEvent (%this, %device, %action)
{
      echo ("Do stuff");
}

Every time I press a key my onInputEvent is successfully called. The problem is everytime I click a mouse button it is also called, so the buttons on my gui are not being activated. How can I let mouse events fall through to the default event handler?