Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

CSQC messagemode

| Inside3d Forums Forum Index -> QuakeC Programming

View previous topic :: View next topic
Author | Message
--- | ---
Urre Joined: 05 Nov 2004 Posts: 1073 Location: Sweden |

Posted: Wed Apr 16, 2008 1:32 pm Post subject: CSQC messagemode |

If I were to hijack the messagemode system and make my own using CSQC for visual purposes (I want it repositioned on my CSQC HUD, inside a dialog), what would be the best way to do it? Do I have to capture all keystrokes myself and code handling of them, together with drawstring or something?
_________________
Look out for Twigboy

Back to top |

Spike Joined: 05 Nov 2004 Posts: 944 Location: UK |

Posted: Wed Apr 16, 2008 8:31 pm Post subject: Re: CSQC messagemode |

Urre wrote:
If I were to hijack the messagemode system and make my own using CSQC for visual purposes (I want it repositioned on my CSQC HUD, inside a dialog), what would be the best way to do it? Do I have to capture all keystrokes myself and code handling of them, together with drawstring or something?

Trigger the messagemode via a console command.
After that start listening for keypresses.
If they hit return or escape, stop listening.
You'll have to concatinate strings yourself, yes.
Both FTEQCC and FrikQCC support 'a' as a character constant and stuff, if I remember correctly. You can use maths on the character values and pass them through to that fte_strings builtin thingie, and concatinate that to the end of the other string. Its a bit of a pain, yes. But it is at least possible to do. :)
_________________
What's a signature?

Back to top |

Urre Joined: 05 Nov 2004 Posts: 1073 Location: Sweden |

Posted: Wed Apr 16, 2008 10:26 pm Post subject: |

Not sure what you mean by fte_strings builtin and character constants in the compiler, where should I use those? I figured there was a way to feed keypresses to the concatenate function more or less directly, not having to hassle with character constants in qc.
_________________
Look out for Twigboy

Back to top |

Spike Joined: 05 Nov 2004 Posts: 944 Location: UK |

Posted: Thu Apr 17, 2008 7:20 pm Post subject: |

fte_strings provides a builtin which converts a character (or 8) value into a string. character values are important because the csqc is told about scancode type keys, not their shifted/alted character values. That is, if you try typing 'OMG NOOB', the keys the engine tells you about are lower case.
The easiest way to do this is to do chr2str(ch-'a'+'A') if they're holding shift, and ditch the extra maths if they're not...
Then you have the whole issue with punctuation...
And non-US keymaps...
Hrm.
That's pretty shit, really.
_________________
What's a signature?

Back to top |

Urre Joined: 05 Nov 2004 Posts: 1073 Location: Sweden |

Posted: Thu Apr 17, 2008 7:44 pm Post subject: |

Yes I do want to support non-US keyboards, seeing as I have one, and DarkPlaces already does this in messagemode. I was hoping I could somehow hijack the handling of keypresses, and just reposition the text where I wanted it. I know I can do it afterwards, just hijack the say command and type the text where I want, but that's not what I'm after.
_________________
Look out for Twigboy

Back to top |

LordHavoc Joined: 05 Nov 2004 Posts: 243 Location: western Oregon, USA |

Posted: Fri Apr 18, 2008 12:23 pm Post subject: |

Spike wrote:
fte_strings provides a builtin which converts a character (or value into a string. character values are important because the csqc is told about scancode type keys, not their shifted/alted character values. That is, if you try typing 'OMG NOOB', the keys the engine tells you about are lower case.
The easiest way to do this is to do chr2str(ch-'a'+'A') if they're holding shift, and ditch the extra maths if they're not...
Then you have the whole issue with punctuation...
And non-US keymaps...
Hrm.
That's pretty shit, really.

You're saying EXT_CSQC doesn't take all keypresses as scancode and UCS-32 value? A shame.
DarkPlaces passes the UCS-32 character as the third parameter to CSQC_InputEvent.

Back to top |

Urre Joined: 05 Nov 2004 Posts: 1073 Location: Sweden |

Posted: Fri Apr 18, 2008 1:58 pm Post subject: |

LordHavoc wrote:
You're saying EXT_CSQC doesn't take all keypresses as scancode and UCS-32 value? A shame. DarkPlaces passes the UCS-32 character as the third parameter to CSQC_InputEvent.

That's funny, Spike said the third parameter is always 0 in the case of keyboard, and in the case of mouse it's ydelta (second parameter is xdelta, first parameter is 2 (1 in the case of keyboard)), which on a side note doesn't seem to be the case in DP.
_________________
Look out for Twigboy

Back to top |

daemon Joined: 07 Nov 2007 Posts: 62 |

Posted: Fri Apr 18, 2008 7:49 pm Post subject: |

You might be looking for this: string(float keynum) keynumtostring = #340; I discovered that AFTER I had already set up conversions for all the text characters I wanted to allow. I was going to convert until I realized it doesn't support a lot of punctuation.
I would just set up some strings containing all the characters you want to use, and position them so you can use substring based on their keynum.
here's my conversion function which contains probably all the characters you might want to use, keynum being negative when shift is held down, and 32 = spacebar:

Code:
string KeyMap(float keynum) = { local string chrlist, key; if(keynum == 32) key = " ";
else
if(keynum >= 39 && keynum <= 61)
{
chrlist = "' *+,-./0123456789 ; =";
key = substring(chrlist, keynum - 39, 1);
}
else
if(keynum <= -39 && keynum >= -61)
{
chrlist = "\" <_>?)!@#$%^&*( : +";
key = substring(chrlist, (-keynum) - 39, 1);
}
else
if(keynum >= 91 && keynum <= 93)
{
chrlist = "[\\]";
key = substring(chrlist, keynum - 91, 1);
}
else
if(keynum <= -91 && keynum >= -93)
{
chrlist = "{|}";
key = substring(chrlist, (-keynum) - 91, 1);
}
else
if(keynum >= 97 && keynum <= 122)
{
chrlist = "abcdefghijklmnopqrstuvwxyz";
key = substring(chrlist, keynum - 97, 1);
}
return key;
}

a-z is also converted to uppercase later if shift is down.
Probably doesn't work too well with keyboards other than US?
_________________
-daemon [ daemonforge.org ]

Back to top |

Display posts from previous:

| Inside3d Forums Forum Index -> QuakeC Programming | All times are GMT
Page 1 of 1

Jump to:

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2004 phpBB Group