I'm processing raw input.
lpb is the raw input data cast to a byte array.
I have all the data I need except for in range or tip. Without a lift off event I have no way to implement a touch up event.
int bufferSize = 0;
RIDInput.GetRawInputDeviceInfo(ri.Header.hDevice, RIDI_PREPARSEDDATA, IntPtr.Zero, ref bufferSize);
IntPtr pPreparsedData = Marshal.AllocHGlobal(bufferSize);
RIDInput.GetRawInputDeviceInfo(ri.Header.hDevice, RIDI_PREPARSEDDATA, pPreparsedData, ref bufferSize);
HIDP_CAPS Caps = new HIDP_CAPS();
HidP_GetCaps(pPreparsedData, ref Caps);
HidP_Value_Caps[] pValueCaps = new HidP_Value_Caps[Caps.NumberInputValueCaps];
short capsLength = Caps.NumberInputValueCaps;
HidP_GetValueCaps(0, pValueCaps, ref capsLength, pPreparsedData);
for (int j = 0; j < pValueCaps.Length; j++)
{
int ret = 0;
ushort usage = 0;
if (pValueCaps[j].IsRange)
{
ret = HidP_GetUsageValue(0, (short)pValueCaps[j].UsagePage, 0, pValueCaps[j].Range.UsageMin, ref value, pPreparsedData,
lpb, lpb.Length);
usage = pValueCaps[j].Range.UsageMin;
}
else
{
ret = HidP_GetUsageValue(0, (short)pValueCaps[j].UsagePage, 0, pValueCaps[j].NotRange.Usage, ref value, pPreparsedData,
lpb, lpb.Length);
usage = pValueCaps[j].NotRange.Usage;
}
if (ret != HIDP_STATUS_SUCCESS)
continue;
switch (pValueCaps[j].UsagePage)
{
case 0x01:
switch (usage)
{
case 0x30:
xMax = (int)pValueCaps[j].LogicalMax;
x = value;
break;
case 0x31:
yMax = (int)pValueCaps[j].LogicalMax;
y = value;
break;
}
break;
case 0x0D:
switch (usage)
{
case 0x30:
Console.WriteLine("Pressure " + value);
break;
case 0x32: // In-Range
inRange = value;
break;
case 0x42: // Tip
tip = value;
break;
case 0x47: // Confidence
Console.WriteLine("Confidence " + value);
break;
case 0x48:
width = value;
break;
case 0x49:
height = value;
break;
case 0x51:
touchId = (byte)value;
break;
case 0x54:
touchCount = value;
break;
case 0x55:
Console.WriteLine("contacts");
maxContacts = value;
break;
// Scan Time
case 0x56:
Console.WriteLine(value);
break;
}
break;
}
}