Hm...
RAWINPUT* raw = (RAWINPUT*)lpb;
So if I'm reading this right... lpb is an int which contains a pointer. This is converted to a RAWINPUT pointer, and stored in a variable raw, which is of type RAWINPUT pointer.
At least that's how it first appears...
But this is the code that's in:
Case WM_INPUT
dwSize:Int = 40
lpb:Byte[40]
GetRawInputData((HRAWINPUT)lParam, RID_INPUT, lpb, &dwSize, SizeOf(RAWINPUTHEADER));
RAWINPUT* raw = (RAWINPUT*)lpb; ' raw is a pointer to data of type RAWINPUT. But why
If (raw->header.dwType == RIM_TYPEMOUSE)
Int xPosRelative = raw->data.mouse.lLastX;
Int yPosRelative = raw->data.mouse.lLastY;
EndIf
Hacked up a bit by me while converting it to blitzmax... But anyway, lpb is an array of 40 bytes. So (RAWINPUT*)lpb can't be converting an int to a pointer... Is it converting a pointer to a pointer of a different type maybe? I guess if it's an array being returned from the function it would have to be a pointer.
Maybe what this is doing is taking the returned pointer lpb which is a pointer to an array of an undefined type, and then converting that pointer to a pointer to the struct RAWINPUT, and the array is 40 bytes because the struct is 40 bytes? Hm. Why wouldn't they have used sizeof() when declaring the array though to make sure it's always the right size if the strucutre changes?
Ugh. What a pain in the ass this seemingly simple task has turned out to be.
|