keymap.c 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. #include QMK_KEYBOARD_H
  2. extern keymap_config_t keymap_config;
  3. // Each layer gets a name for readability, which is then used in the keymap matrix below.
  4. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
  5. // Layer names don't all need to be of the same length, obviously, and you can also skip them
  6. // entirely and just use numbers.
  7. #define _QWERTY 0
  8. #define _LOWER 1
  9. #define _RAISE 2
  10. #define _NEUTRAL 3
  11. enum custom_keycodes {
  12. QWERTY = SAFE_RANGE,
  13. L_LOWER,
  14. R_LOWER,
  15. L_RAISE,
  16. R_RAISE
  17. };
  18. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  19. /* Qwerty
  20. * ,------------------------------------------------------------------------------------.
  21. * | | | | | | || | | | | | |
  22. * | Esc | Q | W | E | R | T || Y | U | I | O | P | Bksp |
  23. * |------+------+------+------+------+------++------+------+------+------+------+------|
  24. * |LCTL_T| | | | | || | | | | | |
  25. * | Tab | A | S | D | F | G || H | J | K | L | ; |Enter |
  26. * |------+------+------+------+------+------++------+------+------+------+------+------|
  27. * | | | | | | || | | | | | |
  28. * | | Z | X | C | V | B || N | M | , | . | ! | |
  29. * |------+------+------+------+------+------++------+------+------+------+------+------|
  30. * | | | | | |LSFT_T||RSFT_T| | | | | |
  31. * |Reset | Alt | GUI |LLower|LRaise|Space ||Space |RRaise|RLower| GUI | Del |Reset |
  32. * `------------------------------------------------------------------------------------'
  33. */
  34. [_QWERTY] = LAYOUT_ortho_4x12( \
  35. KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
  36. LCTL_T(KC_TAB), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENT, \
  37. XXXXXXX, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_EXLM, XXXXXXX, \
  38. RESET, KC_LALT, KC_LGUI, L_LOWER, L_RAISE, LSFT_T( KC_SPC ), RSFT_T( KC_SPC ), R_RAISE, R_LOWER, KC_RGUI, KC_DEL, RESET \
  39. ),
  40. /* Raise
  41. * ,------------------------------------------------------------------------------------.
  42. * | | | | | | || | | | | | |
  43. * | Esc | | & | { | } | % || \ | [ | ] | # | | Bksp |
  44. * |------+------+------+------+------+------++------+------+------+------+------+------|
  45. * |LCTL_T| | | | | || | | | | | |
  46. * | Tab | ~ | | | ( | ) | * || / | < | > | ' | : |Enter |
  47. * |------+------+------+------+------+------++------+------+------+------+------+------|
  48. * | | | | | | || | | | | | |
  49. * | | ` | ^ | @ | $ | + || - | = | _ | " | ? | |
  50. * |------+------+------+------+------+------++------+------+------+------+------+------|
  51. * | | | | | |LSFT_T||RSFT_T| | | | | |
  52. * |Reset | Alt | GUI |LLower|LRaise|Space ||Space |RRaise|RLower| GUI | Del |Reset |
  53. * `------------------------------------------------------------------------------------'
  54. */
  55. [_RAISE] = LAYOUT_ortho_4x12( \
  56. _______, XXXXXXX, KC_AMPR, KC_LCBR, KC_RCBR, KC_PERC, KC_BSLS, KC_LBRC, KC_RBRC, KC_HASH, XXXXXXX, _______, \
  57. _______, KC_TILD, KC_PIPE, KC_LPRN, KC_RPRN, KC_ASTR, KC_SLSH, KC_LABK, KC_RABK, KC_QUOT, KC_COLN, _______, \
  58. _______, KC_GRV, KC_CIRC, KC_AT, KC_DLR, KC_PLUS, KC_MINS, KC_EQL, KC_UNDS, KC_DQUO, KC_QUES, _______, \
  59. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
  60. ),
  61. /* Lower
  62. * ,------------------------------------------------------------------------------------.
  63. * | | | | | | || | | | | | |
  64. * | Esc | 1 | 2 | 3 | 4 | 5 || 6 | 7 | 8 | 9 | 0 | Bksp |
  65. * |------+------+------+------+------+------++------+------+------+------+------+------|
  66. * |LCTL_T| | | | | || | | | | | |
  67. * | Tab | |VolDn |VolUp | Mute | || Left | Down | Up |Right | |Enter |
  68. * |------+------+------+------+------+------++------+------+------+------+------+------|
  69. * | | | | | | || | | | | | |
  70. * | | | | | | || | | | | | |
  71. * |------+------+------+------+------+------++------+------+------+------+------+------|
  72. * | | | | | |LSFT_T||RSFT_T| | | | | |
  73. * |Reset | Alt | GUI |LLower|LRaise|Space ||Space |RRaise|RLower| GUI | Del |Reset |
  74. * `------------------------------------------------------------------------------------'
  75. */
  76. [_LOWER] = LAYOUT_ortho_4x12( \
  77. _______, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, \
  78. _______, XXXXXXX, KC_VOLD, KC_VOLU, KC_MUTE, XXXXXXX, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, XXXXXXX, _______, \
  79. _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, \
  80. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
  81. ),
  82. /* Neutral
  83. * ,------------------------------------------------------------------------------------.
  84. * | | | | | | || | | | | | |
  85. * | Esc | F1 | F2 | F3 | F4 | || + | - | 1 | 2 | 3 | Bksp |
  86. * |------+------+------+------+------+------++------+------+------+------+------+------|
  87. * |LCTL_T| | | | | || | | | | | |
  88. * | Tab | F5 | F6 | F7 | F8 | || * | / | 4 | 5 | 6 |Enter |
  89. * |------+------+------+------+------+------++------+------+------+------+------+------|
  90. * | | | | | | || | | | | | |
  91. * | | F9 | F10 | F11 | F12 | || . | , | 7 | 8 | 9 | |
  92. * |------+------+------+------+------+------++------+------+------+------+------+------|
  93. * | | | | | |LSFT_T||RSFT_T| | | | | |
  94. * |Reset | Alt | GUI |LLower|LRaise|Space ||Space |RRaise|RLower| 0 | Del |Reset |
  95. * `------------------------------------------------------------------------------------'
  96. */
  97. [_NEUTRAL] = LAYOUT_ortho_4x12( \
  98. _______, KC_F1, KC_F2, KC_F3, KC_F4, XXXXXXX, KC_PPLS, KC_PMNS, KC_P1, KC_P2, KC_P3, _______, \
  99. _______, KC_F5, KC_F6, KC_F7, KC_F8, XXXXXXX, KC_PAST, KC_PSLS, KC_P4, KC_P5, KC_P6, _______, \
  100. _______, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX, KC_PDOT, KC_COMM, KC_P7, KC_P8, KC_P9, _______, \
  101. _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_P0, _______, _______ \
  102. )
  103. };
  104. void DualKeyPressed ( bool brother_state, uint8_t target ){
  105. if( brother_state ) return;
  106. layer_on( target );
  107. return;
  108. }
  109. void DualKeyReleased ( bool brother_state, uint8_t target1 ){
  110. if( brother_state ) return ;
  111. layer_off( target1 );
  112. return ;
  113. }
  114. bool LayerSwitch ( keyrecord_t *record, bool *key_state, bool brother, uint8_t layer ){
  115. if ( record -> event.pressed ) {
  116. *key_state = true;
  117. DualKeyPressed( brother, layer );
  118. }
  119. else {
  120. *key_state = false;
  121. DualKeyReleased( brother, layer );
  122. }
  123. update_tri_layer(_LOWER, _RAISE, _NEUTRAL );
  124. return false;
  125. }
  126. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  127. static bool l_lower = false;
  128. static bool r_lower = false;
  129. static bool l_raise = false;
  130. static bool r_raise = false;
  131. switch (keycode) {
  132. case L_LOWER : return LayerSwitch( record, &l_lower, r_lower, _LOWER ); break;
  133. case R_LOWER : return LayerSwitch( record, &r_lower, l_lower, _LOWER ); break;
  134. case L_RAISE : return LayerSwitch( record, &l_raise, r_raise, _RAISE ); break;
  135. case R_RAISE : return LayerSwitch( record, &r_raise, l_raise, _RAISE ); break;
  136. }
  137. return true;
  138. }