float(float eventtype, float arg1, float arg2, float devid) CSQC_InputEvent =
{
if (eventtype == IE_KEYDOWN)
{
arg1 is the scancode, aka some KEY_FOO value used for binds etc. values will not change based upon shift+etc keys.
arg2 is the character codepoint that was pressed. typically ascii but may also be full unicode. use chr2str if you want the codepoint as a string. values WILL change according to modifiers, and will (hopefully) be different according to the user's active keymap.
it is not guarenteed that both args will be set at the same time (you might see two events for the same key). there is no IME integration, you may see bursts of codepoints in some situations (like combining/accent keys followed by a non-combinable char).
return (TRUE if you handled it, to prevent the engine from handling it instead);
}
if (eventtype == IE_KEYUP)
{
same as above.
autorepeat may mean multiple keydowns with a single keyup.
there's no guarentee about codepoints, don't depend on arg2 being anything but 0, consider them separate for maximum compat.
return FALSE; //you can return true, but that's generally bad form as it could prevent the engine from triggering release binds.
}
return FALSE; //unknown types of events should return false to signify disinterest/failure to handle them.
};
so for text entry, just strcat(theline, chr2str(arg2)) inside the keydown event when arg2 isn't 0. for backspace and delete you'll have to check the scancode instead, as these keys are non-printing. you can then drawstring them in your drawing code.
Example from menusys:
https://sourceforge.net/p/fteqw/code/HE ... dittext.qc (scan==arg1, char==arg2, down===eventtype).
I'm sure other people have their own examples...