logo

qmk_firmware

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

keymap.c (3628B)


  1. /* Copyright 2020 Mika Kuitunen
  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. /* Each layer gets a name for readability, which is then used in the keymap matrix below.
  18. * The underscores don't mean anything - you can have a layer called STUFF or any other name.
  19. */
  20. enum layers {
  21. _BASE = 0,
  22. _RGB,
  23. };
  24. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  25. [_BASE] = LAYOUT(
  26. KC_ESC, KC_0, KC_1, KC_2, KC_3, KC_4, KC_5,
  27. KC_Y, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T,
  28. KC_H, KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G,
  29. KC_N, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, TG(_RGB),
  30. KC_LGUI, KC_LCTL, KC_ENT,
  31. KC_LALT, KC_SPC, KC_ENT
  32. ),
  33. [_RGB] = LAYOUT(
  34. UG_PREV, UG_NEXT, UG_TOGG, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  35. UG_HUED, UG_HUEU, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  36. UG_SATD, UG_SATU, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  37. UG_VALD, UG_VALU, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, TG(_RGB),
  38. KC_TRNS, KC_TRNS, KC_TRNS,
  39. KC_TRNS, KC_TRNS, KC_TRNS
  40. ),
  41. };
  42. #ifdef ENCODER_ENABLE
  43. bool encoder_update_user(uint8_t index, bool clockwise) {
  44. if (index == 0) {
  45. if (clockwise) {
  46. tap_code(KC_MS_WH_DOWN);
  47. } else {
  48. tap_code(KC_MS_WH_UP);
  49. }
  50. }
  51. return true;
  52. }
  53. #endif
  54. #ifdef RGBLIGHT_LAYERS
  55. #define HUE_PRIMARY 10
  56. #define HSV_CAPS HUE_PRIMARY, 255, 64
  57. #define HSV_LAYER_BASE HUE_PRIMARY, 255, 64
  58. #define HSV_LAYER_RGB 213, 255, 64
  59. const rgblight_segment_t PROGMEM ug_default_layer[] = RGBLIGHT_LAYER_SEGMENTS(
  60. {10, 4, HSV_OFF}
  61. );
  62. const rgblight_segment_t PROGMEM ug_caps_layer[] = RGBLIGHT_LAYER_SEGMENTS(
  63. {11, 1, HSV_CAPS}
  64. );
  65. const rgblight_segment_t PROGMEM ug_base_layer[] = RGBLIGHT_LAYER_SEGMENTS(
  66. {13, 1, HSV_LAYER_BASE}
  67. );
  68. const rgblight_segment_t PROGMEM ug_rgb_layer[] = RGBLIGHT_LAYER_SEGMENTS(
  69. {13, 1, HSV_LAYER_RGB}
  70. );
  71. /* Define layer order, later layers take precedence */
  72. const rgblight_segment_t* const PROGMEM ug_layers[] = RGBLIGHT_LAYERS_LIST(
  73. ug_default_layer,
  74. ug_caps_layer,
  75. ug_base_layer,
  76. ug_rgb_layer
  77. );
  78. void keyboard_post_init_user(void) {
  79. /* Enable the LED layers and set the initial state */
  80. rgblight_layers = ug_layers;
  81. rgblight_set_layer_state(0, true);
  82. rgblight_set_layer_state(2, true);
  83. }
  84. layer_state_t layer_state_set_user(layer_state_t state) {
  85. /* Both layers will light up if both kb layers are active, latter overrides */
  86. rgblight_set_layer_state(2, layer_state_cmp(state, 0));
  87. rgblight_set_layer_state(3, layer_state_cmp(state, 1));
  88. return state;
  89. }
  90. bool led_update_user(led_t led_state) {
  91. rgblight_set_layer_state(1, led_state.caps_lock);
  92. return true;
  93. }
  94. #endif