You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

261 lines
9.0 KiB

7 years ago
7 years ago
  1. #include "babblePaste.h"
  2. #include QMK_KEYBOARD_H
  3. #define _QWR 0
  4. #define _CDH 2
  5. #define _SYM 3
  6. #define _MOV 4
  7. #define _TRAN 5
  8. enum layer_keycodes {
  9. QWR,
  10. CDH,
  11. SYM,
  12. MOV,
  13. NUM,
  14. TRAN
  15. };
  16. // Shorter spacing
  17. #define XXXX KC_NO
  18. #define ____ KC_TRNS
  19. // Custom macros
  20. /* Fn Keys */
  21. #define LT_SYM LT(_SYM, KC_SPC)
  22. #define TT_SYM MO(_SYM)
  23. #define TT_MOV LT(_MOV,KC_BSPC)
  24. #define TT_NUM MO(_NUM)
  25. enum macro_keycodes {
  26. DHPASTE=1,
  27. VIBRK,
  28. };
  29. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  30. /* QWERTY
  31. *
  32. * |ESC | F1 | F2 | F3 | F4 | F5 | F6 | f7 | F8 | F9 | F10| F11| F12|Vol-|Vol+|_CDH|
  33. * -------------------------------------------------------------------------------'
  34. * | ESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = |Bakspace| Del|
  35. * ---------------------------------------------------------------------------
  36. * | tab | q | w | e | r | t | y | u | i | o | p | [ | ] | \ | |
  37. * -------------------------------------------------------------------------------'
  38. * |Bak/Mov| a | s | d | f | g | h | j | k | l | ; | ' | enter |PgUp|
  39. * --------------------------------------------------------------------------------
  40. * |Lsft | z | x | c | v | b | n | m | , | . | / | Rsft| Up| PgDn|
  41. * ---------------------------------------------------------------------------------
  42. * |Lctl |Lgui |Lalt | Space/Sym | GUI | Sym | Rctl |Left|Down|Rght|
  43. * ---------------------------------------------------------------------------------
  44. */
  45. [_QWR] = LAYOUT( \
  46. KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_VOLD, KC_VOLU, CDH,\
  47. KC_ESC, KC_1, KC_2, KC_3 ,KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINUS, KC_EQL, KC_BSPC, KC_DEL,\
  48. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS,\
  49. TT_MOV, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGUP,\
  50. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT,KC_SLSH,KC_RSFT, KC_UP, KC_PGDN,\
  51. KC_LCTL, KC_LGUI, KC_LALT, LT_SYM, KC_RGUI,TT_SYM,KC_RCTL, KC_LEFT, KC_DOWN, KC_RIGHT
  52. ),
  53. [_CDH] = LAYOUT(\
  54. ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, QWR, \
  55. KC_ESC, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, \
  56. KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_B, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, ____, ____, ____,\
  57. TT_MOV, KC_A, KC_R, KC_S, KC_T, KC_G, KC_M, KC_N, KC_E, KC_I, KC_O, KC_QUOT, KC_ENT, KC_2,\
  58. KC_LSFT, KC_Z, KC_X, KC_C, M(DHPASTE), KC_V, KC_K, KC_H, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, ____, KC_1,\
  59. ____, ____, ____ , LT_SYM, ____, ____, ____, ____, ____, ____
  60. ),
  61. /* SYM
  62. *
  63. * |ESC | F1 | F2 | F3 | F4 | F5 | F6 | f7 | F8 | F9 | F10| F11| F12|Vol-|Vol+|_CDH|
  64. * -------------------------------------------------------------------------------'
  65. * | ESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = |Bakspace|Del |
  66. * --------------------------------------------------------------------------
  67. * | ESC: | ^ | { | } | @ | % | | [ | ( | ) | _ | [ | ] | \ | |
  68. * -------------------------------------------------------------------------------'
  69. * |Bak/Mov| ! | # | 0 | = | { | } | - | 1 | + | ] | ` | enter |PgUp|
  70. * --------------------------------------------------------------------------------
  71. * |Lsft | ; | ~ | : | ~ | "|"| $ | * | | . | / | Rsft| Up| PgDn|
  72. * ---------------------------------------------------------------------------------
  73. * |Lctl |Lgui |Lalt | Space/Sym | GUI | Sym | Rctl |Left|Down|Rght|
  74. * ---------------------------------------------------------------------------------
  75. */
  76. [_SYM] = LAYOUT(\
  77. ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, \
  78. ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, \
  79. M(VIBRK), KC_CIRC, KC_LCBR, KC_RCBR,KC_AT, KC_PERC, ____, KC_LBRC,KC_LPRN,KC_RPRN,KC_UNDS, ____, ____, ____,\
  80. ____, KC_EXLM, KC_HASH, KC_0, KC_EQL, KC_LCBR, KC_RCBR,KC_MINS,KC_1, KC_PLUS,KC_RBRC, KC_GRV, ____, ____,\
  81. ____, KC_SCLN, KC_TILDE, KC_COLN, KC_TILDE, KC_PIPE, KC_DLR, KC_ASTR, ____, KC_DOT , KC_SLSH, ____, ____, ____,\
  82. ____, ____, ____, ____, ____, ____, ____, ____, ____, ____
  83. ),
  84. /*
  85. * |ESC | MAC| Win|RdLn| VI | | | | | | | | | | | |
  86. * -------------------------------------------------------------------------------'
  87. * | | | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = |Bakspace| Del|
  88. * ---------------------------------------------------------------------------
  89. * | tab | | |Find| |pTab |DSOL|DelW| Up |DelW|DEOL| [ | ] | \ | |
  90. * -------------------------------------------------------------------------------'
  91. * |Bak/Mov| | | | |nTab |GSOL| <- | Dwn | -> | EOL | ' | enter |PgUp|
  92. * --------------------------------------------------------------------------------
  93. * |Lsft |Undo| Cut|Copy|Pste| | | | | | / | Rsft| Up| PgDn|
  94. * ---------------------------------------------------------------------------------
  95. * |Lctl |Lgui |Lalt | Space/Sym | GUI | Sym | Rctl |Left|Down|Rght|
  96. * ---------------------------------------------------------------------------------
  97. */
  98. [_MOV] = LAYOUT(\
  99. ____, B_MAC,B_WIN,B_READ, B_VI, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, \
  100. ____, ____, B_PAPP, B_NAPP, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, \
  101. ____, B_UNDO, ____, B_BFND, ____, B_PTAB, B_DSOL, B_DLW, B_UP, B_DRW, B_DEOL, ____, ____, ____, \
  102. ____, B_SELA, B_BRLD, ____, ____, B_NXTB, B_GSOL, B_L1C, B_DOWN, B_R1C,B_GEOL, ____, ____, ____,\
  103. ____, B_UNDO,B_CUT, B_COPY, B_PAST, B_PAST, ____, ____, ____, ____, ____, ____, ____, ____, \
  104. ____, ____, ____, ____, ____, ____, ____, ____, ____, ____
  105. ),
  106. [_TRAN] = LAYOUT(\
  107. ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, \
  108. ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, \
  109. ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, \
  110. ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, \
  111. ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, \
  112. ____, ____, ____, ____, ____, ____, ____, ____, ____, ____
  113. )
  114. };
  115. #ifdef AUDIO_ENABLE
  116. float tone_startup[][2] = SONG(STARTUP_SOUND);
  117. float tone_qwerty[][2] = SONG(QWERTY_SOUND);
  118. float tone_colemak[][2] = SONG(COLEMAK_SOUND);
  119. #endif
  120. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  121. switch (keycode) {
  122. case QWR:
  123. if (record->event.pressed) {
  124. #ifdef AUDIO_ENABLE
  125. PLAY_SONG(tone_qwerty);
  126. #endif
  127. layer_off(_CDH);
  128. }
  129. return false;
  130. break;
  131. case CDH:
  132. if (record->event.pressed) {
  133. #ifdef AUDIO_ENABLE
  134. PLAY_SONG(tone_colemak);
  135. #endif
  136. layer_on(_CDH);
  137. }
  138. return false;
  139. break;
  140. case SYM:
  141. if (record->event.pressed) {
  142. layer_on(_SYM);
  143. } else {
  144. layer_off(_SYM);
  145. }
  146. return false;
  147. break;
  148. }
  149. return true;
  150. }
  151. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
  152. {
  153. /* If id is in the range of BABL macros, call the babl function */
  154. /* Any clever remapping with modifiers should happen here e.g. shift bablkey does opposite*/
  155. #ifdef USE_BABLPASTE
  156. if( id >= BABL_START_NUM && id < (BABL_START_NUM + BABL_NUM_MACROS ) ) {
  157. if (record->event.pressed) { // is there a case where this isn't desired?
  158. babblePaste ( record, id );
  159. return MACRO_NONE;
  160. }
  161. }
  162. #endif
  163. // MACRODOWN only works in this function
  164. switch(id) {
  165. case 0:
  166. if (record->event.pressed) {
  167. register_code(KC_RSFT);
  168. } else {
  169. unregister_code(KC_RSFT);
  170. }
  171. break;
  172. /* Colemak mod-dh moves the D key to the qwerty V position
  173. This hack makes apple-V_position do what I mean */
  174. case DHPASTE:
  175. if(keyboard_report->mods & MOD_BIT(KC_LGUI) ) {
  176. if (record->event.pressed) {
  177. clear_keyboard_but_mods();
  178. register_code(KC_V);
  179. } else {
  180. unregister_code(KC_V);
  181. }
  182. } else {
  183. if (record->event.pressed) {
  184. register_code(KC_D);
  185. } else {
  186. unregister_code(KC_D);
  187. }
  188. }
  189. break;
  190. case VIBRK: // vi esc:
  191. if (record->event.pressed) {
  192. return MACRO( T(ESC),D(LSFT),T(SCLN),U(LSFT), END );
  193. }
  194. break;
  195. default:
  196. return MACRO_NONE;
  197. }
  198. return MACRO_NONE;
  199. };
  200. void matrix_init_user(void) {
  201. }
  202. void matrix_scan_user(void) {
  203. }
  204. void led_set_user(uint8_t usb_led) {
  205. }