Building a custom QMK firmware
I’ve been used to Tap Dance and AutoShift on the Planck EZ and I wanted the same on my Preonic. This led me to find out that QMK Configurator does not support the features out of the box. Downloading the QMK firmware and customising it is the only way.
First step: Install qmk
For Mac OS, using homebrew for installation.
brew install qmk
Install some dependencies using this doc as a reference
Setup QMK using the below command. This will download the QMK firmware for you and if required install any dependencies. On my Mac and this took about 5min.
qmk setup
The output should look like this - along with some git clone to clone the repo. (This is the output when qmk setup is run for the second time).
$ qmk setup
Ψ Found qmk_firmware at /Users/hashnuke/qmk_firmware.
Ψ QMK Doctor is checking your environment.
Ψ CLI version: 0.2.0
Ψ QMK home: /Users/hashnuke/qmk_firmware
Ψ Detected macOS 11.3.1.
Ψ All dependencies are installed.
Ψ Found arm-none-eabi-gcc version 9.3.1
Ψ Found avr-gcc version 8.4.0
Ψ Found avrdude version 6.3
Ψ Found dfu-util version 0.10
Ψ Found dfu-programmer version 0.7.2
Ψ Submodules are up to date.
Ψ QMK is ready to go
Create new keymap
My keyboard layout is going to be based on the default Preonic rev3 layout. I identified this name from the list of keyboards from QMK configurator
qmk new-keymap -kb preonic/rev3
The output should look like below:
$ qmk new-keymap -kb preonic/rev3
Keymap Name: hn-preonic
Ψ hn-preonic keymap directory created in: /Users/hashnuke/qmk_firmware/keyboards/preonic/keymaps/hn-preonic
Ψ Compile a firmware with your new keymap by typing:
qmk compile -kb preonic/rev3 -km hn-preonic
Within the directory mentioned above in the output, I made the following changes.
Enable Tap Dance
Enable Tap Dance in rules.mk file
TAP_DANCE_ENABLE = yes
Define tapping interaval in config.h file
#define TAPPING_TERM 175
Define tap dance functionality in keymap.c
Add this snippet right below the include statements. What I’ve done is make the escape key behave like control if double-tapped.
// Tap Dance declarations
enum {
TD_ESC_CAPS,
};
// Tap Dance definitions
qk_tap_dance_action_t tap_dance_actions[] = {
// Tap once for Escape, twice for Caps Lock
[TD_ESC_CAPS] = ACTION_TAP_DANCE_DOUBLE(KC_ESC, KC_LCTL),
};
Then in the same file, replace any occurrence of KC_ESC
with TD(TD_ESC_CAPS)
Enable AutoShift
Add the below snippet to rules.mk
AUTO_SHIFT_ENABLE = yes
Add the below snippet to config.h
#define AUTO_SHIFT_TIMEOUT 200
Compile the firmware and flash your keyboard with it
$ qmk flash -km hn-preonic -kb preonic/rev3
Once this command begins, ensure to reset your keyboard for the bootloader to be available. On the Drop Preonic, this is at the bottom of the keyboard - you’ll need a needle or something thin to press it.
The build would then be available in the ~/qmk_firmware/.build
directory. The bin file will be flashed to your keyboard.