nshot_mod.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. /*
  3. Copyright 2018-2022 Eric Gebhart <e.a.gebhart@gmail.com>
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 2 of the License, or
  7. (at your option) any later version.
  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. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #include QMK_KEYBOARD_H
  16. // Represents the four states an n-shot key can be in (from users/callum)
  17. typedef enum {
  18. os_up_unqueued,
  19. os_up_queued,
  20. os_down_unused,
  21. os_down_used,
  22. } oneshot_state;
  23. typedef struct {
  24. uint16_t trigger;
  25. uint16_t mod;
  26. uint8_t max_count;
  27. oneshot_state state;
  28. uint8_t count;
  29. } nshot_state_t;
  30. extern nshot_state_t nshot_states[];
  31. extern uint8_t NUM_NSHOT_STATES;
  32. // Keys that should cancel the n-shot mod if tapped
  33. bool is_nshot_cancel_key(uint16_t keycode);
  34. // Keys that should not count towards n-shot usage (e.g., layer toggles)
  35. bool is_nshot_ignored_key(uint16_t keycode);