findkeysforcommand questions

Discuss CSQC related programming.
Post Reply
Nahuel
Posts: 495
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

findkeysforcommand questions

Post by Nahuel »

hey forum :) i have a question for you about findkeysforcommand. I don't understand how this works. in the defs of dp you can read:

Code: Select all

string(string command, float bindmap) findkeysforcommand = #610;
I suppose string command refers to commands that the engine uses, such as "+attack","impulse 2" or any other command.
What I don't understand is what bindmap means.

I have a couple of questions, since I'm trying to program a "custom controls menu" in a menu.dat. For example, I would like to know which key corresponds to "+attack", whats the easiest way for code to know (in string form) which key I am using for that command?
i did try with findkeysforcommand function, with for example +forward command (and using a 0 for bindmap float), but instead a "understable" (for me) string, i did get a various numbers separated for spaces. something like '119' '-1' '-1' '-1'
What this mean? I did search in keycodes.qc (darkplaces) but i didnt find any key for "119", i guess the -1 means "empty" and each command can be seted with 4 keys. BU i am not sure.
if I'm right 119 is refered to "w" but, where i can find that information? its possible to convert that "119" float in the string "w", even using different keyboards ?

Aniway; Once I know what the "+attack" key is. I wish I could change that command, this would be done with a cmd under circumstances declared in m_keyup. I can write exceptions for each different button there.

for example:

"bind a +attack"

but in m_keyup i have

Code: Select all

void(float key, float ascii) m_keyup =
So i have a float, instead a string , so must i use "keynumtostring(key)"?
what means the ascii part?

Thanks for your help :)
hi, I am nahuel, I love quake and qc.
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: findkeysforcommand questions

Post by Spike »

forum ate my post by forgetting that I was signed in.
https://sourceforge.net/p/fteqw/code/HE ... em_bind.qc
figure out what got eaten yourself.
toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: findkeysforcommand questions

Post by toneddu2000 »

usually I use impulses for that.
declare
float myimpulses;
then, n CSQC_Input_Frame()
you can do something like

Code: Select all

if(input_impulse){
		myimpulses= input_impulse;
		switch(myimpulses){
			case 100:
				//dothis
			break;
         case 120:
				//dothat
			break;
			default:
			break;
		}
	}
and then you can add the "bind command" via localcmd() at the pression of the button.
In CSQC_InputFrame you can handle single keys in both state (pressed and released). Every key has a number.
European keyboard (I don't know if U.S keyboard has different mapping system) starts with 97 for letter A and ends at 122 for letter Z, so B is 98, C is 99,D is 100..and so on

So you can do "if player pressed D key use D for bind whatever"
Meadow Fun!! - my first commercial game, made with FTEQW game engine
Post Reply