action_util.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. /* macro modifier */
  45. uint8_t get_macro_mods(void);
  46. void add_macro_mods(uint8_t mods);
  47. void del_macro_mods(uint8_t mods);
  48. void set_macro_mods(uint8_t mods);
  49. void clear_macro_mods(void);
  50. /* oneshot modifier */
  51. void set_oneshot_mods(uint8_t mods);
  52. uint8_t get_oneshot_mods(void);
  53. void clear_oneshot_mods(void);
  54. void oneshot_toggle(void);
  55. void oneshot_enable(void);
  56. void oneshot_disable(void);
  57. bool has_oneshot_mods_timed_out(void);
  58. int8_t get_oneshot_locked_mods(void);
  59. void set_oneshot_locked_mods(int8_t mods);
  60. void clear_oneshot_locked_mods(void);
  61. typedef enum {
  62. ONESHOT_PRESSED = 0b01,
  63. ONESHOT_OTHER_KEY_PRESSED = 0b10,
  64. ONESHOT_START = 0b11,
  65. ONESHOT_TOGGLED = 0b100
  66. } oneshot_fullfillment_t;
  67. void set_oneshot_layer(uint8_t layer, uint8_t state);
  68. uint8_t get_oneshot_layer(void);
  69. void clear_oneshot_layer_state(oneshot_fullfillment_t state);
  70. void reset_oneshot_layer(void);
  71. bool is_oneshot_layer_active(void);
  72. uint8_t get_oneshot_layer_state(void);
  73. bool has_oneshot_layer_timed_out(void);
  74. /* inspect */
  75. uint8_t has_anymod(void);
  76. #ifdef __cplusplus
  77. }
  78. #endif