Jump to content
  • Advertisement

Archived

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

Vlade0000

Buffered input help needed?

This topic is 5968 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

Hi guys i want to get input from the user (like the users name or what eva) so now i use buffered input to read my stuff into a string like this //KB_BUFFER = 20 USHORT temp; DIDEVICEOBJECTDATA didod[KB_BUFFER]; DWORD dwElements = KB_BUFFER; if(FAILED(hr = lpdi_kb->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), didod, &dwElements, DIGDD_PEEK))) { if(hr == DIERR_INPUTLOST) { if(FAILED(hr = lpdi_kb->Acquire())) { MessageBox(NULL, "Keyboard has been lost", "ERROR", MB_OK | MB_ICONEXCLAMATION); logerror(DXI_ER010); killDXInput(); } } } for(DWORD i = 0; i < dwElements; i++) { scan2ascii(didod.dwOfs, &temp); inputStr[i] = (char)temp; } //inputStr size is = to KB_BUFFER now my problem is when i call this @ 60hz all my input is double. it looks kinds like this when i print it "tthhiiss iiss aa tteesstt" any ideas, sucgestions or links? cheers

Share this post


Link to post
Share on other sites
Advertisement
You need to save last frame key state, and add a letter only if it wasn't pressed during last frame. You can use GetDeviceState to capture the keyboard buffer at once.

Also, it's not a good idea to kill dinput if one of your input devices is lost.

[edited by - IndirectX on March 19, 2002 7:24:42 PM]

Share this post


Link to post
Share on other sites
cool thanx for reminding me not to kill every thing!i made a small fix and forgot to add a KillDXIMouse() mouse function



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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!