Archived

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

Vlade0000

Buffered input help needed?

Recommended Posts

Vlade0000    122
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
IndirectX    122
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