action_util.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. Copyright 2013 Jun Wako <wakojun@gmail.com>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #pragma once
  15. #include <stdint.h>
  16. #include "report.h"
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. extern report_keyboard_t *keyboard_report;
  21. void send_keyboard_report(void);
  22. /* key */
  23. inline void add_key(uint8_t key) {
  24. add_key_to_report(keyboard_report, key);
  25. }
  26. inline void del_key(uint8_t key) {
  27. del_key_from_report(keyboard_report, key);
  28. }
  29. inline void clear_keys(void) {
  30. clear_keys_from_report(keyboard_report);
  31. }
  32. /* modifier */
  33. uint8_t get_mods(void);
  34. void add_mods(uint8_t mods);
  35. void del_mods(uint8_t mods);
  36. void set_mods(uint8_t mods);
  37. void clear_mods(void);
  38. /* weak modifier */
  39. uint8_t get_weak_mods(void);
  40. void add_weak_mods(uint8_t mods);
  41. void del_weak_mods(uint8_t mods);
  42. void set_weak_mods(uint8_t mods);
  43. void clear_weak_mods(void);
  44. /* oneshot modifier */
  45. uint8_t get_oneshot_mods(void);
  46. void add_oneshot_mods(uint8_t mods);
  47. void del_oneshot_mods(uint8_t mods);
  48. void set_oneshot_mods(uint8_t mods);
  49. void clear_oneshot_mods(void);
  50. bool has_oneshot_mods_timed_out(void);
  51. uint8_t get_oneshot_locked_mods(void);
  52. void set_oneshot_locked_mods(uint8_t mods);
  53. void clear_oneshot_locked_mods(void);
  54. typedef enum { ONESHOT_PRESSED = 0b01, ONESHOT_OTHER_KEY_PRESSED = 0b10, ONESHOT_START = 0b11, ONESHOT_TOGGLED = 0b100 } oneshot_fullfillment_t;
  55. void set_oneshot_layer(uint8_t layer, uint8_t state);
  56. uint8_t get_oneshot_layer(void);
  57. void clear_oneshot_layer_state(oneshot_fullfillment_t state);
  58. void reset_oneshot_layer(void);
  59. bool is_oneshot_layer_active(void);
  60. uint8_t get_oneshot_layer_state(void);
  61. bool has_oneshot_layer_timed_out(void);
  62. bool has_oneshot_swaphands_timed_out(void);
  63. void oneshot_locked_mods_changed_user(uint8_t mods);
  64. void oneshot_locked_mods_changed_kb(uint8_t mods);
  65. void oneshot_mods_changed_user(uint8_t mods);
  66. void oneshot_mods_changed_kb(uint8_t mods);
  67. void oneshot_layer_changed_user(uint8_t layer);
  68. void oneshot_layer_changed_kb(uint8_t layer);
  69. void oneshot_toggle(void);
  70. void oneshot_enable(void);
  71. void oneshot_disable(void);
  72. bool is_oneshot_enabled(void);
  73. /* inspect */
  74. uint8_t has_anymod(void);
  75. #ifdef SWAP_HANDS_ENABLE
  76. void set_oneshot_swaphands(void);
  77. void release_oneshot_swaphands(void);
  78. void use_oneshot_swaphands(void);
  79. void clear_oneshot_swaphands(void);
  80. #endif
  81. #ifdef __cplusplus
  82. }
  83. #endif