Jump to content
  • Advertisement

Archived

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

bkadoum

direct input bug

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

There's a bug I don't anderstand in my app which is using DirectDraw and DirectInput. When I come back to my app in fullscreen, the keyboard and mouse devices can't retrieving data anymore with function GetDeviceState. When I switch back to my app, I destroy DirectInput and reinitialise it. If I don't do that, the devices in windowed mode don't work anymore. So in conclusion, the bug is exactely the same in windowed mode and in fullscreen but the first one bug when I destroy DI and the other when I don't, it's crazy!!! I could make it working by destroying DirectInput only when I'm in windowed mode but I'm not sure it would be the good way. Maybe I have something wrong in my code. Here is my class Input. My app use two Input objects, for keyboard and mouse.
class Input
{
private:
	LPDIRECTINPUT8 lpDI;
	LPDIRECTINPUTDEVICE8 lpDIDevice;
	HWND dxWnd;
	HINSTANCE hInst;
public:
	Input() {}
	Input(HWND Input_dxWnd, HINSTANCE Input_hInst) {dxWnd = Input_dxWnd; hInst = Input_hInst;}
	void Destroy();
	void CreateDevice(THIS_ REFGUID Guid, THIS_ LPCDIDATAFORMAT DataFormat, int msg);
	LPDIRECTINPUTDEVICE8 GetDevice() {return lpDIDevice;}
};
The member function initialising a DI device.
   
void Input::CreateDevice(THIS_ REFGUID Guid, THIS_ LPCDIDATAFORMAT DataFormat, int msg)
{
	DirectInput8Create(hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&lpDI, NULL);
	lpDI->CreateDevice(Guid, &lpDIDevice, NULL);
	lpDIDevice->SetDataFormat(DataFormat);
	lpDIDevice->SetCooperativeLevel(dxWnd, msg);
	lpDIDevice->Acquire();
}
The member function destroying a DI device.
      
void Input::Destroy()
{
	lpDIDevice->Unacquire();
	lpDIDevice->Release();
	lpDI->Release();
}
If you need more code to help, I can send you later. [edited by - bkadoum on March 4, 2004 6:30:26 PM]

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster



case WM_ACTIVATE:
if(LOWORD(wParam) == WA_INACTIVE || (BOOL)HIWORD(wParam))
{
lpDIDevice->Unacquire();
}
else
{
lpDIDevice->Acquire();
}



Share this post


Link to post
Share on other sites
Yeah! well done, it''s working now. In fact I didn''t use the HIWORD(wParam) in my WndProc. It was only:


if (LOWORD(wParam) == WA_INACTIVE)
//doesn''t work!



It''s a really little difference. Why isn''t it working just like that?

Thanks!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
in MSDN Library

WM_ACTIAVTE

wParam

The low-order word specifies whether the window is being activated or deactivated.

The high-order word specifies the minimized state of the window being activated or deactivated. A nonzero value indicates the window is minimized.

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!