Sign in to follow this  
POLSKASH

Quick DInput Q

Recommended Posts

POLSKASH    100
I'm using the code from my Jim Adams book Programming Roleplaying.... and it's not compiling.
bool ReadData(IDirectInputDevice8* dev, void* DataBuffer, long BufferSize)
{
	while(1)
	{
		dev->Poll();
		
		if(SUCCEEDED(dev->GetDeviceState(BufferSize,(LPVOID)DataBuffer)))
			break;

		dev->Acquire();
	}
	return true;
}

void getInput()
{
	ReadData(mouse, (void*)MouseState, sizeof(DIMOUSESTATE));
	mouseX += MouseState.lX;
	mouseY += MouseState.lY;

	if(MouseButtonState(0) == TRUE)
	{
	}

}


Says I can't typecast MouseState to type (void*), but it's right here in the book. I know books can be wrong, but I'm just making sure here. What gives?

Share this post


Link to post
Share on other sites
TheWanderer    194
One possibility is that you are sending MouseState as a structure and not a pointer. If you have a structure, you need to send it using its address (i.e. put a '&' in front of the name.)

Do you have a line number for the error? Where does it point?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this