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.

27 lines
503 B

  1. #include "tap-hold.h"
  2. #ifndef TAP_HOLD_TIME
  3. #define TAP_HOLD_TIME 200
  4. #endif
  5. uint16_t tap_hold_timer;
  6. void tap_or_hold( keyrecord_t *record, uint16_t tap, uint16_t hold ) {
  7. if ( record->event.pressed ) {
  8. tap_hold_timer = timer_read();
  9. } else {
  10. if ( tap_hold_timer &&
  11. timer_elapsed( tap_hold_timer ) > TAP_HOLD_TIME ) {
  12. /* Held down then released */
  13. tap_code( hold );
  14. } else {
  15. /* Quickly Tapped */
  16. tap_code( tap );
  17. }
  18. tap_hold_timer = 0;
  19. }
  20. }