# HG changeset patch # User sl # Date 1415135461 -3600 # Node ID eed66dfd9848ff44c88187661e0e068a80ed6dd3 # Parent db8e6a25d6bc5d6dcd676947f7fdc4286c6bf034 Cleaning and adding GetRawInputDeviceInfo definition. We will need to use it to get the Usage Page of HID messages. diff -r db8e6a25d6bc -r eed66dfd9848 RemoteControlDevice.cs --- a/RemoteControlDevice.cs Tue Nov 04 20:58:19 2014 +0100 +++ b/RemoteControlDevice.cs Tue Nov 04 22:11:01 2014 +0100 @@ -277,6 +277,9 @@ [DllImport("User32.dll")] extern static uint GetRawInputData(IntPtr hRawInput, uint uiCommand, IntPtr pData, ref uint pcbSize, uint cbSizeHeader); + [DllImport("User32.dll")] + extern static uint GetRawInputDeviceInfo(IntPtr hDevice, uint uiCommand, IntPtr pData, ref uint pcbSize); + private const int WM_KEYDOWN = 0x0100; private const int WM_APPCOMMAND = 0x0319; @@ -538,15 +541,15 @@ { byte* source = (byte*)buffer; source += sizeof(RAWINPUTHEADER) + sizeof(RAWHID); - //source += 1; pRawData = (int)source; } - //int pRawData = buffer.ToUint32() + Marshal.SizeOf(typeof(RAWINPUT)) + 1; - //Marshal.Copy(new IntPtr(pRawData), bRawData, 0, raw.hid.dwSizeHid - 1); + //Copy HID message into our buffer Marshal.Copy(new IntPtr(pRawData), bRawData, 0, raw.hid.dwSizeHid); - //int rawData = bRawData[0] | bRawData[1] << 8; + //bRawData[0] //Not sure what's the meaning of the code at offset 0 + //TODO: check size before access int rawData = bRawData[1]; //Get button code + //Print HID codes in our debug output Debug.WriteLine("HID " + raw.hid.dwCount + "/" + raw.hid.dwSizeHid + ":" + bRawData[0].ToString("X2") + bRawData[1].ToString("X2")); if (Enum.IsDefined(typeof(MceButton), rawData) && rawData!=0) //Our button is a known MCE button