qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

sten.h (2278B)


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