direct input bug

Started by
2 comments, last by bkadoum 20 years, 1 month ago
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]
Advertisement



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



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!
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.

This topic is closed to new replies.

Advertisement