[video] How does a USB keyboard work?

davkol

05 Jun 2021, 16:49

Not mine, here's a Ben Eater's video How does a USB keyboard work? that covers the basic communication.

Findecanor

05 Jun 2021, 18:04

I thought the low-level USB protocol had more framing than it actually does.

User avatar
Sheepless

05 Jun 2021, 23:25

Ah, it's a followup to his "how does PS/2 work" video. Both videos are fun. Note that this one only covers the keyboard in boot protocol mode.

Findecanor

06 Jun 2021, 15:03

Yeah, most keyboards use the same protocol outside boot mode too.
Low-speed USB is limited to 8-byte reports anyway so for those keyboards there is not much of a point to use anything else.

... Except for one weird thing: The protocol has an empty byte in the report for no reason. It could have been 7KRO, or had a bitfield for WASD and four other keys or something else entirely.
There is a detail in the example Report Descriptor example in the HID spec that looks suspicious: INPUT and OUTPUT fields can be interleaved in the descriptor, even though they are different reports.
The declaration for the outgoing LED report is right there in the position for the empty byte.
That makes me believe that perhaps in an early unreleased revision of the USB protocol, endpoints had been bi-directional instead of unidirectional like they are now: that in-going and out-going bytes could have been interleaved within the same Data packet.

Post Reply

Return to “Workshop”