I work with kids in a computer science club. In a project we juggle with Minecraft and the Lego WeDo System (I wrote a mod for Minecraft that uses a java usb hid api). It works perfect. The next step was to connect the Arduino Leonardo as a hid device. Sending reports to the host (to Minecraft) works fine, but receiving data doesn't work. I copied the hid descriptor from the wedo system:
0x05, 0x01, // USAGE_PAGE (Generic Desktop) 0x09, 0x3b, // USAGE (Byte Count) 0xa1, 0x01, // COLLECTION (Application) 0x85, 0x03, // REPORT_ID (3) 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255) 0x19, 0x10, // USAGE_MINIMUM (Reserved (16)) 0x29, 0x17, // USAGE_MAXIMUM (Reserved(23)) 0x95, 0x08, // REPORT_COUNT (8 Fields) 0x75, 0x08, // REPORT_SIZE (8 Bit) 0x81, 0x02, // INPUT (Data,Var,Abs,Liear,Pref State,Bit) 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x26, 0xff, 0x00, // LOGICAL_MAXIMUM (255) 0x19, 0x18, // USAGE_MINIMUM (Reserved (24)) 0x29, 0x1F, // USAGE_MAXIMUM (Reserved(31)) 0x95, 0x08, // REPORT_COUNT (8 Fields) 0x75, 0x08, // REPORT_SIZE (8 Bit) 0x91,0x02, // OUTPUT (Data,Var,Abs,Liear,Pref State,Bit) 0xC0 // END_COLLECTION
Why do I need a report id=3? If I set it to 2, it doesn't work. If I don't set an id, like Lego does with the WeDo Hub, it doesn't work, too. Is it possible to change the vendor/product id? When I remove usage min and max, it doesn't work. It is obsolete, i think?
In another forum someone posted a hint that two different report ids for input and output could help. It doesn't :(
I think the wrong descriptor is the main reason why I can't send bytes to the Leonardo. The second problem is the missing void WEAK HID_ReceiveReport(u8 id, void* data, int len) in HID.cpp. I started to implement that, the compiling works, but the problem of sending data to the Leonardo is reported on host side already. I use SimpleHIDWrite.exe for testing (always starting Minecraft is time consuming), the error messages come from Windows directly.
Has anyone worked with sending data to an Leonardo successfully? Is there an error in my hid descriptor?