logo

qmk_firmware

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

3x5_3.c (3150B)


  1. /**
  2. * Copyright 2020 Christopher Courtney <drashna@live.com> (@drashna)
  3. * Copyright 2021 Quentin LEBASTARD <qlebastard@gmail.com>
  4. * Copyright 2022 Charly Delay <charly@codesink.dev> (@0xcharly)
  5. * Copyright 2023 casuanoob <casuanoob@hotmail.com> (@casuanoob)
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Publicw License as published by
  9. * the Free Software Foundation, either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include "dilemma.h"
  21. #ifdef ENCODER_ENABLE
  22. bool encoder_update_kb(uint8_t index, bool clockwise) {
  23. if (!encoder_update_user(index, clockwise)) {
  24. return false;
  25. }
  26. switch (index) {
  27. case 0: // Left-half encoder, mouse scroll.
  28. tap_code(clockwise ? KC_MS_WH_UP : KC_MS_WH_DOWN);
  29. break;
  30. case 1: // Right-half encoder, volume control.
  31. tap_code(clockwise ? KC_AUDIO_VOL_UP : KC_AUDIO_VOL_DOWN);
  32. break;
  33. }
  34. return true;
  35. }
  36. #endif // ENCODER_ENABLE
  37. #ifdef RGB_MATRIX_ENABLE
  38. // Layer state indicator
  39. bool rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {
  40. if (!rgb_matrix_indicators_advanced_user(led_min, led_max)) { return false; }
  41. if (host_keyboard_led_state().caps_lock) {
  42. for (int i = led_min; i <= led_max; i++) {
  43. if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_MODIFIER)) {
  44. rgb_matrix_set_color(i, MIN(rgb_matrix_get_val() + 76, 255), 0x00, 0x00);
  45. }
  46. }
  47. }
  48. uint8_t layer = get_highest_layer(layer_state);
  49. if (layer > 0) {
  50. hsv_t hsv = rgb_matrix_get_hsv();
  51. switch (get_highest_layer(layer_state)) {
  52. case 1:
  53. hsv = (hsv_t){HSV_BLUE};
  54. break;
  55. case 2:
  56. hsv = (hsv_t){HSV_AZURE};
  57. break;
  58. case 3:
  59. hsv = (hsv_t){HSV_ORANGE};
  60. break;
  61. case 4:
  62. hsv = (hsv_t){HSV_GREEN};
  63. break;
  64. case 5:
  65. hsv = (hsv_t){HSV_TEAL};
  66. break;
  67. case 6:
  68. hsv = (hsv_t){HSV_PURPLE};
  69. break;
  70. case 7:
  71. default:
  72. hsv = (hsv_t){HSV_RED};
  73. break;
  74. };
  75. if (hsv.v > rgb_matrix_get_val()) {
  76. hsv.v = MIN(rgb_matrix_get_val() + 22, 255);
  77. }
  78. rgb_t rgb = hsv_to_rgb(hsv);
  79. for (uint8_t i = led_min; i < led_max; i++) {
  80. if (HAS_FLAGS(g_led_config.flags[i], LED_FLAG_UNDERGLOW)) {
  81. rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b);
  82. }
  83. }
  84. }
  85. return false;
  86. };
  87. #endif // RGB_MATRIX_ENABLE