process_dynamic_tapping_term.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. const char *tapping_term_str = get_u16_str(g_tapping_term, ' ');
  23. // Skip padding spaces
  24. while (*tapping_term_str == ' ') {
  25. tapping_term_str++;
  26. }
  27. send_string(tapping_term_str);
  28. }
  29. bool process_dynamic_tapping_term(uint16_t keycode, keyrecord_t *record) {
  30. if (record->event.pressed) {
  31. switch (keycode) {
  32. case DT_PRNT:
  33. tapping_term_report();
  34. return false;
  35. case DT_UP:
  36. g_tapping_term += DYNAMIC_TAPPING_TERM_INCREMENT;
  37. return false;
  38. case DT_DOWN:
  39. g_tapping_term -= DYNAMIC_TAPPING_TERM_INCREMENT;
  40. return false;
  41. }
  42. }
  43. return true;
  44. }