logo

qmk_firmware

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

dgk6x.c (1994B)


  1. /* Copyright 2021 Jessica Sullivan and Don Kjer
  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 "dgk6x.h"
  17. /* Private Functions */
  18. void off_all_leds(void) {
  19. gpio_write_pin_high(LED_CAPS_LOCK_PIN);
  20. gpio_write_pin_high(LED_WIN_LOCK_PIN);
  21. gpio_write_pin_high(LED_MR_LOCK_PIN);
  22. }
  23. void on_all_leds(void) {
  24. gpio_write_pin_low(LED_CAPS_LOCK_PIN);
  25. gpio_write_pin_low(LED_WIN_LOCK_PIN);
  26. gpio_write_pin_low(LED_MR_LOCK_PIN);
  27. }
  28. /* WinLock and MR LEDs are non-standard. Need to override led init */
  29. void led_init_ports(void) {
  30. gpio_set_pin_output(LED_CAPS_LOCK_PIN);
  31. gpio_set_pin_output(LED_WIN_LOCK_PIN);
  32. gpio_set_pin_output(LED_MR_LOCK_PIN);
  33. off_all_leds();
  34. }
  35. #ifndef WINLOCK_DISABLED
  36. bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
  37. switch (keycode) {
  38. case GU_TOGG:
  39. if (record->event.pressed) {
  40. // Toggle LED on key press
  41. gpio_toggle_pin(LED_WIN_LOCK_PIN);
  42. }
  43. break;
  44. }
  45. return process_record_user(keycode, record);
  46. }
  47. #endif /* WINLOCK_DISABLED */
  48. #ifdef RGB_MATRIX_ENABLE
  49. bool rgb_matrix_indicators_kb(void) {
  50. if (!rgb_matrix_indicators_user()) {
  51. return false;
  52. }
  53. if (host_keyboard_led_state().caps_lock) {
  54. rgb_matrix_set_color(CAPS_LED, 0xFF, 0xFF, 0xFF);
  55. }
  56. return true;
  57. }
  58. #endif /* RGB_MATRIX_ENABLE */