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
627 B

  1. #include "swapper.h"
  2. void update_swapper(
  3. bool *active,
  4. uint16_t cmdish,
  5. uint16_t tabish,
  6. uint16_t trigger,
  7. uint16_t keycode,
  8. keyrecord_t *record
  9. ) {
  10. if (keycode == trigger) {
  11. if (record->event.pressed) {
  12. if (!*active) {
  13. *active = true;
  14. register_code(cmdish);
  15. }
  16. register_code(tabish);
  17. } else {
  18. unregister_code(tabish);
  19. // Don't unregister cmdish until some other key is hit or released.
  20. }
  21. } else if (*active) {
  22. unregister_code(cmdish);
  23. *active = false;
  24. }
  25. }