Skip to main content

USB

All DUELink modules include USB support. A few boards have a built-in USB connector, but others need an adapter like USB Hook or USB Stick.

USB Connection

USB on DUELink module is configured in standard CDC class, making these modules show up as virtual serial port to the connected Hardware.

No drivers are necessary on any modern Windows, Linux, Android or Mac operating systems. These systems use a Host Language to command a Daisylink of modules.

USB Android

USB is also first choice with the Console and Demo Website.


HID Interface

The USB connection presents itself as CDC (Virtual Serial) Class, but it also includes HID (Human Interface Device) Class. A connected computer/phone will see Serial+Keyboard+Mouse devices on the same USB cable (composite device), no matter what OS is being used.

The virtual serial interface is used to communicate with the engine. This works just like all other interfaces.

Through the HID interface, a connected OS will receive "keyboard keystrokes" and "mouse movements, thanks to the Hid(type, [data]) function. type is 1: Keyboard - 2: mouse. The [data] array depends on the device type.

Type Mouse:

DataUse
Byte 0Buttons (bitmask: Left=1, Right=2, Middle=4)
Byte 1-2X movement (signed int16)
Byte 3-4Y movement (signed int16)
Byte 5Wheel (signed int8)
Byte 6Pan (signed int8)

Type Keyboard:

DataUse
Byte 0Modifier keys (e.g., Ctrl, Shift)
Byte 1Reserved (always 0)
Bytes 2-7Keycodes for up to 6 simultaneous key presses
Modifier keyValue
Left Ctrl0x01
Left Shift0x02
Left Alt0x04
Left GUI0x08
Right Ctrl0x10
Right Shift0x20
Right Alt0x40
Right GUI0x80

USB Keyboard keycodes are found in the USB Specifications https://usb.org/sites/default/files/hut1_21.pdf and in many other places online, like https://gist.github.com/MightyPork/6da26e382a7ad91b5496ee55fdc73db2.

For example, the codes for 'G', 'H' and 'I' are 0x0A, 0x0B, and 0x0C respectively.

This is an example that reads touch pads on a DUELink module and then send their status as keyboard arrows key presses.

Asio(1) # Enable Asynchronous Commands
dim b1[8] # keyboard need 8 bytes for one report

_p = 0 # press status
_s = 0 # backup status

while (1)
if (TouchUp())
b1[2] = 0x52
_p = 1
end
if (TouchDown())
b1[2] = 0x51
_p = 1
end
if (TouchLeft())
b1[2] = 0x50
_p = 1
end
if (TouchRight())
b1[2] = 0x4F
_p = 1
end
if _p != _s
if _p = 1
hid(1,b1) # send key
else
hid(1,[0,0,0,0,0,0,0,0]) # release
end
_s = _p
end
_p = 0 # reset press status
wend

Linux Support

USB presents itself as a virtual USB-Serial port. Linux requires permissions to allow access to these ports. Further notes and example script are on the UART interface page.