/// <summary> /// Retrieves the raw input from the specified device. /// </summary> /// <param name="rawInputDataHandle"> /// The handle to the <see cref="RawInputData"/> structure. This comes from <see cref="Message.LParam"/> for /// messages of type <c>WM_INPUT</c>. /// </param> /// <param name="rawInputData"> /// A correctly sized buffer (see <see cref="GetRawInputDataSize"/>) where to copy the data that comes from the /// <see cref="RawInputData"/> structure. /// </param> /// <returns> /// A reference to the <see cref="RawInputData"/> structure. /// </returns> /// <remarks> /// This function gets the raw input one <see cref="RawInputData"/> structure at a time. In contrast, /// <see cref="GetRawInputBuffer"/> gets an array of <see cref="RawInputData"/> structures. /// </remarks> internal static unsafe ref RawInputData GetRawInputData(IntPtr rawInputDataHandle, Span <byte> rawInputData) { var dataSize = (uint)rawInputData.Length; fixed(void *ptrRawInputData = &rawInputData[0]) { GetRawInputData_((void *)rawInputDataHandle, (uint)RawInputDataType.Input, ptrRawInputData, &dataSize, RawInputHeader.HeaderSize); RawInputData *rawInputPtr = (RawInputData *)ptrRawInputData; return(ref *rawInputPtr); } }
/// <summary> /// Retrieves the location of the next structure in an array of <see cref="RawInputData"/> structures. /// </summary> /// <param name="ptrRawInput">A pointer to a structure in an array of <see cref="RawInputData"/> structures.</param> /// <unmanaged>NEXTRAWINPUTBLOCK(ptr)</unmanaged> private static unsafe RawInputData *NextRawInputBlock(RawInputData *ptrRawInput) { // ((PRAWINPUT)RAWINPUT_ALIGN((ULONG_PTR)((PBYTE)(ptr) + (ptr)->header.dwSize))) return((RawInputData *)RawInputAlign((byte *)ptrRawInput + ptrRawInput->Header.Size)); }