keymap.c 6.9 KB

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