nyquist firmware

there are copy to clipboard buttons on code blocks

├── common_functions.c
├── config.h
├── keymap.c
├── macros.h
└── rules.mk

common_functions.c

#include "eeconfig.h"
#include "action_layer.h"

extern keymap_config_t keymap_config;

// Fillers to make layering more clear
#define _______ KC_TRNS
#define XXXXXXX KC_NO

// Each layer gets a name for readability, which is then used in the keymap matrix below.
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
// Layer names don't all need to be of the same length, obviously, and you can also skip them
// entirely and just use numbers.
#define _QWERTY 0
#define _COLEMAK 1
#define _MOVE 6
#define _NAV 7
#define _ERGO1 8
#define _ADJUST 16

enum custom_keycodes {
  QWERTY = SAFE_RANGE,
  COLEMAK,
  ERGO1,
  ADJUST,
  NAV,
  AT_LTAB,
  UT_RND,
  LT_BSPC = LT (_MOVE, KC_BSPC),
  LT_ENT = LT (_MOVE, KC_ENT),
  LT_NAV = LT (_NAV, KC_A),
  KLE    
};


// os
#define CTALTD LALT(LCTL(KC_DEL)) // ctrlaltdel
#define WIN_SEL LALT(LCTL(KC_TAB)) //win 7 pick window

// editing
#define UNDO LCTL(KC_Z)
#define CUT LCTL(KC_X)
#define COPY LCTL(KC_C)
#define PASTE LCTL(KC_V)
#define REDO LCTL(KC_Z)
#define SEL_ALL LCTL(KC_A)

#define FC_OPEN LCTL(KC_O)
#define FC_SAVE LCTL(KC_S)
#define FC_CLOSE LCTL(KC_W)

#define FC_FIND LCTL(KC_F)

// atom and vscode
#define AT_FVIEW  LCTL(KC_BSLASH)
#define AT_COM LALT(KC_SLSH)
#define AT_MENU LCTL(LSFT(KC_P))
#define AT_OPROJ LCTL(LSFT(KC_P))
#define AT_BEAUT LCTL(LALT(KC_B))
#define AT_FIND LCTL(KC_P)
#define AT_TAB LCTL(KC_TAB)
// moved one to process bugged out after leader key
#define AT_MERM LCTL(LALT(KC_O))
#define AT_RUN LALT(LSFT(KC_R))
#define AT_TERM LCTL(KC_GRAVE)

// macros
#define M_P M(0)
#define M_P1 M(1)
#define M_P2 M(2)
#define M_P3 M(3)
#define M_P4 M(4)
#define M_P5 M(5)
#define M_P6 M(6)
#define M_P7 M(7)
#define M_P8 M(8)
#define M_P9 M(9)

#ifdef AUDIO_ENABLE
float tone_qwerty[][2]     = SONG(QWERTY_SOUND);
float tone_dvorak[][2]     = SONG(DVORAK_SOUND);
float tone_colemak[][2]    = SONG(COLEMAK_SOUND);
#endif

void persistent_default_layer_set(uint16_t default_layer) {
  eeconfig_update_default_layer(default_layer);
  default_layer_set(default_layer);
}

// custom keycodes

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  switch (keycode) {
    case QWERTY:
      if (record->event.pressed) {
        #ifdef AUDIO_ENABLE
          PLAY_SONG(tone_qwerty);
        #endif
        persistent_default_layer_set(1UL<<_QWERTY);
      }
      return false;
      break;
    case COLEMAK:
      if (record->event.pressed) {
        #ifdef AUDIO_ENABLE
          PLAY_SONG(tone_colemak);
        #endif
        persistent_default_layer_set(1UL<<_COLEMAK);
      }
      return false;
      break;
    case ERGO1:
      if (record->event.pressed) {
        layer_on(_ERGO1);
        update_tri_layer(_ERGO1, _MOVE, _ADJUST);
      } else {
        layer_off(_ERGO1);
        update_tri_layer(_ERGO1, _MOVE, _ADJUST);
      }
      return false;
      break;  
    case ADJUST:
      if (record->event.pressed) {
        layer_on(_ADJUST);
      } else {
        layer_off(_ADJUST);
      }
      return false;
      break;
    case AT_LTAB:
      if (record->event.pressed) {
        register_code(KC_LCTL);
        register_code(KC_LSFT);
        register_code(KC_TAB);
        unregister_code(KC_LCTL);
        unregister_code(KC_LSFT);
        unregister_code(KC_TAB);
      }
      return false;
      break;      
    case UT_RND:
      if (record->event.pressed) {
        tap_random_base64();
        tap_random_base64();
        tap_random_base64();
        tap_random_base64();
        tap_random_base64();
        tap_random_base64();
        tap_random_base64();
        tap_random_base64();
        tap_random_base64();
      }
      return false;
      break;
    case KLE:
      if (record->event.pressed) {
        register_code(KC_LGUI);
        register_code(KC_R);
        unregister_code(KC_R);
        unregister_code(KC_LGUI);
        wait_ms(80);
        SEND_STRING("chrome https://your.com/path");
        wait_ms(80);
        register_code(KC_ENT);
        unregister_code(KC_ENT);
      } else {
        wait_ms(80);
        register_code(KC_LGUI);
        register_code(KC_R);
        unregister_code(KC_LGUI);
        unregister_code(KC_R);
        wait_ms(80);
        SEND_STRING("put anything here");
        wait_ms(80);
        register_code(KC_ENT);
        unregister_code(KC_ENT);
      }
      return false;
      break;   
  }
  return true;
};

// custom codes end

// macros start

enum macro_id {
  macro_0,
  macro_1,
  macro_2,
  macro_3,
  macro_4,
  macro_5,
  macro_6,
  macro_7,
  macro_8,
  macro_9,
};

#include "macros.h"

const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
    if (record->event.pressed) {
        switch(id) {
            case 0:
                send_string(macro_0);
                return false;
            case 1:
                send_string(macro_1);
                return false;
            case 2:
                send_string(macro_2);
                return false;
            case 3:
                send_string(macro_3);
                return false;
            case 4:
              send_string(macro_4);
              return false;
            case 5:
                send_string(macro_5);
                return false;
            case 6:
              send_string(macro_6);
              return false;
            case 7:
              send_string(macro_7);
              return false;
            case 8:
              send_string(macro_8);
              return false;
            case 9:
              send_string(macro_9);
              return false;              
        }
    }
    return MACRO_NONE;
};

// macros end

// leader start

LEADER_EXTERNS();

void matrix_scan_user(void) {
  LEADER_DICTIONARY() {
    leading = false;
    leader_end();

    SEQ_ONE_KEY(KC_G) {
        register_code(KC_LGUI);
        register_code(KC_R);
        unregister_code(KC_R);
        unregister_code(KC_LGUI);
        wait_ms(80);
        SEND_STRING("chrome https://google.com");
        wait_ms(80);
        register_code(KC_ENT);
        unregister_code(KC_ENT);
    }
    SEQ_ONE_KEY(KC_Y) {
        register_code(KC_LGUI);
        register_code(KC_R);
        unregister_code(KC_R);
        unregister_code(KC_LGUI);
        wait_ms(80);
        SEND_STRING("chrome https://youtube.com");
        wait_ms(80);
        register_code(KC_ENT);
        unregister_code(KC_ENT);
    }
    SEQ_ONE_KEY(KC_N) {
        register_code(KC_LGUI);
        register_code(KC_R);
        unregister_code(KC_R);
        unregister_code(KC_LGUI);
        wait_ms(80);
        SEND_STRING("put anything in here");
        wait_ms(80);
        register_code(KC_ENT);
        unregister_code(KC_ENT);
    }
    SEQ_ONE_KEY(KC_I) {
        register_code(KC_LGUI);
        register_code(KC_R);
        unregister_code(KC_R);
        unregister_code(KC_LGUI);
        wait_ms(80);
        SEND_STRING("");
        wait_ms(80);
        register_code(KC_ENT);
        unregister_code(KC_ENT);
    }
    SEQ_ONE_KEY(KC_M) {
        register_code(KC_LGUI);
        register_code(KC_R);
        unregister_code(KC_R);
        unregister_code(KC_LGUI);
        wait_ms(80);
        SEND_STRING("");
        wait_ms(80);
        register_code(KC_ENT);
        unregister_code(KC_ENT);
    }
    SEQ_ONE_KEY(KC_J) {
        register_code(KC_LGUI);
        register_code(KC_R);
        unregister_code(KC_R);
        unregister_code(KC_LGUI);
        wait_ms(80);
        SEND_STRING("");
        wait_ms(80);
        register_code(KC_ENT);
        unregister_code(KC_ENT);
    }
    SEQ_TWO_KEYS(KC_F, KC_D)
    {
      register_code(KC_LCTL);
      register_code(KC_BSPC);
      unregister_code(KC_BSPC);
      unregister_code(KC_LCTL);
    }
    SEQ_TWO_KEYS(KC_D, KC_F)
    {
      register_code(KC_LSFT);
      register_code(KC_DEL);
      unregister_code(KC_DEL);
      unregister_code(KC_LSFT);
    }
    }
};

// leader end

config.h

#ifndef CONFIG_USER_H
#define CONFIG_USER_H

#include "../../config.h"

/* Use I2C or Serial, not both */

#define LEADER_TIMEOUT 400

#define MOUSEKEY_INTERVAL 16
#define MOUSEKEY_DELAY 0
#define MOUSEKEY_TIME_TO_MAX 60
#define MOUSEKEY_MAX_SPEED 7
#define MOUSEKEY_WHEEL_DELAY 0

#define USE_SERIAL
// #define USE_I2C

/* Select hand configuration */

#define MASTER_LEFT
// #define _MASTER_RIGHT
// #define EE_HANDS

#endif

keymap.c

#include "nyquist.h"

#include "common_functions.c"

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

/* Qwerty
 * ,-----------------------------------------------------------------------------------.
 * |   `  |   1  |   2  |   3  |   4  |   5  |   6  |   7  |   8  |   9  |   0  | Bksp |
 * |------+------+------+------+------+------+------+------+------+------+------+------|
 * | Tab  |   Q  |   W  |   E  |   R  |   T  |   Y  |   U  |   I  |   O  |   P  | Del  |
 * |------+------+------+------+------+-------------+------+------+------+------+------|
 * | Esc  |   A  |   S  |   D  |   F  |   G  |   H  |   J  |   K  |   L  |   ;  |  "   |
 * |------+------+------+------+------+------|------+------+------+------+------+------|
 * | Shift|   Z  |   X  |   C  |   V  |   B  |   N  |   M  |   ,  |   .  |   /  |Enter |
 * |------+------+------+------+------+------+------+------+------+------+------+------|
 * |Adjust| Ctrl | Alt  | GUI  |Lower |Space |Space |Raise | Left | Down |  Up  |Right |
 * `-----------------------------------------------------------------------------------'
 */
[_QWERTY] = KEYMAP( \
  KC_GRV,         KC_1,   KC_2,    KC_3,    KC_4,  KC_5,           KC_6,           KC_7,    KC_8,    KC_9,       KC_0,         KC_BSPC, \
  KC_ESC,         KC_Q,   KC_W,    KC_E,    KC_R,  KC_T,           KC_Y,           KC_U,    KC_I,    KC_O,       KC_P,         KC_TAB, \
  LT_BSPC,        LT_NAV, KC_S,    KC_D,    KC_F,  KC_G,           KC_H,           KC_J,    KC_K,    KC_L,       KC_SCLN,      LT_ENT, \
  KC_LSPO,        KC_Z,   KC_X,    KC_C,    KC_V,  KC_B,           KC_N,           KC_M,    KC_COMM, KC_DOT,     KC_SLSH,      KC_RSPC, \
  CTL_T(KC_QUOT), LT_ENT, KC_LALT, KC_LGUI, ERGO1, SFT_T(KC_BSPC), RSFT_T(KC_SPC), ERGO1,   KC_LEAD, LGUI(KC_L), LALT(CTALTD), CTL_T(KC_F11) \
),

/* Colemak
 * ,-----------------------------------------------------------------------------------.
 * |   `  |   1  |   2  |   3  |   4  |   5  |   6  |   7  |   8  |   9  |   0  | Bksp |
 * |------+------+------+------+------+------+------+------+------+------+------+------|
 * | Tab  |   Q  |   W  |   F  |   P  |   G  |   J  |   L  |   U  |   Y  |   ;  | Del  |
 * |------+------+------+------+------+-------------+------+------+------+------+------|
 * | Esc  |   A  |   R  |   S  |   T  |   D  |   H  |   N  |   E  |   I  |   O  |  "   |
 * |------+------+------+------+------+------|------+------+------+------+------+------|
 * | Shift|   Z  |   X  |   C  |   V  |   B  |   K  |   M  |   ,  |   .  |   /  |Enter |
 * |------+------+------+------+------+------+------+------+------+------+------+------|
 * |Adjust| Ctrl | Alt  | GUI  |Lower |Space |Space |Raise | Left | Down |  Up  |Right |
 * `-----------------------------------------------------------------------------------'
 */
[_COLEMAK] = KEYMAP( \
  KC_GRV,          KC_1,   KC_2,    KC_3,    KC_4,    KC_5,             KC_6,           KC_7,       KC_8,       KC_9,       KC_0,       KC_BSPC, \
  KC_ESC,          KC_Q,   KC_W,    KC_F,    KC_P,    KC_G,             KC_J,           KC_L,       KC_U,       KC_Y,       KC_SCLN,    KC_TAB, \
  LT_BSPC,         LT_NAV, KC_R,    KC_S,    KC_T,    KC_D,             KC_H,           KC_N,       KC_E,       KC_I,       KC_O,       LT_ENT, \
  KC_LSPO,         KC_Z,   KC_X,    KC_C,    KC_V,    KC_B,             KC_K,           KC_M,       KC_COMM,    KC_DOT,     KC_SLSH,    KC_RSPC , \
  CTL_T(KC_QUOT),  LT_ENT, KC_LALT, KC_LGUI, ERGO1,   SFT_T(KC_BSPC),   RSFT_T(KC_SPC), ERGO1,      KC_LEAD,    LGUI(KC_L), LALT(CTALTD), CTL_T(KC_F11)\
),

[_MOVE] = KEYMAP ( \
_______, _______, _______, _______,  _______, _______, _______, _______, _______, _______, _______,      _______, \
_______, AT_LTAB, AT_TAB,  AT_MENU,  AT_FIND, KC_CAPS, KC_VOLU, KC_HOME, KC_UP,   KC_END,  WIN_SEL,      _______, \
_______, UNDO,    CUT,     COPY,     PASTE,   REDO,    KC_MUTE, KC_LEFT, KC_DOWN, KC_RGHT, LGUI(KC_TAB), _______, \
_______, FC_OPEN, FC_SAVE, FC_CLOSE, FC_FIND, SEL_ALL, KC_VOLD, KC_PGDN, KC_PGUP, KC_PGDN, KLE,          _______, \
_______, _______, _______, _______,  _______, _______, _______, _______, _______, AT_TERM, LALT(KC_TAB), _______ \
),

[_NAV] = KEYMAP ( \
_______, _______, _______, _______,    _______,    _______,     _______,             _______,    _______,    _______,  _______,              _______, \
_______, _______, KC_WH_L, KC_WH_R,    _______,    LALT(KC_F4), LALT(KC_F4),         KC_WH_U,    KC_MS_U,    KC_WH_D,  LCTL(LGUI(KC_F4)),    _______, \
_______, LT_NAV,  KC_ACL0, KC_ACL1,    KC_ACL2,    _______,     LCTL(LGUI(KC_LEFT)), KC_MS_L,    KC_MS_D,    KC_MS_R,  LCTL(LGUI(KC_RIGHT)), _______, \
_______, _______, _______, LGUI(KC_T), LGUI(KC_B), KC_F5,       KC_F5,               LGUI(KC_T), LGUI(KC_B), _______,  LCTL(LGUI(KC_D)),     _______, \
_______, _______, _______, _______,    _______,    _______,     _______,             KC_BTN1,    KC_BTN2,    _______,  _______,              _______ \
),

/* _ERGO1 
* ,-----------------------------------------------------------------------------------.
* |      |  F1  |  F2  |  F3  |  F4  |  F5  |  F6  |  F7  |  F8  |  F9  |  F10 | F11  |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* |      |  !   |   @  |  {   |   }  |  |   |   _  |   7  |  8   |  9   |   *  | F12  |
* |------+------+------+------+------+-------------+------+------+------+------+------|
* |      |  #   |   $  |  (   |   )  |  `   |   -  |   4  |  5   |  6   |   +  |      |
* |------+------+------+------+------+------|------+------+------+------+------+------|
* |      |  %   |  ^   |  [   |  ]   |  ~   |   &  |   1  |  2   |  3   |   \  |      |
* |------+------+------+------+------+------+------+------+------+------+------+------|
* |      |      |      |      |      |      |      |      |  .   |  0   |   =  |      |
* `-----------------------------------------------------------------------------------'
*/

[_ERGO1] =  KEYMAP( \
  _______, KC_F1,   KC_F2,   KC_F3,       KC_F4,       KC_F5,   KC_F6,       KC_F7,   KC_F8,   KC_F9,     KC_F10,    KC_F11, \
  _______, KC_EXLM, KC_AT,   KC_LCBR,     KC_RCBR,     KC_PIPE, KC_UNDS,     KC_7,    KC_8,    KC_9,      KC_ASTR,   KC_F12, \
  _______, KC_HASH, KC_DLR,  KC_LPRN,     KC_RPRN,     KC_GRAVE,KC_MINUS,    KC_4,    KC_5,    KC_6,      KC_PLUS,   _______, \
  _______, KC_PERC, KC_CIRC, KC_LBRACKET, KC_RBRACKET, KC_TILD, KC_AMPR,     KC_1,    KC_2,    KC_3,      KC_BSLASH, _______, \
  _______, _______, _______, _______,     _______,     _______, _______,     _______, KC_DOT,  KC_0,      KC_EQL,    _______ \
),

/* Adjust (nav + ergo1)
 * ,-----------------------------------------------------------------------------------.
 * |  F1  |  F2  |  F3  |  F4  |  F5  |  F6  |  F7  |  F8  |  F9  |  F10 |  F11 |  F12 |
 * |------+------+------+------+------+------+------+------+------+------+------+------|
 * |      | Reset|RGB Tg|RGB Md|Hue Up|Hue Dn|Sat Up|Sat Dn|Val Up|Val Dn|      |  Del |
 * |------+------+------+------+------+-------------+------+------+------+------+------|
 * |      |      |      |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak|      |      |
 * |------+------+------+------+------+------|------+------+------+------+------+------|
 * |      |      |      |      |      |      |      |      |      |      |      |      |
 * |------+------+------+------+------+------+------+------+------+------+------+------|
 * |      |      |      |      |      |             |      |      |      |      |      |
 * `-----------------------------------------------------------------------------------'
 */

[_ADJUST] =  KEYMAP( \
KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12, \
_______, _______, M_P,     M_P1,    M_P2,    M_P3,    M_P4,    M_P5,    M_P6,    _______, UT_RND,  KC_DEL, \
_______, M_P7,    M_P8,    M_P9,    _______, _______, _______, QWERTY,  COLEMAK, _______, _______, _______, \
KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12, \
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
)

};

macros.h

#define macro_0 "put"
#define macro_1 "your"
#define macro_2 "macros"
#define macro_3 "here"
#define macro_4 "boo"
#define macro_5 "bar"
#define macro_6 "foo"
#define macro_7 "stuff"
#define macro_8 "blahblah"
#define macro_9 "your@email.com"
// #define macro_10      

rules.mk

# BOOTMAGIC_ENABLE = no       # Virtual DIP switch configuration(+1000)
MOUSEKEY_ENABLE = yes       # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes       # Audio control and System control(+450)
CONSOLE_ENABLE = no         # Console for debug(+400)
# COMMAND_ENABLE = yes        # Commands for debug and configuration
NKRO_ENABLE = yes            # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
MIDI_ENABLE = no            # MIDI controls
AUDIO_ENABLE = no           # Audio output on port C6
UNICODE_ENABLE = no         # Unicode
BLUETOOTH_ENABLE = no       # Enable Bluetooth with the Adafruit EZ-Key HID
# RGBLIGHT_ENABLE = yes

ifndef QUANTUM_DIR
    include ../../../../Makefile
endif

Comments