Platforms to show: All Mac Windows Linux Cross-Platform

Back to WinHIDMBS class.

WinHIDMBS.Close

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 7.5 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Closes the active connection.

WinHIDMBS.Connect as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 7.5 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Creates a connection to the current device.
Example
Function OpenUSBDevice() As boolean
dim i as Integer
dim h as WinHIDMBS

h=FindDevice // see FindFirst example

if h=nil then
MsgBox "No XYZ device found."
Return false
end if

call h.Connect

if h.Lasterror<>0 then
MsgBox "Failed to connect to USB Device."
Return false
end if

Return true

End Function

Lasterror is set.
Returns true on success and false on failure.

The plugin tries to open a read and a write connection. If both fail, connect returns false. If one is okay, it returns true.

Some devices don't allow read or write because of missing permissions.

WinHIDMBS.DevicePath as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 9.3 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
The internal path used by Windows to identify the device.

Only for debugging.

WinHIDMBS.Disconnect

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 7.5 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Disconnets current USB device.

Lasterror is set.

WinHIDMBS.FindFirstDevice as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 7.5 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Finds the first device and loads the properties.
Example
Function FindDevice() As MyWinHIDMBS
dim h as MyWinHIDMBS
dim p as string

h=new MyWinHIDMBS // your own subclass of MacHIDMBS so you can get events

if h.FindFirstDevice then

p=h.Product
if p="MyProduct" then
Return h
end if

while h.FindNextDevice

p=h.Product
if p="MyProduct" then
Return h
end if

wend

end if
End Function

Returns true on success and false on failure.
On Windows finds only devices which can be opened for Read/Write.

WinHIDMBS.FindNextDevice as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 7.5 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Finds next device.

Returns true on success and false on failure.

WinHIDMBS.GetInputReport(data as MemoryBlock, Offset as Integer = 0, Length as Integer = 0) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 15.0 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Returns an input reports from a top-level collection.

This is very low level.
First byte of data block is report ID.
If Length is 0, we use size of memoryblock.
Returns true on success.

see also:
https://msdn.microsoft.com/en-us/library/windows/hardware/ff538945(v=vs.85).aspx

WinHIDMBS.InstallListener(PollSize as Integer) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 7.8 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Installs a second thread which performs Read.
Example
dim h as new WinHIDMBS

call h.InstallListener 9 // 8 bytes + Report ID

Use PollString or PollMemory in a timer or a loop to get the data.
This is an alternative way compared to ReadMessage functions.

WinHIDMBS.Manufacturer as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 7.5 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
The manufacturer name.

On any error an empty string is returned.
Lasterror is set.

WinHIDMBS.PollMemory as memoryblock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 7.8 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Reads a message from the device.

A connection must be open and InstallListener must be used.
Lasterror is set.
You may want to try this function in a loop or a timer till you get data.

WinHIDMBS.PollString as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 7.8 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Reads a message from the device.
Example
dim m as WinHIDMBS // your WinHIDMBS object
dim s as string

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

A connection must be open and InstallListener must be used.
Lasterror is set.
You may want to try this function in a loop or a timer till you get data.

WinHIDMBS.Product as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 7.5 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
The product string of the selected device.

Lasterror is set.

WinHIDMBS.ProductID as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 7.5 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
The product ID of the selected device.

Lasterror is set.

WinHIDMBS.ReadMessage(length as Integer, timeOut as Integer = 0) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 13.3 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Reads a message from the device.
Example
dim m as WinHIDMBS
dim s as string

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

Length is the length of the receive buffer you want to use.
The string returned is 0 to length bytes long.
A connection must be open.
Lasterror is set.
You may want to try this function in a loop till you get data.
Timeout is a timeout value in milliseconds.

WinHIDMBS.ReadMessageMemory(length as Integer, timeOut as Integer = 0) as memoryblock

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 13.3 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Reads a message from the device.
Example
dim m as WinHIDMBS
dim s as memoryblock

do
s=m.ReadMessageMemory(48)
loop until s<>nil // until we got something
MsgBox midb(s,2) // shows result. First byte is ReportID again

Length is the length of the receive buffer you want to use.
The memoryblock returned has a size of 0 to length bytes.
A connection must be open.
Lasterror is set.
You may want to try this function in a loop till you get data.
Timeout is a timeout value in milliseconds.

WinHIDMBS.SendMessage(data as string) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 7.5 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Sends a message to the USB device.
Example
dim m as WinHIDMBS // your hid object
dim s as string
// 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))

A connection must be open.
Returns number of bytes sent.

The first byte must be the Report ID which seems to be zero for most devices.

WinHIDMBS.SendMessageMemory(data as memoryblock, Offset as Integer = 0, length as Integer = 0) as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 7.5 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Sends a message to the USB device.

A connection must be open.
Lasterror is set.
Returns number of bytes sent.

While writing a crossplatform application we saw the following thing: The data buffer for the SendMessageMemory call must be 8 bytes long on Mac for our device (with MacHIDMBS) and 61 bytes long for Windows (with WinHIDMBS) for our HID device. We have 1 byte for the ReportID and 60 data bytes where the first 8 are set like on the Mac. So if the calls fail on Windows, try with a higher length and check the WinHIDMBS.OutputReportByteLength property.

The first byte must be the Report ID which seems to be zero for most devices.
If length is zero, we use the length of memoryblock.

WinHIDMBS.SerialNumber as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 7.5 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
The serial number of the current selected device.

Lasterror is set.

WinHIDMBS.SetOutputReport(data as MemoryBlock, Offset as Integer = 0, Length as Integer = 0) as boolean

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 15.0 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
Sends an output report.

This is very low level.
First byte of data block is report ID.
If Length is 0, we use size of memoryblock.
Returns true on success.

see also
https://msdn.microsoft.com/en-us/library/windows/hardware/ff539690(v=vs.85).aspx

WinHIDMBS.VendorID as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 7.5 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
The vendor ID of the selected device.

Lasterror is set.

WinHIDMBS.VersionNumber as Integer

Type Topic Plugin Version macOS Windows Linux iOS Targets
method USB MBS USB Plugin 7.5 ❌ No ✅ Yes ❌ No ❌ No Desktop, Console & Web
The device specific version number.

Value can be anything.
On any error, 0 is returned.
Lasterror is set.

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


The biggest plugin in space...