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.

108 lines
2.8 KiB

  1. /*
  2. Copyright 2012,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. #ifndef ACTION_H
  15. #define ACTION_H
  16. #include <stdint.h>
  17. #include <stdbool.h>
  18. #include "keyboard.h"
  19. #include "keycode.h"
  20. #include "action_code.h"
  21. #include "action_macro.h"
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* tapping count and state */
  26. typedef struct {
  27. bool interrupted :1;
  28. bool reserved2 :1;
  29. bool reserved1 :1;
  30. bool reserved0 :1;
  31. uint8_t count :4;
  32. } tap_t;
  33. /* Key event container for recording */
  34. typedef struct {
  35. keyevent_t event;
  36. #ifndef NO_ACTION_TAPPING
  37. tap_t tap;
  38. #endif
  39. } keyrecord_t;
  40. /* Execute action per keyevent */
  41. void action_exec(keyevent_t event);
  42. /* action for key */
  43. action_t action_for_key(uint8_t layer, keypos_t key);
  44. /* macro */
  45. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt);
  46. /* user defined special function */
  47. void action_function(keyrecord_t *record, uint8_t id, uint8_t opt);
  48. /* keyboard-specific key event (pre)processing */
  49. bool process_record_quantum(keyrecord_t *record);
  50. /* Utilities for actions. */
  51. #if !defined(NO_ACTION_LAYER) && defined(PREVENT_STUCK_MODIFIERS)
  52. extern bool disable_action_cache;
  53. #endif
  54. /* Code for handling one-handed key modifiers. */
  55. #ifdef ONEHAND_ENABLE
  56. extern bool swap_hands;
  57. extern const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS];
  58. #if (MATRIX_COLS <= 8)
  59. typedef uint8_t swap_state_row_t;
  60. #elif (MATRIX_COLS <= 16)
  61. typedef uint16_t swap_state_row_t;
  62. #elif (MATRIX_COLS <= 32)
  63. typedef uint32_t swap_state_row_t;
  64. #else
  65. #error "MATRIX_COLS: invalid value"
  66. #endif
  67. void process_hand_swap(keyevent_t *record);
  68. #endif
  69. void process_record_nocache(keyrecord_t *record);
  70. void process_record(keyrecord_t *record);
  71. void process_action(keyrecord_t *record, action_t action);
  72. void register_code(uint8_t code);
  73. void unregister_code(uint8_t code);
  74. void register_mods(uint8_t mods);
  75. void unregister_mods(uint8_t mods);
  76. //void set_mods(uint8_t mods);
  77. void clear_keyboard(void);
  78. void clear_keyboard_but_mods(void);
  79. void layer_switch(uint8_t new_layer);
  80. bool is_tap_key(keypos_t key);
  81. /* debug */
  82. void debug_event(keyevent_t event);
  83. void debug_record(keyrecord_t record);
  84. void debug_action(action_t action);
  85. #ifdef __cplusplus
  86. }
  87. #endif
  88. #endif /* ACTION_H */