logo

qmk_firmware

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

keymap.c (8754B)


  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. * | 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. 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|EEPRST| | | | | | | | | 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. _______, QK_BOOT, RGBRST, EE_CLR, _______, _______, _______, _______, _______, _______, _______, KC_DEL,
  99. _______, _______, _______, _______, _______, AG_NORM, AG_SWAP, _______, UG_TOGG, UG_HUEU, UG_SATU, UG_VALU,
  100. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, UG_NEXT, UG_HUED, UG_SATD, UG_VALD
  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. layer_state_t layer_state_set_user(layer_state_t state) {
  120. return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
  121. }
  122. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  123. switch (keycode) {
  124. case EISU:
  125. if (record->event.pressed) {
  126. if (is_mac_mode()) {
  127. register_code(KC_LNG2);
  128. }else{
  129. tap_code16(LALT(KC_GRAVE));
  130. }
  131. } else {
  132. unregister_code(KC_LNG2);
  133. }
  134. return false;
  135. break;
  136. case KANA:
  137. if (record->event.pressed) {
  138. if (is_mac_mode()) {
  139. register_code(KC_LNG1);
  140. }else{
  141. tap_code16(LALT(KC_GRAVE));
  142. }
  143. } else {
  144. unregister_code(KC_LNG1);
  145. }
  146. return false;
  147. break;
  148. case ADJUST:
  149. if (record->event.pressed) {
  150. layer_on(_LOWER);
  151. layer_on(_RAISE);
  152. } else {
  153. layer_off(_LOWER);
  154. layer_off(_RAISE);
  155. }
  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. }