DirectInput to ASCII
Im now using Direct Input for my console and Im using the function Control.g_pKeyboard->GetDeviceState(256, diKeys), the only way I can think of checking what keys have been pressed is by doing a for loop through all 256 of the diKeys, But then how do I convert the number to a letter, like by which element in the array diKeys is which letter, is there a function for the Conversion. Or is there a better way of doing this in Direct Input.
PS: Im know asking a DirectX Question, so I bet I''ll get a million answers , thanks everyone, gamedev.net ROCKS!
Well, if you were using VB you could simply use ASC. I think there''s some C thing that lets you do that, but I''m not sure how to. I would like to read about what other people have to say because this function has been puzzling me for a while.
------------------------
Captured Reality.
------------------------
Captured Reality.
Um...
I haven't used DirectInput for months, but i try to remember... Um... Let's see... oh, ok! I think i've found!
Correct me if i'm wrong, but the entries in the array are ASCII values. SO if key 64 is pressed, you just have to display the ascii character number 64.
Here is some pseudo-code :
Um... I'm not sure at all it will work. I used to write some "magic functions" which do all this stuff. But since i always use them, i don't remember how DirectInput itself works. How lazy i am!
Anyway, tell me if it doesn't work and i'll have a look to my old code.
Prosper / LOADED corporation
Edited by - Prosper/LOADED on June 6, 2000 4:52:34 AM
I haven't used DirectInput for months, but i try to remember... Um... Let's see... oh, ok! I think i've found!
Correct me if i'm wrong, but the entries in the array are ASCII values. SO if key 64 is pressed, you just have to display the ascii character number 64.
Here is some pseudo-code :
// Get the pressed keysControl.g_pKeyboard->GetDeviceState(256, diKeys); // Display pressed keysfor ( int i=0; i<256; i++){ if ( diKeys & 0x8000) display( char(i) );}
Um... I'm not sure at all it will work. I used to write some "magic functions" which do all this stuff. But since i always use them, i don't remember how DirectInput itself works. How lazy i am!
Anyway, tell me if it doesn't work and i'll have a look to my old code.
Prosper / LOADED corporation
Edited by - Prosper/LOADED on June 6, 2000 4:52:34 AM
I just made a 256-char array and manually set each one like this:
DIKeys[DIK_A] = ''A'';
etc etc etc.
Then just do a simple routine to check for which keys were just pressed and check the array for the letter.
DIKeys[DIK_A] = ''A'';
etc etc etc.
Then just do a simple routine to check for which keys were just pressed and check the array for the letter.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement