Jump to content
  • Advertisement

Archived

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

Quiggy

Problem with keyboard Acquire()

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

Just like the subject says my Acquire() function always fails and I have no idea why it's doing that. What can cause this function to fail? Here's my code. The Acquire is at the very bottom.
  
// Initialize DirectInput

bool CGame::InitializeDI(HINSTANCE hInst, HWND hWnd)
{
	//	Set up the Direct Input Stuff

	HRESULT hr;

	hr = (DirectInput8Create(hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&m_pDI, NULL));
	
	if (FAILED(hr))
	{
		WriteToLog("ERROR initializing DirectInput8.");
		return FALSE;
	}

	if (FAILED(m_pDI->CreateDevice(GUID_SysKeyboard, &m_pKeyboard, NULL)))
	{
		WriteToLog("ERROR Creating DirectInput Device.");
		return FALSE;
	}

	if (FAILED(m_pKeyboard->SetDataFormat(&c_dfDIKeyboard)))
	{
		m_pKeyboard->Release();
		WriteToLog("ERROR Setting DataFormat for DirectInput.");
		return FALSE;
	}

	if (FAILED(m_pKeyboard->SetCooperativeLevel(hWnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE)))
	{
		m_pKeyboard->Release();
		WriteToLog("ERROR Setting Cooperative Level for DirectInput.");
		return FALSE;
	}

	if (FAILED(m_pKeyboard->Acquire()))
	{
		m_pKeyboard->Release();
		WriteToLog("ERROR Acquire for DirectInput.");
		return FALSE;
	}

	return true;
}
  
Anybody have any ideas? Quiggy. [edited by - Quiggy on January 30, 2003 7:56:23 PM]

Share this post


Link to post
Share on other sites
Advertisement
Shots in the dark:

1) Is the window (HWND) actually created and displayed by the time you call Aquire?

2) Have you tried creating a buffersize before aquiring?



DIPROPDWORD propdword;
memset(&propdword, 0, sizeof(propdword));

propdword.diph.dwSize = sizeof(propdword);
propdword.diph.dwHeaderSize = sizeof(DIPROPHEADER);
propdword.diph.dwObj = 0;
propdword.diph.dwHow = DIPH_DEVICE;
propdword.dwData = 16;

m_pKeyboard->SetProperty(DIPROP_BUFFERSIZE, &propdword.diph);



Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!