Is this too many keyboard options?
by Kevin Epps · in Torque Game Builder · 03/07/2007 (7:03 am) · 12 replies
I just finished a function that fills a dropdown menu with the keys I think people would actually use to configure their keyboard or joystick when playing a game. Do you think this is too many, too little, or about right?
function GuiPopUpMenuCtrl::fillUp(%this, %type)
{
if(strcmp(%type,"keyboard") == 0)
{
%this.clear();
%this.add("A", 0, 0);
%this.add("B", 1, 0);
%this.add("C", 2, 0);
%this.add("D", 3, 0);
%this.add("E", 4, 0);
%this.add("F", 5, 0);
%this.add("G", 6, 0);
%this.add("H", 7, 0);
%this.add("I", 8, 0);
%this.add("J", 9, 0);
%this.add("K", 10, 0);
%this.add("L", 11, 0);
%this.add("M", 12, 0);
%this.add("N", 13, 0);
%this.add("O", 14, 0);
%this.add("P", 15, 0);
%this.add("Q", 16, 0);
%this.add("R", 17, 0);
%this.add("S", 18, 0);
%this.add("T", 19, 0);
%this.add("U", 20, 0);
%this.add("V", 21, 0);
%this.add("W", 22, 0);
%this.add("X", 23, 0);
%this.add("Y", 24, 0);
%this.add("Z", 25, 0);
%this.add("BACKSPACE", 26, 0);
%this.add("TAB", 27, 0);
%this.add("RETURN", 28, 0);
%this.add("ENTER", 29, 0);
%this.add("LSHIFT", 30, 0);
%this.add("RSHIFT", 31, 0);
%this.add("LCTRL", 32, 0);
%this.add("RCTRL", 33, 0);
%this.add("LALT", 34, 0);
%this.add("RALT", 35, 0);
%this.add("PAUSE", 36, 0);
%this.add("ESCAPE", 37, 0);
%this.add("PAGEDOWN", 38, 0);
%this.add("PAGEUP", 39, 0);
%this.add("END", 40, 0);
%this.add("HOME", 41, 0);
%this.add("UP", 42, 0);
%this.add("DOWN", 43, 0);
%this.add("LEFT", 44, 0);
%this.add("RIGHT", 45, 0);
%this.add("1", 46, 0);
%this.add("2", 47, 0);
%this.add("3", 48, 0);
%this.add("4", 49, 0);
%this.add("5", 50, 0);
%this.add("6", 51, 0);
%this.add("7", 52, 0);
%this.add("8", 53, 0);
%this.add("9", 54, 0);
%this.add("0", 55, 0);
%this.add("NUMPAD1", 56, 0);
%this.add("NUMPAD2", 57, 0);
%this.add("NUMPAD3", 58, 0);
%this.add("NUMPAD4", 59, 0);
%this.add("NUMPAD5", 60, 0);
%this.add("NUMPAD6", 61, 0);
%this.add("NUMPAD7", 62, 0);
%this.add("NUMPAD8", 63, 0);
%this.add("NUMPAD9", 64, 0);
%this.add("NUMPAD0", 65, 0);
%this.add("NUMPADMULT", 66, 0);
%this.add("NUMPADADD", 67, 0);
%this.add("NUMPADSEP", 68, 0);
%this.add("NUMPADMINUS", 69, 0);
%this.add("NUMPADDECIMAL", 70, 0);
%this.add("NUMPADDIVIDE", 71, 0);
%this.add("F1", 72, 0);
%this.add("F2", 73, 0);
%this.add("F3", 74, 0);
%this.add("F4", 75, 0);
%this.add("F5", 76, 0);
%this.add("F6", 77, 0);
%this.add("F7", 78, 0);
%this.add("F8", 79, 0);
%this.add("F9", 80, 0);
%this.add("F10", 81, 0);
%this.add("F11", 82, 0);
%this.add("F12", 83, 0);
%this.add("F13", 84, 0);
%this.add("F14", 85, 0);
%this.add("F15", 86, 0);
%this.add("F16", 87, 0);
%this.add("F17", 88, 0);
%this.add("F18", 89, 0);
%this.add("F19", 90, 0);
%this.add("F20", 91, 0);
%this.add("F21", 92, 0);
%this.add("F22", 93, 0);
%this.add("F23", 94, 0);
%this.add("F24", 95, 0);
}About the author
#2
03/07/2007 (7:37 am)
Wow! too many for me, but if that works well people will have lots of options ;)
#3
03/07/2007 (7:39 am)
Yeah, it works when I run it. Yeah it seems like way too much to me as well, but I just know there are people out there that use some off the wall key that no one else would even THINK of using. There's alway that one...
#4
Maybe you should configure and standar "configuration" and give the option to make changes...
03/07/2007 (8:33 am)
Those rebels!Maybe you should configure and standar "configuration" and give the option to make changes...
#5
03/07/2007 (8:36 am)
:) Yeah, I'm going to have a config.cs files as well. It's no problem with me. Some people like to edit things through a GUI, and it may not matter to other people. Either way, both of those avenues are covered. :) Thanks, Isaac!
#6
03/07/2007 (8:41 am)
You're welcomed.
#7
03/07/2007 (8:47 am)
@Kevin -- if your going to offer 'complete configuration' just make sure you cover all the possible keys and functions ... and your set -- looks like you've got your bases covered ...
#8
03/13/2007 (3:00 pm)
Wow, that is going to be a big popup. Another alternative is to make a key config ActionMap and let them press the key they want to bind something to.
#9
03/13/2007 (4:20 pm)
@Matthew: I was trying to do something like that at first, but I could find anything to "getKeyPressed", or something to that affect. Do you have any idea of how to pursue that?
#10
Then you can just push that ActionMap when they select to configure the key and receive the key input... Now with certain things you won't be able to do bindCmd but must do bind, such as xaxis, yaxis, etc.
03/13/2007 (4:29 pm)
There is something along the lines of what I suggest in another thread... I haven't tested this code:new ActionMap(keyConfigMap);
%keyList = "A B C D E F G H I J";
for(%i=0;%i<getWordCount(%keyList);%i++)
{
keyCOnfigMap.bindCmd(keyboard, getWord(%keyList, %i), "onKeyDown(" @ getWord(%keyList, %i)" @ ");", "onKeyUp(" @ getWord(%keyList, %i)" @ ");");
}
function onKeyDown(%key)
{
}
function onKeyUp(%key)
{
}Then you can just push that ActionMap when they select to configure the key and receive the key input... Now with certain things you won't be able to do bindCmd but must do bind, such as xaxis, yaxis, etc.
#11
03/13/2007 (5:31 pm)
Oh ok, thanks for that, Matt.
#12
Just a thought...
If you decided to do it this way you would have to be very careful about how you assigned things to the array: possibly handling collisions and making sure that you cleared out indeces that were no longer in use.
03/13/2007 (9:25 pm)
If you did it the way Matt suggested, you could have an array of function calls indexed by the letter you press to call that function. Then in your onKeyDown and onKeyUp methods you could just do something like:function onKeyDown(%key)
{
eval($keyDown[%key]);
}
function onKeyUp(%key)
{
eval($keyUp[%key]);
}Just a thought...
If you decided to do it this way you would have to be very careful about how you assigned things to the array: possibly handling collisions and making sure that you cleared out indeces that were no longer in use.
Torque Owner Kevin Epps
else if(strcmp(%type,"joystick/gamepad") == 0) { %this.clear(); %this.add("BUTTON0", 0, 0); %this.add("BUTTON1", 1, 0); %this.add("BUTTON2", 2, 0); %this.add("BUTTON3", 3, 0); %this.add("BUTTON4", 4, 0); %this.add("BUTTON5", 5, 0); %this.add("BUTTON6", 6, 0); %this.add("BUTTON7", 7, 0); %this.add("BUTTON8", 8, 0); %this.add("BUTTON9", 9, 0); %this.add("BUTTON10", 10, 0); %this.add("BUTTON11", 11, 0); %this.add("BUTTON12", 12, 0); %this.add("BUTTON13", 13, 0); %this.add("BUTTON14", 14, 0); %this.add("BUTTON15", 15, 0); %this.add("BUTTON16", 16, 0); %this.add("BUTTON17", 17, 0); %this.add("BUTTON18", 18, 0); %this.add("BUTTON19", 19, 0); %this.add("BUTTON20", 20, 0); %this.add("BUTTON21", 21, 0); %this.add("BUTTON22", 22, 0); %this.add("BUTTON23", 23, 0); %this.add("BUTTON24", 24, 0); %this.add("BUTTON25", 25, 0); %this.add("BUTTON26", 26, 0); %this.add("BUTTON27", 27, 0); %this.add("BUTTON28", 28, 0); %this.add("BUTTON29", 29, 0); %this.add("BUTTON30", 30, 0); %this.add("BUTTON31", 31, 0); %this.add("UPOV", 32, 0); %this.add("DPOV", 33, 0); %this.add("LPOV", 34, 0); %this.add("RPOV", 35, 0); } %this.setFirstSelected(); }