BUFFERED KEYBOARD INPUT WITH DIRECTINPUT
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
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.
HRESULT hRet;
DIDEVICEOBJECTDATA rgdod[5]; // holds the info
DWORD dwItems = 5; // how many pieces of info you can hold
// get the data
hRet = G.lpDIKeyboard->GetDeviceData(
sizeof(DIDEVICEOBJECTDATA),
rgdod,
&dwItems,
0);
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.
--Vic--
HRESULT hRet;
DIDEVICEOBJECTDATA rgdod[5]; // holds the info
DWORD dwItems = 5; // how many pieces of info you can hold
// get the data
hRet = G.lpDIKeyboard->GetDeviceData(
sizeof(DIDEVICEOBJECTDATA),
rgdod,
&dwItems,
0);
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.
--Vic--
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement