summaryrefslogtreecommitdiffstats
path: root/keyboards/planck/keymaps/copface/keymap.c
blob: 376ceeb288ed24abe3809501d8d947c19c566fa4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#include QMK_KEYBOARD_H
#include "muse.h"

// Custom Keycode Definitions
#define LOWER MO(_LOWER)
#define RAISE MO(_RAISE)
#define META MO(_META)

#define KC_PRS LGUI(LALT(LCTL(KC_4)))
#define KC_EUR LALT(KC_4)
#define KC_MGRV LALT(KC_GRV)

#define KC_FORMAT LGUI(LALT(KC_L))
#define KC_FBSP LALT(KC_BSPC)
#define KC_FDEL LALT(KC_DEL)
#define KC_PS3 LSFT(LCTL(LGUI(KC_3)))
#define KC_PS4 LSFT(LCTL(LGUI(KC_4)))

#define HK_TM LALT(KC_2)
#define HK_AF9 LALT(KC_F9)

#define KC_SRC LGUI(KC_F12)
#define KC_RNME LSFT(KC_F6)

#define M_LGSPC LGUI_T(KC_SPC)
#define M_LCENT LCTL_T(KC_ENT)
#define M_LGENT LGUI_T(KC_ENT)

enum planck_layers {
  _DEFAULT = 0,
  _LOWER,
  _RAISE,
  _META,
  _ADJUST
};

enum planck_keycodes {
  KC_ARR = SAFE_RANGE,  // ->
  KC_FARR,              // =>
  HK_CLOS,              // />
  XD1,                  // :D
  XD3,                  // :DDD
  XD5,                  // :DDDDD
  XD15,                 // :DDDDDDDDDDDDDDD
};

enum tapdancers {
    T_BR = 0, // [, ]
    T_PA, // (, )
    T_CU, // {, }
    T_DL, // $, €
    T_SL, // slash, backslash
};

//Tap Dance Definitions
tap_dance_action_t tap_dance_actions[] = {
  [T_BR] = ACTION_TAP_DANCE_DOUBLE(KC_LBRC, KC_RBRC),
  [T_PA] = ACTION_TAP_DANCE_DOUBLE(KC_LPRN, KC_RPRN),
  [T_CU] = ACTION_TAP_DANCE_DOUBLE(KC_LCBR, KC_RCBR),
  [T_DL] = ACTION_TAP_DANCE_DOUBLE(KC_DLR, KC_EUR),
  [T_SL] = ACTION_TAP_DANCE_DOUBLE(KC_SLSH, KC_BSLS),
};

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_DEFAULT] = LAYOUT_planck_grid(
    KC_ESC,  KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,    KC_Y,  KC_U,    KC_I,    KC_O,    KC_P,    KC_BSPC,
    KC_TAB,  KC_A,    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,  KC_J,    KC_K,    KC_L,    XXXXXXX, KC_ENT,
    KC_LSFT, KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_N,  KC_M,    KC_COMM, KC_DOT,  XXXXXXX, QK_LEAD,
    KC_LGUI, KC_LCTL, KC_LALT, KC_LALT, LOWER,   KC_SPC,  META,  RAISE,   KC_RALT, KC_MPRV, KC_MPLY, KC_MNXT
),

[_LOWER] = LAYOUT_planck_grid(
    KC_F1,   KC_EXLM, KC_AT,   KC_HASH, KC_DLR,  KC_PERC, KC_CIRC, KC_AMPR,    KC_ASTR,    XXXXXXX, XXXXXXX,  XXXXXXX,
    _______, KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,       KC_8,       KC_9,    KC_0,     XXXXXXX,
    _______, HK_TM,   XD1,     XD3,     XD5,     XD15,    XXXXXXX, XXXXXXX,    KC_ARR,     KC_FARR, HK_CLOS,  XXXXXXX,
    _______, _______, _______, _______, _______, KC_DEL,  KC_FBSP, RAISE,      KC_RALT,    KC_VOLD, KC_MUTE,  KC_VOLU
),

[_RAISE] = LAYOUT_planck_grid(
    KC_MGRV, KC_MINUS,   KC_EQL,  KC_EXLM,  KC_QUES, KC_PLUS, KC_PGUP, KC_HOME, KC_UP,   KC_END,  XXXXXXX, KC_FBSP,
    KC_TILD, TD(T_BR), TD(T_CU), TD(T_PA), TD(T_DL), KC_SLSH, KC_RNME, KC_LEFT, KC_DOWN, KC_RGHT, XXXXXXX, KC_FORMAT,
    _______, KC_UNDS,   KC_DQUO,  KC_QUOT,  KC_PIPE, KC_BSLS, XXXXXXX, KC_SCLN, KC_COLN, XXXXXXX, XXXXXXX, XXXXXXX,
    _______, _______,   _______,  _______,  _______, KC_DEL,  KC_FDEL, _______, XXXXXXX, KC_VOLD, KC_MUTE, KC_VOLU
),

[_META] = LAYOUT_planck_grid(
    XXXXXXX,   KC_F1,   KC_F2,   KC_F3,   KC_F4, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,  KC_SRC, XXXXXXX,
    KC_CAPS,   KC_F5,   KC_F6,   KC_F7,   KC_F8,   KC_F9, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
    XXXXXXX,  KC_F10,  KC_F11,  KC_F12,  HK_AF9, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
    XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX
),

[_ADJUST] = LAYOUT_planck_grid(
    XXXXXXX, KC_F1,   KC_F2,   KC_F3,   KC_F4,   XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, CG_TOGG, XXXXXXX,
    XXXXXXX, KC_F5,   KC_F6,   KC_F7,   KC_F8,   XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
    XXXXXXX, KC_F9,   KC_F10,  KC_F11,  KC_F12,  XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
    XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, QK_BOOT
)
};

layer_state_t layer_state_set_user(layer_state_t state) {
  return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
}

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  switch (keycode) {
    case KC_ARR:
      if (record->event.pressed) {
        SEND_STRING("->");
      }

      return false;

    case KC_FARR:
      if (record->event.pressed) {
        SEND_STRING("=>");
      }

      return false;

    case XD1:
      if (record->event.pressed) {
        SEND_STRING(":D");
      }

      return false;

    case XD3:
      if (record->event.pressed) {
        SEND_STRING(":DDD");
      }

      return false;

    case XD5:
      if (record->event.pressed) {
        SEND_STRING(":DDDDD");
      }

      return false;

    case XD15:
      if (record->event.pressed) {
        SEND_STRING(":DDDDDDDDDDDDDDD");
      }

      return false;

    case HK_CLOS:
      if (record->event.pressed) {
        SEND_STRING("/>");
      }

      return false;
  }

  return true;
}

void leader_end_user(void) {
    // Screenshot
    if (leader_sequence_one_key(KC_S)) {
        tap_code16(G(C(S(KC_4))));
    }
    // Record Screen
    if (leader_sequence_two_keys(KC_S, KC_S)) {
        tap_code16(S(G(KC_5)));
    }
    // 1Pass browser
    if (leader_sequence_one_key(KC_A)) {
        tap_code16(G(A(KC_BSLS)));
    }
    // 1Pass mini
    if (leader_sequence_two_keys(KC_A, KC_A)) {
        tap_code16(G(KC_BSLS));
    }
    // Comment out
    if (leader_sequence_one_key(KC_F)) {
        tap_code16(G(KC_SLSH));
    }
    // Spotlight
    if (leader_sequence_one_key(KC_SPC)) {
        tap_code16(G(KC_SPC));
    }
    // Auto format
    if (leader_sequence_one_key(KC_ENT)) {
        tap_code16(S(G(A(KC_F))));
    }
    // Focus file tree
    if (leader_sequence_one_key(KC_TAB)) {
        tap_code16(G(KC_1));
    }
    // Caps-lock
    if (leader_sequence_two_keys(KC_TAB, KC_TAB)) {
        tap_code16(KC_CAPS);
    }
}