Hacker News Comments on
How does a USB keyboard work?
Hacker News Stories and CommentsAll the comments and stories posted to Hacker News that reference this video.
Ben Eater has some videos showing the USB protocol on an oscilloscope.
And some videos on using chips and breadboards to meet protocols- https://www.youtube.com/watch?v=l7rce6IQDWs
And a digital protocol too- https://www.youtube.com/watch?v=MCi7dCBhVpQ
⬐ bri3dWith existing USB devices you don't usually need to go nearly this low level to reverse engineer them - just enumerating the endpoints and then using Wireshark and USB packet capture is plenty sufficient.
Understanding how the USB wire protocol works is definitely valuable knowledge in some arenas, but not at all important for the kind of reverse engineering task OP is trying to perform, as they can generally speaking trust the electrical layer is standard and only need to operate at a level above it.
Same for the "write 3 bytes to a USB device" hypothetical from upthread - electrical understanding of USB is interesting but ultimately unimportant if you're using an existing USB stack - higher level knowledge of USB endpoint types and transport mechanisms is the name of the game there.
If I were given this task and I had to produce a driver with source code (rather than just get things working), I'd start with a combination of USB sniffing and static decompilation (Ghidra/IDA) of the Canon binaries, followed by perhaps some dynamic analysis (logging shims) if things turned out very complex.
If I just had to get things working, I'd just use one of the many approaches to mix 32/64-bit userland binaries in order to shim the 32 bit Canon binaries into a 64-bit CUPS driver.
⬐ HPsquaredIs there anything like this on how optical mice work? It'd be interesting to see how the sensor and algorithm works.⬐ zargon⬐ proto_lambdaA USB mouse just sends x/y distance traveled over USB HID protocol. All the details are integrated into silicon. The sensor is a camera and the processor diffs the images to calculate the distance. To learn about the algorithms for that you could look into patents by Avago or PixArt.⬐ dangrie158⬐ raszLook into HP patents around 1990-99 on optical paper sensors. Afaik mouse sensor came from research into large format plotter paper tracking.
US Patent 5,729,008. Interview with inventor: Oral History of Travis Blalock https://www.youtube.com/watch?v=wmqa9XJED-Q https://archive.computerhistory.org/resources/access/text/20...
"each array element had nearest neighbor connectivity so you would calculate nine correlations, an autocorrelation and eight cross-correlations, with each of your eight nearest neighbors, the diagonals and the perpendicular, and then you could interpolate in correlation space where the best fit was. "
all in analog domain
another one from HP/Agilent/Avago: Oral History of Gary Gordon https://www.youtube.com/watch?v=TxxoWhCzIeUBen Eater makes amazing educational videos, unfortunately he's been MIA for half a year now. His patreon sneakily got updated from a "per video" to a "per month" payment model a couple months ago (this has since been reverted) and I cancelled my membership after I didn't get any explanation for over a week, and there have been no other signs of life as far as I know.⬐ protoster⬐ seanalltogetherI'd give Ben the benefit of the doubt and assume it was a mistake since up to that point he has been a class act.
As for the radio silence, I'm afraid that this could be something bad. I've seen other examples of creators doing great work who are seemingly impossible to dislike, and STILL receive harassment to a point of not wanting to continue (e.g. Handmade Hero)⬐ stagger87⬐ cmeacham98> I've seen other examples of creators doing great work who are seemingly impossible to dislike, and STILL receive harassment to a point of not wanting to continue (e.g. Handmade Hero)
Are you saying that Casey Muratori is "seemingly impossible to dislike"? Isn't he still doing HH?⬐ bergentyWhat kind of harassment did Casey receive? Was it if the “this is stupid because he’s not using an engine variety”?⬐ protoster⬐ OJFordHe didn't go into details of harassment when speaking about it, which is understandable, except that it was about things he said on stream.Well, nevermind anything nefarious, life can throw unexpected things in the mix too. This Old Tony was similarly away for a while recently (now back) after a family member died. I imagine it only gets more difficult to return too, once people notice and maybe you see them asking in comments, on Reddit or HN, etc. 'where' you've gone, and start to feel some need to not only return but explain your absence.
I check occasionally for new videos, I enjoy them and hope there's more to come, but I don't need to know 'why', it's none of my business, and he doesn't owe me anything. (I'm not a Patreon supporter, that apparent change is a bit different of course, perhaps just a mistake as you said.)⬐ protosterAll I want is a simple "channel on hiatus for personal reasons" post somewhere.⬐ martinmunkDef. agree on this one.
I'm reminded of the closure viewers of the YouTuber Bosnian Bill got about his disappearance, by Lock Picking Lawyer doing an explanation video: https://www.youtube.com/watch?v=7ASQQboFg98
But I do also understand not all creators have a relationship with another creator which as much overlap of audience that it is possible.I'm very surprised Patreon would let a creator switch that without asking for existing patron's consent, it seems ripe for abuse and borderline illegal.⬐ judge2020⬐ HandytingeThey hope their creators will inform them it seems, although maybe there is a patreon-initiated email informing backers when they make this change (I just can't find any evidence of it).
> Letting your patrons know about billing changes in advance is most important when switching from per creation to another option. Patrons may want to upgrade their subscription if they know that their pledged amount will be x 1. Say Patron F is at your $5 tier with a monthly max of 2 creations per month. When you switch to monthly, their subscription amount defaults to $5 a month -- they may want to increase to $10 a month to account for the change.⬐ cmeacham98IANAL, but this still looks very suspicious to me. Agreeing to pay someone $5/month is not the same as agreeing to pay them $5/video (or vice versa). Charging me for something I never authorized is a form of fraud, no?⬐ xeromalI'm sure the ability to do so is buried in 50 pages of terms of service.⬐ cmeacham98Terms of Service don't override the law or CC networks' rules.⬐ lozengeIf their class action waiver holds, that's fairly irrelevant.He was around for sure in Feb, I was emailing him and he replied.⬐ VBprogrammerYeah, I'd wondered what he's up to. At the same time, people have their own lives and sometimes shit happens. Changing the terms for existing patrons though does sound slightly shady. I'm surprised that is allowed without some kind of confirmation on the platform.⬐ judge2020I believe Patreon sends backers an email, however it doesn't require a confirmation from every patron to continue supporting.Are there any tools on mac that shows how much bandwidth is being used on a usb/thunderbolt port? I've always suspected that I'm saturating the connection from laptop to hub but don't have a definitive way of knowing for sure. When I move my second monitor off the hub and plug directly into a different usb port on my laptop I seem to have less problems.⬐ LaputanMachineCL!ng may be what you're looking for . The app is available in the App Store, but I have not tested it.⬐ mikequinlanYou can use a cable like this https://www.amazon.com/Wiredge-Display-Charging-Braided-Comp...
Note I am not recommending this specific cable; it is just the first one that showed up in my search.⬐ akelly⬐ MrLeapThat cable only shows power draw not bandwidth. And I'm not aware of a cable that does show bandwidth.Wireshark has usb tools, might be derivable.
If you're interested, here's a really comprehensive video on how USB keyboards work which may answer your question: https://youtu.be/wdgULBpRoXk
⬐ vlmutoloWow, that was an absolutely incredible breakdown. Didn't expect to watch a 30min video on the USB protocol tonight.
Really didn't expect to suddenly want an oscilloscope.⬐ SxC97Ben Eater has one of the best channels on YouTube! If you haven’t already, check out his 8 bit bread board computer series. He explains how to make a computer, completely from scratch. Coming from the software world, I found this to be absolutely fascinating!⬐ phibzAny idea why Ben hasn't posted in a while?
I'm sorry but serious question, why would you need a high-speed for a keyboard? A usb packet for a keystroke is roughly 180 bits (I'm estimating from glancing at https://youtu.be/wdgULBpRoXk?t=1390). So 1.5 Mbit/s low speed could roughtly handle over 8,000 keystrokes per second. Do you really need more keystrokes or finer resolution than that?
⬐ StillBored"I have a couple devices that might be nice if they had keyboards but don't support USB1 low/full speed. "
Its not about the keyboard, its about the host not supporting USB1 speeds or TTs.
About the USB keyboard, that may be true only for the cheapest keyboard you could find, but basically not applicable anymore nowadays. Rather than giving you the details, let me link to this video, which is awesome at explaining it and much more -- the USB vs PS/2 part starts here: https://www.youtube.com/watch?v=wdgULBpRoXk&t=1766s
Ben Eater has a good video on this:
> Embedded programming? Dealing with signals?! God forbid, man.
"How does a USB keyboard work? by Ben Eater:
I'd imagine it would be very difficult, and would require a relatively powerful MCU. Ben Eater's made a few videos discussing how PS/2 and USB keyboards work. USB's a vastly more complicated protocol compared to PS/2.
⬐ userbinatorYou only need a bare minimum host controller (USB 1.1) to accept a keyboard, and hardcode everything in the firmware to assume one. A suitable MCU is pretty cheap:
Looks like someone already made (at least the source) for an adapter based around that MCU family available:
As for relative lack of availability, I think that says more about how many people want to use an old keyboard with a new computer (semi-common) vs. a new keyboard with an old computer (rare).⬐ RJIb8RBYxzAMX9uFrom your link:
> The CH554 is a microcontroller with an E8051 core with a 24 MHz clock, a little more than 1 kB of RAM, and a bit more than 14 kB split between the code and data Flash.
I think that qualifies as "relatively powerful" when compared to a Z80 or 6502. :-)
I do agree that the lack of such adapters is due to zero market demand though.
Apparently  PS/2 limited by a slower data rate than USB 2.0 which cancels out almost all the advantage of its lower initial latency to begin the transmission, making them both about equally capable in actual latency - at least in theory.
Even if this conclusion is wrong, that video is a very pleasant and understandable explanation of the USB protocol.
⬐ kitsunesobaI wonder how much CPU load changes the equation. I've experienced USB input locking up or stuttering as a result of high CPU load, which presumably wouldn't happen with PS/2.
There’s a great video here that goes through all this - the gist is that USB keyboards specify what polling rate to use, 1000hz for the best ones, maybe 125hz for the cheaper ones. An interesting thing about ps/2 is that even though it doesn’t have to wait for the keyboard to poll it transmits data at much slower speed than USB (khz vs mhz) which somewhat offsets the advantage it gets from being interrupt driven
edit: ah, sorry, I see someone's posted a link to this video already!
> Also wondering how much PS/2 vs USB matters.
Ben Eater has a great video on this:
Piggy-backing this comment to add some context for the OP video: This "USB device discovery" video is actually the latest in a series of videos where Ben Eater is building a simple 8-bit computer on breadboards. He hooked up a PS/2 keyboard as an input device, and then got sucked into a tangent of investigating and explaining keyboard protocols.
- He investigates the PS/2 keyboard protocol: https://www.youtube.com/watch?v=7aXbh9VUB3U
- Somebody on Patreon asked about USB keyboards having higher latency than PS/2, so he made a video about the basic USB protocol: https://www.youtube.com/watch?v=wdgULBpRoXk
- He made the OP video about USB keyboards being limited to holding six keys at once.
⬐ throw0101a> on breadboards.
Whatever happened to wire wrap?
I can understand BBs for quick prototyping and tinkering, but once you've settled on the design, I'd think WW would be less fragile to deal with.