Post 4: The backend (firmware!)
Mid Sept 2020 | By: David
We take for granted that everything kind of just works without any second thought about how it works. You plug in your keyboard, your computer recognizes it (insert USB chime here), and then it works.
But what about a macropad (with a rotary), with programmable keys? How does the computer know that it is a macropad? How does the computer know I'm pressing a key? How does it know I'm pressing THIS key rather than THAT key.
Luckily, people much smarter than I am have thought about this and created a standard: the USB Human Interface Device (HID) class. This essentially creates standard in which to recognize peripherals as keyboards, mice etc. Essentially, the flow looks like this:
Human (you, probably) ⇒ Key Press ⇒ Processor ⇒ USB ⇒ Computer
The processor essentially figures out what keys are pressed and sends a HID keyboard scan code (that has been standardized by USB) to the computer (for example, 0x04 is the code for the letter A). Depending on what OS your computer is running, it will process the code and return the corresponding key press or function. This is why sometimes, there are keys that work on macOS that won't work on Windows and vice versa!
So what this means is that our macropad has to have a processor and have firmware that allows us to interact with the computer over USB as a keyboard. In addition, we wanted it to be easy (without code) to change the keys on the fly! Because of these constraints, we decided to go with QMK (an open source firmware for keyboards, among other things!) In addition, we could utilize VIA, an easy to use GUI to change keybinds.