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