How does a USB keyboard work?
Video Statistics and Information
Channel: Ben Eater
Views: 575,711
Rating: 4.9851561 out of 5
Keywords:
Id: wdgULBpRoXk
Channel Id: undefined
Length: 34min 15sec (2055 seconds)
Published: Sat Jun 05 2021
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
A good way to see how a USB keyboard works is to look at the QMK source code. It is the firmware used by people who build their own mechanical keyboards, runs on a variety of boards like Arduino's with the 32u4 chip, STM32s, teensy's, etc
https://github.com/qmk/qmk_firmware
Seconding all the comments that USB is brutal. Last time I tried to write my own keyboard firmware, I was trying to use no external dependences-- so, no LUFA or whatever. Implementing everything manually according to the spec. It was SO INVOLVED and I still don't know if I did everything correctly or if there were weird edge cases where the whole thing would go to hell.
I'm building a new keyboard now and just using QMK. Screw doing that USB stuff again.
God the USB stack is such a pain in the ass. Sure you can sort of sum up a simple HID device like keyboard into a 40 minute video, but it still beings back the PTSD of looking into all the descriptors and intricacies of other non-HID crap in college. USB is convenient, but I'm never dealing with it at a low level again if I can help it. And the hardware and firmware for USB-C connectors is a nightmare now, at least USB A you could solder it through-hole or surface mount by hand.
When I watched this video this morning it struck me how in some aspects of both hardware and software we've come full circle in about 40 years from polling to event-driven and now back to polling again.
His videos are always awesome.
Damn, that was fascinating. I never had 30 minutes pass by so quickly.
I absolutely love his videos. The explanation was easy to follow and for once, USB makes sense.
I always wondered how 'complicated' a USB keyboard is. I'm sure there's non keyboard stuff he skipped over regarding USB but this video was really good and I got a lot out of it.
Maybe I missed it but it seemed like there's no 'let go' signal? It strictly list the 6 + modifier keys that can be held down and if it isn't listed it isn't pressed?
Maybe it's me but I prefer that over 'events' that give me a per key down/press/up. Just give me a list of whats held down and I'll handle the rest
holy crap, this is way cool to learn. I'll never ever need to know this, but this brings back memories of my CompE class work.