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.

31 lines
984 B

  1. #pragma once
  2. #include QMK_KEYBOARD_H
  3. // Represents the four states a oneshot key can be in
  4. typedef enum {
  5. os_up_unqueued,
  6. os_up_queued,
  7. os_down_unused,
  8. os_down_used,
  9. } oneshot_state;
  10. // Custom oneshot mod implementation that doesn't rely on timers. If a mod is
  11. // used while it is held it will be unregistered on keyup as normal, otherwise
  12. // it will be queued and only released after the next non-mod keyup.
  13. void update_oneshot(
  14. oneshot_state *state,
  15. uint16_t mod,
  16. uint16_t trigger,
  17. uint16_t keycode,
  18. keyrecord_t *record
  19. );
  20. // To be implemented by the consumer. Defines keys to cancel oneshot mods.
  21. bool is_oneshot_cancel_key(uint16_t keycode);
  22. // To be implemented by the consumer. Defines keys to ignore when determining
  23. // whether a oneshot mod has been used. Setting this to modifiers and layer
  24. // change keys allows stacking multiple oneshot modifiers, and carrying them
  25. // between layers.
  26. bool is_oneshot_ignored_key(uint16_t keycode);