colinta / Mechy

54 stars 3 forks source link

Home Row Mods #5

Open MohrJonas opened 10 months ago

MohrJonas commented 10 months ago

Hi there, I really enjoy using Mechy on my Dactyl Manuform (https://github.com/MohrJonas/Dactyl-firmware). Recently I learned about home row mods (https://precondition.github.io/home-row-mods) and was wondering, if Mechy supports them as well, or plans to in the future.

colinta commented 10 months ago

Hey just saw this issue today! Dunno how it missed my inbox.

Glad you're enjoying Mechy; and with a split keyboard! wow back when I created this library it was intentionally with split support (I was trying out the BFO9000), but then I switched to an xd75 and since then I haven't touched that code ever since. But hey, it's C code, if it works today it oughta work in 200 years. šŸ¤£

My first thought to solve this was to use TapHold ā€“Ā tap "A" to type "a", press and hold to activate the modifier. This has the additional feature that if you long press and do nothing, it will ignore the key event, so you can change your mind and just "extra hold" the key.

I haven't compiled and tested this, but I think...

// I don't like that _order matters_, I'd definitely prefer a macro that "stores" the TH
// commands, and then automatically generates the `->add()` code... but either that's 
// impossible (it sounds impossible) or I don't know how to do it.
#define TH_GUIA  TH_0
#define TH_ALTS  TH_1
#define TH_SFTD  TH_2
#define TH_CTLF  TH_3

#define TH_CTLJ  TH_4
#define TH_SFTK  TH_5
#define TH_ALTL  TH_6
#define TH_GUIOD TH_7

void setup() {
  TapHold* tapHold = new TapHold();
  tapHold->add(DE_A, KC_LGUI);     // TH_GUIA
  tapHold->add(DE_S, KC_LALT);      // TH_ALTS
  tapHold->add(DE_D, KC_LSFT);      // TH_SFTD
  tapHold->add(DE_F, KC_LCTL);      // TH_CTLF

  // btw, your layout uses Left-Shift, even on the right, there's not a bug w/
  // KC_RSFT is there? could be a customization or just a copy/paste, but I only use
  // *left* modifiers, so wanted to check
  tapHold->add(DE_J, KC_LSFT);      // TH_CTLJ
  tapHold->add(DE_K, KC_RALT);      // TH_SFTK
  tapHold->add(DE_L, KC_RGUI);      // TH_ALTL
  tapHold->add(DE_ODIA, KC_RCTL);      // TH_GUIOD
  mechy.add(tapHold);
}

Maybe give that a try, let me know if it works!

This keymap uses mechy, as it is (in my opinion, of course), a way better qmk alternative šŸ˜ High praiseĀ ā€“Ā and I agree! šŸ˜ QMK looks and feels like a clunky mess. I really enjoyed building the APIs and key macros for Mechy.