Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
APIs from QB64PE and parameters defined As Any and unions of types ?
#23
(06-06-2024, 06:51 PM)SpriggsySpriggs Wrote: Oh I just had a thought. Since you are calling GetRawInputData with a zero for that pData field, you are grabbing the size that you need for the struct. That's how we figure it out for the keyboards! If the returned dwSize is equal to RAWINPUT containing RAWMOUSE, then you know it should be a mouse call. Therefore, you need to make a second RAWINPUT type, maybe RAWINPUT_K and make that one contain RAWINPUTHEADER and RAWKEYBOARD. Then you'd do the rest the same way except you'd be using the keyboard's type.
Maybe something like this:
Code: (Select All)

Type RAWINPUT
    As RAWINPUTHEADER header
    As RAWMOUSE mouse
End Type

Type RAWINPUT_K
    As RAWINPUTHEADER header
    As RAWKEYBOARD keyboard
End Type
'.......
'.......
GetRawInputData lParam, RID_INPUT, 0, Offset(dwSize), Len(rih)

' KEYBOARD VERSION:
'GetRawInputData(CBLPARAM, %RID_INPUT, BYVAL %NULL, ByteCount, SIZEOF(RAWINPUTHEADER)) 'Get size of raw input buffer
Dim As RAWINPUT raw
Dim As RAWINPUT_K rawk
lpb = MemNew(dwSize)
If lpb.SIZE = 0 Then
    MainWndProc = 0
    Exit Function
End If

If GetRawInputData(lParam, RID_INPUT, lpb.OFFSET, Offset(dwSize), Len(rih)) <> dwSize Then
    Print "GetRawInputData doesn't return correct size!"
End If
Select Case dwSize
    Case Len(raw)
        MemGet lpb, lpb.OFFSET, raw
    Case Len(rawk)
        MemGet lpb, lpb.OFFSET, rawk
End Select

Don't paste that code as-is. It's just an idea for you to expand upon. However, I think it will get you closer. You'll need to do a lot more work but it might be a solution. Maybe. ¯\_(ツ)_/¯

Hmm, makes sense, could work? 
I will look into that when back at my PC. 
Thank you sir!
Reply


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



Users browsing this thread: 8 Guest(s)