private static HidDeviceCapabilities GetDeviceCapabilities(IntPtr hidHandle) { var capabilities = default(NativeMethods.HIDP_CAPS); var preparsedDataPointer = default(IntPtr); if (NativeMethods.HidD_GetPreparsedData(hidHandle, ref preparsedDataPointer)) { NativeMethods.HidP_GetCaps(preparsedDataPointer, ref capabilities); NativeMethods.HidD_FreePreparsedData(preparsedDataPointer); } return(new HidDeviceCapabilities(capabilities)); }