fix DZ60 info.json (#7000)
[jackhill/qmk/firmware.git] / tmk_core / common / action.h
CommitLineData
a074364c 1/*
2Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along 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
28extern "C" {
29#endif
30
31/* tapping count and state */
32typedef 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 */
41typedef 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 */
49void action_exec(keyevent_t event);
50
51/* action for key */
52action_t action_for_key(uint8_t layer, keypos_t key);
53
54/* macro */
55const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt);
56
57/* user defined special function */
58void action_function(keyrecord_t *record, uint8_t id, uint8_t opt);
59
acd64aa8 60/* keyboard-specific key event (pre)processing */
bf5c2cce 61bool 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 65extern 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 70extern bool swap_hands;
dd378601 71extern const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS];
b624f32f 72# if (MATRIX_COLS <= 8)
73typedef uint8_t swap_state_row_t;
74# elif (MATRIX_COLS <= 16)
75typedef uint16_t swap_state_row_t;
76# elif (MATRIX_COLS <= 32)
77typedef uint32_t swap_state_row_t;
78# else
79# error "MATRIX_COLS: invalid value"
80# endif
dd378601
JW
81
82void process_hand_swap(keyevent_t *record);
83#endif
84
bf5c2cce
JH
85void process_record_nocache(keyrecord_t *record);
86void process_record(keyrecord_t *record);
87void process_action(keyrecord_t *record, action_t action);
a074364c 88void register_code(uint8_t code);
89void unregister_code(uint8_t code);
02d44beb 90void tap_code(uint8_t code);
a074364c 91void register_mods(uint8_t mods);
92void unregister_mods(uint8_t mods);
b624f32f 93// void set_mods(uint8_t mods);
a074364c 94void clear_keyboard(void);
95void clear_keyboard_but_mods(void);
93b004c9 96void clear_keyboard_but_mods_and_keys(void);
a074364c 97void layer_switch(uint8_t new_layer);
98bool is_tap_key(keypos_t key);
8e47f648 99bool is_tap_action(action_t action);
a074364c 100
5d771039
JW
101#ifndef NO_ACTION_TAPPING
102void process_record_tap_hint(keyrecord_t *record);
103#endif
104
a074364c 105/* debug */
106void debug_event(keyevent_t event);
107void debug_record(keyrecord_t record);
108void debug_action(action_t action);
109
110#ifdef __cplusplus
111}
112#endif
113
b624f32f 114#endif /* ACTION_H */