keymap.c 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /* Copyright 2020 yushakobo
  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. // Defines names for use in layer keycodes and the keymap
  18. enum layer_names {
  19. _QWERTY = 0,
  20. _LOWER,
  21. _RAISE,
  22. _ADJUST
  23. };
  24. // Defines the keycodes used by our macros in process_record_user
  25. enum custom_keycodes {
  26. EISU = SAFE_RANGE,
  27. KANA,
  28. ADJUST,
  29. RGBRST
  30. };
  31. #define LOWER FN_MO13
  32. #define RAISE FN_MO23
  33. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  34. /* Qwerty
  35. * ,-----------------------------------------. ,-----------------------------------------.
  36. * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del |
  37. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  38. * | Tab | Q | W | E | R | T | | Y | U | I | O | P | Bksp |
  39. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  40. * | Ctrl | A | S | D | F | G | | H | J | K | L | ; | ' |
  41. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  42. * | Shift| Z | X | C | V | B | [ | ] | N | M | , | . | / |Enter |
  43. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  44. * |Adjust| Esc | Alt | GUI | EISU |Lower |Space |Space |Raise | KANA | Left | Down | Up |Right |
  45. * `-------------------------------------------------------------------------------------------------'
  46. */
  47. [_QWERTY] = LAYOUT( \
  48. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
  49. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
  50. KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
  51. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_LBRC, KC_RBRC, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
  52. MO(_ADJUST), KC_ESC, KC_LALT, KC_LGUI, EISU, LOWER, KC_SPC, KC_SPC, RAISE, KANA, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
  53. ),
  54. /* Lower
  55. * ,-----------------------------------------. ,-----------------------------------------.
  56. * | | | | | | | | | | | | | |
  57. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  58. * | ~ | ! | @ | # | $ | % | | ^ | & | * | ( | ) | |
  59. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  60. * | | F1 | F2 | F3 | F4 | F5 | | F6 | _ | + | { | } | | |
  61. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  62. * | CAPS | F7 | F8 | F9 | F10 | F11 | ( | ) | F12 | | | Home | End | |
  63. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  64. * | | | | | | | | | | | Next | Vol- | Vol+ | Play |
  65. * `-------------------------------------------------------------------------------------------------'
  66. */
  67. [_LOWER] = LAYOUT( \
  68. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
  69. KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, \
  70. _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
  71. KC_CAPS, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_LPRN, KC_RPRN, KC_F12, _______, _______, KC_HOME, KC_END, _______, \
  72. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
  73. ),
  74. /* Raise
  75. * ,-----------------------------------------. ,-----------------------------------------.
  76. * | | | | | | | | | | | | | Bksp |
  77. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  78. * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del |
  79. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  80. * | | F1 | F2 | F3 | F4 | F5 | | F6 | - | = | [ | ] | \ |
  81. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  82. * | CAPS | F7 | F8 | F9 | F10 | F11 | | | F12 | | |PageDn|PageUp| |
  83. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  84. * | | | | | | | | | | | Next | Vol- | Vol+ | Play |
  85. * `-------------------------------------------------------------------------------------------------'
  86. */
  87. [_RAISE] = LAYOUT( \
  88. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_BSPC, \
  89. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
  90. _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \
  91. KC_CAPS, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______, _______, KC_F12, _______, _______, KC_PGDN, KC_PGUP, _______, \
  92. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
  93. ),
  94. /* Adjust (Lower + Raise)
  95. * ,-----------------------------------------. ,-----------------------------------------.
  96. * | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 |
  97. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  98. * | | Reset|RGBRST| | | | | | | | | | Del |
  99. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  100. * | | | | | | Mac | | Win | | | | | |
  101. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  102. * | | | | | | | | | | |RGB ON| HUE+ | SAT+ | VAL+ |
  103. * |------+------+------+------+------+------+------+------+------+------+------+------+------+------|
  104. * | | | | | | | | | | | MODE | HUE- | SAT- | VAL- |
  105. * `-------------------------------------------------------------------------------------------------'
  106. */
  107. [_ADJUST] = LAYOUT( \
  108. KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
  109. _______, RESET, RGBRST, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \
  110. _______, _______, _______, _______, _______, AG_NORM, AG_SWAP, _______, _______, _______, _______, _______, \
  111. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, \
  112. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD \
  113. )
  114. };
  115. bool encoder_update_user(uint8_t index, bool clockwise) {
  116. if (index == 0) { /* Left side encoder */
  117. if (clockwise) {
  118. tap_code(KC_PGDN);
  119. } else {
  120. tap_code(KC_PGUP);
  121. }
  122. } else if (index == 1) { /* Right side encoder */
  123. if (clockwise) {
  124. tap_code(KC_DOWN);
  125. } else {
  126. tap_code(KC_UP);
  127. }
  128. }
  129. return true;
  130. }
  131. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  132. switch (keycode) {
  133. case EISU:
  134. if (record->event.pressed) {
  135. if (is_mac_mode()) {
  136. register_code(KC_LANG2);
  137. }else{
  138. tap_code16(LALT(KC_GRAVE));
  139. }
  140. } else {
  141. unregister_code(KC_LANG2);
  142. }
  143. return false;
  144. break;
  145. case KANA:
  146. if (record->event.pressed) {
  147. if (is_mac_mode()) {
  148. register_code(KC_LANG1);
  149. }else{
  150. tap_code16(LALT(KC_GRAVE));
  151. }
  152. } else {
  153. unregister_code(KC_LANG1);
  154. }
  155. return false;
  156. break;
  157. case RGBRST:
  158. #ifdef RGBLIGHT_ENABLE
  159. if (record->event.pressed) {
  160. eeconfig_update_rgblight_default();
  161. rgblight_enable();
  162. }
  163. #endif
  164. break;
  165. }
  166. return true;
  167. }
  168. /*
  169. void matrix_init_user(void) {
  170. }
  171. void matrix_scan_user(void) {
  172. }
  173. bool led_update_user(led_t led_state) {
  174. return true;
  175. }
  176. */