keymap.c 9.3 KB

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