logo

qmk_firmware

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

wt60_xt.c (2369B)


  1. /* Copyright 2020 Jason Williams (Wilba)
  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. #ifdef AUDIO_ENABLE
  18. #include "audio.h"
  19. #include "song_list.h"
  20. float tone_caps_on[][2] = SONG(CAPS_LOCK_ON_SOUND);
  21. float tone_caps_off[][2] = SONG(CAPS_LOCK_OFF_SOUND);
  22. float tone_numlk_on[][2] = SONG(NUM_LOCK_ON_SOUND);
  23. float tone_numlk_off[][2] = SONG(NUM_LOCK_OFF_SOUND);
  24. float tone_scroll_on[][2] = SONG(SCROLL_LOCK_ON_SOUND);
  25. float tone_scroll_off[][2] = SONG(SCROLL_LOCK_OFF_SOUND);
  26. float tone_device_indication[][2] = SONG(FANTASIE_IMPROMPTU);
  27. #endif
  28. void keyboard_pre_init_kb(void) {
  29. gpio_set_pin_output(F1);
  30. keyboard_pre_init_user();
  31. }
  32. bool led_update_kb(led_t led_state) {
  33. if (led_update_user(led_state)) {
  34. gpio_write_pin(F1, led_state.caps_lock);
  35. }
  36. #ifdef AUDIO_ENABLE
  37. static led_t old_led_state = { .raw = 0 };
  38. wait_ms(10); // gets rid of tick
  39. if (led_state.caps_lock && !old_led_state.caps_lock)
  40. {
  41. PLAY_SONG(tone_caps_on);
  42. }
  43. else if (!led_state.caps_lock && old_led_state.caps_lock)
  44. {
  45. PLAY_SONG(tone_caps_off);
  46. }
  47. else if (led_state.num_lock && !old_led_state.num_lock)
  48. {
  49. PLAY_SONG(tone_numlk_on);
  50. }
  51. else if (!led_state.num_lock && old_led_state.num_lock)
  52. {
  53. PLAY_SONG(tone_numlk_off);
  54. }
  55. else if (led_state.scroll_lock && !old_led_state.scroll_lock)
  56. {
  57. PLAY_SONG(tone_scroll_on);
  58. }
  59. else if (!led_state.scroll_lock && old_led_state.scroll_lock)
  60. {
  61. PLAY_SONG(tone_scroll_off);
  62. }
  63. old_led_state = led_state;
  64. #endif // AUDIO_ENABLE
  65. return true;
  66. }
  67. void via_set_device_indication(uint8_t value) {
  68. if ( value == 0 ) {
  69. PLAY_SONG(tone_device_indication);
  70. }
  71. }