Programming Macros for Ergodox

The default configuration tool on Input Club or Massdrop don’t allow for macro programming. So you will have to get your hands dirty and mess with the firmware code a little. It’s not hard.

  1. Run the following commands on your terminal to clone Ben Blazak’s firmware code from github and create a custom layout for yourself
              git clone https://github.com/benblazak/ergodox-firmware.git
              cd ergodox-firmware
              # Macros are supported in his partial re-write branch 
              git checkout partial-rewrite
              cp firmware/keyboard/ergodox/layouts/qwerty--ben.c firmware/keyboard/ergodox/layouts/qwerty--custom.c
          
  2. Open keyboard/ergodox/options.mk and add qwerty–custom to the KEYBOARD_LAYOUTS and change the KEYBOARD_LAYOUT to qwerty–custom. The keyboard layout will look something like this :

    KEYBOARD_LAYOUT := qwerty--custom
    # default layout for this keyboard
    
    KEYBOARD_LAYOUTS := \
        test \
        arensito--ben \
        qwerty--ben \
        qwerty--custom \
        colemak--kinesis-mod \
        dvorak--kinesis-mod \
        qwerty--kinesis-mod
            
  3. Edit keyboard/ergodox/layout/fragments/macros.part.h and create a function for your macro. As an example, we will do a macro that prints b4.

    // Define a constant for the keys
    #define K_4 0x5C   // 4
    #define K_b 0x05   // b
    
    // Our macro's name is m_b4
    void keys__press__m_b4(void) {
        // Press and release b
        usb__kb__set_key(true, K_b);
        usb__kb__send_report();
        usb__kb__set_key(false, K_b);
        usb__kb__send_report();
    
        // Press and release 4
        usb__kb__set_key(true, K_4);
        usb__kb__send_report();
        usb__kb__set_key(false, K_4);
        usb__kb__send_report();
    }
    
    // Do this for all your macro functions
    void R(m_copy)(void) {}
    
          
  4. Now that the macro is ready, it can be placed in the layout. Put m_b4 for whichever key you want the macro to trigger. Edit firmware/keyboard/ergodox/layouts/qwerty–custom.c and put your macro in it.

    
        MATRIX_LAYER(  // layer 2 : symbols and function keys
    // macro, unused,
           K,    nop,
    // left hand ...... ......... ......... ......... ......... ......... .........
      lpo2l2,       F1,       F2,       F3,       F4,       F5,      F11,
      transp,   braceL,   braceR,    brktL,    brktR,      nop,   lpo2l2,
      transp,  semicol,    slash,     dash,        0,    colon,
      transp,        6,        7,        8,        9,     plus, lpupo3l3,
      transp,   transp,   transp,   transp,   transp,
                                                                  transp,     m_b4,
                                                        transp,   transp,   transp,
                                                        transp,   transp,   transp,
    // right hand ..... ......... ......... ......... ......... ......... .........
                   F6,       F7,       F8,       F9,       F10,      F11,      F12,
                lpo2l2,    caret,  undersc, lessThan, grtrThan,   dollar,  volumeU,
                         bkslash,        1,   parenL,   parenR,    equal,  volumeD,
              lpupo3l3, asterisk,        2,        3,        4,        5,     mute,
                                    transp,   transp,   transp,   transp,   power,
      transp,   transp,
      transp,   transp,   transp,
      transp,   transp,   transp  ),
    
    
    
  5. In the terminal, run make It will create firmware.hex
    Upload the file to Ergodox and your macro will be ready for use.

You can look up the hex codes for keys here: http://www.usb.org/developers/hidpage/Hut1_12v2.pdf


Posted

in

,

by

Tags:

Comments

One response to “Programming Macros for Ergodox”

  1. dude Avatar
    dude

    Thank you for a very simple presentation of how to create new macros for the Ergo Dox. I haven’t yet got mine, but I’m planning my next keyboard design, this certainly makes me more likely to choose Ergo Dox.

Leave a Reply

Your email address will not be published. Required fields are marked *