On 2008-07-31 23:45, stax76 wrote:
Hello,
can anybody tell me what it would look like in C++?
byte[] bRawData = new byte[raw.hid.dwSizHid];
Use a char array for bytes, since you will do some bit-shifting you
probably want unsigned char. But to be safe you should check how
shifting affects C# bytes, but it seems in this case that the result is
an integer type larger (more bits) than a byte.
unsigned char* bRawData = new unsigned char[raw.hid.dwSizHid];
int pRawData = buffer.ToInt32() + Marshal.SizeOf(typeof(RAWINPUT)) +
1; // buffer is of type IntPtr
In you case buffer should be of type unsigned char* or perhaps void*,
what this code does is getting a pointer which points to some offset
from the beginning of the buffer containing the data you want. RAWINPUT
should be a struct or a class.
unsigned char* pRawData = buffer + sizeof(RAWINPUT) + 1;
Marshal.Copy(new IntPtr(pRawData), bRawData, 0, raw.hid.dwSizHid - 1);
Looks like they copy the interesting parts from the buffer into the
array, use memcpy().
int rawData = bRawData[0] | bRawData[1] << 8;
Here they combine the values of bRawData[0] and bRawData[1] so that the
value in bRawData[1] is in bis 8-15 and bRawData[0] is in bits 0-8. This
line should work as it is.
the full code is taken from the following article:
http://msdn.microsoft.com/en-us/library/ms996387.aspx
Since you are not doing .Net development looking at the .Net
documentation might not be the best idea, it is better looking at the
Win32 documentation:
http://msdn.microsoft.com/en-us/libr...85(VS.85).aspx
Check the Raw Input section for more information relevant to your problem.
--
Erik Wikström