diff options
Diffstat (limited to 'tmk_core/common/action.h')
-rw-r--r-- | tmk_core/common/action.h | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/tmk_core/common/action.h b/tmk_core/common/action.h new file mode 100644 index 000000000..8a4736d7b --- /dev/null +++ b/tmk_core/common/action.h | |||
@@ -0,0 +1,82 @@ | |||
1 | /* | ||
2 | Copyright 2012,2013 Jun Wako <wakojun@gmail.com> | ||
3 | |||
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 | |||
9 | This program is distributed in the hope that it will be useful, | ||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | GNU General Public License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | #ifndef ACTION_H | ||
18 | #define ACTION_H | ||
19 | |||
20 | #include <stdint.h> | ||
21 | #include <stdbool.h> | ||
22 | #include "keyboard.h" | ||
23 | #include "keycode.h" | ||
24 | #include "action_code.h" | ||
25 | #include "action_macro.h" | ||
26 | |||
27 | |||
28 | #ifdef __cplusplus | ||
29 | extern "C" { | ||
30 | #endif | ||
31 | |||
32 | /* tapping count and state */ | ||
33 | typedef struct { | ||
34 | bool interrupted :1; | ||
35 | bool reserved2 :1; | ||
36 | bool reserved1 :1; | ||
37 | bool reserved0 :1; | ||
38 | uint8_t count :4; | ||
39 | } tap_t; | ||
40 | |||
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 | |||
49 | /* Execute action per keyevent */ | ||
50 | void action_exec(keyevent_t event); | ||
51 | |||
52 | /* action for key */ | ||
53 | action_t action_for_key(uint8_t layer, keypos_t key); | ||
54 | |||
55 | /* macro */ | ||
56 | const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt); | ||
57 | |||
58 | /* user defined special function */ | ||
59 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt); | ||
60 | |||
61 | /* Utilities for actions. */ | ||
62 | void process_action(keyrecord_t *record); | ||
63 | void register_code(uint8_t code); | ||
64 | void unregister_code(uint8_t code); | ||
65 | void register_mods(uint8_t mods); | ||
66 | void unregister_mods(uint8_t mods); | ||
67 | //void set_mods(uint8_t mods); | ||
68 | void clear_keyboard(void); | ||
69 | void clear_keyboard_but_mods(void); | ||
70 | void layer_switch(uint8_t new_layer); | ||
71 | bool is_tap_key(keypos_t key); | ||
72 | |||
73 | /* debug */ | ||
74 | void debug_event(keyevent_t event); | ||
75 | void debug_record(keyrecord_t record); | ||
76 | void debug_action(action_t action); | ||
77 | |||
78 | #ifdef __cplusplus | ||
79 | } | ||
80 | #endif | ||
81 | |||
82 | #endif /* ACTION_H */ | ||