2
0

keymap.c 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. #include "planck.h"
  2. #include "action_layer.h"
  3. #ifdef AUDIO_ENABLE
  4. #include "audio.h"
  5. #endif
  6. #include "eeconfig.h"
  7. extern keymap_config_t keymap_config;
  8. // Each layer gets a name for readability, which is then used in the keymap matrix below.
  9. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
  10. // Layer names don't all need to be of the same length, obviously, and you can also skip them
  11. // entirely and just use numbers.
  12. #define _BASE 0
  13. #define _MOVE 1
  14. #define _SYMB 2
  15. #define _MOUSE 3
  16. #define _FUNC 4
  17. enum planck_keycodes {
  18. MOVE = SAFE_RANGE,
  19. SYMB,
  20. FUNC,
  21. BELOW,
  22. ABOVE
  23. };
  24. // Fillers to make layering more clear
  25. #define _______ KC_TRNS
  26. #define XXXXXXX KC_NO
  27. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  28. /* BASE
  29. * ,-----------------------------------------------------------------------------------.
  30. * | Tab | Q | W | F | P | G | J | L | U | Y | ; | - |
  31. * |------+------+------+------+------+------+------+------+------+------+------+------|
  32. * | Bksp | A | R | S | T | D | H | N | E | I | O | " |
  33. * |------+------+------+------+------+------+------+------+------+------+------+------|
  34. * | Shift| Z | X | C | V | B | K | M | , | . | / | Shift|
  35. * |------+------+------+------+------+------+------+------+------+------+------+------|
  36. * | Func | Ctrl | Alt | Cmd | Symb | Enter| Space| Move | Cmd | Alt | Ctrl | Func |
  37. * `-----------------------------------------------------------------------------------'
  38. */
  39. [_BASE] = {
  40. {KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_MINS},
  41. {KC_BSPC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT},
  42. {KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT},
  43. {FUNC, KC_LCTL, KC_LALT, KC_LGUI, SYMB, KC_ENT, KC_SPC, MOVE, KC_RGUI, KC_RALT, KC_RCTL, FUNC }
  44. },
  45. /* MOVE
  46. * ,-----------------------------------------------------------------------------------.
  47. * | Esc | | Cmd-L| Up | Cmd-R| | | Cmd-L| Up | Cmd-R| | Esc |
  48. * |------+------+------+------+------+------+------+------+------+------+------+------|
  49. * | Del | Caps | Left | Down | Right| | | Left | Down | Right| Caps | Del |
  50. * |------+------+------+------+------+------+------+------+------+------+------+------|
  51. * | | | | Pg Up| Pg Dn| Above| | Pg Dn| Pg Up| | | |
  52. * |------+------+------+------+------+------+------+------+------+------+------+------|
  53. * | | | | | | Below| | | | | | |
  54. * `-----------------------------------------------------------------------------------'
  55. */
  56. [_MOVE] = {
  57. {KC_ESC, XXXXXXX, LGUI(KC_LEFT), KC_UP, LGUI(KC_RGHT), XXXXXXX, XXXXXXX, LGUI(KC_LEFT), KC_UP, LGUI(KC_RGHT), XXXXXXX, KC_ESC },
  58. {KC_DEL, KC_CAPS, KC_LEFT, KC_DOWN, KC_RGHT, XXXXXXX, XXXXXXX, KC_LEFT, KC_DOWN, KC_RGHT, KC_CAPS, KC_DEL },
  59. {_______, XXXXXXX, XXXXXXX, KC_PGUP, KC_PGDN, ABOVE, XXXXXXX, KC_PGDN, KC_PGUP, XXXXXXX, XXXXXXX, _______},
  60. {_______, _______, _______, _______, _______, BELOW, _______, _______, _______, _______, _______, _______}
  61. },
  62. /* SYMB
  63. * ,-----------------------------------------------------------------------------------.
  64. * | Esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | – |
  65. * |------+------+------+------+------+------+------+------+------+------+------+------|
  66. * | Del | ! | @ | # | $ | % | ^ | & | * | ( | ) | £ |
  67. * |------+------+------+------+------+------+------+------+------+------+------+------|
  68. * | | ~ | ` | + | = | | | \ | [ | ] | { | } | |
  69. * |------+------+------+------+------+------+------+------+------+------+------+------|
  70. * | | | | | | | | | | | | |
  71. * `-----------------------------------------------------------------------------------'
  72. */
  73. [_SYMB] = {
  74. {KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, LALT(KC_MINS)},
  75. {KC_DEL, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, LALT(KC_3)},
  76. {_______, KC_TILD, KC_GRV, KC_PLUS, KC_EQL, KC_PIPE, KC_BSLS, KC_LBRC, KC_RBRC, KC_LCBR, KC_RCBR, _______},
  77. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}
  78. },
  79. /* MOUSE
  80. * ,-----------------------------------------------------------------------------------.
  81. * | | | ACC-2| ACC-1| ACC-0| | | SW-L | M-U | SW-R | | |
  82. * |------+------+------+------+------+------+------+------+------+------+------+------|
  83. * | | | MB-3 | MB-2 | MB-1 | | | M-L | M-D | M-R | | |
  84. * |------+------+------+------+------+------+------+------+------+------+------+------|
  85. * | | | | | | | | SW-D | SW-U | | | |
  86. * |------+------+------+------+------+------+------+------+------+------+------+------|
  87. * | | | | | | | | | | | | |
  88. * `-----------------------------------------------------------------------------------'
  89. */
  90. [_MOUSE] = {
  91. {XXXXXXX, XXXXXXX, KC_ACL2, KC_ACL1, KC_ACL0, XXXXXXX, XXXXXXX, KC_WH_L, KC_MS_U, KC_WH_R, XXXXXXX, XXXXXXX},
  92. {XXXXXXX, XXXXXXX, KC_BTN3, KC_BTN2, KC_BTN1, XXXXXXX, XXXXXXX, KC_MS_L, KC_MS_D, KC_MS_R, XXXXXXX, XXXXXXX},
  93. {_______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_WH_D, KC_WH_U, XXXXXXX, XXXXXXX, _______},
  94. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______}
  95. },
  96. /* FUNC
  97. * ,-----------------------------------------------------------------------------------.
  98. * | Reset| F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | Vol+ |
  99. * |------+------+------+------+------+------+------+------+------+------+------+------|
  100. * | | F11 | F12 | F13 | F14 | F15 | F16 | F17 | F18 | F19 | F20 | Vol- |
  101. * |------+------+------+------+------+------+------+------+------+------+------+------|
  102. * | | F21 | F22 | F23 | F24 | | | Lock | | | | |
  103. * |------+------+------+------+------+------+------+------+------+------+------+------|
  104. * | | | | | Prev | Mute | Play | Next | | | | |
  105. * `-----------------------------------------------------------------------------------'
  106. */
  107. [_FUNC] = {
  108. {RESET, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_VOLU},
  109. {XXXXXXX, KC_F11, KC_F12, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_VOLD},
  110. {_______, KC_F21, KC_F22, KC_F23, KC_F24, XXXXXXX, XXXXXXX, S(LCTL(KC_POWER)), XXXXXXX, XXXXXXX, XXXXXXX, _______},
  111. {_______, _______, _______, _______, KC_MPRV, KC_MUTE, KC_MPLY, KC_MNXT, _______, _______, _______, _______}
  112. }
  113. };
  114. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  115. switch (keycode) {
  116. case MOVE:
  117. if (record->event.pressed) {
  118. layer_on(_MOVE);
  119. update_tri_layer(_MOVE, _SYMB, _MOUSE);
  120. } else {
  121. layer_off(_MOVE);
  122. update_tri_layer(_MOVE, _SYMB, _MOUSE);
  123. }
  124. return false;
  125. break;
  126. case SYMB:
  127. if (record->event.pressed) {
  128. layer_on(_SYMB);
  129. update_tri_layer(_MOVE, _SYMB, _MOUSE);
  130. } else {
  131. layer_off(_SYMB);
  132. update_tri_layer(_MOVE, _SYMB, _MOUSE);
  133. }
  134. return false;
  135. break;
  136. case FUNC:
  137. if (record->event.pressed) {
  138. layer_on(_FUNC);
  139. } else {
  140. layer_off(_FUNC);
  141. }
  142. return false;
  143. break;
  144. case BELOW:
  145. if (record->event.pressed) {
  146. register_code(KC_LGUI);
  147. register_code(KC_RGHT);
  148. unregister_code(KC_RGHT);
  149. unregister_code(KC_LGUI);
  150. register_code(KC_ENT);
  151. unregister_code(KC_ENT);
  152. }
  153. return false;
  154. break;
  155. case ABOVE:
  156. if (record->event.pressed) {
  157. register_code(KC_LGUI);
  158. register_code(KC_LEFT);
  159. unregister_code(KC_LEFT);
  160. unregister_code(KC_LGUI);
  161. register_code(KC_ENT);
  162. unregister_code(KC_ENT);
  163. register_code(KC_UP);
  164. unregister_code(KC_UP);
  165. }
  166. return false;
  167. break;
  168. }
  169. return true;
  170. }