This `_WmInput` function prints raw data. Tested with a joystick.
Add this line to the `api` class:
Example output:
The data depends on device and probably is undocumented, unless it is a well-known standard device (but I don't know where it's documented). For example, when testing with a joystick, some bytes are different depending on button and axis values.
unsafe void _WmInput(nint wParam, nint lParam) {
//print.it("WM_INPUT");
//get header
int headerSize = sizeof(api.RAWINPUTHEADER), size = headerSize;
api.RAWINPUTHEADER rih = default;
if (api.GetRawInputData(lParam, api.RID_HEADER, &rih, ref size, headerSize) <= 0) return;
//print.it(rih.dwType); //0 mouse, 1 keyboard, 2 other
if (rih.dwType != 2) return;
//get data
var b = stackalloc byte[size = rih.dwSize];
if (api.GetRawInputData(lParam, api.RID_INPUT, b, ref size, headerSize) <= 0) return;
ref api.RAWINPUT raw = ref *(api.RAWINPUT*)b;
//but I don't know how to read the data for non-keyboard/mouse devices. It depends on device. Ask AI.
//print raw data
print.it(raw.data.hid.dwCount, raw.data.hid.dwSizeHid);
var data = raw.data.hid.bRawData.AsSpan(raw.data.hid.dwSizeHid);
print.it(data, 8);
print.it($"Joystick button: {data[49]}. Values of axis X and Y: {BitConverter.ToUInt32(data[1..])} {BitConverter.ToUInt32(data[5..])}.");
}Add this line to the `api` class:
internal const uint RID_HEADER = 0x10000005;Example output:
1, 65
01 00 40 00 00 00 40 00 ..@...@.
00 00 40 00 00 01 00 00 ..@.....
00 00 00 00 00 00 00 00 ........
00 00 00 00 00 00 00 00 ........
00 00 00 00 00 00 00 00 ........
00 68 30 F9 40 06 02 00 .h0.@...
00 00 00 00 00 00 00 00 ........
00 00 00 00 00 00 00 00 ........
00 .The data depends on device and probably is undocumented, unless it is a well-known standard device (but I don't know where it's documented). For example, when testing with a joystick, some bytes are different depending on button and axis values.
