• Advertisement

Archived

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

Whats wrong with my Direct Input/Mouse?

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

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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

  • Advertisement