logo

qmk_firmware

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

keymap.c (4762B)


  1. #include QMK_KEYBOARD_H
  2. #ifdef PROTOCOL_LUFA
  3. #include "lufa.h"
  4. #include "split_util.h"
  5. #endif
  6. extern keymap_config_t keymap_config;
  7. #ifdef RGBLIGHT_ENABLE
  8. //Following line allows macro to read current RGB settings
  9. extern rgblight_config_t rgblight_config;
  10. #endif
  11. extern uint8_t is_master;
  12. // Each layer gets a name for readability, which is then used in the keymap matrix below.
  13. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
  14. // Layer names don't all need to be of the same length, obviously, and you can also skip them
  15. // entirely and just use numbers.
  16. enum layer_number {
  17. _QWERTY = 0,
  18. _MACROPAD,
  19. _FN,
  20. _ADJ
  21. };
  22. enum custom_keycodes {
  23. FN = SAFE_RANGE,
  24. ADJ,
  25. BACKLIT,
  26. RGBRST
  27. };
  28. enum macro_keycodes {
  29. KC_SAMPLEMACRO,
  30. };
  31. #define QWERT PDF(_QWERTY)
  32. #define MACROPAD PDF(_MACROPAD)
  33. #define FN_ESC LT(_FN, KC_ESC)
  34. #define FN_CAPS LT(_FN, KC_CAPS)
  35. // Define your non-alpha grouping in this define's LAYOUT, and all your BASE_LAYERS will share the same mod/macro columns
  36. #define BASE_LAYOUT( \
  37. _00, _01, _02, _03, _04, \
  38. _10, _11, _12, _13, _14, \
  39. _20, _21, _22, _23, _24, \
  40. _30, _31, _32, _33, _34 \
  41. ) \
  42. LAYOUT_ortho_5x6( \
  43. QK_GESC, _00, _01, _02, _03, _04, \
  44. KC_TAB, _10, _11, _12, _13, _14, \
  45. FN_CAPS, _20, _21, _22, _23, _24, \
  46. KC_LSFT, _30, _31, _32, _33, _34, \
  47. KC_LCTL, KC_LGUI, KC_LALT, UG_TOGG, ADJ, KC_SPC \
  48. )
  49. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  50. [_QWERTY] = BASE_LAYOUT(
  51. KC_1, KC_2, KC_3, KC_4, KC_5,
  52. KC_Q, KC_W, KC_E, KC_R, KC_T,
  53. KC_A, KC_S, KC_D, KC_F, KC_G,
  54. KC_Z, KC_X, KC_C, KC_V, KC_B
  55. ),
  56. [_MACROPAD] = BASE_LAYOUT(
  57. KC_F13, KC_F14, KC_F15, KC_F16, KC_F17,
  58. KC_F18, KC_F19, KC_F20, KC_F21, KC_F22,
  59. KC_A, KC_S, KC_D, KC_F, KC_G,
  60. KC_Z, KC_X, KC_C, KC_V, KC_B
  61. ),
  62. [_FN] = LAYOUT_ortho_5x6(
  63. KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6,
  64. _______, KC_PGDN, KC_UP, KC_PGUP, _______, _______,
  65. _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______,
  66. _______, _______, _______, _______, _______, _______,
  67. _______, _______, _______, UG_NEXT, _______, _______
  68. ),
  69. [_ADJ] = LAYOUT_ortho_5x6(
  70. KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6,
  71. _______, UG_SATD, UG_VALU, UG_SATU, QK_BOOT, _______,
  72. _______, UG_HUED, UG_VALD, UG_HUEU, RGBRST, _______,
  73. _______, _______, _______, _______, _______, _______,
  74. _______, _______, _______, UG_NEXT, _______, _______
  75. )
  76. };
  77. // define variables for reactive RGB
  78. bool TOG_STATUS = false;
  79. int RGB_current_mode;
  80. // Setting ADJ layer RGB back to default
  81. void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
  82. if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
  83. #ifdef RGBLIGHT_ENABLE
  84. //rgblight_mode(RGB_current_mode);
  85. #endif
  86. layer_on(layer3);
  87. } else {
  88. layer_off(layer3);
  89. }
  90. }
  91. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  92. //uint8_t shifted = get_mods() & (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT));
  93. switch (keycode) {
  94. case FN:
  95. if (record->event.pressed) {
  96. //not sure how to have keyboard check mode and set it to a variable, so my work around
  97. //uses another variable that would be set to true after the first time a reactive key is pressed.
  98. if (TOG_STATUS) { //TOG_STATUS checks is another reactive key currently pressed, only changes RGB mode if returns false
  99. } else {
  100. TOG_STATUS = !TOG_STATUS;
  101. #ifdef RGBLIGHT_ENABLE
  102. //rgblight_mode(15);
  103. #endif
  104. }
  105. layer_on(_FN);
  106. } else {
  107. #ifdef RGBLIGHT_ENABLE
  108. //rgblight_mode(RGB_current_mode); // revert RGB to initial mode prior to RGB mode change
  109. #endif
  110. layer_off(_FN);
  111. TOG_STATUS = false;
  112. }
  113. return false;
  114. break;
  115. case ADJ:
  116. if (record->event.pressed) {
  117. layer_on(_ADJ);
  118. } else {
  119. layer_off(_ADJ);
  120. }
  121. return false;
  122. break;
  123. //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
  124. case RGBRST:
  125. #ifdef RGBLIGHT_ENABLE
  126. if (record->event.pressed) {
  127. eeconfig_update_rgblight_default();
  128. rgblight_enable();
  129. RGB_current_mode = rgblight_config.mode;
  130. }
  131. #endif
  132. break;
  133. }
  134. return true;
  135. }
  136. void matrix_init_user(void) {
  137. #ifdef RGBLIGHT_ENABLE
  138. RGB_current_mode = rgblight_config.mode;
  139. #endif
  140. }