I can't believe I am stumped by this, but this is my issue and I can't see any other solution for this anywhere.
I have an official Arduino Leonardo loaded up with the following code:
void setup() {
Keyboard.begin();
}
void loop() {
char keyToPress = random('A', 'Z'); // choose a random letter between 'A' and 'Z'
delay(1900);
Keyboard.press(keyToPress);
delay(100);
Keyboard.release(keyToPress); // overall loop time is ~2s, with a 100mS keypress length
}
On OSX and Linux, I get a predictable output - random capital letters typed by a keyboard, two seconds apart: FWTDXJP etc.
However, on Windows 7(x64), I get... nothing. I have the Leonardo appear correctly as a CDC COM port, drivers were installed from the latest 1.6.5 installer on their website. I have tried uninstalling the Leonardo in device manager while checking the "remove software" box so as to be sure that the driver I install is the one being used.
Has anyone seen this before? A search of the Arduino forum reveals some people having the same issue, a bit of a discussion and then usually "I don't know what I did but the problem has gone now".
This is the output from USB Device Tree Viewer, which seems to correctly show the USB HID descriptor:
=========================== USB Port2 ===========================
Connection Status : 0x01 (Device is connected)
Port Chain : 1-2
======================== USB Device ========================
+++++++++++++++++ Device Information ++++++++++++++++++
Friendly Name : Arduino Leonardo (COM3)
Device Description : Arduino Leonardo
Device Path : \\?\usb#vid_2341&pid_8036#5&18f54cb7&0&2#{a5dcbf10-6530-11d2-901f-00c04fb951ed}
Device ID : USB\VID_2341&PID_8036\5&18F54CB7&0&2
Driver KeyName : {4d36e978-e325-11ce-bfc1-08002be10318}\0001 (GUID_DEVCLASS_PORTS)
Driver : C:\Windows\system32\DRIVERS\usbser.sys (Version: 6.1.7601.18247 Date: 2013-08-29)
Driver Inf : C:\Windows\inf\oem6.inf
Legacy BusType : PNPBus
Class : Ports
Service : usbser
Enumerator : USB
Location Info : Port_#0002.Hub_#0001
Location IDs : PCIROOT(0)#PCI(0600)#USBROOT(0)#USB(2)
Container ID : {2d5fa232-297c-11e5-9565-080027ccdb00}
Manufacturer Info : Arduino LLC (www.arduino.cc)
Capabilities : 0x84 (Removable, SurpriseRemovalOK)
Address : 2
Problem Code : 0
Power State : D0 (supported: D0, D3, wake from D0)
COM-Port : COM3 (\Device\USBPDO-3)
---------------- Connection Information ---------------
Connection Index : 0x02 (2)
Connection Status : 0x01 (DeviceConnected)
Current Config Value : 0x01
Device Address : 0x02 (2)
Is Hub : 0x00 (no)
Number Of Open Pipes : 0x04 (4)
Device Bus Speed : 0x01 (Full-Speed)
Pipe0ScheduleOffset : 0x04 (4)
Pipe1ScheduleOffset : 0x00 (0)
Pipe2ScheduleOffset : 0x00 (0)
Pipe3ScheduleOffset : 0x00 (0)
------------------ Device Descriptor ------------------
bLength : 0x12 (18 bytes)
bDescriptorType : 0x01 (Device Descriptor)
bcdUSB : 0x200 (USB Version 2.00)
bDeviceClass : 0x02 (Communications and CDC Control)
bDeviceSubClass : 0x00
bDeviceProtocol : 0x00
bMaxPacketSize0 : 0x40 (64 bytes)
idVendor : 0x2341
idProduct : 0x8036
bcdDevice : 0x100
iManufacturer : 0x01 (String Descriptor 1)
Language 0x0409 : "Arduino LLC"
iProduct : 0x02 (String Descriptor 2)
Language 0x0409 : "Arduino Leonardo"
iSerialNumber : 0x00 (No String Descriptor)
bNumConfigurations : 0x01
------------------ String Descriptors -----------------
------ String Descriptor 0 ------
bLength : 0x04 (4 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language ID[0] : 0x0409 (English - United States)
------ String Descriptor 1 ------
bLength : 0x18 (24 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language 0x0409 : "Arduino LLC"
------ String Descriptor 2 ------
bLength : 0x22 (34 bytes)
bDescriptorType : 0x03 (String Descriptor)
Language 0x0409 : "Arduino Leonardo"
-------------- Configuration Descriptor ---------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x02 (Configuration Descriptor)
wTotalLength : 0x0064 (100 bytes)
bNumInterfaces : 0x03
bConfigurationValue : 0x01
iConfiguration : 0x00 (No String Descriptor)
bmAttributes : 0x80
D7: Reserved, set 1 : 0x01
D6: Self Powered : 0x00 (no)
D5: Remote Wakeup : 0x00 (no)
D4..0: Reserved, set 0 : 0x00
MaxPower : 0xFA (500 mA)
------------------- IAD Descriptor --------------------
bLength : 0x08 (8 bytes)
bDescriptorType : 0x0B
bFirstInterface : 0x00
bInterfaceCount : 0x02
bFunctionClass : 0x02 (Communications and CDC Control)
bFunctionSubClass : 0x02
bFunctionProtocol : 0x01
iFunction : 0x00 (No String Descriptor)
---------------- Interface Descriptor -----------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x04 (Interface Descriptor)
bInterfaceNumber : 0x00
bAlternateSetting : 0x00
bNumEndpoints : 0x01 (1 Endpoint)
bInterfaceClass : 0x02 (Communications and CDC Control)
bInterfaceSubClass : 0x02
bInterfaceProtocol : 0x00
iInterface : 0x00 (No String Descriptor)
-------------- CDC Interface Descriptor ---------------
bFunctionLength : 0x05 (5 bytes)
bDescriptorType : 0x24 (Interface)
bDescriptorSubType : 0x00 (Header Functional Descriptor)
bcdCDC : 0x110 (CDC Version 1.10)
-------------- CDC Interface Descriptor ---------------
bFunctionLength : 0x05 (5 bytes)
bDescriptorType : 0x24 (Interface)
bDescriptorSubType : 0x01 (Call Management Functional Descriptor)
bmCapabilities : 0x01
bDataInterface : 0x01
-------------- CDC Interface Descriptor ---------------
bFunctionLength : 0x04 (4 bytes)
bDescriptorType : 0x24 (Interface)
bDescriptorSubType : 0x02 (Abstract Control Management Functional Descriptor)
bmCapabilities : 0x06
-------------- CDC Interface Descriptor ---------------
bFunctionLength : 0x05 (5 bytes)
bDescriptorType : 0x24 (Interface)
bDescriptorSubType : 0x06 (Union Functional Descriptor)
bControlInterface : 0x00
bSubordinateInterface[0] : 0x01
----------------- Endpoint Descriptor -----------------
bLength : 0x07 (7 bytes)
bDescriptorType : 0x05 (Endpoint Descriptor)
bEndpointAddress : 0x81 (Direction=IN EndpointID=1)
bmAttributes : 0x03 (TransferType=Interrupt)
wMaxPacketSize : 0x0010 (16 bytes) (16 bytes)
bInterval : 0x40 (64 ms)
---------------- Interface Descriptor -----------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x04 (Interface Descriptor)
bInterfaceNumber : 0x01
bAlternateSetting : 0x00
bNumEndpoints : 0x02 (2 Endpoints)
bInterfaceClass : 0x0A (CDC-Data)
bInterfaceSubClass : 0x00
bInterfaceProtocol : 0x00
iInterface : 0x00 (No String Descriptor)
----------------- Endpoint Descriptor -----------------
bLength : 0x07 (7 bytes)
bDescriptorType : 0x05 (Endpoint Descriptor)
bEndpointAddress : 0x02 (Direction=OUT EndpointID=2)
bmAttributes : 0x02 (TransferType=Bulk)
wMaxPacketSize : 0x0040 (64 bytes) (64 bytes)
bInterval : 0x00 (ignored)
----------------- Endpoint Descriptor -----------------
bLength : 0x07 (7 bytes)
bDescriptorType : 0x05 (Endpoint Descriptor)
bEndpointAddress : 0x83 (Direction=IN EndpointID=3)
bmAttributes : 0x02 (TransferType=Bulk)
wMaxPacketSize : 0x0040 (64 bytes) (64 bytes)
bInterval : 0x00 (ignored)
---------------- Interface Descriptor -----------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x04 (Interface Descriptor)
bInterfaceNumber : 0x02
bAlternateSetting : 0x00
bNumEndpoints : 0x01 (1 Endpoint)
bInterfaceClass : 0x03 (HID - Human Interface Device)
bInterfaceSubClass : 0x00 (None)
bInterfaceProtocol : 0x00 (None)
iInterface : 0x00 (No String Descriptor)
------------------- HID Descriptor --------------------
bLength : 0x09 (9 bytes)
bDescriptorType : 0x21 (HID Descriptor)
bcdHID : 0x0101 (HID Version 1.01)
bCountryCode : 0x00 (00 = not localized)
bNumDescriptors : 0x01
Descriptor 1:
bDescriptorType : 0x22 (Class=Report)
wDescriptorLength : 0x0065 (101 bytes)
05 01 Usage Page (Generic Desktop Controls)
09 02 Usage (Mouse)
A1 01 Collection (Application)
09 01 Usage (Pointer)
A1 00 Collection (Physical)
85 01 Report ID (0x01)
05 09 Usage Page (Buttons)
19 01 Usage Minimum (1)
29 03 Usage Maximum (3)
15 00 Logical Minimum (0)
25 01 Logical Maximum (1)
95 03 Report Count (3)
75 01 Report Size (1)
81 02 Input (Var)
95 01 Report Count (1)
75 05 Report Size (5)
81 03 Input (Const, Var)
05 01 Usage Page (Generic Desktop Controls)
09 30 Usage (Direction-X)
09 31 Usage (Direction-Y)
09 38 Usage (Wheel)
15 81 Logical Minimum (-127)
25 7F Logical Maximum (127)
75 08 Report Size (8)
95 03 Report Count (3)
81 06 Input (Var, Rel)
C0 End Collection
C0 End Collection
05 01 Usage Page (Generic Desktop Controls)
09 06 Usage (Keyboard)
A1 01 Collection (Application)
85 02 Report ID (0x02)
05 07 Usage Page (Keyboard)
19 E0 Usage Minimum (-32)
29 E7 Usage Maximum (-25)
15 00 Logical Minimum (0)
25 01 Logical Maximum (1)
75 01 Report Size (1)
95 08 Report Count (8)
81 02 Input (Var)
95 01 Report Count (1)
75 08 Report Size (8)
81 03 Input (Const, Var)
95 06 Report Count (6)
75 08 Report Size (8)
15 00 Logical Minimum (0)
25 65 Logical Maximum (101)
05 07 Usage Page (Keyboard)
19 00 Usage Minimum (0)
29 65 Usage Maximum (101)
81 00 Input ()
C0 End Collection
----------------- Endpoint Descriptor -----------------
bLength : 0x07 (7 bytes)
bDescriptorType : 0x05 (Endpoint Descriptor)
bEndpointAddress : 0x84 (Direction=IN EndpointID=4)
bmAttributes : 0x03 (TransferType=Interrupt)
wMaxPacketSize : 0x0040 (64 bytes) (64 bytes)
bInterval : 0x01 (1 ms)
And this is a screenshot from Device Manager, showing just one HID device (my keyboard / trackpad on my laptop):
Any ideas? I have obviously tried the example USB keyboard code from the Arduino IDE too - my code was just to get a minimum system to simplify testing. All help gratefully received.