summaryrefslogtreecommitdiff
path: root/users/ericgebhart/extensions/keycodes.h
blob: eafdfbad43647cf9c617177ddebea174f7a5845c (plain)
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
#pragma once
/*
  Copyright 2018-2022 Eric Gebhart <e.a.gebhart@gmail.com>

  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "quantum.h"
#include "process_keycode/process_tap_dance.h"
#include "eeconfig.h"
#include "keymap_bepo.h"
//#include "keymap_us_international.h"
#include "keymap_us_international_linux.h"
#include "lang.h"
#include "ericgebhart.h"

//#define ONESHOT_TAP_TOGGLE 2  /* Tapping this number of times holds the key until tapped once again. */

// #define DEFAULT_LANG EN // US_INT // EN, BEPO, US_INT, EURkey

#define KEY_NAME(NAME, ...) NAME,
#define BLANK(...)

bool process_record_secrets(uint16_t keycode, keyrecord_t *record);

enum userspace_custom_keycodes {
  // Get all the custom keys from the defs if we can.
  ALT_LOCAL_KEYS_START = SAFE_RANGE,
#ifdef ALT_LOCAL_ENABLE
#undef MK_KEY
#define MK_KEY KEY_NAME
#undef MK_SKEY
#define MK_SKEY KEY_NAME
#include "altlocal_keys.def"
#undef MK_KEY
#undef MK_SKEY
#endif
  ALT_LOCAL_KEYS_END,

#ifdef ACCENTED_KEYS_ENABLE
#undef ACCENTED
#define ACCENTED KEY_NAME
#include "accented_keys.def"
#undef ACCENTED
#endif

#ifdef TAP_HOLD_ENABLE
#undef TP_TPL
#define TP_TPL KEY_NAME
#undef TP_SML
#define TP_SML KEY_NAME
#undef OPEN_OCL
#define OPEN_OCL KEY_NAME
#undef OPEN_OCL_ND
#define OPEN_OCL_ND KEY_NAME
#include "tap_hold.def"
#undef OPEN_OCL
#undef OPEN_OCL_ND
#undef TP_TPL
#undef TP_SML
#endif

#ifdef UNICODE_ENABLE
#undef UC_STR
#define UC_STR KEY_NAME
#include "unicode.def"
#undef UC_STR
#endif

#ifdef SEND_STRING_ENABLE
#undef SEND_STR
#define SEND_STR KEY_NAME
#undef SEND_STR_DELAY
#define SEND_STR_DELAY KEY_NAME
#include "send_string.def"
#undef SEND_STR
#undef SEND_STR_DELAY
#endif

#ifdef SMART_LOCK_ENABLE
#undef SMLM
#define SMLM KEY_NAME
#undef SMLL
#define SMLL KEY_NAME
#include "smart_lock.def"
#undef SMLM
#undef SMLL
#endif

#ifdef MOD_LOCK_ENABLE
#undef IGNORE_KC
#define IGNORE_KC BLANK
#undef MODL
#define MODL KEY_NAME
#include "mod_lock.def"
#undef IGNORE_KC
#undef MODL
#endif


#undef IGNORE_KEY
#define IGNORE_KEY BLANK
#undef CANCEL_KEY
#define CANCEL_KEY BLANK
#undef ONESHOT
#undef NSHOT
#define ONESHOT KEY_NAME
#define NSHOT KEY_NAME

#ifdef NSHOT_ENABLE
#include "nshot.def"
#else
  TS_RCTL,
  TS_LCTL,
#endif

#ifdef ONESHOT_MOD_ENABLE
#include "oneshot.def"
#endif

#undef IGNORE_KEY
#undef CANCEL_KEY
#undef ONESHOT
#undef NSHOT

#ifdef SWAPPER_ENABLE
#undef SWAPPER_KEY
#define SWAPPER_KEY KEY_NAME
#include "swapper.def"
#undef SWAPPER_KEY
#endif

#ifdef NOT_DEAD_ENABLE
#undef NOT_DEAD
#define NOT_DEAD KEY_NAME
#include "not_dead.def"
#undef NOT_DEAD
#endif

#include "custom_keys.def"
  NEW_SAFE_RANGE
};

#define FIRST_LAYER (BEGINNING_OF_BASE_LAYERS + 1)

#define TL_DQUO TLKC(_DQUO)
#define TL_QUOT TLKC(_QUOT)
#define TL_COMM TLKC(_COMM)
#define TL_DOT  TLKC(_DOT)
#define TL_SCLN TLKC(_SCLN)
#define TL_SLSH TLKC(_SLSH)
#define TL_EXLM TLKC(_EXLM)
#define TL_MINS TLKC(_MINS)
#define TL_LPRN TLKC(_LPRN)
#define TL_LCBR TLKC(_LCBR)
#ifdef SYMBOL_LAYER_ENABLE
#define TL_DOT_SYMB LT(LN_SYMB, LANG_KC(TL_DOT))
#endif


#define BP_LT BP_LABK
#define BP_GT BP_RABK
#define BP_TAB KC_TAB
#define US_GT US_RABK
#define US_LT US_LABK
#define US_TAB KC_TAB
#define US_DCMM KC_COMM // us doesn't have this dead key.

// this is odd, there is interplay between this and
// the not-dead extension. - and tap-hold not-dead.
#undef US_TILD
#define US_TILD KC_TILD
// redefine us_circ so we actually get a circ.
#undef US_CIRC
#define US_CIRC KC_CIRC
#define US_EQUAL KC_EQUAL
// redefine us_quote so we actually get a quote.
#undef US_QUOT
#define US_QUOT KC_QUOT

#define US_PRINT_SCREEN KC_PRINT_SCREEN
#define US_SCROLL_LOCK KC_SCROLL_LOCK
#define US_PAUSE KC_PAUSE
#define BP_PRINT_SCREEN KC_PRINT_SCREEN
#define BP_SCROLL_LOCK KC_SCROLL_LOCK
#define BP_PAUSE KC_PAUSE

#define BP_F1 KC_F1
#define BP_F2 KC_F2
#define BP_F3 KC_F3
#define BP_F4 KC_F4
#define BP_F5 KC_F5
#define BP_F6 KC_F6
#define BP_F7 KC_F7
#define BP_F8 KC_F8
#define BP_F9 KC_F9
#define BP_F10 KC_F10
#define BP_F11 KC_F11
#define BP_F12 KC_F12
#define BP_TRNS KC_TRNS

#define US_F1 KC_F1
#define US_F2 KC_F2
#define US_F3 KC_F3
#define US_F4 KC_F4
#define US_F5 KC_F5
#define US_F6 KC_F6
#define US_F7 KC_F7
#define US_F8 KC_F8
#define US_F9 KC_F9
#define US_F10 KC_F10
#define US_F11 KC_F11
#define US_F12 KC_F12
#define US_TRNS KC_TRNS

#ifdef KEYPAD_LAYER_ENABLE
#define TT_KEYPAD TT(LANG_N(_KEYPAD))
#define MO_KEYPAD MO(LANG_N(_KEYPAD))
#else
#define TT_KEYPAD ___
#define MO_KEYPAD ___
#endif

#ifdef SYMBOL_LAYER_ENABLE
#define TT_SYMB TT(LANG_N(_SYMB))
#define MO_SYMB MO(LANG_N(_SYMB))
#define OSL_SYMB OSL(LANG_N(_SYMB))
#else
#define TT_SYMB ___
#define MO_SYMB ___
#define OSL_SYMB ___
#endif

#ifdef TOPROWS_LAYER_ENABLE
#define TT_TOPROWS TT(LANG_N(_TOPROWS))
#define MO_TOPROWS MO(LANG_N(_TOPROWS))
#else
#define TT_TOPROWS ___
#define MO_TOPROWS ___
#endif

#ifdef RGB_LAYER_ENABLE
#define MO_RGB MO(_RGB)
#else
#define MO_RGB ___
#endif

#ifdef ADJUST_LAYER_ENABLE
#define MO_ADJUST MO(_ADJUST)
#else
#define MO_ADJUST ___
#endif

#ifdef ACCENTS_MORTE_LAYER_ENABLE
//#define LN_ACCENTS_MORTE LANG_N(_ACCENTS_MORTE)
#define OSL_ACCENTS_MORTE OSL(LANG_N(_ACCENTS_MORTE))
#else
#define OSL_ACCENTS_MORTE ___
#endif

#ifdef ACCENTS_LAYER_ENABLE
#define LN_ACCENTS LANG_N(_ACCENTS)
#define OSL_ACCENTS OSL(LN_ACCENTS)
#else
#define OSL_ACCENTS ___
#endif

#ifdef MORTE_LAYER_ENABLE
#define LN_MORTE LANG_N(_MORTE)
#define OSL_MORTE OSL(LN_MORTE)
#else
#define OSL_MORTE ___
#endif

#define CTLGUI_T(kc) MT(MOD_LGUI | MOD_LCTL, kc)
#define SFTGUI_T(kc) MT(MOD_LGUI | MOD_LSFT, kc)
#define ALTGUI_T(kc) MT(MOD_LGUI | MOD_LALT, kc)

#define ALT_ENT     ALGR_T(KC_ENT)       // Alt oor nter
#define CTL_ENT     CTL_T(KC_ENT)       // ctrl or space
#define CTL_SPC     CTL_T(KC_SPC)       // ctrl or space
#define CTL_BSPC    CTL_T(KC_BSPC)      // ctrl or backspace
#define ALT_DEL     ALT_T(KC_DEL)       // Alt or delete
#define GUI_ESC     GUI_T(KC_ESC)       // Gui or escape
#define ALGR_SYMB   ALGR_T(TG(LANG_N(_SYMB))) // Alt gre or toggle symbol layer

// one shot on tap, or hold like usual
#define OSLCTL_CTL CTL_T(OS_LCTL)
#define OSLSFT_SFT SFT_T(OS_LSFT)
#define OSLALT_ALT ALT_T(OS_LALT)
#define OSLGUI_GUI GUI_T(OS_LGUI)

/* miryoku */
/*   esc_media, space_navnm, tab_navm,  ENT_SYM, BSPC_TOPR, del_fun */
/* hands down */
/* TL_COMM, TL_DOT_SYMB, GUI_ESC, ALT_ENT, SPC_TOPR, BSPC */

// Lots of LT options.  My thumb keys.
#ifdef TOPROWS_LAYER_ENABLE
#define LN_TOPROWS LANG_N(_TOPROWS)
#else
#define LN_TOPROWS KC_NO
#endif

#ifdef SYMBOL_LAYER_ENABLE
#  define LN_SYMB LANG_N(_SYMB)
#  define TH_LTR_SYM LT(LN_SYMB, THUMB_LETTER)
#else
#  define TH_LTR_SYM THUMB_LETTER
#endif

#define TH_LTR_NAV LT(_NAV, THUMB_LETTER)

#define LN_KEYPAD LANG_N(_KEYPAD)

#define ACCENTS_RALT MT(MOD_RALT, OSL_ACCENTS)
#define ACCENTS_CTL MT(MOD_LCTL, OSL_ACCENTS)
#define ENT_SYM LT(LN_SYMB, KC_ENT)
#define ENT_NAV LT(_NAV, KC_ENT)
#define ENT_TOPR LT(LN_TOPROWS, KC_ENT)

#define ESC_TOPR LT(LN_TOPROWS, KC_ESC)
#define ESC_SYMB LT(LN_SYMB, KC_ESC)
#define ESC_NUM LT(LN_KEYPAD, KC_ESC)
#define ESC_MEDIA LT(_MEDIA, KC_ESC)

#define DEL_FUN LT(_FUN, KC_DEL)
#define TAB_NAVM LT(_NAVm, KC_TAB)
#define TAB_NUM LT(LN_KEYPAD, KC_TAB)
#define I_SYMB LT(LN_SYMB, KC_I)

#define SPC_NAVm   LT(_NAVm, KC_SPC)
#define SPC_NAVnm  LT(_NAVnm, KC_SPC)
#define SPC_NAV    LT(_NAV, KC_SPC)
#define SPC_SYMB   LT(LN_SYMB, KC_SPC)
#define SPC_TOPR   LT(LN_TOPROWS, KC_SPC)
#define SPC_LAYR   LT(_LAYERS, KC_SPC)
#define SPC_ADJ    LT(_ADJUST, KC_SPC)
#define SPC_NUM    LT(LN_KEYPAD, KC_SPC)

#define BSPC_NAVm  LT(_NAVm, KC_BSPC)
#define BSPC_NAV   LT(_NAV, KC_BSPC)
#ifdef SYMBOL_LAYER_ENABLE
#define BSPC_SYMB  LT(LN_SYMB, KC_BSPC)
#else
#define BSPC_SYMB  KC_BSPC
#endif
#define BSPC_TOPR  LT(LN_TOPROWS, KC_BSPC)
#define BSPC_NUM   LT(LN_KEYPAD, KC_BSPC)
#define BSPC_ALT   MT(MOD_LALT, KC_BSPC)
#define BSPC_MEDIA LT(_MEDIA, KC_BSPC)

#define KC_BKTAB    LSFT(KC_TAB)

// layer toggles
#define LAYER_OSL   OSL(_LAYERS)
#define SYM_OSL     OSL(LN_SYMB)
#define SYM_TG      TG(LN_SYMB)
#define SYM_MO      MO(LN_SYMB)
#define NAV_TG      TG(_NAV)
#define COMBO_REF_TG_EN TG(_COMBO_REF)
#define NUM_OSL     OSL(LN_KEYPAD)
#define NUM_TO      TO(LN_KEYPAD)
#define FUN_OSL     OSL(LN_FUNC)
#define SYS_OSL     OSL(LN_SYSTEM)
#define SYS_TG      TG(LN_SYSTEM)

// Shortcuts
#define S_CUT       S(KC_DEL)
#define S_COPY      C(KC_INS)
#define S_PASTE     S(KC_INS)
#define S_UNDO      C(KC_Z)
#define S_REDO      C(KC_Y)
#define S_SAVE      C(KC_S)
#define S_ALL       C(KC_A)
#define S_BACK      A(KC_LEFT)
#define S_FWD       A(KC_RIGHT)
#define C_BSPC      C(KC_BSPC)
#define SCREEN      S(C(KC_PSCR))

// One Shot Mods keycodes,
#define KC_MLSF OSM(MOD_LSFT)
#define KC_MRSF OSM(MOD_RSFT)
#define OS_LGUI OSM(MOD_LGUI)
#define OS_RGUI OSM(MOD_RGUI)
#define OS_LSFT OSM(MOD_LSFT)
#define OS_RSFT OSM(MOD_RSFT)
#define OS_LCTL OSM(MOD_LCTL)
#define OS_RCTL OSM(MOD_RCTL)
#define OS_LALT OSM(MOD_LALT)
#define OS_RALT OSM(MOD_RALT)
#define ALT_APP ALT_T(KC_APP)

#define MG_NKRO MAGIC_TOGGLE_NKRO

#define UC_IRNY UC(0x2E2E)
#define UC_CLUE UC(0x203D)


////  TAP DANCE

typedef struct {
  bool is_press_action;
  int state;
} tdtap;

enum {
  SINGLE_TAP = 1,
  SINGLE_HOLD = 2,
  DOUBLE_TAP = 3,
  DOUBLE_HOLD = 4,
  DOUBLE_SINGLE_TAP = 5, //send two single taps
  TRIPLE_TAP = 6,
  TRIPLE_HOLD = 7
};

//Tap Dance Declarations
enum {
  TD_ESC_CAPS = 0,
  TD_TAB_BKTAB = 1,
  TD_MDIA_SYMB = 2,
  TD_HOME_END = 3,
  TD_XMONAD_ESC = 4,
  TD_DEF_LAYER_SW = 5,
  TD_DEF_OS_LAYER_SW = 6,
  TD_MOUSE_BTNS = 7,
  TD_DVORAK_BEPO = 8,
  TD_UP_HOME = 9,
  TD_DOWN_END = 10,
  TD_RIGHT_TAB = 11,
  TD_LEFT_BACKTAB = 12
};


// Tap dance
#define TAB_BKTAB       TD(TD_TAB_BKTAB)  // Tab or backtab tapdance.
#define MDIA_SYMB_KP_LAYERS TD(TD_MDIA_SYMB)  // MDIA, symb, keypad, layouts layer tapdance toggle.
#define DEF_LAYER_SW    TD(TD_DEF_LAYER_SW)  // dvorak, dvorak_on_bepo, bepo default layer
#define DEF_OS_LAYER_SW TD(TD_DEF_OS_LAYER_SW)  // dvorak, dvorak_on_bepo, bepo default layer
#define HOME_END        TD(TD_HOME_END)  // home or end tapdance.
#define XMONAD_ESC      TD(TD_XMONAD_ESC)  // Escape, dvorak, media or symb. - tap and hold tap dance. 1-4
#define DVORAK_ET_BEPO  TD(TD_DVORAK_BEPO)  // Escape, dvorak, media or symb. - tap and hold tap dance. 1-4
#define TDMOUSE_BTNS    TD(TD_MOUSE_BTNS)  // hmmm. 1-5
#define RIGHT_TAB       TD(TD_RIGHT_TAB)   // Bad idea these 4. Maybe with good timing...
#define LEFT_BACKTAB    TD(TD_LEFT_BACKTAB)
#define UP_HOME         TD(TD_UP_HOME)
#define DOWN_END        TD(TD_DOWN_END)  //  No! Down Down Not End....

// HOME ROW LAYER TOGGLE (LT) and Shift.
// both sides of the home row have  "shift, ___, media , symb, ___"  and  "___, symb, media, ___, shift".
// so pinky fingers are shift when held and the index and second fingers are symbol and
// media layers when held.

// The most portable copy/paste keys (windows (mostly), linux, and some terminal emulators).
// The KC_CCCV key takes care of the last two...
#define MK_CUT    LSFT(KC_DEL)  // shift + delete
#define MK_COPY   LCTL(KC_INS)  // ctrl + insert
#define MK_PASTE  LSFT(KC_INS)  // shift + insert
#define EOT     LCTL(KC_D)
#define NAK     LCTL(KC_U)
#define XPASTE   LCTL(LSFT(KC_V))
#define UNDO    LCTL(KC_Z)
#define XCOPY   LCTL(LSFT(KC_C))

#undef ___ //kint defines it as KC_NO
#define ___ KC_TRNS
#define XXX KC_NO
#define ____ _TRNS

// Blocking keys
#define _X_ XXX
#define ___X___ XXX
#define ___X2___ XXX, XXX
#define ___X3___ ___X2___, XXX
#define ___X4___ ___X3___, XXX
#define ___X5___ ___X4___, XXX
#define ___X6___ ___X5___, XXX
#define ___X12___ ___X6___, ___X6___
#define ___X15___ ___X5___, ___X5___,  ___X5___

// Transparent keys
#define ___2___ ___, ___
#define ___3___ ___2___, ___
#define ___4___ ___3___, ___
#define ___5___ ___4___, ___
#define ___6___ ___5___, ___
#define ___10___ ___6___, ___4___
#define ___12___ ___6___, ___6___
#define ___14___ ___5___, ___4___,  ___5___
#define ___15___ ___5___, ___5___,  ___5___
#define ___16___ ___15___, ___

#define ____2_ ____, ____
#define ____3_ ____2_, ____
#define ____4_ ____3_, ____
#define ____5_ ____4_, ____
#define ____6_ ____5_, ____
#define ____10_ ____6_, ____4_
#define ____12_ ____6_, ____6_
#define ____14_ ____5_, ____4_,  ____5_
#define ____15_ ____5_, ____5_,  ____5_
#define ____16_ ____15_, ____

int on_qwerty(void);

#ifdef TAP_DANCES_ENABLE
int cur_dance (tap_dance_state_t *state);

//for the x tap dance. Put it here so it can be used in any keymap
void x_finished (tap_dance_state_t *state, void *user_data);
void x_reset (tap_dance_state_t *state, void *user_data);
#endif