Skip to main content
GameDev.net gamedev.net
🔒 Locked

direct input bug

Started by bkadoum Mar 4, 2004 at 11:12 AM 2 replies 950+ views
Original Post
bkadoum
bkadoum
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]
bkadoum
bkadoum
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!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.