Skip to main content
gamedev.net
🔒 Locked

Keyboard input

Started by Muzlack Dec 3, 2001 at 12:34 PM 2 replies 150+ views
Original Post
Muzlack
Muzlack
is there a way to make an easy "any key" using direct input? I hate typing if(keydown(DIK_SPACE)||keydown(DIK_ESCAPE)) etc...
--Muzlack
GameDweeb
GameDweeb
I don''t know much about DirectX, but maybe just try

"if(keydown())"

I''m not positive how the function works, but just from what I can gather from that little snippet of code you posted, it seems that it just scans the keyboard and if it detects the particualar key that specified being pressed it completes the action specified. So with that line of thinking in mind, if you don''t specify a particular return from that function, just "a" return then it should work.

Correct me if I''m wrong guys, I think that should work though...
Muzlack
Muzlack
Sorry... I guess I forgot to explain this...
#define keydown(key) (KeyArray[key]==0x001) ? 1:0
something like that... I''m not at my code right now, but It''s something similiar to this code
--Muzlack
darookie
darookie
try it using a simple linear search on your KeyArray
  
int KeyCount ( )
{
int i,result = 0;
char *keys = KeyArray;
for ( i = 0; i < 256; ++i )
result += *keys++;
return result;
}


not very fast but works.
Anyway, speed is not important for "any key" functions

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.