keymap.c 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. /* Copyright 2015-2018 Jack Humbert, Corey Kump
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. //#pragma message "You may need to add LAYOUT_planck_grid to your keymap layers - see default for an example"
  17. #include "planck.h"
  18. #include "action_layer.h"
  19. #include "kc_prefixer.h"
  20. extern keymap_config_t keymap_config;
  21. enum planck_layers {
  22. _COLEMAK,
  23. _QWERTY,
  24. _LOWER,
  25. _LEANDOWN,
  26. _RAISE,
  27. _WOBBLE,
  28. _PLOVER,
  29. _ADJUST
  30. };
  31. /* This include relies on the layer constants above and so must be declared after them */
  32. #include "tapdance.c"
  33. enum planck_keycodes {
  34. QWERTY = SAFE_RANGE,
  35. COLEMAK,
  36. LOWER,
  37. RAISE,
  38. BACKLIT
  39. };
  40. #define KC_ KC_TRNS
  41. #define KC_____ KC_TRNS
  42. #define KC_XXXX KC_NO
  43. #define KC_LOWR LOWER
  44. #define KC_RASE RAISE
  45. /**
  46. * Custom Corvec Bindings
  47. *
  48. * Previously used but currently unused bindings are commented out.
  49. **/
  50. // Activate the Wobble layer
  51. #define KC_WOBL MO(_WOBBLE)
  52. // Dual function with Raise
  53. #define KC_RESC LT(_RAISE, KC_ESC)
  54. // Dual functions with Lower
  55. #define KC_LENT LT(_LOWER, KC_ENT)
  56. #define KC_LQUT LT(_LEANDOWN, KC_QUOT)
  57. // Dual functions with Shift
  58. #define KC_SDEL MT(MOD_LSFT, KC_DEL)
  59. #define KC_SAPP MT(MOD_LSFT, KC_APP)
  60. /**
  61. * Functions taking advantage of tap dance:
  62. **/
  63. // Tap once: quote. Hold: LEANDOWN layer. Tap twice: minus.
  64. #define KC_TQTD TD(TD_QUOT_LEAN_MINS)
  65. // Tap once: [. Hold: RALT. Tap twice: {
  66. #define KC_TALT TD(TD_LBRC_RALT_LCBR)
  67. // Tap once: ]. Hold: RGUI. Tap twice: }
  68. #define KC_TGUI TD(TD_RBRC_RGUI_RCBR)
  69. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  70. [_COLEMAK] = KC_PREFIX(LAYOUT_planck_grid,
  71. //-----+----+----+----+----+----+----+----+----+----+----+----
  72. TAB , Q , W , F , P , G , J , L , U , Y ,SCLN,BSPC,
  73. //-----+----+----+----+----+----+----+----+----+----+----+----
  74. RESC, A , R , S , T , D , H , N , E , I , O ,TQTD,
  75. //-----+----+----+----+----+----+----+----+----+----+----+----
  76. LSFT, Z , X , C , V , B , K , M ,COMM,DOT ,SLSH,RSFT,
  77. //-----+----+----+----+----+----+----+----+----+----+----+----
  78. LCTL,LGUI,WOBL,LALT,LENT, SPC, SPC,RASE,SDEL,TALT,TGUI,RCTL
  79. ),
  80. [_QWERTY] = KC_PREFIX(LAYOUT_planck_grid,
  81. //-----+----+----+----+----+----+----+----+----+----+----+----
  82. TAB , Q , W , E , R , T , Y , U , I , O , P ,BSPC,
  83. //-----+----+----+----+----+----+----+----+----+----+----+----
  84. RESC, A , S , D , F , G , H , J , K , L ,SCLN,TQTD,
  85. //-----+----+----+----+----+----+----+----+----+----+----+----
  86. LSFT, Z , X , C , V , B , N , M ,COMM,DOT ,SLSH,RSFT,
  87. //-----+----+----+----+----+----+----+----+----+----+----+----
  88. LCTL,LGUI,WOBL,LALT,LENT, SPC, SPC,RASE,RALT,SAPP,RGUI,RCTL
  89. ),
  90. [_LOWER] = KC_PREFIX(LAYOUT_planck_grid,
  91. GRV ,EXLM, AT ,HASH, DLR,PERC,CIRC,AMPR,ASTR,LPRN,RPRN,____,
  92. ____,LPRN,RPRN,LBRC,RBRC,XXXX,LEFT,DOWN, UP ,RGHT,XXXX,MINS,
  93. ____,BSLS,TILD,PIPE,EQL ,UNDS,HOME,PGDN,PGUP,END ,BSLS,____,
  94. ____,____,____,____,____,____,____,____,____,____,____,____
  95. ),
  96. [_LEANDOWN] = KC_PREFIX(LAYOUT_planck_grid,
  97. GRV ,EXLM, AT ,HASH, DLR,PERC,CIRC,AMPR,ASTR,LPRN,RPRN,____,
  98. ____,LPRN,RPRN,LBRC,RBRC,LCBR,LCBR,DLR ,PERC,CIRC,____,____,
  99. ____,BSLS,TILD,PIPE,EQL ,UNDS,HOME,EXLM, AT ,HASH,BSLS,____,
  100. ____,____,____,____,____,____,____,____,LEFT,DOWN, UP ,RGHT
  101. ),
  102. [_RAISE] = KC_PREFIX(LAYOUT_planck_grid,
  103. GRV , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 ,____,
  104. ____,LPRN,RPRN,LCBR,RCBR,XXXX,XXXX, 4 , 5 , 6 ,PPLS,MINS,
  105. ____,BSLS,TILD,PIPE,EQL ,UNDS,XXXX, 1 , 2 , 3 ,PAST,____,
  106. ____,____,____,____,____,____,____,____,____,____,____,____
  107. ),
  108. // [_WOBBLE] = KC_PREFIX(LAYOUT_planck_grid,
  109. // GRV , F1 , F2 , F3 , F4 , NO ,MUTE,VOLD,VOLU, NO , NO , DEL,
  110. // , F5 , F6 , F7 , F8 , NO ,MPRV,MPLY,MSTP,MNXT, NO ,BSLS,
  111. // , F9 , F10, F11, F12, NO , NO , NO , NO , INS,PSCR, ,
  112. // , , , , , , , , , , ,
  113. // ),
  114. /* Adjust (Lower + Raise)
  115. * ,-----------------------------------------------------------------------------------.
  116. * |Colemk| | Debug|RGB Tg|RGB Md|RGB H+|RGB H-|RGB S+|RGB S-|RGB V+|RGB V-|Qwerty|
  117. * |------+------+------+------+------+-------------+------+------+------+------+------|
  118. * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk| |AS On | AS + |
  119. * |------+------+------+------+------+------|------+------+------+------+------+------|
  120. * | |Voice-|Voice+|Mus on|Musoff|MIDIon|MIDIof|TermOn|TermOf|AS Rep|AS Off| AS - |
  121. * |------+------+------+------+------+------+------+------+------+------+------+------|
  122. * | | | | | | | | | | | Reset|
  123. * `-----------------------------------------------------------------------------------'
  124. */
  125. [_ADJUST] = {
  126. {COLEMAK, _______, DEBUG, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, QWERTY },
  127. {_______, _______, MU_MOD, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, _______, KC_ASON, KC_ASUP},
  128. {_______, MUV_DE, MUV_IN, MU_ON, MU_OFF, MI_ON, MI_OFF, TERM_ON, TERM_OFF,KC_ASRP, KC_ASOFF,KC_ASDN},
  129. {_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RESET }
  130. }
  131. };
  132. #ifdef AUDIO_ENABLE
  133. float plover_song[][2] = SONG(PLOVER_SOUND);
  134. float plover_gb_song[][2] = SONG(PLOVER_GOODBYE_SOUND);
  135. #endif
  136. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  137. switch (keycode) {
  138. case QWERTY:
  139. if (record->event.pressed) {
  140. print("mode just switched to qwerty and this is a huge string\n");
  141. set_single_persistent_default_layer(_QWERTY);
  142. }
  143. return false;
  144. break;
  145. case COLEMAK:
  146. if (record->event.pressed) {
  147. set_single_persistent_default_layer(_COLEMAK);
  148. }
  149. return false;
  150. break;
  151. case LOWER:
  152. if (record->event.pressed) {
  153. layer_on(_LOWER);
  154. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  155. } else {
  156. layer_off(_LOWER);
  157. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  158. }
  159. return false;
  160. break;
  161. case RAISE:
  162. if (record->event.pressed) {
  163. layer_on(_RAISE);
  164. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  165. } else {
  166. layer_off(_RAISE);
  167. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  168. }
  169. return false;
  170. break;
  171. case BACKLIT:
  172. if (record->event.pressed) {
  173. register_code(KC_RSFT);
  174. #ifdef BACKLIGHT_ENABLE
  175. backlight_step();
  176. #endif
  177. PORTE &= ~(1<<6);
  178. } else {
  179. unregister_code(KC_RSFT);
  180. PORTE |= (1<<6);
  181. }
  182. return false;
  183. break;
  184. }
  185. return true;
  186. }