我正试图仅从触摸屏捕获rawdata。检查HID
时,我得到了很多。而且根据doc,我应该只收到0,1和2.为什么我收到3?主要目标是从触摸屏捕获并打印出所有的坐标。所有的coords意味着可能有多次接触。
[DllImport("user32.dll")]
internal static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("User32.dll")]
internal static extern uint GetRawInputData(IntPtr hRawInput, uint uiCommand,
IntPtr pData, ref uint pcbSize, uint cbSizeHeader);
[DllImport("User32.dll")]
internal static extern bool RegisterRawInputDevices(RAWINPUTDEVICE[] pRawInputDevice,
uint uiNumDevices, uint cbSize);
[DllImport("User32.dll")]
internal static extern uint GetRawInputDeviceList(IntPtr pRawInputDeviceList,
ref uint uiNumDevices, uint cbSize);
[DllImport("User32.dll")]
internal static extern uint GetRawInputDeviceInfo(IntPtr hDevice, uint uiCommand,
IntPtr pData, ref uint pcbSize);
internal const int RIM_TYPEHID = 2;
internal const uint RIDI_DEVICENAME = 0x20000007;
private void Form1_Load(object sender, RoutedEventArgs e)
{
uint deviceCount = 0;
int dwSize = Marshal.SizeOf(typeof(RAWINPUTDEVICELIST));
if (GetRawInputDeviceList(IntPtr.Zero, ref deviceCount, (uint)dwSize) == 0)
{
IntPtr pRawInputDeviceList = Marshal.AllocHGlobal((int)(dwSize * deviceCount));
GetRawInputDeviceList(pRawInputDeviceList, ref deviceCount, (uint)dwSize);
for (int i = 0; i < deviceCount; i++)
{
// ***here! how can I know which one is from touchscreen?***
}
}
else
{
throw new ApplicationException("Error!");
}
}