Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

WinHIDMBS class

Type Topic Plugin Version macOS Windows Linux Console & Web iOS
class USB MBS USB Plugin 7.5 No Yes No Yes, Windows only No
Function: A class to work with HID devices on Windows.
Example:
dim m as new WinHIDMBS
dim s as string

#if not TargetWin32
MsgBox "This example requires Windows."
#endif

if m.FindFirstDevice then

do
ListBox1.AddRow ""

ListBox1.Cell(ListBox1.LastIndex,0)=hex(m.ProductID)
ListBox1.Cell(ListBox1.LastIndex,1)=hex(m.VendorID)
ListBox1.cell(ListBox1.LastIndex,2)=m.Product
ListBox1.cell(ListBox1.LastIndex,3)=m.Manufacturer
ListBox1.cell(ListBox1.LastIndex,4)=m.SerialNumber
ListBox1.cell(ListBox1.LastIndex,5)=hex(m.VersionNumber)

if left(m.Product,3)="RF1" then // my test device

if m.Connect then
// write 9 bytes report
// first byte is report ID plus 8 byte data
s=chr(0)+"P"+chr(0)+chr(0)+chr(0)+chr(0)+chr(0)+chr(0)+chr(0)

MsgBox "Send bytes: "+str(m.SendMessage(s))

do
s=m.ReadMessage(17)
loop until lenb(s)>0 // until we got something
MsgBox midb(s,2) // shows result. First byte is ReportID again

m.Disconnect
end if
end if

loop until not m.FindNextDevice

end if

Title=str(ListBox1.ListCount)+" devices found."
Notes:
For newer development, please use our HIDAPIMBS class.

Updated in version 10.4 of plugins to ignore devices which you don't have permissions to access them. So you will now see devices with VendorID=0 and ProductID=0.

This class can be used in three different ways. First normal with Connect and ReadMessage/SendMessage. Second with InstallListener and SendMessage/Poll functions. Third low level via GetInputReport and SetOutputReport.

Feedback, Comments & Corrections

This class has no sub classes.

Some examples which use this class:

Blog Entries


The items on this page are in the following plugins: MBS USB Plugin.


WinGestureInfoMBS   -   WinHTTPClientAutoProxyOptionsMBS




Links
MBS Xojo tutorial videos