06-06-2024, 06:51 PM
(This post was last modified: 06-06-2024, 07:01 PM by SpriggsySpriggs.)
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:
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. ¯\_(ツ)_/¯
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. ¯\_(ツ)_/¯
Tread on those who tread on you