Help with HID keyboard commands not working on one device but working on another

Hello,
I'm working on my first Arduino project and have hit a snag. I'm trying to use an Adafruit ItsyBitsy (32u4 chipset) as a USB keyboard emulator to start and stop a digital audio recorder that supports USB keyboards. Part of the keyboard support is starting record via CTL-R and stopping via CTL-S.

I've got the Itsy up and running, and when I plug it into my Mac it is recognized as a keyboard and I can see it's sending the correct keystrokes via the keyboard viewer when I push the appropriate button. When I plug the Itsy into the recorder it doesn't respond when I push the button connected to the Itsy.

I've tried using the standard Keyboard library as well as Nicohood's HID Project library as a boot keyboard with no change in behavior; works on my Mac, not on the recorder.

Im using v1.8.5 of the IDE, all libraries are up to date. The code I'm using is:

#include <Keyboard.h>

const int buttonPin = A0;

void setup() {
  pinMode(buttonPin, INPUT_PULLUP);  
  Keyboard.begin();
}

void loop() {
  if (!digitalRead(buttonPin)) {
    // debounce delay
    delay(100);
    Keyboard.press(KEY_RIGHT_CTRL); // send CTL key
    delay(10);
    Keyboard.press('r'); // send R key
    digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(100);              // wait for half a second
    digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
    Keyboard.releaseAll();
    //Keyboard.release(KEY_RIGHT_CTRL);
    //Keyboard.release('r');
    // Wait for button to go back up
    while (!digitalRead(buttonPin)) { }
  }
}

I've attached two pcaps of the USB bus on my Mac. One is plugging in a keyboard that works with the recorder and then triggering the desired keystrokes, the other with the Arduino. This is my first foray into USB so I'm not sure how to tell if this is an issue of the Arduino not describing itself properly or something else.

The equipment manufacturer won't give me any details on their USB implementation so I'm working blindly. Any assistance would be greatly appreciated!

HID pcaps.zip (2.45 KB)

As another data point I've tried inserting a powered USB hub between the recorder and Itsy to make sure it isn't a power draw issue, but there was no change.

The problem is probably the Arduino Pluggable USB system sends composite USB descriptors (also known as Interface Association descriptors) but a real keyboard sends different, simpler USB descriptors. Modern operating systems can handle composite USB descriptors but older ones cannot. Embedded firmware such as BIOS or firmware inside a recorder may also be confused by composite USB descriptors.

If the pcaps show USB bus traffic you should see the different descriptors. My wireshark does not decode the packets in the pcapng files.

See this message for some work to force a Leonardo (also based on 32u4) to look like a real keyboard.

https://forum.arduino.cc/index.php?topic=545288.msg3717028#msg3717028

If it is too hard, Teensy 3/LC has an option to look like a real keyboard (no composite USB descriptors).

Thank you for your help, but still no go. I downloaded the project from your link, moved the HID folder from usb-metamorph into my libraries folder and recompiled. Same result- computer sees the keypress, recorder doesn't. Here's the code I used:

include <HID.h>

#include <Keyboard.h>

const int buttonPin = A0;

void setup() {
  pinMode(buttonPin, INPUT_PULLUP);  
  Keyboard.begin();
}

void loop() {
  if (!digitalRead(buttonPin)) {
    // debounce delay
    delay(100);
    Keyboard.press(KEY_RIGHT_CTRL); // send CTL key
    delay(10);
    Keyboard.press('r'); // send R key
    digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(100);              // wait for half a second
    digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
    Keyboard.releaseAll();
    //Keyboard.release(KEY_RIGHT_CTRL);
    //Keyboard.release('r');
    // Wait for button to go back up
    while (!digitalRead(buttonPin)) { }
  }
}

I found a USB probe application and I've attached a report.

USB Bus Probe Itsy 3.txt (6.54 KB)

That is not a library so does not belong in your libraries folder. It is an example sketch. The USB probe report reports the 32u4 is still reporting Interface Association descriptors.

I got confused when I read "Move the HID directory/folder to sketchbook/libraries. This version will override the default HID library."

Still getting up to speed, haven't programmed in almost 30 years.

Find your sketch folder. On Linux it is ~/Arduino. In this folder there is one folder per sketch. Add the sketch folder USBSerPassThruLine.

Folder structure after adding USBSerPassThruLine.

~/Arduino
├── libraries
... Lots of stuff not listed
├── USBSerPassThruLine
│   ├── CDC.cpp
│   ├── HID
│   │   ├── HID.cpp
│   │   ├── HID.h
│   │   └── library.properties
│   ├── PluggableUSB.cpp
│   ├── PluggableUSB.h
│   ├── README.md
│   ├── USBCore.cpp
│   ├── USBCore.h
│   ├── USBDesc.h
│   ├── USBSerPassThruLine.ino

Copy the HID folder to the libraries folder.

Folder structure after copying the HID folder to the libraries directory.

~/Arduino
├── libraries
... Lots of stuff not listed
│   ├── HID
│   │   ├── HID.cpp
│   │   ├── HID.h
│   │   └── library.properties
... Lots of stuff not listed
├── USBSerPassThruLine
│   ├── CDC.cpp
│   ├── HID
│   │   ├── HID.cpp
│   │   ├── HID.h
│   │   └── library.properties
│   ├── PluggableUSB.cpp
│   ├── PluggableUSB.h
│   ├── README.md
│   ├── USBCore.cpp
│   ├── USBCore.h
│   ├── USBDesc.h
│   ├── USBSerPassThruLine.ino

Upload USBSerPassThruLine to your 32u4 processor. Check out the USB device descriptors. They should now be close to what a real keyboard sends. You can change the contents of the INO file to do what you want (that is, send ctrl-R and ctrl-S). If you rename the INO file be sure to rename the folder to match.