diff options
Diffstat (limited to 'keyboards/gboards/engine/engine.h')
-rw-r--r-- | keyboards/gboards/engine/engine.h | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/keyboards/gboards/engine/engine.h b/keyboards/gboards/engine/engine.h new file mode 100644 index 000000000..5b9d5b0ec --- /dev/null +++ b/keyboards/gboards/engine/engine.h | |||
@@ -0,0 +1,104 @@ | |||
1 | /* 2019, g Heavy Industries | ||
2 | Blessed mother of Christ, please keep this readable | ||
3 | and protect us from segfaults. For thine is the clock, | ||
4 | the slave and the master. Until we return from main. | ||
5 | |||
6 | Amen. | ||
7 | |||
8 | This is a stripped down version of the Georgi engine meant for use with | ||
9 | . As such serial-Steno features are disabled, chords are 16bits and | ||
10 | crap is removed where possible | ||
11 | */ | ||
12 | |||
13 | #include QMK_KEYBOARD_H | ||
14 | #pragma once | ||
15 | #include "keymap.h" | ||
16 | #include <string.h> | ||
17 | #include <stdint.h> | ||
18 | #include <stdio.h> | ||
19 | #include "config_engine.h" | ||
20 | #include <avr/pgmspace.h> | ||
21 | #include "wait.h" | ||
22 | |||
23 | // Maximum values for combos | ||
24 | #define COMBO_END 0x00 | ||
25 | |||
26 | // In memory chord datatypes | ||
27 | enum specialActions { | ||
28 | SPEC_STICKY, | ||
29 | SPEC_REPEAT, | ||
30 | SPEC_CLICK, | ||
31 | SPEC_SWITCH, | ||
32 | }; | ||
33 | struct funcEntry { | ||
34 | C_SIZE chord; | ||
35 | void (*act)(void); | ||
36 | } funcEntry_t; | ||
37 | struct stringEntry { | ||
38 | C_SIZE chord; | ||
39 | PGM_P str; | ||
40 | } stringEntry_t; | ||
41 | struct comboEntry { | ||
42 | C_SIZE chord; | ||
43 | PGM_P keys; | ||
44 | } comboEntry_t; | ||
45 | struct keyEntry { | ||
46 | C_SIZE chord; | ||
47 | uint8_t key; | ||
48 | } keyEntry_t; | ||
49 | struct specialEntry { | ||
50 | C_SIZE chord; | ||
51 | enum specialActions action; | ||
52 | uint16_t arg; | ||
53 | } specialEntry_t; | ||
54 | |||
55 | // Chord Temps | ||
56 | extern C_SIZE cChord; | ||
57 | extern C_SIZE test; | ||
58 | |||
59 | // Function defs | ||
60 | void processKeysUp(void); | ||
61 | void processChord(void); | ||
62 | C_SIZE processQwerty(bool lookup); | ||
63 | C_SIZE processFakeSteno(bool lookup); | ||
64 | void saveState(C_SIZE cChord); | ||
65 | void restoreState(void); | ||
66 | uint8_t bitpop_v(C_SIZE val); | ||
67 | |||
68 | // Macros for use in keymap.c | ||
69 | void SEND(uint8_t kc); | ||
70 | void REPEAT(void); | ||
71 | void SET_STICKY(C_SIZE); | ||
72 | void SWITCH_LAYER(int); | ||
73 | void CLICK_MOUSE(uint8_t); | ||
74 | C_SIZE process_engine_post(C_SIZE cur_chord, uint16_t keycode, keyrecord_t *record); | ||
75 | C_SIZE process_chord_getnext(C_SIZE cur_chord); | ||
76 | |||
77 | // Keymap helpers | ||
78 | // New Approach, multiple structures | ||
79 | #define P_KEYMAP(chord, keycode) {chord, keycode}, | ||
80 | |||
81 | #define K_KEYMAP(chord, name, ...) {chord, (PGM_P)&name}, | ||
82 | #define K_ACTION(chord, name, ...) const uint8_t name[] PROGMEM = __VA_ARGS__; | ||
83 | |||
84 | #define S_KEYMAP(chord, name, string) {chord, (PGM_P)&name}, | ||
85 | #define S_ACTION(chord, name, string) const char name[] PROGMEM = string; | ||
86 | |||
87 | #define X_KEYMAP(chord, name, func) {chord, name}, | ||
88 | #define X_ACTION(chord, name, func) \ | ||
89 | void name(void) { func } | ||
90 | |||
91 | #define Z_KEYMAP(chord, act, arg) {chord, act, arg}, | ||
92 | |||
93 | #define TEST_COLLISION(chord, ...) \ | ||
94 | case chord: \ | ||
95 | break; | ||
96 | #define BLANK(...) | ||
97 | |||
98 | // Shift to internal representation | ||
99 | // i.e) S(teno)R(ight)F | ||
100 | #define STN(n) ((C_SIZE)1 << n) | ||
101 | #define ENGINE_HOOK(keycode, chord) \ | ||
102 | case keycode: \ | ||
103 | pr ? (pressed |= (chord)) : (pressed &= ~(chord)); \ | ||
104 | break; | ||