12 ms·
Myths about USB NKRO and how USB HID works
- gruez 6y agoAFAIK most USB keyboards with nkro implement it by emulating multiple USB keyboards, which I guess is also within the hid spec? The manufacturers probably figured that approach was more reliable than using one hid device with a custom reporting format.
- p_l 6y agoIt's cheaper to reuse the same USB 1.0 controller chip than update. That's it, the dirty secret. Some keyboards also do that to support OSes that have broken HID drivers, like Mac.
- Alupis 6y ago> It's cheaper to reuse the same USB 1.0 controller chip than update. That's it, the dirty secret. How can this be for high end gaming keyboards that retail for $150-$200 or more?
- mschuster91 6y agoThe only thing "high end" in there are the switches, and even that not necessarily.
- DiabloD3 6y agoBelieve it or not, there is a very small number of keyboards that use custom USB 3.0 controllers purely for isosynchronous mode, to get "PS/2 port interrupt"-like behavior. However, if you have a modern USB 2.0 "gaming keyboard controller" polling at 1000ms, who cares. Job done, go home.
- rasz 6y agoDo you mean Endpoint Ready (ERDY)? That is only available for non-isochronous endpoints.
- monocasa 6y agoNo, I think they're just constantly streaming out updates over a custom isochronous endpoint so the driver doesn't have to go out and request it at all like you do even with ERDY.
- rasz 6y agoWouldnt that swamp CPU with interrupts?
- monocasa 6y agoI mean, as much as a USB microphone does. That'd be isochronous too, and about the same bitrate and latency.
- amluto 6y agoThat would be awful for a keyboard. With sound, either the CPU wakes up to process sound very frequently or it processed sound in big chunks with high latency. Neither choice is reasonable for a keyboard.
- monocasa 6y agoIf you're the kind of person that gets that keyboard, you don't really care about power consumption on your CPU. Handling it as it's streamed in really isn't that big of a deal. It's not even like sound where you'd be doing a bunch of DSP on it right after.
- CarVac 6y agoMore margins make for more profit. It's always good to reduce costs regardless of how much you charge.
- Alupis 6y agoThere's some other factor surely. We're talking pennies on a BoM, and I'm certain some high end keyboard manufacturer would love to tout a better usb controller, etc.
- p_l 6y agoConsider the support costs involved in dealing with things like broken BIOSes that don't send "switch to boot protocol" command and similar. Cost of electronics is not everything.
- ChickeNES 6y ago> Some keyboards also do that to support OSes that have broken HID drivers, like Mac. What's broken on macOS?
- p_l 6y agoDon't remember full details, but essentially something was broken in handling of HID reports for keyboards combined with how input events were handled in upper layers. Resulted in some keyboards having special cases for dealing with "NKRO" on Mac.
- rasz 6y agoNo, and it makes no sense. There are no fixed function USB HID controller chips. They are all microcontrollers with USB interface. Makes no difference from chip point of view if it reports being basic HID profile or a custom one. Besides you can even bitbang being 10 hid devices on a good old Arduino.
- baybal2 6y agoYes, but for most keyboard makers, they come preflashed, and are indistinguishable from dumb asics
- p_l 6y agoA cent here and there on manufacturing several hundred thousand units quickly adds up. And that's just the MCU used. The cost of replacing the MCU with something that can run USB1.1 instead of 1.0, cost of programming, cost of dealing with broken cases that don't support HID properly (for example BIOSes that don't send "boot proto only" command, or every Mac) quickly increase the total cost. And the margins are thin. And then there's the fact that even people who should know better often believe myths about USB being unable to report more than 6 keys - even if they are keyboard vendors who should know better and are making a high-enough margin to use better controller.
- rasz 6y ago>cent here and there someone counting cents will not use several microcontrollers + separate usb hub chip, where did you get that idea from anyway? >cost of replacing the MCU with something that can run USB1.1 instead of 1.0 http://www.os2museum.com/wp/how-fast-again/ http://www.os2museum.com/wp/how-fast-again/ there is no hardware difference between 1.0 and 1.1.
- p_l 6y agoWhat I found was that in Low Speed mode, the maximum packet size made it impractical to use anything but the Boot Protocol. As for counting cents - for majority of keyboards made, you'll get as little work done on the keyboard controller as possible. If they add a separate USB chip, it's usually logically separate from the keyboard anyway. When you reach the more fancy keyboards, you deal with another problem. Namely, what to do with all the broken software involved. Your priority for reducing costs is removing support calls, angry gamers calling when they can't change their overclocking parameters in BIOS, Macintosh users complaining the keyboard doesn't work at all, corporate/OEM clients returning keyboards because it is not possible to input password to McBuggy Disk Encryption and Employee Spyware v6.66 when the computer starts. Those limit your options when the budget for your fancy keyboard would provide for better microcontroller.
- omgtehlion 6y agoYeah, I implemented it too. Many years ago, I didn't read spec or really think about custom report desc. Solution to pretend to be multiple keyboards seemed to be obvious ))
- JdeBP 6y agoHaving multiple report formats is also obvious, but generally so from reading the spec, which addresses the subject. (-:
- DiabloD3 6y agoOn top of that, its usually two: often, the WASD+QE cluster, the most pressed buttons in gaming, with everything else on the other.
- ardy42 6y ago> the WASD+QE cluster, the most pressed buttons in gaming It's been a long time since I've gamed, but when I did I always used ESDF (which I picked up from Tribes). It seems kinda silly to hyper-optimize solely to a default like WSAD.
- zenexer 6y agoIn modern competitive gaming, I believe it’s fairly rare to remap away from WASD. Other keys get remapped, but not those ones. Since these expensive keyboards are catering to the (wannabe-)pro-gamer crowd, they tend to focus on that cluster.
- makomk 6y agoYeah, as I understand it there were some fairly nasty BIOS compatibility issues with keyboards that try and do full spec-compliant NKRO, and some older OSes might have had issues too. The specification says that software which requires the special boot protocol need to request it, but in practice it often doesn't, so most keyboards only support that format and are limited to 6-key rollover plus modifiers. A few hobbyist keyboard designers have tried doing this the proper way and quickly regretted it once they sold enough keyboards to be exposed to real-world systems and their behaviour.
- janci 6y agoIf I remember correctly, the good old PS/2 keyboards used to send "key down" and "key up" events - so no limit on number of simultaneous keypresses. Why was this not reflected in USB HID?
- simias 6y agoMy guess is that the problem with sending events is that if you miss one you're in trouble (in this case it's especially bad if you miss/lose the "key up" message). Given the potential complexity of USB topologies making the protocol stateful might have caused more problem than it would've solved. Besides is there any use for NKRO besides being a meme feature for overpriced keyboards? The only use case I can think of is if you play two player games on the same keyboard but doesn't seem very common these days (and you can probably buy a decent gamepad for the price of a NKRO keyboard).
- smileybarry 6y agoWhile I can't reproduce it at-will I've definitely had occasional input problems in competitive shooter games with 6KRO + 125Hz. A depress would be processed "too late" to accidentally fall into the next window and affect movement then (e.g.: jump in wrong direction). Yes, the key combination probably doesn't go over 6 keys at once and I don't always have ~8-16ms presses but switching over to NKRO + 1000Hz (which are coupled on QMK) would stop this from happening.
- SuperPaintMan 6y agoStenography! When stroking a chord you can have 6+ keys held down easily. I design and write firmware for QMK powered writers/ergonomic keyboards, and NKRO is absolutely vital if you don't want to resort to serial devices [1]. Plover uses this technique to allow for use of gaming keyboards as a low cost stenographic writer powered by FOSS. [1] https://www.gboards.ca/ https://www.gboards.ca/
- derefr 6y agoWould it be that expensive to put ~4K of RAM in the keyboard’s microcontroller to act as an event queue? Write keydowns/keyups into the buffer; then push (or respond to a poll with) the complete contents of the buffer as a single USB packet; and flush the buffer on ACK. (I presume USB does ACKs?) 4K would be more than enough to buffer all possible key events a pair of human hands could create in a reasonable polling interval (~16ms, i.e. 1 frame for a 60Hz game.) Add a clock chip to the HID device as well, and you could even get finer event-reporting granularity than the OS cares to poll for (i.e. the buffer delivered at (Polling Interval x N)ms, would contain events timestamped for (Interval x (N-1)) ms, (Interval x (N-1) + 1)ms, etc.) The timestamps could just be relative to the beginning of the interval, so they wouldn’t need to take up that many bits at all.
- praseodym 6y ago> Yes, this means you could theoretically make an analog keyboard which reports the level of key depression. There is at least one company making analog keyboards, mainly for gaming: https://wooting.io/ https://wooting.io/
- DavidVoid 6y agoThe Realforce 108UH-ANLG [1] can also do that and can even emulate the analog sticks and buttons used on gaming controllers. Here's a demo video of one being used as a piano [2]. You can tell that harder keypresses result in louder notes. I don't think it's been released outside of Japan yet but they have some keyboards with customizable actuation points using the same Topre switches [3]. [1] https://www.realforce.co.jp/products/108UH-ANLG_AFAX01/index.html https://www.realforce.co.jp/products/108UH-ANLG_AFAX01/index... [2] https://www.youtube.com/watch?v=mhCSIy-Qt0M https://www.youtube.com/watch?v=mhCSIy-Qt0M [3] https://www.realforce.co.jp/en/products/R2A-US4G-BK/index.html https://www.realforce.co.jp/en/products/R2A-US4G-BK/index.ht...
- m463 6y agoThe Steelseries Apex Pro has keys that can detect depth, but they too use it for actuation points. They keys are omnipoint. I really (really) like my topre realforce rgb although the apex pro is very close in terms of solid feel, and has much more interesting electronics.
- AndrewStephens 6y agoFirst thing I thought of when I read that line was a keyboard with no shift key. If you want capital letters you really have to MASH THOSE KEYS TO MAKE YOUR POINT!
- lejboua 6y agoToday I learned. Thanks for this!
- ploxiln 6y agoThe trick to get not-exactly-standard BIOS and OS working (with NKRO for the OS) is not at all obvious ... I first read about it in https://static.wongcornall.com/ibm-capsense-usb-web/ibm-capsense-usb.html#x1-160003.3.2 https://static.wongcornall.com/ibm-capsense-usb-web/ibm-caps...
- ScarZy 6y agoThis is my kind of post. Respect.
- SlowRobotAhead 6y agoPretty clever trick using the padding to get the boot info there for compatibility.
- guerby 6y agoI wonder if USB HID compliant keyboard can report their key map (like QWERTY vs AZERTY)? If yes is there some OS taking advantage of it and how? In 2020 keyboard mapping is still a mess IMHO but may be I'm missing something :)
- JdeBP 6y agoYou're missing the fact that keyboards do not have key maps to report. The wire protocol and the device do not remap keys. It's all done in software on the host. * https://news.ycombinator.com/item?id=22207431 https://news.ycombinator.com/item?id=22207431
- guerby 6y agoThanks for the link! But that does not tell me why there is no standard way for a key map / layout to be transmitted by the hardware to the software. When the vendor makes the keyboard, he's the one choosing both the physical layout (A vs Q) and the USB microcontroller behaviour, so nothing prevents transmission of physical layout in some way to the software. In 2020 we do not have to tell the software what the screen resolution is, what the drive size is, but we still have to manually tell software AZERTY vs QWERTY ...
- JdeBP 6y agoYes, it does tell you. You keep asking for the transmission of something that does not exist. Learn this fact: there is no keyboard map on the keyboard. It's all in software on the host. Your keytops could be entirely blank and the operation of the keyboard would continue unaffected. You have to tell software what the keyboard map is, because software on the host is where the keyboard map is.
- amluto 6y agoYou aren’t answering the question. Sure, keyboards don’t currently report a mapping from button to label, and software doesn’t expect such a report. This doesn’t mean it has to be this way. A keyboard could tell the host “here is how I think I’m labeled”, and the host could make use of this information.
- colejohnson66 6y agoI’ve noticed this on my keyboard. It has a “BIOS mode”, but it works fine in “regular mode” in the BIOS anyways. Maybe because it’s actually UEFI?
- p_l 6y agoIt means that either your firmware has more complete HID driver (doubtful) or, or likely, it properly sends "switch to boot proto" command.
- coretx 6y agoThe cheap Chinese keyboard I have over here emulates NKRO by simply reporting 5 different keyboards. Although the idea makes me cringe from a engineering pov I've to admit it works really well.