Whats wrong with my Direct Input/Mouse?

Started by
1 comment, last by johnnyBravo 20 years, 7 months ago
I''m trying to detect if the left mouse button is pressed. When i run the program it keeps detecting that the button is being pressed even though it isnt.


	class DIMouse {
	private:
		LPDIRECTINPUTDEVICE8 di_mouse;		
	public:
		LPDIRECTINPUT8 di_DI;
		LPDIRECTINPUTDEVICE8 di_device;
		void Init(HWND hWNd)
		{
			di_DI->CreateDevice(GUID_SysMouse, &di_mouse, NULL);
			di_mouse->SetDataFormat(&c_dfDIMouse);
			di_mouse->SetCooperativeLevel(hWNd, DISCL_EXCLUSIVE|DISCL_FOREGROUND);
			di_mouse->Acquire();
		}

		bool Button()
		{
			
			DIMOUSESTATE MouseState;
			di_mouse->GetDeviceState(sizeof(DIMOUSESTATE), (LPVOID)&MouseState);
			if (MouseState.rgbButtons[1]& 0x80)
				return true;
			else
				return false;
		}
	

	};
I can''t work out whats wrong from looking at the tutorials
Advertisement
if( MouseState[ MouseState.rgbButtons[1] ] & 0x80 ){
// Yup!
}else{
// Nope
}

Does it work???




.lick


[edited by - Pipo DeClown on September 3, 2003 10:05:40 AM]
didnt actually work but i forgot to set something up, thanks anyway

This topic is closed to new replies.

Advertisement