findkeysforcommand questions

Discuss CSQC related programming.

Moderator: InsideQC Admins

findkeysforcommand questions

Postby Nahuel » Tue Mar 06, 2018 4:47 pm

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.
User avatar
Posts: 485
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: findkeysforcommand questions

Postby Spike » Tue Mar 06, 2018 6:32 pm

forum ate my post by forgetting that I was signed in. ... em_bind.qc
figure out what got eaten yourself.
Posts: 2881
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: findkeysforcommand questions

Postby toneddu2000 » Tue Mar 06, 2018 8:38 pm

usually I use impulses for that.
float myimpulses;
then, n CSQC_Input_Frame()
you can do something like
Code: Select all
      myimpulses= input_impulse;
         case 100:
         case 120:

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"
Posts: 1305
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Return to CSQC Programming

Who is online

Users browsing this forum: No registered users and 1 guest