Commit | Line | Data |
---|---|---|
a074364c | 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 | ||
a074364c | 27 | #ifdef __cplusplus |
28 | extern "C" { | |
29 | #endif | |
30 | ||
31 | /* tapping count and state */ | |
32 | typedef struct { | |
b624f32f | 33 | bool interrupted : 1; |
34 | bool reserved2 : 1; | |
35 | bool reserved1 : 1; | |
36 | bool reserved0 : 1; | |
37 | uint8_t count : 4; | |
a074364c | 38 | } tap_t; |
39 | ||
40 | /* Key event container for recording */ | |
41 | typedef struct { | |
b624f32f | 42 | keyevent_t event; |
a074364c | 43 | #ifndef NO_ACTION_TAPPING |
44 | tap_t tap; | |
45 | #endif | |
46 | } keyrecord_t; | |
47 | ||
48 | /* Execute action per keyevent */ | |
49 | void action_exec(keyevent_t event); | |
50 | ||
51 | /* action for key */ | |
52 | action_t action_for_key(uint8_t layer, keypos_t key); | |
53 | ||
54 | /* macro */ | |
55 | const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt); | |
56 | ||
57 | /* user defined special function */ | |
58 | void action_function(keyrecord_t *record, uint8_t id, uint8_t opt); | |
59 | ||
acd64aa8 | 60 | /* keyboard-specific key event (pre)processing */ |
bf5c2cce | 61 | bool process_record_quantum(keyrecord_t *record); |
ef21a855 | 62 | |
a074364c | 63 | /* Utilities for actions. */ |
74344947 | 64 | #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE) |
20dd9c03 | 65 | extern bool disable_action_cache; |
20dd9c03 | 66 | #endif |
dd378601 JW |
67 | |
68 | /* Code for handling one-handed key modifiers. */ | |
7230923b | 69 | #ifdef SWAP_HANDS_ENABLE |
b624f32f | 70 | extern bool swap_hands; |
dd378601 | 71 | extern const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS]; |
b624f32f | 72 | # if (MATRIX_COLS <= 8) |
73 | typedef uint8_t swap_state_row_t; | |
74 | # elif (MATRIX_COLS <= 16) | |
75 | typedef uint16_t swap_state_row_t; | |
76 | # elif (MATRIX_COLS <= 32) | |
77 | typedef uint32_t swap_state_row_t; | |
78 | # else | |
79 | # error "MATRIX_COLS: invalid value" | |
80 | # endif | |
dd378601 JW |
81 | |
82 | void process_hand_swap(keyevent_t *record); | |
83 | #endif | |
84 | ||
bf5c2cce JH |
85 | void process_record_nocache(keyrecord_t *record); |
86 | void process_record(keyrecord_t *record); | |
87 | void process_action(keyrecord_t *record, action_t action); | |
a074364c | 88 | void register_code(uint8_t code); |
89 | void unregister_code(uint8_t code); | |
02d44beb | 90 | void tap_code(uint8_t code); |
a074364c | 91 | void register_mods(uint8_t mods); |
92 | void unregister_mods(uint8_t mods); | |
b624f32f | 93 | // void set_mods(uint8_t mods); |
a074364c | 94 | void clear_keyboard(void); |
95 | void clear_keyboard_but_mods(void); | |
93b004c9 | 96 | void clear_keyboard_but_mods_and_keys(void); |
a074364c | 97 | void layer_switch(uint8_t new_layer); |
98 | bool is_tap_key(keypos_t key); | |
8e47f648 | 99 | bool is_tap_action(action_t action); |
a074364c | 100 | |
5d771039 JW |
101 | #ifndef NO_ACTION_TAPPING |
102 | void process_record_tap_hint(keyrecord_t *record); | |
103 | #endif | |
104 | ||
a074364c | 105 | /* debug */ |
106 | void debug_event(keyevent_t event); | |
107 | void debug_record(keyrecord_t record); | |
108 | void debug_action(action_t action); | |
109 | ||
110 | #ifdef __cplusplus | |
111 | } | |
112 | #endif | |
113 | ||
b624f32f | 114 | #endif /* ACTION_H */ |