Mail Archives: djgpp/2000/04/20/06:35:36
> From: "Edward Griffin" <edward AT neptune DOT greatxscape DOT net>
> Newsgroups: comp.os.msdos.djgpp
> Date: Wed, 19 Apr 2000 08:30:51 +0100
>
> I'm writting a server program for a network game and I need to write my own
> custom text input function. The program runs in text mode so I don't need
> any graphical stuff. It currently handles IPX packets and sends them to
> other computers on the network. When it's not doing that, I want it to be
> checking for keypresses, and if it gets one, add the letter to a string, and
> display the text on the screen.
>
> It also needs to understand delete, pgup, pgdn, enter and esc seperately.
> How should I go about doing this? There are so many functions like getch,
> kbhit, getche, putchar, getchar etc. I've tried hundreds of combinations and
> I can't get it to work.
I'm sorry that you are frustrated, but I find it unfortunate that you
didn't tell more about the specific problems that you encountered with
the various input functions. This puts a damper on the effectiveness
of the help we could give you.
Anyway, here are two simple alternatives:
- If you don't need this code to be portable to other platforms like
Linux, use `kbhit' to check whether a key was pressed and
`getxkey' to read the keys;
- If portability to Unix/Linux *is* an issue, use `tcsetattr' to put
the console into single-character raw-mode input mode, call
`select' to check for keypresses and use `getc' (NOT `getch'!) to
read the keys one by one. Note that this alternative does NOT
support special keys like PgDn etc., as there's no portable way of
reading these keys.
- Raw text -