logo

qmk_firmware

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

white.c (5360B)


  1. /* Copyright 2023 @ Keychron (https://www.keychron.com)
  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 "quantum.h"
  17. // clang-format off
  18. #ifdef LED_MATRIX_ENABLE
  19. const snled27351_led_t PROGMEM g_snled27351_leds[SNLED27351_LED_COUNT] = {
  20. /* Refer to SNLED27351 manual for these locations
  21. * driver
  22. * | LED address
  23. * | | */
  24. {0, CB1_CA16}, // esc
  25. {0, CB1_CA15}, // f1
  26. {0, CB1_CA14}, // f2
  27. {0, CB1_CA13}, // f3
  28. {0, CB1_CA12}, // f4
  29. {0, CB1_CA11}, // f5
  30. {0, CB1_CA10}, // f6
  31. {0, CB1_CA9}, // f7
  32. {0, CB1_CA8}, // f8
  33. {0, CB1_CA7}, // f9
  34. {0, CB1_CA6}, // f10
  35. {0, CB1_CA5}, // f11
  36. {0, CB1_CA4}, // f12
  37. {0, CB1_CA2}, // print
  38. {0, CB1_CA1}, // siri
  39. {0, CB7_CA1}, // light
  40. {0, CB2_CA16}, // ~
  41. {0, CB2_CA15}, // 1!
  42. {0, CB2_CA14}, // 2@
  43. {0, CB2_CA13}, // 3#
  44. {0, CB2_CA12}, // 4$
  45. {0, CB2_CA11}, // 5%
  46. {0, CB2_CA10}, // 6^
  47. {0, CB2_CA9}, // 7&
  48. {0, CB2_CA8}, // 8*
  49. {0, CB2_CA7}, // 9(
  50. {0, CB2_CA6}, // 0)
  51. {0, CB2_CA5}, // -_
  52. {0, CB2_CA4}, // =+
  53. {0, CB2_CA3}, // back space
  54. {0, CB2_CA2}, // INS
  55. {0, CB2_CA1}, // HOME
  56. {0, CB8_CA1}, // PGUP
  57. {0, CB3_CA16}, // tab
  58. {0, CB3_CA15}, // q
  59. {0, CB3_CA14}, // w
  60. {0, CB3_CA13}, // e
  61. {0, CB3_CA12}, // r
  62. {0, CB3_CA11}, // t
  63. {0, CB3_CA10}, // y
  64. {0, CB3_CA9}, // u
  65. {0, CB3_CA8}, // i
  66. {0, CB3_CA7}, // o
  67. {0, CB3_CA6}, // p
  68. {0, CB3_CA5}, // [{
  69. {0, CB3_CA4}, // ]}
  70. {0, CB3_CA3}, // \|
  71. {0, CB3_CA2}, // DEL
  72. {0, CB3_CA1}, // END
  73. {0, CB7_CA6}, // PGDN
  74. {0, CB4_CA16}, // caps lock
  75. {0, CB4_CA15}, // a
  76. {0, CB4_CA14}, // s
  77. {0, CB4_CA13}, // d
  78. {0, CB4_CA12}, // f
  79. {0, CB4_CA11}, // g
  80. {0, CB4_CA10}, // h
  81. {0, CB4_CA9}, // j
  82. {0, CB4_CA8}, // k
  83. {0, CB4_CA7}, // l
  84. {0, CB4_CA6}, // ;:
  85. {0, CB4_CA5}, // '"
  86. {0, CB4_CA3}, // enter
  87. {0, CB8_CA7}, // CPAS
  88. {0, CB8_CA8}, // MAC
  89. {0, CB8_CA9}, // WIN
  90. {0, CB5_CA16}, // left shift
  91. {0, CB5_CA14}, // z
  92. {0, CB5_CA13}, // x
  93. {0, CB5_CA12}, // c
  94. {0, CB5_CA11}, // v
  95. {0, CB5_CA10}, // b
  96. {0, CB5_CA9}, // b
  97. {0, CB5_CA8}, // n
  98. {0, CB5_CA7}, // m
  99. {0, CB5_CA6}, // ,<
  100. {0, CB5_CA5}, // .>
  101. {0, CB5_CA3}, // right shift
  102. {0, CB5_CA1}, // up
  103. {0, CB6_CA16}, // left ctrl
  104. {0, CB6_CA15}, // left command
  105. {0, CB6_CA14}, // left option
  106. {0, CB6_CA10}, // space
  107. {0, CB6_CA6}, // right command
  108. {0, CB6_CA5}, // right option
  109. {0, CB6_CA4}, // right ctrl
  110. {0, CB6_CA3}, // Fn
  111. {0, CB6_CA2}, // left
  112. {0, CB6_CA1}, // down
  113. {0, CB7_CA13}, // right
  114. };
  115. // clang-format on
  116. bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
  117. if (!process_record_user(keycode, record)) {
  118. return false;
  119. }
  120. switch (keycode) {
  121. case LM_TOGG:
  122. if (record->event.pressed) {
  123. switch (led_matrix_get_flags()) {
  124. case LED_FLAG_ALL: {
  125. led_matrix_set_flags(LED_FLAG_NONE);
  126. led_matrix_set_value_all(0);
  127. } break;
  128. default: {
  129. led_matrix_set_flags(LED_FLAG_ALL);
  130. } break;
  131. }
  132. }
  133. if (!led_matrix_is_enabled()) {
  134. led_matrix_set_flags(LED_FLAG_ALL);
  135. led_matrix_enable();
  136. }
  137. return false;
  138. }
  139. return true;
  140. }
  141. bool led_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {
  142. if (!led_matrix_indicators_advanced_user(led_min, led_max)) {
  143. return false;
  144. }
  145. if ((host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 0))) {
  146. led_matrix_set_value(CAPS_LOCK_LED_INDEX, 255);
  147. led_matrix_set_value(MAC_LOCK_LED_INDEX, 255);
  148. led_matrix_set_value(WIN_LOCK_LED_INDEX, 0);
  149. } else if ((!host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 0))) {
  150. led_matrix_set_value(CAPS_LOCK_LED_INDEX, 0);
  151. led_matrix_set_value(MAC_LOCK_LED_INDEX, 255);
  152. led_matrix_set_value(WIN_LOCK_LED_INDEX, 0);
  153. } else if ((host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 2))) {
  154. led_matrix_set_value(CAPS_LOCK_LED_INDEX, 255);
  155. led_matrix_set_value(MAC_LOCK_LED_INDEX, 0);
  156. led_matrix_set_value(WIN_LOCK_LED_INDEX, 255);
  157. } else if ((!host_keyboard_led_state().caps_lock) && (default_layer_state == (1 << 2))) {
  158. led_matrix_set_value(CAPS_LOCK_LED_INDEX, 0);
  159. led_matrix_set_value(MAC_LOCK_LED_INDEX, 0);
  160. led_matrix_set_value(WIN_LOCK_LED_INDEX, 255);
  161. }
  162. return true;
  163. }
  164. #endif