Getting keyboard input w/ DirectX

Started by
6 comments, last by Peon 23 years, 1 month ago
Alright, I understand DI enough to get input from the keyboard. They press ESC I exit the program. Now I want to make it so the user can type a file name to load and I want to use DI. Now I already know how to check for individual keys, but without checking each key specifically, how could I do this? I''m aiming to do something like cin, but more simple. thanks in advance Peon
Peon
Advertisement
You''ve gotta make your own function that writes chars to a string every time you press a letter. It''ll take a little typing, buty once yo finish it, the rest will be easy.


-Forcas

"Elvis is alive. He is Barney the purple dinosaur. He is the pied piper that leads our children into the wages of sin and eternal damnation."
-Forcaswriteln("Does this actually work?");
i would just intercept the WM_CHAR message for typing things in - that way you get the keyboard refresh rates (etc) by default.
Will WM_CHAR messages be generated, or will DI intercept them?
Alexander "DmGoober" Jhinalexjh@online.microsoft.com[Warning! This email account is not attended. All comments are the opinions of an individual employee and are not representative of Microsoft Corporation.]
I think that''s my problem, Forcas. I know how to check keys using an if statement or something, ie:

if (keystate[DIK_A]
{
do...
}

Or whatever. My problem is that I want to get input without going: if (A), if (B), if (C).. You know what I mean? I might just be misunderstanding you, let me know if you have something else in mind

Thanks

Peon
Peon
You can get DI to Poll/GetDeviceState - which is what you''re probably doing OR you can setup DI for BUFFERED input (which sounds like what you want). Check out the DX-DI function GetDeviceData() or do a search for "Buffered Keyboard Data" in the SDK help files. I think that''s what you''re looking for.

Regards,
Jumpster
Regards,JumpsterSemper Fi
OK, I''ll have to try that. I hope it works

Thanks,

Peon
Peon
Sounds like you are going to want to convert DIK codes to ASCII codes. There''s an article here on GameDev about this, in the resources.

Andy.

This topic is closed to new replies.

Advertisement