EspTinyUSB icon indicating copy to clipboard operation
EspTinyUSB copied to clipboard

HIDcomposite key repeat issue with Raspberry Pi

Open jokkebk opened this issue 2 years ago • 1 comments

I was trying to use EspTinyUSB library based device with a fresh Raspberry Pi OS install (64 bit, RaspPi4 HW) and turns out the sent keys get "stuck", i.e. device.sendKey(HID_KEY_A); results in aaaaaaaaaaaaaaaaaaaaaa... instead of a single letter.

Sample code to reproduce:

#include "hidcomposite.h"

HIDcomposite device;

void setup() { 
    device.begin();
}

void loop() {
    device.sendKey(HID_KEY_A);
    delay(1000);
}

I assumed it might related to how Linux handles key repeat and release delays vs. Windows (and it could be), but what is strange, that using HIDkeyboard instead of a composite device works just fine. Could there be some difference that causes the sendPress to fail with a composite device, or sendRelease not succeeding?

My knowledge of the raw HID reports is rusty & largely missing, but happy to investigate further, if there are any pointers what to check first (relying on single led and no serial ATM).

jokkebk avatar Mar 28 '22 17:03 jokkebk

Yes, it may be the problem with timing. I am suggesting to play with last parameter in this line: https://github.com/chegewara/EspTinyUSB/blob/master/src/device/hid/hidkeyboard.cpp#L16 and delay in this line (delay should be longer than the other param): https://github.com/chegewara/EspTinyUSB/blob/master/src/device/hid/hidkeyboard.cpp#L34

PS usually first line parameter should be 10, but i decided to make it 1 to let faster sending keys

chegewara avatar Mar 28 '22 17:03 chegewara