logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

keymap.c (10191B)


  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 MO(_LOWER)
  32. #define RAISE MO(_RAISE)
  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. 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|EEPRST| | | | | | | | | 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. _______, QK_BOOT, RGBRST, EE_CLR, _______, _______, _______, _______, _______, _______, _______, KC_DEL,
  110. _______, _______, _______, _______, _______, AG_NORM, AG_SWAP, _______, _______, _______, _______, _______,
  111. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, UG_TOGG, UG_HUEU, UG_SATU, UG_VALU,
  112. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, UG_NEXT, UG_HUED, UG_SATD, UG_VALD
  113. )
  114. };
  115. #if defined(ENCODER_MAP_ENABLE)
  116. const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
  117. [_QWERTY] = { ENCODER_CCW_CW(KC_MS_WH_UP, KC_MS_WH_DOWN), ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
  118. [_LOWER] = { ENCODER_CCW_CW(KC_PGUP, KC_PGDN), ENCODER_CCW_CW(KC_HOME, KC_END) },
  119. [_RAISE] = { ENCODER_CCW_CW(UG_VALD, UG_VALU), ENCODER_CCW_CW(UG_SPDD, UG_SPDU) },
  120. [_ADJUST] = { ENCODER_CCW_CW(UG_PREV, UG_NEXT), ENCODER_CCW_CW(KC_RIGHT, KC_LEFT) },
  121. };
  122. #endif
  123. layer_state_t layer_state_set_user(layer_state_t state) {
  124. return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
  125. }
  126. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  127. switch (keycode) {
  128. case EISU:
  129. if (record->event.pressed) {
  130. if (is_mac_mode()) {
  131. register_code(KC_LNG2);
  132. }else{
  133. tap_code16(LALT(KC_GRAVE));
  134. }
  135. } else {
  136. unregister_code(KC_LNG2);
  137. }
  138. return false;
  139. break;
  140. case KANA:
  141. if (record->event.pressed) {
  142. if (is_mac_mode()) {
  143. register_code(KC_LNG1);
  144. }else{
  145. tap_code16(LALT(KC_GRAVE));
  146. }
  147. } else {
  148. unregister_code(KC_LNG1);
  149. }
  150. return false;
  151. break;
  152. case ADJUST:
  153. if (record->event.pressed) {
  154. layer_on(_LOWER);
  155. layer_on(_RAISE);
  156. } else {
  157. layer_off(_LOWER);
  158. layer_off(_RAISE);
  159. }
  160. break;
  161. case RGBRST:
  162. #ifdef RGBLIGHT_ENABLE
  163. if (record->event.pressed) {
  164. eeconfig_update_rgblight_default();
  165. rgblight_enable();
  166. }
  167. #endif
  168. break;
  169. }
  170. return true;
  171. }