06-05-2024, 10:16 PM
The union usage in TYPEs like `RID_DEVICE_INFO` and `RAWMOUSE` are not correct, there's no `_OFFSET` involved. The union represents memory in the struct itself, not a pointer to memory elsewhere. You should probably just declare it as a fixed STRING member (`dummy AS STRING * 250`) where the length of the string the size of the union. Then you can use `_MEM()` on that member and use `_MEMGET` to copy that data at the location of the STRING into a variable of the proper type.
You're correct that `hDevice` in `RAWINPUTDEVICeLIST` should be an `_OFFSET` to correspond with the `HANDLE` type. I would refer to this page on the C types and what they correspond too.
The `RAWHID` and `bRawData` is ok, but just recognize the `TYPE` is not the real size of the data. When you use it you'll have to use `_MEMNEW()` to actually create it, and then you can `_MEMGET` from that memory to read the `RAWHID` header and then the `bRawData` itself (which will go past the end of the `RAWHID` TYPE).
`RAWMOUSE` probably also has padding between the `usFlags` and the union. The union starts with a `ULONG`, which requires 4 byte alignment, but the `USHORT` leaves the struct on a 2-byte boundary, so you need 2 bytes of padding to get proper alignment for the `ULONG`. `ulRawButtons` probably also requires padding before it.
You're correct that `hDevice` in `RAWINPUTDEVICeLIST` should be an `_OFFSET` to correspond with the `HANDLE` type. I would refer to this page on the C types and what they correspond too.
The `RAWHID` and `bRawData` is ok, but just recognize the `TYPE` is not the real size of the data. When you use it you'll have to use `_MEMNEW()` to actually create it, and then you can `_MEMGET` from that memory to read the `RAWHID` header and then the `bRawData` itself (which will go past the end of the `RAWHID` TYPE).
`RAWMOUSE` probably also has padding between the `usFlags` and the union. The union starts with a `ULONG`, which requires 4 byte alignment, but the `USHORT` leaves the struct on a 2-byte boundary, so you need 2 bytes of padding to get proper alignment for the `ULONG`. `ulRawButtons` probably also requires padding before it.