Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
APIs from QB64PE and parameters defined As Any and unions of types ?
#18
(06-06-2024, 02:09 PM)DSMan195276 Wrote:
(06-06-2024, 03:15 AM)madscijr Wrote: I don't see any of the UNIONed type being hidden in _OFFSET, or any "padding" or MEMGET or any of that stuff happening to access the members of that type. 

I don't see any of that funny stuff, but it still works. How? Why?
Well that has a lot to do with what you're trying to do with these APIs. The APIs can return any of RAWMOUSE, RAWHID, and RAWKEYBOARD responses, that's the purpose of the union. If you only care about the RAWMOUSE ones (that's the case for the program you posted), then you can ignore the `union` and just pretend it's a `RAWMOUSE` struct (since that's the only one of the union members you would use anyway). If you want to be able to process all three of RAWMOUSE, RAWHID, and RAWKEYBOARD then the union issues come into play.

Also, the code does having padding inserted, that's the `Aiignment` members in the TYPEs `RAWINPUTDEVICELIST`, `PAINTSTRUCT`, and `RAWMOUSE` have padding added (though I'm not entirely sure `RAWMOUSE` is correct, I think that padding is also needed for 32-bit).
Hmm, ok. Maybe I can fudge it to not need the unions, because I really don't want to have to get into the low-level MEM stuff. That stuff is WAY too low-level for me. All I know is the mouse API routines work, and I was able to get the mouse stuff working. If I can limp across the finish line with the rest of the API functions for keyboard, I'm good!
Reply


Messages In This Thread
RE: APIs from QB64PE and parameters defined As Any and unions of types ? - by madscijr - 06-06-2024, 02:47 PM



Users browsing this thread: 1 Guest(s)