arpruss / USBComposite_stm32f1

USB Composite library for STM32F1 (HID, Serial, MIDI and XBox360 controller)
Other
382 stars 76 forks source link

Hid keyboard extra empty report #78

Open rurigk opened 4 years ago

rurigk commented 4 years ago

I wrote a HIDCustomKeyboard class based on HIDKeyboard

Change the press and release methods to receive the raw keycodes instead of translating the character

The problem I have is that when I do Alt + Tab it should keep the window toggle view until I release the Alt key

Like this: imagen

But instead it doesn't hold up and switch the window immediately

Analyzing the reports I noticed something strange

With my keyboard (which I use every day) I receive 1 report 8 bytes without id

The following image shows two reports corresponding to pressing the A key and then releasing it

imagen

With the HIDKeyboard I receive 2 reports One of 9 bytes with id (1 byte id and 8 from keyboard) And another 9-byte report that is empty

The following image shows four reports, two corresponding to pressing the A key and then releasing it and two with unknown origin imagen

Where do the reports with length 0 come from?

NOTE: I tested this in a new sketch only using the unmodified HIDKeyboard and the ghost report still apears

Setup code

#include <USBComposite.h>

USBCompositeSerial USBCSerial;
USBHID HID;
HIDKeyboard Keyboard(HID);

void setup()
{
    // Clear USB plugins
    USBComposite.clear();
    // Register components
    HID.registerComponent();
    USBCSerial.registerComponent();
    // Start USBComposite
    USBComposite.begin();
    // Wait for USBComposite to be ready
    while(!USBComposite);
}

And i just call

Keyboard.press('a');

Alt Setup code

#include <USBComposite.h>

USBHID HID;
HIDKeyboard Keyboard(HID);

void setup()
{
    // Clear USB plugins
    USBComposite.clear();
    // Register components
    HID.registerComponent();
    // Start USBComposite
    USBComposite.begin();
    // Wait for USBComposite to be ready
    while(!USBComposite);
}

And i just call

Keyboard.press('a');