Keyboard input Question.

Started by
6 comments, last by Ephimus 23 years, 6 months ago
Hello. This may be a trivial problem, but I can''t figure it out. Anyway I am writing a little game in c/c++ and am using ddraw for graphics. My question is how do you do the equivalent to a scanf() function in a full screen ddraw application? I want the player to be able to input their name at a prompt from the game. I have looked around and have not been able to find any info on this. Could you please explain it or point me towards a tutorial or some source code? Thanks. Ephimus
Advertisement
Use GetAsynchKeyState(). It should be in MSDN, although I got it from Windows Game Programming for Dummies. You need to & the return value with some constant to tell whether or not the key is pressed or released. I am sure someone has the KEY_DOWN() and KEY_UP() macros handy. They are in my vector graphics engine source code if you want to look at it. Follow the ROAD Programming link in my signature and click community then downloads. It is the only download. Since you seem to know DD and C, maybe you could check out my unfindable bug thread and help me out...

--------------------


You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming


You are unique. Just like everybody else.

Yanroy@usa.com

Visit the ROAD Programming Website for more programming help.

--------------------

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

You could also use the DirectInput and use the sdk docs for help. All you have to do a draw a prompt and a cursor which you blink at a set interval. Then use the the direct input functions to read keys and when a key is read display it with either a GDI function or something than move the cursor. You loop until the user as hit the enter key or something else and you can read every value entered. From this it is not difficult to create a backspace type like function. I do not have the code for all of this right now but if you still need more help let me know. ( For direct input help just look at the SDK or this site ).
WHO DO THEYTHINK THEY'REFOOLING : YOU ?

Thanks Guys. This will give me a start. Hopefully I can play around with it enough to get it working for me.


Bleakcabal -
I am using Win NT and I could not(after hours and hours of trying) get dinput to work under NT. If you have any advice in this area it would be appreciated.


Thanks.
Ephimus

handle the WM_CHAR message in your message procedure - the wParam can be cast to a char (this has the advantage of standard keyboard repeat rates etc...)
Just wondering why are you using Win NT to develop a game??

DirectInput not working under NT is no surprise...

:/

Cel
Cel aka Razehttp://chopper2k.qgl.org
NT rocks. It doesn't beat-pud or lockup or bluescreen nearly as often as 9x.

If I remember right, SP4 for NT4 included Dx5 support; so you can't use any Dx7 stuff in NT4, unless you a new sp has support for it. And you need SP4 for any Dx stuff to work.

Win2000 has Dx7 support.


Most people who code for M$ Windows code under NT.

Edited by - Magmai Kai Holmlor on October 3, 2000 10:52:24 PM
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Ya i know, I use win2k myself, but perhaps he hasnt installed the NT service packs thus not getting proper directx support....

Cel
Cel aka Razehttp://chopper2k.qgl.org

This topic is closed to new replies.

Advertisement