keymap.c 8.4 KB

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