Game Development Community

OptionsDlg -- Keybindings

by David Higgins · in Torque Game Builder · 04/29/2007 (10:57 pm) · 7 replies

Ok, I'm not trying to be negative here or anything ... but ... what is the functional use of the Keybindings in OptionsDlg ... a recent forum post brought this to my attention, and ... after digging through tons of stuff, we eventually figured out how simple it is to get things into the OptionsDlg ...

HOWEVER ... Here's the catch ... and this one's kind of a crappy catch ...

OptionsDlg keybindings only work with the ActionMap::bind() ... and the KeysTextList in the OptionsDlg GUI is hard-coded to only work with ActionMap::bind() ... so ... if your game requires Press/Release callbacks (ala bindCmd) ... your at a complete loss for using a premade GUI ... and, if you don't have the Pro license, your completely out of luck for figuring out how to do it cause the code for OptionsDlg isn't included (or does the non-Pro still have the source included in /common ... unsure of this?)


Anyhow ... I attempted to do a real quick revamp of this and failed miserably ... I went about it completely wrong ... so, obviously, it didn't work as an end result ...

Granted, due to the way it's all written ... it's fairly easy to completely rewrite it to work with only the bindCmd ... or to switch between bind and bindCmd ... depending on whether you pass a 'release' action ....

Another problem I have is that all the key-bindings are loaded before any objects are loaded ... and the keybindings package that is activated to add keys to the list with an override for ActionMap::bind ... is deactivated right after the 'SetupKeybinds' is called in main.cs ...

This seems a fairly non-functional way to do things ... and makes me wonder ... how many people didn't add key-mapping options to there game just because they either a) couldn't figure out how to ... or b) didn't want to bother redoing the logic they used (which was taught to them in the tutorials)


So ... yeah ... the point in this post is to more or less get some input on this from both GG and the community as a whole ... I'm curious what everyone's thoughts on this are ... am I looking at this the wrong way? am I looking at it the right way?

Yes, I realize this is a fairly tedious thing to bark about, but hey ... I've gotta bark about something, right?



#1
05/01/2007 (10:16 am)
I am going to have to go with option A on why I did not use it from the start.
I could not figure out how to use the optionsDlg menu so I built my own less savory version what I used in Retrotank.
I did not even notice the action map issue until David mentioned it, most likely I would not have for a while because at this point in work on Retrotank I do only need action, not press and release controls.
It would be nice to have better documentation and that made a little more user friendly :-)
#2
07/17/2007 (10:52 pm)
It would be simpler to have a command that listen to whatever keyboard or joypad button is pressed (with exceptions for axis) and return the value (with a callback) once a key is pressed, so we could do whatever we want with it and write our own keybind menu.
#3
07/21/2007 (10:51 pm)
For those who might be interested, I found a way to have user Input and remap controls without using OptionsDlg.

Here's the starter code, it will pop up a dialog asking to press a key :

The gui :
//--- OBJECT WRITE BEGIN ---
%guiContent = new GuiControl(controlremap) {
   profile = "GuiDefaultProfile";
   horizSizing = "right";
   vertSizing = "bottom";
   position = "0 0";
   extent = "640 480";
   minExtent = "8 8";
   visible = "1";
   helpTag = "0";

   new GuiControl(controlDlg) {
      profile = "GuiWindowProfile";
      horizSizing = "relative";
      vertSizing = "relative";
      position = "213 213";
      extent = "243 64";
      minExtent = "8 8";
      visible = "1";
      helpTag = "0";

      new GuiTextCtrl(controlText) {
         profile = "GuiTextProfile";
         horizSizing = "center";
         vertSizing = "center";
         position = "2 21";
         extent = "243 20";
         minExtent = "8 8";
         visible = "1";
         helpTag = "0";
         text = "Press button for action";
         maxLength = "255";
      };
      new GuiInputCtrl(controlInput) {
         profile = "GuiInputCtrlProfile";
         horizSizing = "relative";
         vertSizing = "relative";
         position = "0 0";
         extent = "243 64";
         minExtent = "8 8";
         visible = "1";
         helpTag = "0";
      };
   };
};
//--- OBJECT WRITE END ---

And the script :
function controlInput::onInputEvent(%this, %device, %action)
{
    if ((%device $= "") || (%action $= ""))
    return;
	Canvas.popDialog(controlremap);
	
	echo(%device SPC %action);
}

To use it, you'll just have to call the gui like this canvas.pushdialog(controlremap), and whatever key pressed will be echoed. It's up to you to replace the echo by a binding, and to make your own menu option to use it.
#4
07/27/2007 (6:39 pm)
Hmm i tried Benjamin gruer idea , But none of my key is echoed
I've tried

function controlInput::onInputEvent(%this, %device, %action)
{ echo("hahahahahaha");
if ((%device $= "") || (%action $= ""))
return;
Canvas.popDialog(controlremap);

echo(%device SPC %action);
}
But none of "hahahha" text echoed either i click mouse or press any key on keyboard

And also my mouse click won't work again
. I don't know why?
Or did i miss something
#5
07/28/2007 (5:17 pm)
Did you exec the gui before calling canvas.pushdialog(controlremap) ?
#6
07/29/2007 (4:37 pm)
Yes
the Press button for action is appeared
right after i canvas.pushdialog(controlremap)

But there is something strange I couldn't find guiinputcontrol on my
selection list when i try to create GUI.
so I just put down your script on a newly created gui file

My TGB version is 1.3 Indie license.can my version access this GUIInputcontrol
#7
07/29/2007 (7:25 pm)
I don't know, since I'm working only under 1.5 now. Seems to be it, you'll have to dig in the 1.3 common directory to find the equivalent function in keybinding.cs and remap.gui.