Skip to main content
GameDev.net gamedev.net
🔒 Locked

Direct Input Buffered Mode Tutorial

Started by jtmerchant Jul 16, 2004 at 12:07 PM 0 replies 550+ views
Original Post
jtmerchant
jtmerchant
I have been having some trouble with Direct Input's buffered mode, and I've decided that the problem resides in my lack of understanding of the buffered mode. Can someone please refer me to a good tutorial on Direct Input 8 Buffered Input for the keyboard? Thank you for your support, Joshua Merchant
Quote:
That should be food for thought. No one replied, so I assumed you were hungry.
circlesoft
circlesoft
The 'Keyboard' sample/tutorial covers buffered mode, as well as immediate mode. This can be useful, because you may want to use both buffered and immediate in the same app. For example, I may use immediate mode for all my in-game input, but I use buffered mode for all my GUI input (ie for text boxes).

You can get buffered input this way:
// keyboard is the IDirectInputDevice8 objectDIDEVICEOBJECTDATA data[8];  // You can change this if you wantDWORD numElements;if( FAILED( keyboard->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), data, &numElements, 0 ) ) ){   // Handle lost keyboard}for( int i = 0; i < numElements; i++ ){   if( data.dwOfs == DIK_A )   {      // Test A key            if( data.dwData & 0x80 )      {         // A has been pressed      }      else      {         // A has been released      }   }}

Topic Locked

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

Sign in to reply to this topic.