-
Notifications
You must be signed in to change notification settings - Fork 4
/
adapt_magic.c
330 lines (325 loc) · 9.86 KB
/
adapt_magic.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
//
// adaptive_magic.c
//
//
// Created by Alan on 1/22/24.
//
//
// embedded in the switch in ive.c
//
//
// first the common non-alpha adaptives for macros (Basically a "Magic" key, like a reverse LeaderKey)
//
case KC_SLSH: // the "MAGIC_SLSH" keys
if (preprior_keycode == KC_DOT)
break;
if (prior_keycode == KC_DOT) { // ./ but not ../
send_string("com");
return_state = false; // done.
}
break;
case KC_COMM:
switch (prior_keycode) { // a tap-dance of sorts
case KC_COMM: // double comma = CAPS_WORD.
tap_code(KC_BSPC);
toggle_caps_word();
return_state = false; // done.
break;
}
break;
case KC_DOT:
if (preprior_keycode == KC_DOT)
break;
switch (prior_keycode) {
case KC_SLSH: // /. => !
tap_code(KC_BSPC);
tap_code16(KC_EXLM);
return_state = false; // done.
break;
}
break;
case KC_DQUO:
switch (prior_keycode) {
case KC_DOT:
send_string("edu");
return_state = false; // done.
break;
case KC_SLSH: // /" => ?
tap_code(KC_BSPC);
tap_code16(KC_QUES);
return_state = false; // done.
}
break;
case KC_QUOT:
switch (prior_keycode) {
case KC_DOT:
send_string("org");
return_state = false; // done.
break;
#ifndef ADAPT_H // alternate way to handle the AU/EO SFBs
case KC_A: //
tap_code(KC_U); // "A'" yields "AU"
return_state = false; // done.
break;
case KC_U:
tap_code(KC_A); // "U'" yields "UA"
return_state = false; // done.
break;
case KC_E:
tap_code(KC_O); // "E'" yields "EO"
return_state = false; // done.
break;
case KC_O:
tap_code(KC_E); // "O'" yields "OE"
return_state = false; // done.
break;
#endif
}
break;
#ifdef HD_MAGIC
case HD_MAGIC: // default is KC_HASH "#"
if (preprior_keycode) // allow only 1 deep
break;
return_state = false; // presume we do something.
switch (prior_keycode) {
#ifdef A_MAGIC
case KC_A: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(A_MAGIC); //
break;
#endif
#ifdef B_MAGIC
case KC_B: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(B_MAGIC); //
break;
#endif
#ifdef C_MAGIC
case KC_C: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(C_MAGIC); //
break;
#endif
#ifdef D_MAGIC
case KC_D: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(D_MAGIC); //
break;
#endif
#ifdef E_MAGIC
case KC_E: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(E_MAGIC); //
break;
#endif
#ifdef F_MAGIC
case KC_F: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(F_MAGIC); //
break;
#endif
#ifdef G_MAGIC
case KC_G: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(G_MAGIC); //
break;
#endif
#ifdef H_MAGIC
case KC_H: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(H_MAGIC); //
break;
#endif
#ifdef I_MAGIC
case KC_I: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(I_MAGIC); //
break;
#endif
#ifdef J_MAGIC
case KC_J: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(J_MAGIC); //
break;
#endif
#ifdef K_MAGIC
case KC_K: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(K_MAGIC); //
break;
#endif
#ifdef L_MAGIC
case KC_L: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(L_MAGIC); //
break;
#endif
#ifdef M_MAGIC
case KC_M: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(M_MAGIC); //
break;
#endif
#ifdef N_MAGIC
case KC_N: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(N_MAGIC); //
break;
#endif
#ifdef O_MAGIC
case KC_O: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(O_MAGIC); //
break;
#endif
#ifdef P_MAGIC
case KC_P: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(P_MAGIC); //
break;
#endif
#ifdef R_MAGIC
case KC_R: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(R_MAGIC); //
break;
#endif
#ifdef S_MAGIC
case KC_S: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(S_MAGIC); //
break;
#endif
#ifdef T_MAGIC
case KC_T: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(T_MAGIC); //
break;
#endif
#ifdef U_MAGIC
case KC_U: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(U_MAGIC); //
break;
#endif
#ifdef V_MAGIC
case KC_V: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(V_MAGIC); //
break;
#endif
#ifdef W_MAGIC
case KC_W: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(W_MAGIC); //
break;
#endif
#ifdef X_MAGIC
case KC_X: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(X_MAGIC); //
break;
#endif
#ifdef Y_MAGIC
case KC_Y: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(Y_MAGIC); //
break;
#endif
#ifdef Z_MAGIC
case KC_Z: //
tap_code(KC_BSPC); // and may have been lowercase
send_string(Z_MAGIC); //
break;
#endif
default: //
return_state = true; // didn't end up doing anything.
}
break;
#endif // HD_MAGIC
#ifdef HD_MAGIC_A
case HD_MAGIC_A: //
switch (prior_keycode) {
case KC_E: //
tap_code(KC_O); //
return_state = false; // done.
break;
case KC_O: //
tap_code(KC_E); //
return_state = false; // done.
break;
case KC_A: //
tap_code(KC_U);
return_state = false; // done.
break;
case KC_U: //
tap_code(KC_A); //
return_state = false; // done.
break;
}
break;
#endif // HD_MAGIC_A
#ifdef HD_MAGIC_B
case HD_MAGIC_B: // for most common double letters (inherently SFBs)
switch (prior_keycode) {
case KC_L: // LN eliminate SFB
case KC_M: // MN eliminate SFB
tap_code(KC_N);
return_state = false; // done.
break;
#ifndef HD_MAGIC_A
case KC_E: //
tap_code(KC_O); //
return_state = false; // done.
break;
case KC_O: //
tap_code(KC_E); //
return_state = false; // done.
break;
case KC_A: //
tap_code(KC_U);
return_state = false; // done.
break;
case KC_U: //
if (preprior_keycode == KC_O) // oux (french)
tap_code(KC_X); //
else
tap_code(KC_A); //
return_state = false; // done.
break;
#endif
/* double-letter frequencies from Peter Norvig's data <https://norvig.com/mayzner.html>
* nearly all double consonants are followed by a vowel, and double vowels by a consonant
* which limits candidates to basically consonant thumb to avoid possible scissoring/SFBs.
* Each case needs to be vetted.
*/
/*
case KC_L: // (0.577%) // Hands Down Platinum – not exactly recommended
case KC_S: // (0.405%)
case KC_E: // (0.378%) // with cons on thumb, these are problematic
case KC_O: // (0.210%)
case KC_T: // (0.171%) // Hands Down Gold
case KC_F: // (0.146%)
case KC_P: // (0.137%)
case KC_R: // (0.121%) // Hands Down Titanium/Rhodium/Vibranium/Promethium
// These aren't frequent enough to bother?
case KC_M: // (0.096%)
case KC_C: // (0.083%)
case KC_N: // (0.073%) // Hands Down Silver
case KC_D: // (0.043%)
case KC_G: // (0.025%)
// These are def not frequent enough to bother?
case KC_I: // (0.023%)
case KC_B: // (0.011%)
case KC_A: // (0.003%)
case KC_Z: // (0.003%)
case KC_X: // (0.003%)
case KC_U: // (0.001%)
case KC_H: // (0.001%) // Hands Down Bronze
*/
default: // make it a dumb repeater
tap_code(prior_keycode); // eliminate SFB on double
return_state = false; // done.
}
break;
#endif // HD_MAGIC_B