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.

127 lines
3.5 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. #pragma once
  15. #include <stdint.h>
  16. #include <stdbool.h>
  17. #include "keyboard.h"
  18. #include "keycode.h"
  19. #include "action_code.h"
  20. #include "action_macro.h"
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. /* Disable macro and function features when LTO is enabled, since they break */
  25. #ifdef LTO_ENABLE
  26. # ifndef NO_ACTION_MACRO
  27. # define NO_ACTION_MACRO
  28. # endif
  29. # ifndef NO_ACTION_FUNCTION
  30. # define NO_ACTION_FUNCTION
  31. # endif
  32. #endif
  33. /* tapping count and state */
  34. typedef struct {
  35. bool interrupted : 1;
  36. bool reserved2 : 1;
  37. bool reserved1 : 1;
  38. bool reserved0 : 1;
  39. uint8_t count : 4;
  40. } tap_t;
  41. /* Key event container for recording */
  42. typedef struct {
  43. keyevent_t event;
  44. #ifndef NO_ACTION_TAPPING
  45. tap_t tap;
  46. #endif
  47. } keyrecord_t;
  48. /* Execute action per keyevent */
  49. void action_exec(keyevent_t event);
  50. /* action for key */
  51. action_t action_for_key(uint8_t layer, keypos_t key);
  52. /* macro */
  53. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt);
  54. /* user defined special function */
  55. void action_function(keyrecord_t *record, uint8_t id, uint8_t opt);
  56. /* keyboard-specific key event (pre)processing */
  57. bool process_record_quantum(keyrecord_t *record);
  58. /* Utilities for actions. */
  59. #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
  60. extern bool disable_action_cache;
  61. #endif
  62. /* Code for handling one-handed key modifiers. */
  63. #ifdef SWAP_HANDS_ENABLE
  64. extern bool swap_hands;
  65. extern const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS];
  66. # if (MATRIX_COLS <= 8)
  67. typedef uint8_t swap_state_row_t;
  68. # elif (MATRIX_COLS <= 16)
  69. typedef uint16_t swap_state_row_t;
  70. # elif (MATRIX_COLS <= 32)
  71. typedef uint32_t swap_state_row_t;
  72. # else
  73. # error "MATRIX_COLS: invalid value"
  74. # endif
  75. void process_hand_swap(keyevent_t *record);
  76. #endif
  77. void process_record_nocache(keyrecord_t *record);
  78. void process_record(keyrecord_t *record);
  79. void process_record_handler(keyrecord_t *record);
  80. void post_process_record_quantum(keyrecord_t *record);
  81. void process_action(keyrecord_t *record, action_t action);
  82. void register_code(uint8_t code);
  83. void unregister_code(uint8_t code);
  84. void tap_code(uint8_t code);
  85. void tap_code_delay(uint8_t code, uint16_t delay);
  86. void register_mods(uint8_t mods);
  87. void unregister_mods(uint8_t mods);
  88. void register_weak_mods(uint8_t mods);
  89. void unregister_weak_mods(uint8_t mods);
  90. // void set_mods(uint8_t mods);
  91. void clear_keyboard(void);
  92. void clear_keyboard_but_mods(void);
  93. void clear_keyboard_but_mods_and_keys(void);
  94. void layer_switch(uint8_t new_layer);
  95. bool is_tap_key(keypos_t key);
  96. bool is_tap_action(action_t action);
  97. #ifndef NO_ACTION_TAPPING
  98. void process_record_tap_hint(keyrecord_t *record);
  99. #endif
  100. /* debug */
  101. void debug_event(keyevent_t event);
  102. void debug_record(keyrecord_t record);
  103. void debug_action(action_t action);
  104. #ifdef __cplusplus
  105. }
  106. #endif