Sign in to follow this  

DirectX Buffered Keyboard Input help!

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

My source code for my function is below. I am trying to get whatever key was pressed by the user using buffered input... I already call GetDeviceData() in my acquire buffered keyboard function. The following code will always return NULL instead of the keypress. Can anyone see anything I might be doing wrong? Let me know. Thanks in advance.

// Get the keyboard state first...
	if (!GetKeyboardState(m_ucKeyData))
		return NULL;

	UINT uiKeyCode = 0;
	
	for (unsigned int i = 0; i < m_dwKeyElements; i++)
	{
		for (unsigned int j = 0; j < 256; j++)
		{
			if ((m_diodKeyboard[i].dwOfs == j) && (m_diodKeyboard[i].dwData & 0x80))
			{
				uiKeyCode = MapVirtualKeyEx(m_diodKeyboard[i].dwOfs, 1, GetKeyboardLayout(NULL));

				return (char)uiKeyCode;
			}
		}
	}

	// Nothing....
	return NULL;


Share this post


Link to post
Share on other sites
uhhm, much more information please [smile]

There are two return NULL statements. Which is it that's actually returning?

Have you stepped through the code? try some OutputDebugString()'s to try and pin point where it's going wrong.

What is the state of all the variables you're using? m_dwKeyElements amongst others seems to appear out of nowhere. The device state, m_ucKeyData, doesn't seem to be used anywhere either.

hth
Jack

Share this post


Link to post
Share on other sites
Ok,

I think I found the problem. The GetDeviceData returns this HRESULT.
"The owner SID on a per-user subscrtiption doesn't exist". (0x80040207)

Is there any way to look up this error?

Thanks again.



// AcquireBufferedKeyboard Function
bool CInputSystem::AcquireBufferedKeyboard(void)
{
if (!m_pDIKeyboard)
return false;

// Acquire our keyboard...
m_pDIKeyboard->Acquire();

// Clear out the keyboard information...
ZeroMemory(m_diodKeyboard, sizeof(m_diodKeyboard));

if (m_pDIKeyboard->GetDeviceData(sizeof(DIDEVICEOBJECTDATA), m_diodKeyboard, &m_dwKeyElements, 0) == DIERR_INPUTLOST)
{
if (FAILED(m_pDIKeyboard->Acquire()))
return false;
}
// Return success... woot.
return true;
}







[Edited by - jwbaumgartner on January 9, 2006 9:10:08 AM]

Share this post


Link to post
Share on other sites
You're trying to read buffered data from a device that isn't buffered:

Quote:
HRESULT: 0x80040207 (2147746311)
Name: DIERR_NOTBUFFERED
VFW_E_NO_ACCEPTABLE_TYPES
Description: Attempted to read buffered device data from a device that is not buffered. & There is no common media type between these pins.
Severity code: Failed
Facility Code: FACILITY_ITF (4)
Error Code: 0x0207 (519)


(You should have a DirectX Error Lookup tool in your Start menu.)

Share this post


Link to post
Share on other sites
You have to set up a buffer size (using SetProperty) to enable buffered mode input. Take a look at the Keyboard sample in the SDK Samples directory for an example of how to set up the keyboard device for buffered input.

Share this post


Link to post
Share on other sites

This topic is 4359 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this