Game Development Community

User Defined Keys

by Kevin James · in Torque Game Builder · 07/08/2010 (11:30 am) · 7 replies

Does anyone have a code example of how to allow the user to customize the key controls? I think it has something to do with GuiInputCtrl but documentation is hard to find.

About the author

Computer security, digital forensics, and platform jumper enthusiast. shells.myw3b.net/~syreal/


#1
07/09/2010 (6:41 am)
All you need to do is allow them to change the actionMap. I can't remember if TGB had a stock gui in place for this or not, I know TGE/A/3D does. I don't have it installed on this machine so I can't check.

Basically you just need to create a gui, take input from the user and bind that action to the key they specified.
#2
07/09/2010 (7:55 am)
@Scott,
I'm pretty sure it's not in TGB. Is it cool to post that section from TGE here? It seems like I'd be doing something wrong.
#3
07/09/2010 (8:03 am)
That would be great if someone could post an example. I did a lot of research and everything I found turned up the same answer as Scott, but with no example posted or the files they referenced are missing on my system.
#4
07/09/2010 (8:09 am)
@Patrick
Not a problem at all, post away. Its all the same code anyhow. I was hoping someone would post it since I couldn't, I'm in the airport right now.
#5
07/09/2010 (1:11 pm)
Here you go Kevin.

User clicks on the "Controls" button. setPane("Controls") is called and the OptRemapList is populated with the longlist of globals in the cs file.

User clicks on the OptRemapList and the soMap function is called.

Hope it helps you. Taken from the Stronghold example in TGEA.
#6
07/09/2010 (6:10 pm)
Thanks Patrick! I'll let you know how it goes.
#7
07/10/2010 (4:17 pm)
Well, this doesn't work at all. Thanks for trying. I spent 30 minutes commenting out a bunch of lines because apparently this thing was not made with TGB in mind. But the nails in the coffin are these errors:
game/gameScripts/optionsDlg.cs (478): Unable to find object: 'OptRemapText' attempting to call function 'setValue'
common/gameScripts/keybindings.cs (116): Unable to find object: '' attempting to call function 'getCommand'

It looks like these problems go much deeper than I can handle. That puts me back to my original question: How do I let the player assign his own keys? I must need a gui control that takes user input and returns the key that was pressed (left shift / right shift / enter / space)