logo

qmk_firmware

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

keymap.c (4468B)


  1. /* Copyright 2020 yushakobo
  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. #define FAVORITE_COLOR HSV_CYAN
  18. // Defines names for use in layer keycodes and the keymap
  19. enum layer_names {
  20. _BASE
  21. };
  22. // Defines the keycodes used by our macros in process_record_user
  23. enum custom_keycodes {
  24. YUSHAURL = SAFE_RANGE,
  25. KEY_00,
  26. KEY_01,
  27. KEY_02,
  28. KEY_10,
  29. KEY_11,
  30. KEY_12,
  31. KEY_20,
  32. KEY_21,
  33. KEY_22
  34. };
  35. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  36. /* Base */
  37. [_BASE] = LAYOUT(
  38. KEY_00, KEY_01, KEY_02,
  39. KEY_10, KEY_11, KEY_12,
  40. KEY_20, KEY_21, KEY_22
  41. )
  42. };
  43. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  44. switch (keycode) {
  45. case KEY_00:
  46. if (record->event.pressed) {
  47. rgblight_sethsv_at(FAVORITE_COLOR, 0);
  48. } else {
  49. rgblight_sethsv_at(HSV_WHITE, 0);
  50. }
  51. break;
  52. case KEY_01:
  53. if (record->event.pressed) {
  54. rgblight_sethsv_at(FAVORITE_COLOR, 1);
  55. } else {
  56. rgblight_sethsv_at(HSV_WHITE, 1);
  57. }
  58. break;
  59. case KEY_02:
  60. if (record->event.pressed) {
  61. rgblight_sethsv_at(FAVORITE_COLOR, 2);
  62. } else {
  63. rgblight_sethsv_at(HSV_WHITE, 2);
  64. }
  65. break;
  66. case KEY_10:
  67. if (record->event.pressed) {
  68. rgblight_sethsv_at(FAVORITE_COLOR, 3);
  69. } else {
  70. rgblight_sethsv_at(HSV_WHITE, 3);
  71. }
  72. break;
  73. case KEY_11:
  74. if (record->event.pressed) {
  75. rgblight_sethsv_at(FAVORITE_COLOR, 4);
  76. } else {
  77. rgblight_sethsv_at(HSV_WHITE, 4);
  78. }
  79. break;
  80. case KEY_12:
  81. if (record->event.pressed) {
  82. rgblight_sethsv_at(FAVORITE_COLOR, 5);
  83. } else {
  84. rgblight_sethsv_at(HSV_WHITE, 5);
  85. }
  86. break;
  87. case KEY_20:
  88. if (record->event.pressed) {
  89. rgblight_sethsv_at(FAVORITE_COLOR, 6);
  90. } else {
  91. rgblight_sethsv_at(HSV_WHITE, 6);
  92. }
  93. break;
  94. case KEY_21:
  95. if (record->event.pressed) {
  96. rgblight_sethsv_at(FAVORITE_COLOR, 7);
  97. } else {
  98. rgblight_sethsv_at(HSV_WHITE, 7);
  99. }
  100. break;
  101. case KEY_22:
  102. if (record->event.pressed) {
  103. rgblight_sethsv_at(FAVORITE_COLOR, 8);
  104. } else {
  105. rgblight_sethsv_at(HSV_WHITE, 8);
  106. }
  107. break;
  108. }
  109. return true;
  110. }
  111. bool encoder_update_user(uint8_t index, bool clockwise) {
  112. if (index == 0) { // Left encoder
  113. if (clockwise) {
  114. tap_code(KC_VOLU);
  115. } else {
  116. tap_code(KC_VOLD);
  117. }
  118. }
  119. else if (index == 1) { // Right encoder
  120. if (clockwise) {
  121. rgblight_decrease_hue_noeeprom();
  122. } else {
  123. rgblight_increase_hue_noeeprom();
  124. }
  125. }
  126. return true;
  127. }
  128. const rgblight_segment_t PROGMEM quick7_capslock[] = RGBLIGHT_LAYER_SEGMENTS(
  129. {9,1,FAVORITE_COLOR},
  130. {12,1,FAVORITE_COLOR}
  131. );
  132. const rgblight_segment_t PROGMEM quick7_numlock[] = RGBLIGHT_LAYER_SEGMENTS(
  133. {10,1,FAVORITE_COLOR},
  134. {11,1,FAVORITE_COLOR}
  135. );
  136. const rgblight_segment_t* const PROGMEM quick7_rgb_layers[] = RGBLIGHT_LAYERS_LIST(
  137. quick7_capslock,
  138. quick7_numlock
  139. );
  140. void keyboard_post_init_user(void){
  141. rgblight_layers = quick7_rgb_layers;
  142. rgblight_sethsv(HSV_WHITE);
  143. }
  144. bool led_update_user(led_t led_state){
  145. rgblight_set_layer_state(0, led_state.caps_lock);
  146. rgblight_set_layer_state(1, led_state.num_lock);
  147. return true;
  148. }