Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with Layer Lock #21

Open
iovis opened this issue Sep 14, 2024 · 4 comments
Open

Compatibility with Layer Lock #21

iovis opened this issue Sep 14, 2024 · 4 comments

Comments

@iovis
Copy link

iovis commented Sep 14, 2024

Hi! I was wondering if you'd know how I'd make sm_td work with layer lock.

I'm guessing I should add the appropriate range from sm_td here:

  switch (keycode) {
    case QK_MOMENTARY ... QK_MOMENTARY_MAX:  // `MO(layer)` keys.
      return handle_mo_or_tt(QK_MOMENTARY_GET_LAYER(keycode), record);

    case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX:  // `TT(layer)`.
      return handle_mo_or_tt(QK_LAYER_TAP_TOGGLE_GET_LAYER(keycode), record);

    case QK_LAYER_MOD ... QK_LAYER_MOD_MAX: {  // `LM(layer, mod)`.
      uint8_t layer = QK_LAYER_MOD_GET_LAYER(keycode);
      if (is_layer_locked(layer)) {
        if (record->event.pressed) {  // On press, unlock the layer.
          layer_lock_invert(layer);
        } else {  // On release, clear the mods.
          clear_mods();
          send_keyboard_report();
        }
        return false;  // Skip default handling.
      }
    } break;

#ifndef NO_ACTION_TAPPING
    case QK_LAYER_TAP ... QK_LAYER_TAP_MAX:  // `LT(layer, key)` keys.
      if (record->tap.count == 0 && !record->event.pressed &&
          is_layer_locked(QK_LAYER_TAP_GET_LAYER(keycode))) {
        // Release event on a held layer-tap key where the layer is locked.
        return false;  // Skip default handling so that layer stays on.
      }
      break;
#endif  // NO_ACTION_TAPPING
  }

But I'm not sure what range would that be. I tried using SMTD_KEYCODES_BEGIN ... SMTD_KEYCODES_END but it didn't work, I'm guessing I need some kind of modifier keycode?

Thank you!

@iovis
Copy link
Author

iovis commented Sep 14, 2024

For context, I'm using SMTD_LT(NV_SLSH, KC_SLSH, _NV), you can see my current layout here

@stasmarkin
Copy link
Owner

Unfortunately there is no easy way to make layer_lock work with sm_td. I use a custom layer switching mechanism for the SMTD_LT macro because the default from QMK doesn't work well with sm_td. So all custom functions with layer switching won't work here.

@stasmarkin
Copy link
Owner

I've added this to the backlog, I'll probably be able to figure something out.

@iovis
Copy link
Author

iovis commented Sep 15, 2024

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants