]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/georgi/sten.h
[Keyboard] Snagpad Configurator bugfix and readme refactor (#6381)
[qmk_firmware.git] / keyboards / georgi / sten.h
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 #include QMK_KEYBOARD_H
9 #include "mousekey.h"
10 #include "keymap.h"
11 #include "keymap_steno.h"
12 #include "wait.h"
13
14 extern size_t keymapsCount;                     // Total keymaps
15 extern uint32_t cChord;                         // Current Chord
16 extern uint32_t stenoLayers[];          // Chords that simulate QMK layers
17 extern size_t stenoLayerCount;          // Number of simulated layers
18 uint32_t refChord;                                      // Reference chord for PC macro
19
20 // Function defs
21 void                    processChord(bool useFakeSteno);
22 uint32_t                processQwerty(bool lookup);
23 uint32_t                processFakeSteno(bool lookup);
24 void                    saveState(uint32_t cChord);
25 void                    restoreState(void);
26
27 // Macros for use in keymap.c
28 void                    SEND(uint8_t kc);
29 void                    REPEAT(void);
30 void                    SET_STICKY(uint32_t);
31 void                    SWITCH_LAYER(int);
32 void                    CLICK_MOUSE(uint8_t);
33
34 // Keymap helper
35 #define P(chord, act) if (cChord == (chord)) { if (!lookup) {act;} return chord;}
36 #define PC(chord, act) if (cChord == (chord)) { if (!lookup) {act;} return chord;} \
37         for(int i = 0; i < stenoLayerCount; i++) { \
38                 refChord = stenoLayers[i] | chord; \
39                 if (cChord == (refChord)) { if (!lookup) {act;} return refChord;}; \
40 }
41
42 // Shift to internal representation
43 // i.e) S(teno)R(ight)F
44 #define STN(n) (1L<<n)
45 enum ORDER { 
46                 SFN = 0, SPWR, SST1, SST2, SST3, SST4, SNUML, SNUMR,
47                 SLSU, SLSD, SLT, SLK, SLP, SLW, SLH, SLR, SLA, SLO, 
48                 SRE, SRU, SRF, SRR, SRP, SRB, SRL, SRG, SRT, SRS, SRD, SRZ, SRES1, SRES2
49 };
50
51 // Break it all out
52 #define FN      STN(SFN)
53 #define PWR     STN(SPWR)
54 #define ST1 STN(SST1)
55 #define ST2 STN(SST2)
56 #define ST3 STN(SST3)
57 #define ST4 STN(SST4)
58 #define LNO STN(SNUML)  // STN1-6
59 #define RNO STN(SNUMR)  // STN7-C
60 #define RES1 STN(SRES1) // Use reserved for sticky state
61 #define RES2 STN(SRES2)
62
63 #define LSU STN(SLSU)
64 #define LSD STN(SLSD)
65 #define LFT STN(SLT)    // (L)e(F)t (T), preprocessor conflict
66 #define LK  STN(SLK)
67 #define LP  STN(SLP)
68 #define LW  STN(SLW)
69 #define LH  STN(SLH)
70 #define LR  STN(SLR)
71 #define LA  STN(SLA)
72 #define LO  STN(SLO)
73
74 #define RE  STN(SRE)
75 #define RU  STN(SRU)
76 #define RF  STN(SRF)
77 #define RR  STN(SRR)
78 #define RP  STN(SRP)
79 #define RB  STN(SRB)
80 #define RL  STN(SRL)
81 #define RG  STN(SRG)
82 #define RT  STN(SRT)
83 #define RS  STN(SRS)
84 #define RD  STN(SRD)
85 #define RZ  STN(SRZ)