logo

qmk_firmware

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

keymap.c (3697B)


  1. /* Copyright 2019 yynmt
  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. enum layer_number {
  22. _BASE = 0,
  23. _LOWER,
  24. _RAISE,
  25. _ADJUST
  26. };
  27. enum custom_keycodes {
  28. BASE = SAFE_RANGE,
  29. LOWER,
  30. RAISE,
  31. ADJUST,
  32. RGBRST
  33. };
  34. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  35. /* Base
  36. * ,-----------------------------------------.
  37. * | Cut | Copy |Paste | Up |Delete| Bksp |
  38. * | | | | | |Raise |
  39. * |------+------+------+------+------+------|
  40. * | Ctrl |Shift | Left | Down |Right |Enter |
  41. * | | | | | |Lower |
  42. * `-----------------------------------------'
  43. */
  44. [_BASE] = LAYOUT(
  45. LCTL(KC_X), LCTL(KC_C), LCTL(KC_V), KC_UP, KC_DEL, LT(_RAISE,KC_BSPC),
  46. KC_LCTL, KC_LSFT, KC_LEFT, KC_DOWN, KC_RGHT, LT(_LOWER,KC_ENT)
  47. ),
  48. /* Lower
  49. * ,-----------------------------------------.
  50. * | | | | Page | | |
  51. * | | | | Up | | |
  52. * |------+------+------+------+------+------|
  53. * | | | Home | Page | End | |
  54. * | | | | Down | | |
  55. * `-----------------------------------------'
  56. */
  57. [_LOWER] = LAYOUT(
  58. _______, _______, _______, KC_PGUP, _______, _______,
  59. _______, _______, KC_HOME, KC_PGDN, KC_END, _______
  60. ),
  61. /* Raise
  62. * ,-----------------------------------------.
  63. * | | | | | | |
  64. * | | | | | | |
  65. * |------+------+------+------+------+------|
  66. * | | | | | | |
  67. * | | | | | | |
  68. * `-----------------------------------------'
  69. */
  70. [_RAISE] = LAYOUT(
  71. _______, _______, _______, _______, _______, _______,
  72. _______, _______, _______, _______, _______, _______
  73. ),
  74. /* Adjust
  75. * ,-----------------------------------------.
  76. * | RGB | RGB | RGB | RGB | RGB | |
  77. * |Toggle|Mode+ | Hue+ | Sat+ | Val+ | |
  78. * |------+------+------+------+------+------|
  79. * | RGB | RGB | RGB | RGB | RGB | |
  80. * |Reset |Mode- | Hue- | Sat- | Val- | |
  81. * `-----------------------------------------'
  82. */
  83. [_ADJUST] = LAYOUT(
  84. UG_TOGG, UG_NEXT, UG_HUEU, UG_SATU, UG_VALU, _______,
  85. RGBRST, UG_PREV, UG_HUED, UG_SATD, UG_VALD, _______
  86. )
  87. };
  88. layer_state_t layer_state_set_user(layer_state_t state) {
  89. return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
  90. }
  91. int RGB_current_mode;
  92. void matrix_init_user(void) {
  93. #ifdef RGBLIGHT_ENABLE
  94. RGB_current_mode = rgblight_config.mode;
  95. #endif
  96. }
  97. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  98. switch (keycode) {
  99. case RGBRST:
  100. #ifdef RGBLIGHT_ENABLE
  101. if (record->event.pressed) {
  102. eeconfig_update_rgblight_default();
  103. rgblight_enable();
  104. RGB_current_mode = rgblight_config.mode;
  105. }
  106. #endif
  107. break;
  108. }
  109. return true;
  110. }