Archived

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

johnnyBravo

Whats wrong with my Direct Input/Mouse?

Recommended Posts

johnnyBravo    100
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