As of SDK version 1.7.0 and later, the V4 and V4½ support USB HID device mode for connecting to a PC.
The controllers have one USB device port implemented as a USB Type B socket.
After startup, the port is disabled and any connection to a PC or other host will be ignored.
To enable the port, it is necessary to configure the USB properties.
At the end of this document some example initialization code is shown.
The example has the VID/PID identifiers replaced by asterisks. You will have to provide your own registered vendor ID and make up a unused product ID. Also the vendor and product names need to be replaced by proper values. Note how the code passes the controller's serial number on to USB.
The HID device sets up the fastest possible polling interval (1ms). The HID standard limits the allowed packet sizes to 64 bytes even if the controller hardware could support more. We're playing it safe here and stick to 64 bytes.
The example HID report descriptor looks complicated. All this does is telling the PC to expect messages of constant 64 bytes going in both directions. Unfortunately HID does not support variable message lengths.
The example code also enables a special packet mode provided by the Core4 SDK which helps to overcome the fixed message length requirement. More below.
Once the port has been initialized like this, a cable connection to a PC will make the PC detect the controller as a HID device. Typically, a windows machine will briefly display a balloon popup the first time the connection is plugged in. The popup shows the vendor and product strings, so it's a good idea to put something meaningful there.
After initialization, the port is ready for data transfer.
To send data to the host, simply write() it to the handle. When not using the packet mode, then the written data must be exactly the length as specified in the insize parameter or an error will be returned.
When the host sends data to the controller, it can be read() from the device handle. Each read call will return one message. The usual event signalling is also available.
The SDK can buffer a few messages arriving from the host if the application does not read them quickly enough. Once the buffer is full, the controller will stop accepting data from the host until the application reads some messages from the buffer. (Technically, the controller NAKs any further messages until it can accept more.)
For the host side, there is free framework available for download from the web going by the name HIDAPI.