keymap.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. /*
  2. * A keyboard layout for the gridded planck.
  3. *
  4. * Copyright (C) 2017 Luke Silva
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. *
  20. * ,-----------------------------------------------------------------------------------.
  21. * | | | | | | | | | | | | |
  22. * |------+------+------+------+------+------+------+------+------+------+------+------|
  23. * | | | | | | | | | | | | |
  24. * |------+------+------+------+------+------+------+------+------+------+------+------|
  25. * | | | | | | | | | | | | |
  26. * |------+------+------+------+------+------+------+------+------+------+------+------|
  27. * | | | | | | | | | | | | |
  28. * `-----------------------------------------------------------------------------------'
  29. *
  30. * This layout uses colemak by default, and is designed for programming, with easy access to symbols
  31. * through either double purpose modifiers or colemak style rolling for commonly used symbol clusters
  32. * Eg: compare colemak 'this' to '(){\n}' on the symbol layer.
  33. *
  34. * The layout also supports a range of multilingual characters, covering those
  35. * needed for French, German, Swedish and likely some other European Languages.
  36. * In the future full support for Colemak's multilingual deadkeys may be introduced.
  37. *
  38. * The multilingual characters are inputted through QMK's unicode engine, using
  39. * the Linux input method by default, however this can be changed at runtime.
  40. *
  41. */
  42. #include "planck.h"
  43. #define _______ KC_TRNS
  44. #define XXXXXXX KC_NO
  45. // Layers
  46. #define _COLEMAK 0
  47. #define _QWERTY 1
  48. #define _SYM 2
  49. #define _NUM 3
  50. #define _GR 4
  51. #define _GR_S 5
  52. #define _ADJ 6
  53. #define _NAV 7
  54. #define _PLOVER 8
  55. // Macro ID numbers
  56. #define M_ALT_HASH 1
  57. #define M_GR_DASH 2
  58. #define M_SYM_LPRN 3
  59. #define M_NAV_UNDS 4
  60. #define M_NUM_RPRN 5
  61. #define M_CTRL_DLR 6
  62. #define M_LCBR_ENT 7
  63. #define M_PLOVER 8
  64. #define M_EXT_PLV 9
  65. #define M_WINDOWS 10
  66. #define M_LINUX 11
  67. #define M_OSX 12
  68. #define M_FUNCTION 13
  69. #define M_THEN 14
  70. #define M_CATCH 15
  71. // Macro keys
  72. #define ALT_HASH MACROTAP(M_ALT_HASH) // tap for #, hold for Alt
  73. #define GR_DASH MACROTAP(M_GR_DASH) // tap for -, hold for GR layer a-class-name
  74. #define SYM_LPRN MACROTAP(M_SYM_LPRN) // tap for (, hold for symbols layer if()
  75. #define NAV_UNDS MACROTAP(M_NAV_UNDS) // tap for _, hold for navigation layer snake_case_variable
  76. #define NUM_RPRN MACROTAP(M_NUM_RPRN) // tap for ), hold for numbers layer else if()
  77. #define CTRL_DLR MACROTAP(M_CTRL_DLR) // tap for $, hold for ctrl $php_is_really_weird
  78. #define LCBR_ENT M(M_LCBR_ENT) // {\n easier code formatting
  79. #define PLOVER M(M_PLOVER) // PHROPB (plover) or ERFVIK(qwerty) starts plover
  80. #define EXT_PLV M(M_EXT_PLV) // PHRO*F (plover) or ERFVYU(qwerty) stops plover
  81. #define WINDOWS M(M_WINDOWS) // Sets Unicode handler to windows
  82. #define LINUX M(M_LINUX) // Sets Unicode handler to linux
  83. #define OSX M(M_OSX) // Sets Unicode handler to OSX
  84. #define FUNCTION M(M_FUNCTION)
  85. #define THEN M(M_THEN)
  86. #define CATCH M(M_CATCH)
  87. // Renames of QMK keys... (would have otherwise been a macro)
  88. #define QWERTY DF(_QWERTY)
  89. #define COLEMAK DF(_COLEMAK)
  90. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  91. /* Colemak
  92. * ,-----------------------------------------------------------------------------------.
  93. * | Tab | Q | W | F | P | G | J | L | U | Y | ;: | Bksp |
  94. * |------+------+------+------+------+------+------+------+------+------+------+------|
  95. * | Bksp | A | R | S | T | D | H | N | E | I | O | '" |
  96. * |------+------+------+------+------+------+------+------+------+------+------+------`---.
  97. * |Shift=| Z | X | C | V | B | K | M | ,< | .> | /? |Shift/Ent |
  98. * |------+------+------+------+------+------+------+------+------+------+------+----------|
  99. * |CtCaps|GUIF4 | Alt# | Gr- | Sym( | Nav_ |Space | Num) |Ctrl$ | F11 | F12 |Nav toggle|
  100. * `---------------------------------------------------------------------------------------'
  101. */
  102. [_COLEMAK] = {
  103. {KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC},
  104. {KC_BSPC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT},
  105. {SFT_T(KC_EQL), KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, SFT_T(KC_ENT) },
  106. {CTL_T(KC_CAPS), KC_LGUI, ALT_HASH, GR_DASH, SYM_LPRN, NAV_UNDS, KC_SPC, NUM_RPRN, CTRL_DLR, KC_F11, KC_F12, TG(_NAV)}
  107. },
  108. /* QWERTY
  109. * ,-----------------------------------------------------------------------------------.
  110. * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp |
  111. * |------+------+------+------+------+------+------+------+------+------+------+------|
  112. * | Bksp | A | S | D | F | G | H | J | K | L | ;: | '" |
  113. * |------+------+------+------+------+------+------+------+------+------+------+------`---.
  114. * |Shift=| Z | X | C | V | B | N | M | ,< | .> | /? |Shift/Ent |
  115. * |------+------+------+------+------+------+------+------+------+------+------+----------|
  116. * |CtCaps|GUIF4 | Alt# | Gr- | Sym( | Nav_ |Space | Num) |Ctrl$ | F11 | F12 |Nav toggle|
  117. * `---------------------------------------------------------------------------------------'
  118. */
  119. [_QWERTY] = {
  120. {KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC},
  121. {KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT},
  122. {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, SFT_T(KC_ENT) },
  123. {CTL_T(KC_CAPS), KC_LGUI, KC_LALT, GR_DASH, SYM_LPRN,KC_SPC, KC_SPC, NUM_RPRN, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT}
  124. },
  125. /* Symbols
  126. * ,-----------------------------------------------------------------------------------.
  127. * | Tab | ` | @ | / | * | ^ | % | : | + | - | Del | Bksp |
  128. * |------+------+------+------+------+------+------+------+------+------+------+------|
  129. * | | [ | ; | } | ( | " | ' | ) | {\n | ! | ] | \ |
  130. * |------+------+------+------+------+------+------+------+------+------+------+------|
  131. * |Shift | . | { | < | > | ~ | X2 | = | & | | | ? |Enter |
  132. * |------+------+------+------+------+------+------+------+------+------+------+------|
  133. * | | | | | Sym | _ |Space | NUM | X2 | | | |
  134. * `-----------------------------------------------------------------------------------'
  135. */
  136. [_SYM] = {
  137. {KC_TAB, KC_GRV, KC_AT, KC_SLSH, KC_ASTR, KC_CIRC, KC_PERC, KC_COLN, KC_PLUS, KC_MINS, KC_DEL, KC_BSPC},
  138. {FUNCTION,KC_LBRC, KC_SCLN, KC_RCBR, KC_LPRN, KC_DQT, KC_QUOT, KC_RPRN, LCBR_ENT,KC_EXLM, KC_RBRC, KC_BSLS},
  139. {KC_LSFT, KC_DOT, KC_LCBR, KC_LABK, KC_RABK, KC_TILD, _______, KC_EQL, KC_AMPR, KC_PIPE, KC_QUES, KC_ENT },
  140. {THEN, CATCH, XXXXXXX, XXXXXXX, _______, _______, _______, _______, _______, XXXXXXX, XXXXXXX, _______}
  141. },
  142. /* Numbers
  143. * ,-----------------------------------------------------------------------------------.
  144. * | Tab | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
  145. * |------+------+------+------+------+------+------+------+------+------+------+------|
  146. * | Bksp | x | D | E | F | + | - | 4 | 5 | 6 | 0 |Enter |
  147. * |------+------+------+------+------+------+------+------+------+------+------+------|
  148. * |Shift | ( | A | B | C | * | / | 1 | 2 | 3 | ) |Enter |
  149. * |------+------+------+------+------+------+------+------+------+------+------+------|
  150. * | | | | GR | SYM | _ |Space | NUM | 0 | . | f | |
  151. * `-----------------------------------------------------------------------------------'
  152. */
  153. [_NUM] = {
  154. {KC_TAB, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC},
  155. {KC_BSPC, KC_X, S(KC_D), S(KC_E), S(KC_F), KC_PLUS, KC_MINS, KC_4, KC_5, KC_6, KC_0, KC_ENT },
  156. {KC_LSFT, KC_LPRN, S(KC_A), S(KC_B), S(KC_C), KC_ASTR, KC_SLSH, KC_1, KC_2, KC_3, KC_RPRN, KC_ENT },
  157. {_______, _______, _______, _______, _______, _______, _______, _______, KC_0, KC_DOT, KC_F, _______}
  158. },
  159. /* Gr layer / international keys
  160. * ,-----------------------------------------------------------------------------------.
  161. * | | ä | å | | ¢£ | €¥ | | ë | ê | ü | ù | |
  162. * |------+------+------+------+------+------+------+------+------+------+------+------|
  163. * | | â | à | ß | | | | è | é | ï | ö | |
  164. * |------+------+------+------+------+------+------+------+------+------+------+------|
  165. * | | æ | ô | ç | œ | | | û | « | » | î | |
  166. * |------+------+------+------+------+------+------+------+------+------+------+------|
  167. * | | | | | | | | | | | | |
  168. * `-----------------------------------------------------------------------------------'
  169. */
  170. [_GR] = {
  171. {_______, UC(0xE4),UC(0xE5), _______,UC(0xA2), UC(0x20AC),_______,UC(0xEB),UC(0xEA),UC(0xFC),UC(0xF9), _______},
  172. {_______, UC(0xE2),UC(0xE0),UC(0xDF), _______, _______, _______,UC(0xE8),UC(0xE9),UC(0xEF),UC(0xF6), _______},
  173. {MO(_GR_S),UC(0xE6),UC(0xF4),UC(0xE7),UC(0x153),_______, _______,UC(0xFB),UC(0xAB),UC(0xBB),UC(0xEE), MO(_GR_S)},
  174. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}
  175. },
  176. // Shifted layer of the above
  177. [_GR_S] = {
  178. {_______, UC(0xC4),UC(0xC5), _______, UC(0xA3), UC(0xA5),_______, UC(0xCB),UC(0xCA),UC(0xDC),UC(0xD9),_______},
  179. {_______, UC(0xC2),UC(0xC0), UC(0xDF),_______, _______, _______, UC(0xC8),UC(0xC9),UC(0xCF),UC(0xD6),_______},
  180. {MO(_GR_S),UC(0xC6),UC(0xD4), UC(0xC7),UC(0x152),_______, _______, UC(0xDB),UC(0xAB),UC(0xBB),UC(0xCE),MO(_GR_S)},
  181. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}
  182. },
  183. /* Adjust Layer (Gr + Num)
  184. * ,-----------------------------------------------------------------------------------.
  185. * | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 |
  186. * |------+-------------+------+------+------+------+------+------+------+------+------|
  187. * | | |Prntscr| ESC |VOLUP | PLAY | PREV |QWERTY|COLEMAK|PLOVER| | |
  188. * |------+-------------+------+------+------+------+------+------+------+------+------|
  189. * | | |BACKLIT| INS |VOLDWN| MUTE | NEXT | WIND |LINUX | OSX | | |
  190. * |------+-------------+------+------+------+------+------+------+------+------+------|
  191. * | | | | | | | | | | | | |
  192. * `-----------------------------------------------------------------------------------'
  193. */
  194. [_ADJ] = {
  195. {KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12 },
  196. {XXXXXXX, XXXXXXX, KC_PSCR, KC_ESC, KC_VOLU, KC_MPLY, KC_MPRV, QWERTY, COLEMAK, PLOVER, XXXXXXX, XXXXXXX},
  197. {XXXXXXX, XXXXXXX, BL_STEP, KC_INS, KC_VOLD, KC_MUTE, KC_MNXT, WINDOWS, LINUX, OSX, XXXXXXX, XXXXXXX},
  198. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}
  199. },
  200. /* Navigation
  201. * ,-----------------------------------------------------------------------------------.
  202. * | | | BTN3 | BTN2 | BTN1 | | ACL0 | HOME | PGDN | PGUP | END | Bksp |
  203. * |------+------+------+------+------+------+------+------+------+------+------+------|
  204. * | |MSLEFT| MSDN | MSUP |MSRGHT| | ACL1 | LEFT | DOWN | UP | RGHT |Enter |
  205. * |------+------+------+------+------+------+------+------+------+------+------+------|
  206. * | |WHLEFT| WHDN | WHUP |WHRGHT| | ACL2 |C-LEFT|C-PGDN|C-PGUP|C-RGHT|Enter |
  207. * |------+------+------+------+------+------+------+------+------+------+------+------|
  208. * | | | | | | _ |Space | ACL0 | ACL1 | ACL2 | |TGLNAV|
  209. * `-----------------------------------------------------------------------------------'
  210. */
  211. [_NAV] = {
  212. {XXXXXXX, XXXXXXX, KC_BTN3, KC_BTN2, KC_BTN1, XXXXXXX, KC_ACL0, KC_HOME, KC_PGDN, KC_PGUP, KC_END, KC_BSPC},
  213. {XXXXXXX, KC_MS_L, KC_MS_D, KC_MS_U, KC_MS_R, XXXXXXX, KC_ACL1, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT,KC_ENT },
  214. {XXXXXXX, KC_WH_L, KC_WH_D, KC_WH_U, KC_WH_R, XXXXXXX, KC_ACL2, LCTL(KC_LEFT), LCTL(KC_PGDN), LCTL(KC_PGUP), LCTL(KC_RIGHT), KC_ENT },
  215. {_______, _______, _______, _______, _______, _______, _______, KC_ACL0, KC_ACL1, KC_ACL2, _______, _______}
  216. },
  217. /* Plover Layer
  218. * ,-----------------------------------------------------------------------------------.
  219. * | | S | T | P | H | * | * | F | P | L | T | D |
  220. * |------+------+------+------+------+------+------+------+------+------+------+------|
  221. * |TogOut| S | K | W | R | * | * | R | B | G | S | Z |
  222. * |------+------+------+------+------+------+------+------+------+------+------+------|
  223. * | # | # | # | # | # | # | # | # | # | # | # | # |
  224. * |------+------+------+------+------+------+------+------+------+------+------+------|
  225. * | Exit | | | # | A | O | E | U | | | | |
  226. * `-----------------------------------------------------------------------------------'
  227. */
  228. [_PLOVER] = {
  229. {XXXXXXX, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC},
  230. {XXXXXXX, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT},
  231. {KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1, KC_1 },
  232. {EXT_PLV, XXXXXXX, XXXXXXX, KC_1, KC_C, KC_V, KC_N, KC_M, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX}
  233. }
  234. };
  235. const uint16_t PROGMEM fn_actions[] = {
  236. };
  237. void matrix_init_user(){
  238. set_unicode_input_mode(UC_LNX);
  239. }
  240. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
  241. {
  242. switch(id) {
  243. case M_ALT_HASH:
  244. return MACRO_TAP_SHFT_KEY_HOLD_MOD(record, 3, LALT);
  245. case M_GR_DASH:
  246. {
  247. const macro_t* macro = MACRO_TAP_HOLD_LAYER(record, MACRO(T(MINS)), _GR);
  248. update_tri_layer(_NUM, _GR, _ADJ);
  249. return macro;
  250. }
  251. case M_SYM_LPRN:
  252. return MACRO_TAP_SHFT_KEY_HOLD_LAYER(record, 9, _SYM);
  253. case M_NAV_UNDS:
  254. return MACRO_TAP_SHFT_KEY_HOLD_LAYER(record, MINS, _NAV);
  255. case M_NUM_RPRN:
  256. {
  257. const macro_t* macro = MACRO_TAP_SHFT_KEY_HOLD_LAYER(record, 0, _NUM);
  258. update_tri_layer(_NUM, _GR, _ADJ);
  259. return macro;
  260. }
  261. case M_CTRL_DLR:
  262. return MACRO_TAP_SHFT_KEY_HOLD_MOD(record, 4, LCTL);
  263. case M_LCBR_ENT:
  264. return MACRODOWN(I(10), D(LSFT), T(LBRC), U(LSFT), T(ENT), END);
  265. case M_PLOVER:
  266. if (record->event.pressed) {
  267. layer_and(0);
  268. layer_on(_PLOVER);
  269. default_layer_set(_PLOVER);
  270. // Starts plover
  271. return MACRO(I(10), D(E), D(R), D(F), D(V), D(I), D(K), U(E), U(R), U(F), U(V), U(I), U(K), END);
  272. }
  273. break;
  274. case M_EXT_PLV:
  275. if (!record->event.pressed) {
  276. layer_off(_PLOVER);
  277. default_layer_set(_COLEMAK);
  278. //Pauses plover
  279. return MACRO(I(10), D(E), D(R), D(F), D(V), D(Y), D(U), U(E), U(R), U(F), U(V), U(Y), U(U), END);
  280. }
  281. break;
  282. case M_WINDOWS:
  283. set_unicode_input_mode(UC_WIN);
  284. break;
  285. case M_LINUX:
  286. set_unicode_input_mode(UC_LNX);
  287. break;
  288. case M_OSX:
  289. set_unicode_input_mode(UC_OSX);
  290. break;
  291. case M_FUNCTION:
  292. if (record->event.pressed) {
  293. SEND_STRING("function");
  294. }
  295. break;
  296. case M_THEN:
  297. if (record->event.pressed) {
  298. SEND_STRING("then");
  299. }
  300. break;
  301. case M_CATCH:
  302. if (record->event.pressed) {
  303. SEND_STRING("catch");
  304. }
  305. break;
  306. }
  307. return MACRO_NONE;
  308. };