keymap.c 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* Copyright 2018 'Masayuki Sunahara'
  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 QMK_KEYBOARD_H
  17. // Each layer gets a name for readability, which is then used in the keymap matrix below.
  18. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
  19. // Layer names don't all need to be of the same length, obviously, and you can also skip them
  20. // entirely and just use numbers.
  21. #define _QWERTY 0
  22. #define _LOWER 3
  23. #define _RAISE 4
  24. #define _ADJUST 16
  25. enum custom_keycodes {
  26. QWERTY = SAFE_RANGE,
  27. LOWER,
  28. RAISE,
  29. ADJUST
  30. };
  31. #define ________ KC_TRNS
  32. #define XXXXXXXX KC_NO
  33. #define KC_LOWER LOWER
  34. #define KC_RAISE RAISE
  35. #define KC_ADJ ADJUST
  36. #define KC_CTLTB CTL_T(KC_TAB)
  37. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  38. [_QWERTY] = LAYOUT(
  39. //,---------------------------------------------------------------------. ,---------------------------------------------------------------------.
  40. KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_LPRN, KC_RPRN, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,\
  41. //|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------|
  42. KC_CTLTB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_LBRC, KC_RBRC, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,\
  43. //|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------|
  44. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_ADJ, KC_ADJ, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT,\
  45. //|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------|
  46. KC_LALT, KC_LOWER, KC_LGUI, KC_SPC, KC_SPC, KC_RGUI, KC_RAISE, KC_RALT \
  47. //`---------------------------------------' `---------------------------------------'
  48. ),
  49. [_LOWER] = LAYOUT( \
  50. //,---------------------------------------------------------------------. ,---------------------------------------------------------------------.
  51. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, ________, ________, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSLS,\
  52. //|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------|
  53. ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, KC_MINS, KC_EQL, ________,\
  54. //|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------|
  55. ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________,\
  56. //|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------|
  57. ________, ________, ________, ________, ________, ________, ________, ________ \
  58. //`---------------------------------------' `---------------------------------------'
  59. ),
  60. [_RAISE] = LAYOUT( \
  61. //,---------------------------------------------------------------------. ,---------------------------------------------------------------------.
  62. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, ________, ________, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSLS,\
  63. //|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------|
  64. ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, KC_MINS, KC_EQL, ________,\
  65. //|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------|
  66. ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________,\
  67. //|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------|
  68. ________, ________, ________, ________, ________, ________, ________, ________ \
  69. //`---------------------------------------' `---------------------------------------'
  70. ),
  71. [_ADJUST] = LAYOUT( \
  72. //,---------------------------------------------------------------------. ,---------------------------------------------------------------------.
  73. ________, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_LCBR, KC_RCBR, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, ________,\
  74. //|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------|
  75. ________, KC_F11, KC_F12, ________, ________, ________, KC_LCBR, KC_RCBR, KC_HOME, KC_PGDN, KC_PGUP, KC_END, ________, ________,\
  76. //|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------|
  77. ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________, ________,\
  78. //|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------|
  79. ________, ________, ________, ________, ________, ________, ________, ________ \
  80. //`---------------------------------------' `---------------------------------------'
  81. )
  82. };
  83. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  84. if (record->event.pressed) {
  85. // set_timelog();
  86. }
  87. switch (keycode) {
  88. case QWERTY:
  89. if (record->event.pressed) {
  90. set_single_persistent_default_layer(_QWERTY);
  91. }
  92. return false;
  93. break;
  94. case LOWER:
  95. if (record->event.pressed) {
  96. layer_on(_LOWER);
  97. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  98. } else {
  99. layer_off(_LOWER);
  100. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  101. }
  102. return false;
  103. break;
  104. case RAISE:
  105. if (record->event.pressed) {
  106. layer_on(_RAISE);
  107. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  108. } else {
  109. layer_off(_RAISE);
  110. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  111. }
  112. return false;
  113. break;
  114. case ADJUST:
  115. if (record->event.pressed) {
  116. layer_on(_ADJUST);
  117. } else {
  118. layer_off(_ADJUST);
  119. }
  120. return false;
  121. break;
  122. }
  123. return true;
  124. }