Archived

This topic is now archived and is closed to further replies.

StonerSunshine

Taking in Text Input

Recommended Posts

I''m currently working on an OpenGL game project, and I need to be able to take in text input from the user. I tried using the _kbhit() function along with _getch() but they didn''t work at all. (The _kbhit() function never picked up when a key was hit. Maybe because I''m using Windows XP?) Does anyone know of a good way to take in text from the user other than an "if" check for every keyboard key? Thanks in advance for any help.

Share this post


Link to post
Share on other sites
The _kbhit and _getch functions are low level borland library functions that bypass the console to get input before the console does.

See, this is your problem; you have no console since you are running a windows application. Thus, you must use the Windows event handler to pick up keypresses. You must have an event handler, otherwise you won''t have a validly working windows application.

-----------------------------
Final Frontier Trader
If I were you, I would look into DirectInput. You can make a rather simple keyboard input routine for around, fifteen lines (give or take).
There are some good tutorials in the articles section, and the help files with DirectX SDK aren''t all that bad...

I don''t have a signature, sorry.

Share this post


Link to post
Share on other sites
Thanks for the replies. I see... So, maybe I can use the Windows WM_KEYDOWN message to know when a key is hit. Is there a function that can tell me specifically which character was hit when the WM_KEYDOWN message is sent?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Handle WM_KEYDOWN, and the wParam (IIRC) parameter of your window proc contains the virtual key code for the key that was pressed.

Share this post


Link to post
Share on other sites