Game Development Community

Capturing user input to set keybinding?

by Jon Mitchell · in Torque Game Builder · 03/06/2007 (12:37 pm) · 10 replies

I have been searching for a tutorial or a resource on how to capture user input that would be used for setting custom user key bindings. I have been limiting my self to results with TGB and I have not been very successful,
does anyone knows if a tutorial or resource exists for allowing users to set their own key bindings?
Getting keyboard keys would not be that hard, simply have a person enter the desired key for a given function and save it to a prefs file, but grabbing input form gamepads is a bit more of a challange I think.


thank you! :-)

-Jon

#1
03/06/2007 (1:49 pm)
@Jon, there is no 'easy' way to do it ... there's a few ideas you could try ... but they all involve a lot of code ...

How interested in this are you? :)
#2
03/06/2007 (3:29 pm)
I am fairly interested in how it is done, but it is not such of a must have item for me, setting an option to use keyboard or game pad then manually bind the game pad controls and use text inputs for keyboard binding is the plan I had in mind.
If there is not a resource that has gone over it yet, I am not so sure I would be the best person to try and build/work through it. Heck I just finally just got the hang of pickRadius :-p
#3
03/06/2007 (3:45 pm)
@Jon, I asked because I was wondering whether or not going over it with you would be a waste of time or not ... I'd have to work through some concepts on it myself before having anything mildly useful, but it sounds like something that would be fairly trivial to use once it's been written ...


Basically, you'd have to create a function that all your listened for inputs called -- such as "function userInput(%input) { }" ... and %input would be of type "a", "b", "pov1", "pov2", etc, etc ... thats a fairly simplified concept ... and then your userInput() function would then simple perform whatever had to be performed depending on the input ...

so if the user had WASD and the Gamepad's D-Pad mapped to movement ... if "W" or "D-Pad Up" were sent, it would call $player.moveUp(); or something ...

It would require a decent 'easy to use' GUI to perform all the custom mapping, and could easily store all the settings in the prefs.cs ...
#4
03/06/2007 (3:46 pm)
Isn't this already in the starter.fps example in TGE?
#5
03/06/2007 (3:48 pm)
@Matt, as were in the TGB Forums, it could be fairly assumed neither of us has the starter.fps from TGE ...

If this functionality is completely covered in starter.fps for both keyboard AND gamepad, then please, do share with us...
#6
03/06/2007 (3:51 pm)
I understand that, but the TGE demo does have that functionality. I'd recommend downloading it and giving it a look.
#7
03/06/2007 (6:24 pm)
I do happen to have TGE, but I never did much with it, I found it a little overwhelming and decided to start out working with TGB instead. I will indeed take a peek at it, I do wonder though I have read both that code is interchangeable between TGB and TGE and also it is not, I am wondering how something like this would translate over.
#8
03/14/2007 (7:09 pm)
Hum... TGB Editor has keybinding, so maybe if we try to look that way we could find out how to reuse it for game purpose.
#9
03/15/2007 (10:20 am)
Look at keybindings.cs in common... the use of GuiInputCtrl is very helpful.
#10
03/18/2007 (6:31 pm)
Also the 2D adventure kit uses keybinding same as the TGB editor, Looking at how they did it is one of the many things I want to get done but am trying to stay focused on my current tasks or I will never get anything done :-p