keymap.c 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. #include QMK_KEYBOARD_H
  2. extern keymap_config_t keymap_config;
  3. #define _QWERTY 0
  4. #define _COLEMAK 1
  5. #define _DVORAK 2
  6. #define _LOWER 3
  7. #define _RAISE 4
  8. #define _MOUSE 5
  9. #define _ADJUST 16
  10. enum custom_keycodes {
  11. QWERTY = SAFE_RANGE,
  12. COLEMAK,
  13. DVORAK,
  14. LOWER,
  15. RAISE,
  16. MOUSE,
  17. ADJUST,
  18. };
  19. // Fillers to make layering more clear
  20. #define _______ KC_TRNS
  21. #define KC_ KC_TRNS
  22. #define XXXXXXX KC_NO
  23. #define ESC_CMD MT(MOD_LGUI, KC_ESC)
  24. #define RSE_ENT LT(_RAISE, KC_ENT)
  25. #define KC_LOWR LOWER
  26. #define KC_RASE RAISE
  27. #define KC_ADJ ADJUST
  28. #define MOUSE TG(_MOUSE)
  29. #define DESK_L LCTL(KC_LEFT)
  30. #define DESK_R LCTL(KC_RGHT)
  31. #define MSN_CTL LCTL(KC_UP)
  32. #define APP_WND LCTL(KC_DOWN)
  33. #define SWITCHR LGUI(KC_TAB)
  34. #define WORD_L LALT(KC_LEFT)
  35. #define WORD_R LALT(KC_RGHT)
  36. #define LINE_L LGUI(KC_LEFT)
  37. #define LINE_R LGUI(KC_RGHT)
  38. #define COPY LGUI(KC_C)
  39. #define CUT LGUI(KC_X)
  40. #define PASTE LGUI(KC_V)
  41. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  42. [_QWERTY] = LAYOUT_ortho_4x12(
  43. // .--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------.
  44. KC_TAB , KC_Q , KC_W , KC_E , KC_R , KC_T , KC_Y , KC_U , KC_I, KC_O , KC_P , KC_BSPC, \
  45. // |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  46. ESC_CMD, KC_A , KC_S , KC_D , KC_F , KC_G , KC_H , KC_J , KC_K, KC_L , KC_SCLN, KC_QUOT, \
  47. // |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  48. KC_LSPO, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_N , KC_M , KC_COMM, KC_DOT , KC_SLSH, KC_RSPC, \
  49. // |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  50. KC_LCTL, KC_HYPR, MOUSE , KC_LALT, LOWER , KC_SPC , KC_SPC , RSE_ENT, KC_LEFT, KC_DOWN, KC_UP , KC_RGHT \
  51. // '--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------'
  52. ),
  53. [_COLEMAK] = LAYOUT_ortho_4x12( \
  54. // .--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------.
  55. KC_TAB , KC_Q , KC_W , KC_F , KC_P , KC_G , KC_J , KC_L , KC_U , KC_Y , KC_SCLN, KC_BSPC, \
  56. // |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  57. ESC_CMD, KC_A , KC_R , KC_S , KC_T , KC_D , KC_H , KC_N , KC_E , KC_I , KC_O , KC_QUOT, \
  58. // |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  59. KC_LSPO, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_K , KC_M , KC_COMM, KC_DOT , KC_SLSH, KC_RSPC, \
  60. // |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  61. KC_LCTL, KC_HYPR, MOUSE , KC_LALT, LOWER , KC_SPC , KC_SPC , RSE_ENT, KC_LEFT, KC_DOWN, KC_UP , KC_RGHT \
  62. // '--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------'
  63. ),
  64. [_DVORAK] = LAYOUT_ortho_4x12( \
  65. // .--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------.
  66. KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC, \
  67. // |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  68. ESC_CMD, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH, \
  69. // |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  70. KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT , \
  71. // |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  72. KC_LCTL, KC_HYPR, MOUSE , KC_LALT, LOWER , KC_SPC , KC_SPC , RSE_ENT, KC_LEFT, KC_DOWN, KC_UP , KC_RGHT \
  73. // '--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------'
  74. ),
  75. [_LOWER] = LAYOUT_ortho_4x12( \
  76. // .--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------.
  77. SWITCHR, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_7, KC_8, KC_9, KC_MINS, _______, \
  78. // |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  79. KC_TILD, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_4, KC_5, KC_6, KC_PLUS, KC_PIPE, \
  80. // |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  81. _______, _______, _______, KC_UNDS, KC_EQL, _______, _______, KC_1, KC_2, KC_3, _______, _______, \
  82. // |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  83. _______, _______, _______, _______, _______, _______, _______, KC_0, KC_DOT, KC_COMM, _______, _______ \
  84. // '--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------'
  85. ),
  86. [_RAISE] = LAYOUT_ortho_4x12( \
  87. // .--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------.
  88. KC_GRV, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_UNDS, KC_EQL, KC_DEL, \
  89. // |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  90. _______, _______, KC_LBRC, KC_LCBR, KC_RCBR, KC_RBRC, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, KC_BSLS, \
  91. // |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  92. _______, _______, _______, _______, _______, _______, LINE_L, WORD_L, WORD_R, LINE_R, _______, _______, \
  93. // |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  94. _______, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_VOLD, KC_VOLU, KC_MNXT \
  95. // '--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------'
  96. ),
  97. [_MOUSE] = LAYOUT_ortho_4x12( \
  98. // .--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------.
  99. SWITCHR, _______, _______, KC_MS_U, _______, _______, _______, KC_ACL0, KC_ACL1, KC_ACL2, _______, _______, \
  100. // |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  101. _______, _______, KC_MS_L, KC_MS_D, KC_MS_R, _______, _______, KC_BTN1, KC_BTN2, KC_BTN3, _______, _______, \
  102. // |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  103. _______, _______, _______, KC_WH_U, KC_WH_D, COPY, PASTE, KC_BTN4, KC_BTN5, _______, _______, _______, \
  104. // |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------|
  105. _______, _______, MOUSE , _______, _______, KC_SPC, KC_SPC, KC_ENT, KC_LEFT, KC_DOWN, KC_UP , KC_RGHT \
  106. // '--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------'
  107. ),
  108. [_ADJUST] = LAYOUT_ortho_4x12( \
  109. _______, QWERTY, COLEMAK, DVORAK, RESET, _______, _______, _______, _______, AG_NORM, AG_SWAP, _______, \
  110. _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, _______, _______, AU_OFF , AU_ON , _______, \
  111. _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______, \
  112. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
  113. )
  114. };
  115. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  116. switch (keycode) {
  117. case QWERTY:
  118. if (record->event.pressed) {
  119. set_single_persistent_default_layer(_QWERTY);
  120. }
  121. return false;
  122. break;
  123. case COLEMAK:
  124. if (record->event.pressed) {
  125. set_single_persistent_default_layer(_COLEMAK);
  126. }
  127. return false;
  128. break;
  129. case DVORAK:
  130. if (record->event.pressed) {
  131. set_single_persistent_default_layer(_DVORAK);
  132. }
  133. return false;
  134. break;
  135. case LOWER:
  136. if (record->event.pressed) {
  137. layer_on(_LOWER);
  138. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  139. } else {
  140. layer_off(_LOWER);
  141. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  142. }
  143. return false;
  144. break;
  145. case RAISE:
  146. if (record->event.pressed) {
  147. layer_on(_RAISE);
  148. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  149. } else {
  150. layer_off(_RAISE);
  151. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  152. }
  153. return false;
  154. break;
  155. case ADJUST:
  156. if (record->event.pressed) {
  157. layer_on(_ADJUST);
  158. } else {
  159. layer_off(_ADJUST);
  160. }
  161. return false;
  162. break;
  163. }
  164. return true;
  165. }