You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

203 lines
10 KiB

  1. /* Copyright 2020 monksoffunk
  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. #ifdef RGBLIGHT_ENABLE
  18. //Following line allows macro to read current RGB settings
  19. // Light LEDs 6 to 9 and 12 to 15 red when caps lock is active. Hard to ignore!
  20. const rgblight_segment_t PROGMEM capslock_layer[] = RGBLIGHT_LAYER_SEGMENTS(
  21. {12, 1, HSV_RED} // Light 4 LEDs, starting with LED 6
  22. );
  23. // Light LEDs 9 & 10 in cyan when keyboard layer 1 is active
  24. const rgblight_segment_t PROGMEM lower_layer[] = RGBLIGHT_LAYER_SEGMENTS(
  25. {24, 6, HSV_GOLDENROD}
  26. );
  27. // Light LEDs 11 & 12 in purple when keyboard layer 2 is active
  28. const rgblight_segment_t PROGMEM raise_layer[] = RGBLIGHT_LAYER_SEGMENTS(
  29. {54, 6, HSV_GOLDENROD}
  30. );
  31. // Now define the array of layers. Later layers take precedence
  32. const rgblight_segment_t* const PROGMEM rgb_layers[] = RGBLIGHT_LAYERS_LIST(
  33. capslock_layer,
  34. lower_layer,
  35. raise_layer
  36. );
  37. void keyboard_post_init_user(void) {
  38. // Enable the LED layers
  39. rgblight_layers = rgb_layers;
  40. }
  41. #endif
  42. extern uint8_t is_master;
  43. // Each layer gets a name for readability, which is then used in the keymap matrix below.
  44. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
  45. // Layer names don't all need to be of the same length, obviously, and you can also skip them
  46. // entirely and just use numbers.
  47. enum layer_number {
  48. _QWERTY = 0,
  49. _LOWER,
  50. _RAISE,
  51. _ADJUST,
  52. _ADJUST2
  53. };
  54. enum custom_keycodes {
  55. QWERTY = SAFE_RANGE,
  56. KANA,
  57. EISU,
  58. ADJUST,
  59. RGBRST
  60. };
  61. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  62. /* Qwerty
  63. * ,-----------------------------------------. ,-----------------------------------------.
  64. * | Tab | Q | W | E | R | T | | Y | U | I | O | P | Bksp |
  65. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  66. * | Ctrl | A | S | D | F | G | | H | J | K | L | ; | ' |
  67. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  68. * | Shift| Z | X | C | V | B | | N | M | , | . | / |Enter |
  69. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  70. * | Esc |ADJUST| Win | Alt |LOWER |Space | | Space| RAISE| Left | Down | Up | Right|
  71. * `-----------------------------------------' `-----------------------------------------'
  72. */
  73. [_QWERTY] = LAYOUT_ortho_4x12(
  74. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC,
  75. KC_LCTL, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
  76. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT ,
  77. KC_ESC, MO(_ADJUST), KC_LGUI, KC_LALT, MO(_LOWER), KC_SPC, KC_SPC, MO(_RAISE), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
  78. ),
  79. /* Lower
  80. * ,-----------------------------------------. ,-----------------------------------------.
  81. * | ~ | ! | @ | # | $ | % | | ^ | & | * | ( | ) | |
  82. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  83. * | | | | | | | | - | _ | + | { | } | | |
  84. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  85. * | | | | | | | | | | | Home | End | |
  86. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  87. * | | | | | | | | | | Next | Vol- | Vol+ | Play |
  88. * `-----------------------------------------' `-----------------------------------------'
  89. */
  90. [_LOWER] = LAYOUT_ortho_4x12(
  91. KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______,
  92. _______, _______, _______, _______, _______, _______, KC_MINS, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE,
  93. _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_END, _______,
  94. _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY
  95. ),
  96. /* Raise
  97. * ,-----------------------------------------. ,-----------------------------------------.
  98. * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | Del |
  99. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  100. * | | F1 | F2 | F3 | F4 | F5 | | F6 | - | = | [ | ] | \ |
  101. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  102. * | | F7 | F8 | F9 | F10 | F11 | | F12 | | | | |
  103. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  104. * | | | | | | | | | | Next | Vol- | Vol+ | Play |
  105. * `-----------------------------------------' `-----------------------------------------'
  106. */
  107. [_RAISE] = LAYOUT_ortho_4x12(
  108. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL,
  109. _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS,
  110. _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______, _______, _______,
  111. _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY
  112. ),
  113. /* Adjust (Lower + Raise)
  114. * ,-----------------------------------------. ,-----------------------------------------.
  115. * | | Reset|RGBRST|Aud on|Audoff| | | |Qwerty|Colemk|Dvorak| | Ins |
  116. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  117. * | |RGB ON| HUE+ | SAT+ | VAL+ | Mac | | Win | - | = |Print |ScLock|Pause |
  118. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  119. * |MODE R| MODE | HUE- | SAT- | VAL- | | | | | | |PageUp| |
  120. * |------+------+------+------+------+------| |------+------+------+------+------+------|
  121. * | | | | EISU | EISU | EISU | | KANA | KANA | Home |PageDn|PageUp| End |
  122. * `-----------------------------------------' `-----------------------------------------'
  123. */
  124. [_ADJUST] = LAYOUT_ortho_4x12(
  125. _______, QK_BOOT, RGBRST, _______, _______, _______, _______, QWERTY, _______, _______, _______, KC_INS,
  126. _______, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, AG_NORM, AG_SWAP, KC_MINS, KC_EQL, KC_PSCR, KC_SCRL, KC_PAUS,
  127. RGB_RMOD,RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD, _______, _______, _______, _______, _______, KC_PGUP, _______,
  128. _______, _______, _______, EISU, EISU, EISU, KANA, KANA, KANA, KC_HOME, KC_PGDN, KC_END
  129. ),
  130. [_ADJUST2] = LAYOUT_ortho_4x12(
  131. _______, QK_BOOT, RGBRST, _______, _______, _______, _______, QWERTY, _______, _______, _______, KC_INS,
  132. _______, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, AG_NORM, AG_SWAP, KC_MINS, KC_EQL, KC_PSCR, KC_SCRL, KC_PAUS,
  133. RGB_RMOD,RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD, _______, _______, _______, _______, _______, KC_PGUP, _______,
  134. _______, _______, _______, EISU, EISU, EISU, KANA, KANA, KANA, KC_HOME, KC_PGDN, KC_END
  135. )
  136. };
  137. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  138. switch (keycode) {
  139. case EISU:
  140. if (record->event.pressed) {
  141. if(keymap_config.swap_lalt_lgui==false){
  142. register_code(KC_LNG2);
  143. } else {
  144. SEND_STRING(SS_LALT("`"));
  145. }
  146. } else {
  147. unregister_code(KC_LNG2);
  148. }
  149. return false;
  150. case KANA:
  151. if (record->event.pressed) {
  152. if(keymap_config.swap_lalt_lgui==false){
  153. register_code(KC_LNG1);
  154. } else {
  155. SEND_STRING(SS_LALT("`"));
  156. }
  157. } else {
  158. unregister_code(KC_LNG1);
  159. }
  160. return false;
  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. }
  172. layer_state_t layer_state_set_user(layer_state_t state) {
  173. state = update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST2);
  174. #ifdef RGBLIGHT_LAYERS
  175. // Both layers will light up if both kb layers are active
  176. rgblight_set_layer_state(1, layer_state_cmp(state, 1));
  177. rgblight_set_layer_state(2, layer_state_cmp(state, 2));
  178. #endif
  179. return state;
  180. }
  181. bool led_update_user(led_t led_state) {
  182. rgblight_set_layer_state(0, led_state.caps_lock);
  183. return true;
  184. }