# 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()
{
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 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 on other sites
POLSKASH    100
Gah, thanks. I was typecasting the structure itself and not the address.

##### Share on other sites
TheWanderer    194

##### Share on other sites
Pipo DeClown    804
Have you checked the books website for all the code fixes?