Jump to content
  • Advertisement


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



This topic is 6076 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Is it possible to get buffered keyboard input with DirectInput? Is there anything like scanf() or getchar() ? Newbie to game programming? visit KaBooMgames Great for Newbs, Masters welcome as well

Share this post

Link to post
Share on other sites
Yes, Direct Input has a method to do this. I don''t have the code in front of me or memorized, but pretty much when you create your keyboard object in DI, you have to set some values so that it can use buffered data. Then in your loop, you create an array of . . . here, let me get the code.


DIDEVICEOBJECTDATA rgdod[5]; // holds the info
DWORD dwItems = 5; // how many pieces of info you can hold
// get the data
hRet = G.lpDIKeyboard->GetDeviceData(

Anyway, after it is called, the dwItems will hold how many DIDEVICEOBJECTDATAs are actually filled. You go through the array with a for loop like for(int i = 0; i < dwItems; i++) and I believe by default, when you read the buffered data, it erases itself. I''m not sure the specifics, so just look up Get DeviceData in the DX helps. They should give you what I left out.
By the way, BE SURE YOU SET YOUR KEYBOARD TO BUFFERED IN SetProperty(). Can''t remember exactly how, but look it up.


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!