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.

29 lines
1.0 KiB

  1. #include "taphold.h"
  2. bool taphold_process(uint16_t keycode, keyrecord_t *record) {
  3. for (int i = 0; i < taphold_config_size; i++) {
  4. taphold_t *config = &taphold_config[i];
  5. if (config->key == keycode && record->event.pressed) {
  6. if (config->mode == TAPHOLD_LAYER) {
  7. layer_on(config->longAction);
  8. } else {
  9. register_code(config->longAction);
  10. }
  11. config->time = timer_read32();
  12. config->keypos = record->event.key;
  13. return false;
  14. } else if (KEYEQ(record->event.key, config->keypos) && !record->event.pressed) {
  15. if (config->mode == TAPHOLD_LAYER) {
  16. layer_off(config->longAction);
  17. } else {
  18. unregister_code(config->longAction);
  19. }
  20. if (timer_elapsed32(config->time) < taphold_timeout) {
  21. tap_code(config->shortAction);
  22. }
  23. config->keypos.row = 255;
  24. return false;
  25. }
  26. }
  27. return true;
  28. }