Archived

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

bangz

Direct Input

Recommended Posts

bangz    119
Hello, I''ve got a little problem with getting an input from the keyboard. The user presses and holds an arrow key and the player moves accordingly, although when the key is held the player only initially moves, then pauses for a brief moment, then continues along in a smooth fashion. Im using code very similar to that used in the nexe keyboard tutorial (which, apparently is also very similar to that of the DX SDK). Here is the processing of the keyboard input
  
void  KeyboardInput(HWND hwnd)
{
	hr = lpDIDEVICE8->GetDeviceState(sizeof(UCHAR)*256,(LPVOID) buffer);
	if(hr == DIERR_INPUTLOST)
	{
		//reaquire iterface

		hr = lpDIDEVICE8->Acquire();
		if(FAILED(hr))
		{
			DIShutdown();
		}
	}
	

	if(KEYDOWN(buffer,DIK_RIGHT))
	{
		g_paddle.Translate(0.05, 0);
	}
	else if(KEYDOWN(buffer,DIK_LEFT))
	{
		g_paddle.Translate(-0.05, 0);
	}
}
  
I have set the cooperative level as NONEXCLUSIVE FOREGROUND. Regards, bangz. http://www.thebigredhouse.co.uk - vote Richard Bangs

Share this post


Link to post
Share on other sites
tok_junior    229
My guess would be that it''s because of the keyboard repeat settings in your bios-settings.


--
MFC is sorta like the swedish police... It''''s full of crap, and nothing can communicate with anything else.

Share this post


Link to post
Share on other sites
Shannon Barber    1681
That is striking similar to the repeat delay, but DI and GetState should not be affected by that.

I noticed a couple of problems, but do not think they will solve your problem. Never-the-less, after you reacquire the device, you need to call GetState again.

Also, you should not use if/elseif - you''ll only process one key every iteration, and only the first one in the if chain. It should just be if{} if{} if{} - no else''s.

Share this post


Link to post
Share on other sites
tok_junior    229
True, it SHOULD not, but who can know for sure, with DX being so blackboxed, and each keyboard working differently?
I suggest first of all, try setting the repeat-settings to 0, so no delays, try using a different keyboard, and try using a different bios.
This should tell you if it''s got anything to do with the kb/setting atleast...


--
MFC is sorta like the swedish police... It''''s full of crap, and nothing can communicate with anything else.

Share this post


Link to post
Share on other sites