I've been using the below API to get data from my game controllers and it's worked fine up until my new controller arrived, which has more than the 32 buttons the API supports (The Windows Game Controller control panel applet doesn't even show them all!)
Public Declare Function joyGetPosEx Lib "winmm.dll" (ByVal uJoyID As Long, pji As JOYINFOEX) As Long
I have API that can send up to 65 bytes to any USB device given the Vendor/Product IDs
I just need to know what bytes to send it. And I can't find any low level documentation like that
I can't use directinput as this is not a game and must run in the background, still allowing use of the controller to games, and I do not want such a large uneeded dependancy
Public Function ReadAndWriteToDevice(MyVendorID As Long, MyProductID As Long, Optional Byte1 As Byte, Optional Byte2 As Byte, Optional Byte3 As Byte, Optional Byte4 As Byte, Optional Byte5 As Byte, Optional Byte6 As Byte, Optional Byte7 As Byte, Optional Byte8 As Byte, Optional ReadBytes As Long = 8, Optional Timeout_in_msec As Integer = 5000) As Byte()
Dim i As Long
Dim OutputReportData(65) As Byte
Dim InputReportData(65) As Byte
Dim RET() As Byte
OutputReportData(1) = Byte1 ' the code is set up to only send 8 bytes so far but changing it to a max of 65 looks easy
OutputReportData(2) = Byte2
OutputReportData(3) = Byte3
OutputReportData(4) = Byte4
OutputReportData(5) = Byte5
OutputReportData(6) = Byte6
OutputReportData(7) = Byte7
OutputReportData(8) = Byte8
If MyDeviceDetected = False Then
MyDeviceDetected = FindTheHid(MyVendorID, MyProductID)
End If
If MyDeviceDetected Then
Call WriteToHID(OutputReportData)
If ReadFromHID(InputReportData, , Timeout_in_msec, False) = -1 Then Exit Function
End If
If ReadBytes > 64 Or ReadBytes < 1 Then
ReadAndWriteToDevice = InputReportData
Else
ReDim RET(1 To ReadBytes)
For i = 1 To ReadBytes
RET(i) = InputReportData(i)
Next i
ReadAndWriteToDevice = RET 'InputReportData(1)
End If
End Function