ESP32-USB-Soft-Host icon indicating copy to clipboard operation
ESP32-USB-Soft-Host copied to clipboard

add support to read and print keystrokes.

Open mayur-rajput opened this issue 2 years ago • 1 comments

hello, it would be more helpful if you can add support for usb keyboard to read and serial print the keystroke.

mayur-rajput avatar Oct 02 '23 07:10 mayur-rajput

hi,

please refer to the keyboard parser in M5Stack_Grey_USB_Test, where usbkbd.h implements a basic qwerty layout, and kbdparser.h handles the parsing events.

just copy usbkbd.h and kbdparser.h files to your sketch folder

you can keep usbkbd.h unchanged, but you will have to edit kbdparser.h (e.g. remove all tft.* statements), and replace the callback function in your sketch:

KbdRptParser Prs;

// keyboard data parser to pass to the USB driver as a callback
static void my_USB_PrintCB(uint8_t usbNum, uint8_t byte_depth, uint8_t* data, uint8_t data_len)
{
  Prs.Parse( usbNum, data_len, data );
}

if you feel like such example sketch will be helpful, feel free to submit a pull request :wink:

tobozo avatar Oct 02 '23 08:10 tobozo