process_dynamic_tapping_term.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /* Copyright 2020 Vladislav Kucheriavykh
  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. #include "process_dynamic_tapping_term.h"
  18. #ifndef DYNAMIC_TAPPING_TERM_INCREMENT
  19. # define DYNAMIC_TAPPING_TERM_INCREMENT 5
  20. #endif
  21. static void tapping_term_report(void) {
  22. #ifdef SEND_STRING_ENABLE
  23. const char *tapping_term_str = get_u16_str(g_tapping_term, ' ');
  24. // Skip padding spaces
  25. while (*tapping_term_str == ' ') {
  26. tapping_term_str++;
  27. }
  28. send_string(tapping_term_str);
  29. #endif
  30. }
  31. bool process_dynamic_tapping_term(uint16_t keycode, keyrecord_t *record) {
  32. if (record->event.pressed) {
  33. switch (keycode) {
  34. case QK_DYNAMIC_TAPPING_TERM_PRINT:
  35. tapping_term_report();
  36. return false;
  37. case QK_DYNAMIC_TAPPING_TERM_UP:
  38. g_tapping_term += DYNAMIC_TAPPING_TERM_INCREMENT;
  39. return false;
  40. case QK_DYNAMIC_TAPPING_TERM_DOWN:
  41. g_tapping_term -= DYNAMIC_TAPPING_TERM_INCREMENT;
  42. return false;
  43. }
  44. }
  45. return true;
  46. }