Flashing HHKB Jp Controller Mac Layout Hex

Having recently received Hasu’s fantastic HHKB JP Bluetooth Controller, I noticed one irksome thing: the alt and command keys were reversed on the left hand side, and the kana key that I typically remap to right command was reverted.

This is normal: the keyboard targets Windows users primarily, but one thing you lose when upgrading to the Hasu controller are the dip switches that allow changing the role of caps lock, the arrow keys and setting it to macOS mode.

The default HHKB layout without Hasu controller
The default HHKB JP OSX layout without Hasu controller – link

Of course it’s a pretty easy change to fix: you simply need to head over to the TMK Keymap Editor and edit the current layout, then download the hex file and flash it, but I’ve done the work, so I might as well share!

HHKB Hasu Jp OSX Layout
A layout that reverses alt and command and sets the kana key to right command for use with macOS computers
HHKB Hasu Jp Alternative Controller Layer 2
An overview of the second layer (layer1, counting from 0) used in the Hasu HHKB JP default layout

First off, as in other tutorials, you’ll need the DFU/AVR tools installed in OSX. This is accomplished by using Homebrew.

The code to get these installed is as follows:

brew tap osx-cross/avr
brew install avr-libc dfu-programmer

Next up, you’ll need to download the layout hex file that I have compiled here: “mac_version.hex“. If, for whatever reason, you need to go back to the default firmware, I have that compiled as well: default.hex. Remember to unzip these files prior to using them if Safari doesn’t automatically unzip your downloads.

Finally, put the keyboard in DFU mode by pressing the button on the back of the controller, where the dip switches used to reside. You may need to remove the cover to do so, and note that you can use the cover if you have short fingernails.

Once in DFU mode, this one-liner will erase the firmware, load the new hex layout and reset the keyboard so that you can use it once again. Note that I’m assuming your hex file will be in the Downloads folder in your home directory, and I’d also recommend having a spare keyboard handy in case anything goes wrong.

Bash script:

sudo dfu-programmer atmega32u4 erase --force && \
sudo dfu-programmer atmega32u4 flash ~/Downloads/mac_version.hex && \
sudo dfu-programmer atmega32u4 reset

Finally, if your layout is still a bit odd (underscore and pipe not working), you may have set the keyboard to the wrong layout. In Apple OSX this can be done by opening the keyboard section of the settings and changing the keyboard layout. Note that it doesn’t really matter that ANSI is suggested when you hit shift+z, shift+?, but that you select JIS once completed, like so:

Open the keyboard panel in System Preferences, then click “Change Keyboard Type…” on the bottom left
Click continue (or press return) to start the detection wizard
Press shift+z, then shift+? as instructed
Select the JIS radio button, even though it defaults to ANSI

Building Zeal60 Keymaps on OSX

Before starting, this guide requires Homebrew, which you can install from here: https://brew.sh

Open Terminal, and paste in the following. It will take a while to build, but you should be able to get it all done in one fell swoop:

git clone https://github.com/Wilba6582/qmk_firmware.git
cd qmk_firmware
git branch zeal60
cd keyboards/zeal60
git submodule update --init --recursive
brew tap osx-cross/avr
brew install avr-gcc avr-libc dfu-programmer

You can then make your keymap, like so:

  • make keymap=default
  • make keymap=poker2_ansi
  • make keymap=poker2_iso
  • make keymap=hhkb_ansi

You can run them all if you want, but you’ll probably only need one 🙂

Once you have your firmware, you can flash like so (for HHKB ANSI):

sudo dfu-programmer atmega32u4 erase --force
sudo dfu-programmer atmega32u4 flash hhkb_ansi.hex
sudo dfu-programmer atmega32u4 reset

Getting Started with the ZealPC Zeal60 Keyboard PCB

Recently I picked up a Zeal 60 printed circuit board from BC-based ZealPC, and I couldn’t be happier!

The board supports a few layouts for now, though it’s open source, and you can either fork it to add your own, or add a pull request to share with the community.

The first thing you’ll want to do after getting a Zeal60 PCB is to flash it with the “default.hex” file. I used Windows for this, though you can achieve similar results on Linux and MacOS (OSX).

Initial Downloads

  1. Download Java Runtime Environment (JRE) here: http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html
  2. Download the Atmel flashing utility “FLIP”: http://www.atmel.com/tools/flip.aspx
  3. Grab the most recent Zeal 60 keyboard zip: https://cdn.shopify.com/s/files/1/0490/7329/files/zeal60_v0_3.zip
  4. Unzip the zeal60_v0_3.zip file to your desktop

Install the Driver

  1. Plug in your Zeal60 to your computer via USB
  2. Hit “Windows” and “r” keys together, then type “devmgmt.msc”
  3. Right click the device with the exclamation point next to it
  4. Click “browse for driver”
  5. Navigate to C:\Program Files\FLIP\Drivers
  6. Hit “next”

Flashing the Board

  1. Install the driver –
  2. If you’ve not started assembling anything yet, press the golden button between the “A” and “S” pads on the board (if you’ve already assembled it, unplug it and hold the “space” and “esc” keys while plugging in the USB cable)
  3. Open FLIP
  4. In FLIP, hit connect to the device, and select “ATMega32U4”
  5. Hit “ctrl” + “U” keys to connect to the Zeal 60 PCB
  6. Hit “ctrl” + “L” to load a file
  7. Select the “default.hex” file in the Zeal 60 folder you extracted to your desktop
  8. On the left-hand window, click “Run”
  9. Once completed, then click “Start Application” in the right window

You’re all set!