0
\$\begingroup\$

First off, I am really confused whether this question should be on this site or stack overflow. Please go easy if this is not the good choice.

I am going through the tutorial to make a simple HID device with the help of Arduino through a tutorial on inscrutable. The maker creates a 8 byte buffer. Then he stores the key-code for (a,s,w,d) into the second byte of the keyboard buffer. Out of curiosity, I started searching what is stored in the remaining bytes. I still have not found what I am exactly searching for. Any links for this would be helpful.

I found this video on youtube where it is mentioned that the first byte is used as modifier byte, 2nd byte is reserved and remaining 6 bytes are used for key presses. 6 bytes = 48 bits and there are 2^48 possible combinations. And I have less that 200 keys in my laptop keyboard. What is the point behind this? I am missing something here but what exactly?

Thank you!!!

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Please don't use youtube links for key parts of your question. Really questions are supposed to stand on their own without critical reliance on external links (which may only supplement), but in terms of external links, videos are a truly terrible choice. \$\endgroup\$ Sep 4 '20 at 16:44
  • \$\begingroup\$ Why don't you talk about what you are looking to achieve? I certainly am not interested in diagnosing or explaining a video to you, even assuming I might understand it (which I may not.) I can't debate the video, I can't argue with it, I can't ask it questions. It just sits there. Like a wall. Kind of a pointless activity, really. So what do you really want to do? \$\endgroup\$
    – jonk
    Sep 4 '20 at 18:29
1
\$\begingroup\$

The 6 bytes can contain codes for 6 keys, and this is why standard USB HID keyboards have a limit of being capable of reporting only up to 6 pressed keys at once. Each keycode is one byte.

\$\endgroup\$
11
  • \$\begingroup\$ I tried pressing 7 keys at once but they are not "simultaneous" i guess. All of them are being typed. \$\endgroup\$
    – G-aura-V
    Sep 4 '20 at 16:55
  • \$\begingroup\$ Technically the intent was that this 6-key limitation would apply only in a simplified "boot" mode understandable by a minimally USB-aware BIOS, and that there would be another mode that could report an arbitrary combination of keys which would be used once a full operating system was up. In practice only the boot mode may be implemented, especially on an Arduino project... \$\endgroup\$ Sep 4 '20 at 16:57
  • \$\begingroup\$ @Justme, I wonder why they didn't represent a single key-press with single bit. \$\endgroup\$
    – G-aura-V
    Sep 4 '20 at 17:02
  • \$\begingroup\$ @ChrisStratton the buffer is still 8 bytes in "another mode". How can it represent more than 6 keys? \$\endgroup\$
    – G-aura-V
    Sep 4 '20 at 17:03
  • 1
    \$\begingroup\$ Presumably by sending make/break events against cumulative state. These 6 keys are down. And also these. And oh, that one is now up... As for the real world, if there's an issue with actually building it, then it wouldn't be the first time a spec was written without actually doing a practical implementation of the idea as a test. \$\endgroup\$ Sep 4 '20 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.