logo

qmk_firmware

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

keymap.c (10212B)


  1. /* Copyright 2017 Cole Markham
  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. extern rgblight_config_t rgblight_config;
  20. #endif
  21. #define _QWERTY 0
  22. #define _LOWER 1
  23. #define _RAISE 2
  24. #define _ADJUST 3
  25. enum custom_keycodes {
  26. LOWER = SAFE_RANGE,
  27. RAISE,
  28. ADJUST,
  29. };
  30. // define variables for reactive RGB
  31. bool TOG_STATUS = false;
  32. int RGB_current_mode;
  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. * | Esc | A | S | D | F | G | H | J | K | L | ; | ' |
  39. * |------+------+------+------+------+------|------+------+------+------+------+------|
  40. * | Shift| Z | X | C | V | B | N | M | , | . |//GUI |Enter |
  41. * |------+------+------+------+------+------+------+------+------+------+------+------|
  42. * | Ctrl | GUI | Alt | GUI |Lower |Space |Enter |Raise | 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_ESC, 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, GUI_T(KC_SLSH), KC_ENT,
  49. KC_LCTL, KC_LGUI, KC_LALT, KC_RGUI, LOWER, KC_SPC, KC_ENT, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT
  50. ),
  51. /* Lower
  52. * ,-----------------------------------------------------------------------------------.
  53. * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | DEL |
  54. * |------+------+------+------+------+-------------+------+------+------+------+------|
  55. * | | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | | |
  56. * |------+------+------+------+------+------|------+------+------+------+------+------|
  57. * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | | |
  58. * |------+------+------+------+------+------+------+------+------+------+------+------|
  59. * | | | | | | | | | Home | PgUp | PgDn | End |
  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, KC_DEL,
  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_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, S(KC_NUHS), S(KC_NUBS), _______, _______, _______,
  66. _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END
  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. * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / | | | |
  75. * |------+------+------+------+------+------+------+------+------+------+------+------|
  76. * | | | | | | | | | Home | PgUp | PgDn | End |
  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_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______,
  83. _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END
  84. ),
  85. /* Adjust (Lower + Raise)
  86. * ,-----------------------------------------------------------------------------------.
  87. * | | Reset| | | | | | | | | | Del |
  88. * |------+------+------+------+------+-------------+------+------+------+------+------|
  89. * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty| | | | |
  90. * |------+------+------+------+------+------|------+------+------+------+------+------|
  91. * | | | | | | | | | | | | |
  92. * |------+------+------+------+------+------+------+------+------+------+------+------|
  93. * | | | | | | | | | | | |
  94. * `-----------------------------------------------------------------------------------'
  95. */
  96. [_ADJUST] = LAYOUT(
  97. BL_TOGG, QK_BOOT, _______, KC_MRWD, KC_MPLY, KC_MFFD, KC_PSCR, _______, KC_MUTE, KC_VOLD, KC_VOLU, KC_DEL,
  98. BL_STEP, UG_NEXT, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, _______, _______, _______, _______, _______,
  99. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  100. _______, KC_PSCR, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______
  101. )
  102. };
  103. // Setting ADJUST layer RGB back to default
  104. void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
  105. if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
  106. #ifdef RGBLIGHT_ENABLE
  107. rgblight_mode(RGB_current_mode);
  108. #endif
  109. layer_on(layer3);
  110. } else {
  111. layer_off(layer3);
  112. }
  113. }
  114. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  115. switch (keycode) {
  116. case LOWER:
  117. if (record->event.pressed) {
  118. //not sure how to have keyboard check mode and set it to a variable, so my work around
  119. //uses another variable that would be set to true after the first time a reactive key is pressed.
  120. if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
  121. } else {
  122. TOG_STATUS = !TOG_STATUS;
  123. #ifdef RGBLIGHT_ENABLE
  124. rgblight_mode(16);
  125. #endif
  126. }
  127. layer_on(_LOWER);
  128. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  129. } else {
  130. #ifdef RGBLIGHT_ENABLE
  131. rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
  132. #endif
  133. TOG_STATUS = false;
  134. layer_off(_LOWER);
  135. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  136. }
  137. return false;
  138. break;
  139. case RAISE:
  140. if (record->event.pressed) {
  141. //not sure how to have keyboard check mode and set it to a variable, so my work around
  142. //uses another variable that would be set to true after the first time a reactive key is pressed.
  143. if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
  144. } else {
  145. TOG_STATUS = !TOG_STATUS;
  146. #ifdef RGBLIGHT_ENABLE
  147. rgblight_mode(15);
  148. #endif
  149. }
  150. layer_on(_RAISE);
  151. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  152. } else {
  153. #ifdef RGBLIGHT_ENABLE
  154. rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
  155. #endif
  156. layer_off(_RAISE);
  157. TOG_STATUS = false;
  158. update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST);
  159. }
  160. return false;
  161. break;
  162. case ADJUST:
  163. // FIXME add RGB feedback
  164. if (record->event.pressed) {
  165. layer_on(_ADJUST);
  166. } else {
  167. layer_off(_ADJUST);
  168. }
  169. return false;
  170. break;
  171. case BL_STEP:
  172. if (record->event.pressed) {
  173. print("Stepping backlight\n");
  174. #ifdef BACKLIGHT_ENABLE
  175. print("Really stepping backlight\n");
  176. backlight_step();
  177. #endif
  178. }
  179. return false;
  180. break;
  181. //led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released
  182. #ifdef RGBLIGHT_ENABLE
  183. case QK_UNDERGLOW_MODE_NEXT:
  184. if (record->event.pressed) {
  185. rgblight_mode(RGB_current_mode);
  186. rgblight_step();
  187. RGB_current_mode = rgblight_config.mode;
  188. }
  189. return false;
  190. break;
  191. #endif
  192. // case BL_UP:
  193. // meira_inc_backlight_level();
  194. // return false;
  195. // break;
  196. }
  197. return true;
  198. }