An introduction to hacking an open keyboard
Macros and Plugins
Both macros and plugins are code that extend functionality. The difference is that macros are added directly to the .ino
file, and plugins are called as libraries and stored as separate files. Often, plugins are much longer than macros, although some plugins are short. A number of third-party macros and plugins are available, and both are discussed and improved on the Keyboardio forum [6]. In installing third-party macros and plugins, you can learn the rudiments of writing your own customizations.
The exact instructions for installing either may differ in detail. For instance, some macros may need to be added before others. However, most follow the same general rules [7]. A typical example is included by default in the firmware, the Any key macro, which produces a random character and is assigned to the Any key. Using the macro requires three pieces in the firmware:
- Add the macro code and accompanying comments after the keymaps for each layer in the
.ino
file. Follow the comments to find the proper place. Search for the listing of macros and add the name of each macro, one per line so that they can be easily read; for example:
enum { MACRO_VERSION_INFO, MACRO_ANY };
- Map the name of the macro to a key; for example,
M(MACRO_ANY)
. TheM
signals that a macro is called, and the text inside the parentheses is the name of the macro.
Installing plugins requires a different general procedure [8]:
Add the code to:
$HOME/Arduino/hardware/keyboardio/ avr/libraries/
The simplest way to add the code is to change to this directory and then use git clone
, specifying the URL to the code.
Add calls for the plugin near the top of the firmware file. For example, for
Kaleidoscope-MacrosOnTheFly
, add:#include <Kaleidoscope.h> #include <Kaleidoscope-MacrosOnTheFly.h> void setup (){ Kaleidoscope.use(&MacrosOnTheFly); Kaleidoscope.setup();
- Assign the names specified in its code to a key. For example,
Kaleidoscope-MacrosOnTheFly
requires two assigned keys:Key_MacroRec
for recording macros andKey_MacroPlay
to playback macros. Many plugins require only one key assignment.
Two third-party plugins that are especially useful if you want to add more than a few macros are Kaleidoscope-MacrosOnTheFly
, which not only creates macros by recording keystrokes, but also allows each key to be assigned a macro, and Kaleidoscope-OneShot
, which turns any key into a command key. With these tools, your customizations are limited only by your imagination and the Model 01's memory.
Flashing the Firmware
You can add your changes to the keyboard in two ways. At the command line, change to the directory containing the modified .ino
file and enter the command make flash
. When prompted, keep pressing the Prog key while pressing Enter. Do not release the Prog key until the process is completed. Then, unplug the keyboard and reconnect it to start the keyboard with the revised firmware. Alternatively, from the Arduino IDE, select the modified .ino
file and click the Upload button while pressing the Prog key.
In both cases, do not release the Prog key until the process is completed. When the flashing is happening, the left half of the keyboard will have a red spark flash across the keys to show that the process is happening. Then, unplug the keyboard and reconnect it to start the keyboard with the revised firmware.
Should you run into trouble – for example, if you assign a command or character to the Prog key on the default layer – disconnect the keyboard and restart it while holding down the Prog key to revert to the original firmware. The left-hand circuit board has a reset button, although using it requires unscrewing the enclosure to find it. Using either one will allow you to flash another version of the firmware.
At some point, a graphical interface will be completed for simple remappings of the keys and the creation of layers, but for now, programming the Model 01 is strictly a command-line process. The bonus is that, by confronting the code head-on, you can add more complex customizations and learn how to work with other Arduino-driven devices.
Infos
- Model 01: https://shop.keyboard.io/
- Arduino C: https://www.arduino.cc/reference/en/
- Installing Arduino IDE: https://github.com/keyboardio/Kaleidoscope/wiki/Install-Arduino-support-on-Linux
- Installing firmware: https://github.com/keyboardio/Model01-Firmware/blob/master/README.md
- Keycodes: https://github.com/keyboardio/Kaleidoscope/wiki/Keycode-meanings
- Keyboardio forum: https://community.keyboard.io/
- Installing macros: https://github.com/keyboardio/Kaleidoscope-Macros
- Installing plugins: https://community.keyboard.io/c/programming
« Previous 1 2
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Canonical Releases Ubuntu 24.04
After a brief pause because of the XZ vulnerability, Ubuntu 24.04 is now available for install.
-
Linux Servers Targeted by Akira Ransomware
A group of bad actors who have already extorted $42 million have their sights set on the Linux platform.
-
TUXEDO Computers Unveils Linux Laptop Featuring AMD Ryzen CPU
This latest release is the first laptop to include the new CPU from Ryzen and Linux preinstalled.
-
XZ Gets the All-Clear
The back door xz vulnerability has been officially reverted for Fedora 40 and versions 38 and 39 were never affected.
-
Canonical Collaborates with Qualcomm on New Venture
This new joint effort is geared toward bringing Ubuntu and Ubuntu Core to Qualcomm-powered devices.
-
Kodi 21.0 Open-Source Entertainment Hub Released
After a year of development, the award-winning Kodi cross-platform, media center software is now available with many new additions and improvements.
-
Linux Usage Increases in Two Key Areas
If market share is your thing, you'll be happy to know that Linux is on the rise in two areas that, if they keep climbing, could have serious meaning for Linux's future.
-
Vulnerability Discovered in xz Libraries
An urgent alert for Fedora 40 has been posted and users should pay attention.
-
Canonical Bumps LTS Support to 12 years
If you're worried that your Ubuntu LTS release won't be supported long enough to last, Canonical has a surprise for you in the form of 12 years of security coverage.
-
Fedora 40 Beta Released Soon
With the official release of Fedora 40 coming in April, it's almost time to download the beta and see what's new.