You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.7 KiB

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