From 6685a22166b9798c753714f0ffafd0537e328ea6 Mon Sep 17 00:00:00 2001
From: Timothy Davis <tmthydvs@gmail.com>
Date: Wed, 11 Oct 2023 17:12:41 +0930
Subject: [PATCH] Go back to BRMs and configure auto/retro-tap

---
 config.h           |  5 +++
 flmng0.c           | 79 ++++++++++++++++++++++++++++++++++++++++++----
 keymaps/combo.json |  2 +-
 layout.h           | 69 +++++++++++++++++++++++++++++++++-------
 rules.mk           |  4 +++
 5 files changed, 141 insertions(+), 18 deletions(-)

diff --git a/config.h b/config.h
index a54c2c1..bc43a05 100644
--- a/config.h
+++ b/config.h
@@ -7,6 +7,11 @@
 
 #define COMBO_TERM_PER_COMBO
 
+#define RETRO_SHIFT 500
+
+#define NO_AUTO_SHIFT_NUMBERIC
+#define NO_AUTO_SHIFT_SYMBOLS
+
 #ifndef __ASSEMBLER__
 #include "layout.h"
 #endif
diff --git a/flmng0.c b/flmng0.c
index 89b60c3..f2b6aac 100644
--- a/flmng0.c
+++ b/flmng0.c
@@ -8,17 +8,17 @@
  *
  * Open on left hand, close on right hand.
  */
-const uint16_t PROGMEM c_lparen[] = {HM_T, KC_D, COMBO_END};
-const uint16_t PROGMEM c_rparen[] = {HM_N, KC_H, COMBO_END};
+const uint16_t PROGMEM c_lparen[] = {CC_T, CC_D, COMBO_END};
+const uint16_t PROGMEM c_rparen[] = {CC_N, CC_H, COMBO_END};
 
-const uint16_t PROGMEM c_lbracket[] = {HM_S, KC_C, COMBO_END};
-const uint16_t PROGMEM c_rbracket[] = {HM_E, KC_COMM, COMBO_END};
+const uint16_t PROGMEM c_lbracket[] = {CC_S, CC_C, COMBO_END};
+const uint16_t PROGMEM c_rbracket[] = {CC_E, CC_COMM, COMBO_END};
 
 const uint16_t PROGMEM c_lbrace[] = {KC_G, KC_V, COMBO_END};
 const uint16_t PROGMEM c_rbrace[] = {KC_M, KC_K, COMBO_END};
 
-const uint16_t PROGMEM c_langle[] = {HM_R, KC_X, COMBO_END};
-const uint16_t PROGMEM c_rangle[] = {HM_I, KC_DOT, COMBO_END};
+const uint16_t PROGMEM c_langle[] = {CC_R, CC_X, COMBO_END};
+const uint16_t PROGMEM c_rangle[] = {CC_I, CC_DOT, COMBO_END};
 
 /**
  * Common symbols.
@@ -88,6 +88,70 @@ bool caps_word_press_user(uint16_t keycode) {
   }
 }
 
+/* bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *record) { */
+/*   switch (keycode) { */
+/*   #ifdef HOME_ROW_MODS */
+/*     case HM_A: */
+/*     case HM_R: */
+/*     case HM_S: */
+/*     case HM_T: */
+/*     case HM_N: */
+/*     case HM_E: */
+/*     case HM_I: */
+/*     case HM_O: */
+/*       return true; */
+/**/
+/*   #else */
+/*     case BM_Z: */
+/*     case BM_X: */
+/*     case BM_C: */
+/*     case BM_D: */
+/*     case BM_H: */
+/*     case BM_COMM: */
+/*     case BM_DOT: */
+/*     case BM_QUOT: */
+/*       return true; */
+/*   #endif */
+/**/
+/*     case KC_A ... KC_Z: */
+/*     case KC_TAB: */
+/*       return true; */
+/*   } */
+/**/
+/*   return false; */
+/* } */
+
+bool get_custom_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {
+  switch (keycode) {
+  #ifdef HOME_ROW_MODS
+    case HM_A:
+    case HM_R:
+    case HM_S:
+    case HM_T:
+    case HM_N:
+    case HM_E:
+    case HM_I:
+    case HM_O:
+      return true;
+
+  #else
+    case BM_Z:
+    case BM_X:
+    case BM_C:
+    case BM_D:
+    case BM_H:
+    case BM_COMM:
+    case BM_DOT:
+    case BM_QUOT:
+      return true;
+
+  #endif
+  }
+
+  return false;
+}
+
+#ifdef HOME_ROW_MODS
 #define ROLLOVER(kca, kcb, modded_b, mod_a) \
   case modded_b: \
     if (record->event.pressed && record->tap.count > 0) { \
@@ -100,8 +164,10 @@ bool caps_word_press_user(uint16_t keycode) {
       } \
     } \
     return true;
+#endif
 
 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+  #ifdef HOME_ROW_MODS
   uint8_t mods = get_mods();
 
   switch (keycode) {
@@ -115,6 +181,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
     ROLLOVER(KC_I, KC_E, HM_E, KC_LALT);
     ROLLOVER(KC_O, KC_I, HM_I, KC_RGUI);
   }
+  #endif
 
   return true;
 }
diff --git a/keymaps/combo.json b/keymaps/combo.json
index af83731..4ac7597 100644
--- a/keymaps/combo.json
+++ b/keymaps/combo.json
@@ -6,7 +6,7 @@
   "keymap": "flmng0",
   "layout": "LAYOUT_a_dux_wrap",
   "layers": [
-    [ "_BASE_HRM" ],
+    [ "_BASE" ],
     [ "_NAV" ],
     [ "_SYM" ],
     [ "_NUM" ],
diff --git a/layout.h b/layout.h
index 1d5f56e..a62001c 100644
--- a/layout.h
+++ b/layout.h
@@ -19,16 +19,8 @@
 
 /* #define S_TAB LSFT_T(KC_TAB) */
 
-#define BM_Z LGUI_T(KC_Z)
-#define BM_X LALT_T(KC_X)
-#define BM_C LSFT_T(KC_C)
-#define BM_D LCTL_T(KC_D)
-
-#define BM_H    RCTL_T(KC_H)
-#define BM_COMM RSFT_T(KC_COMM)
-#define BM_DOT  LALT_T(KC_DOT)
-#define BM_QUOT RGUI_T(KC_QUOT)
 
+#ifdef HOME_ROW_MODS
 
 #define HM_A LGUI_T(KC_A)
 #define HM_R LALT_T(KC_R)
@@ -40,19 +32,70 @@
 #define HM_I LALT_T(KC_I)
 #define HM_O RGUI_T(KC_O)
 
+#define CC_T HM_T
+#define CC_D KC_D
 
-#define _BASE_HRM \
+#define CC_N HM_N
+#define CC_H KC_H
+
+#define CC_S HM_S
+#define CC_C KC_C
+
+#define CC_E    HM_E
+#define CC_COMM KC_COMM
+
+#define CC_R HM_R
+#define CC_X KC_X
+
+#define CC_I   HM_I
+#define CC_DOT KC_DOT
+
+
+#define _BASE \
   KC_Q   , KC_W   , KC_F   , KC_P   , KC_B   , KC_J   , KC_L   , KC_U   , KC_Y   , KC_SCLN, \
   HM_A   , HM_R   , HM_S   , HM_T   , KC_G   , KC_M   , HM_N   , HM_E   , HM_I   , HM_O   , \
   KC_Z   , KC_X   , KC_C   , KC_D   , KC_V   , KC_K   , KC_H   , KC_COMM, KC_DOT , KC_QUOT, \
                              L_NUM  , L_NAV  , L_SYM  , KC_BSPC
 
-#define _BASE_BRM \
+#else
+
+#define BM_Z LGUI_T(KC_Z)
+#define BM_X LALT_T(KC_X)
+#define BM_C LSFT_T(KC_C)
+#define BM_D LCTL_T(KC_D)
+
+#define BM_H    RCTL_T(KC_H)
+#define BM_COMM RSFT_T(KC_COMM)
+#define BM_DOT  LALT_T(KC_DOT)
+#define BM_QUOT RGUI_T(KC_QUOT)
+
+#define CC_T KC_T
+#define CC_D BM_D
+
+#define CC_N KC_N
+#define CC_H BM_H
+
+#define CC_S KC_S
+#define CC_C BM_C
+
+#define CC_E    KC_E
+#define CC_COMM BM_COMM
+
+#define CC_R KC_R
+#define CC_X BM_X
+
+#define CC_I   KC_I
+#define CC_DOT BM_DOT
+
+
+#define _BASE \
   KC_Q   , KC_W   , KC_F   , KC_P   , KC_B   , KC_J   , KC_L   , KC_U   , KC_Y   , KC_SCLN, \
   KC_A   , KC_R   , KC_S   , KC_T   , KC_G   , KC_M   , KC_N   , KC_E   , KC_I   , KC_O   , \
   BM_Z   , BM_X   , BM_C   , BM_D   , KC_V   , KC_K   , BM_H   , BM_COMM, BM_DOT , BM_QUOT, \
                              L_NUM  , L_NAV  , L_SYM  , KC_BSPC
 
+#endif
+
 #define _NAV \
   KC_ESC , KC_NO  , KC_NO  , KC_NO  , KC_NO  , KC_NO  , KC_HOME, KC_PGDN, KC_PGUP, KC_END , \
   CW_TOGG, KC_NO  , KC_NO  , KC_NO  , KC_NO  , KC_NO  , KC_LEFT, KC_DOWN, KC_UP  , KC_RGHT, \
@@ -77,5 +120,9 @@
   KC_LCTL, KC_Z   , KC_S   , KC_X   , KC_C   , KC_V   , KC_B   , KC_NO  , KC_NO  , KC_NO  , \
                              KC_LALT, KC_SPC , KC_NO  , KC_NO
 
+// TODO: finish off the gaming alternate layer
+/* #define _GAME_ALT \ */
+/*   KC_ESC , KC_5   , KC_6   , KC_7   , KC_8   , KC_NO  , KC_NO  , KC_NO  , KC_NO  , KC_NO  , \ */
+
 
 #define LAYOUT_a_dux_wrap(...) LAYOUT_split_3x5_2(__VA_ARGS__)
diff --git a/rules.mk b/rules.mk
index d0aceb9..12d123c 100644
--- a/rules.mk
+++ b/rules.mk
@@ -1,5 +1,9 @@
 COMBO_ENABLE = yes
 CAPS_WORD_ENABLE = yes
+AUTO_SHIFT_ENABLE = yes
 
 INTROSPECTION_KEYMAP_C = flmng0.c
 
+
+# OPT_DEFS += -DHOME_ROW_MODS
+