Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support to read and print keystrokes. #46

Open
mayur-rajput opened this issue Oct 2, 2023 · 1 comment
Open

add support to read and print keystrokes. #46

mayur-rajput opened this issue Oct 2, 2023 · 1 comment

Comments

@mayur-rajput
Copy link

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

@tobozo
Copy link
Owner

tobozo commented Oct 2, 2023

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 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants