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

Support for custom keys/custom shifted keys in Autoshift #8127

Closed
wants to merge 6 commits into from

Conversation

IsaacElenbaas
Copy link
Contributor

@IsaacElenbaas IsaacElenbaas commented Feb 9, 2020

Allows keys to be added to AS without editing process_auto_shift.c
Custom keys can be set for when any key is held longer than the timout
Custom keys can override the action of a key already enabled in autoshift via #define or default (eg. one letter)
Support for KC_NO; one can make a key have no action when held
Permissive Hold-like behavior (see ced1019's commit message) for when accidentally releasing modifier before Auto Shift key. Removed, actually the opposite of IGNORE_MOD_TAP_INTERRUPT which is by default 'enabled' (in behavior) for Auto Shift because modifiers are evaluated on release, not press. Breaking change and will be put in another pull once I work out the kinks and this is merged.

Description

I've made a function definable in one's keymap to add and/or set shifted values of keys. The return value of the function, if it is a key, will be the shifted value. If it is -1, the key will have its default shifted value, but be added to AS. -2 is the default, and changes nothing.
This shouldn't be a breaking change, but it is a rather large refactor. One of the main things I'm not sure about is the return values. . . as I wanted support for KC_NO as a shifted key (and needed two extra return values anyway, default shifted value and not autoshifted), I just went with negative numbers as they seemed easiest for the user to type and couldn't cause conflicts.
Also, there's no way to remove a key from autoshift. Not a big deal, but if you want all but one letter enabled you'll need a case for KC_A ... KC_J and KC_L ... KC_Z and to disable AS_ALPHA. Would be nice to fix.

Types of Changes

  • Core
  • Bugfix
  • New feature
  • Enhancement/optimization
  • Keyboard (addition or update)
  • Keymap/layout/userspace (addition or update)
  • Documentation

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. Planning on doing it tomorrow. Done.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • I have tested the changes and verified that they work and don't break anything (as well as I can manage).

Example custom function:

int16_t autoshift_custom_shifts(uint16_t keycode, keyrecord_t *record) {
  switch(keycode) {
    case KC_TAB:
    case KC_ENT:
    case KC_QUOT:
      return -1; // adds the key to Auto Shift with its default shifted action
    case KC_COMM:
      return KC_QUES; // send ? when , is held
    case KC_DOT:
      return KC_EXLM;
    case KC_SLSH:
      return KC_BSLASH;
    case KC_AMPR:
      return KC_PIPE;
    case KC_LPRN:
      return KC_LBRC;
    case KC_RPRN:
      return KC_RBRC;
    case KC_A:
      // note you can override the actions of already enabled keys, and KC_NO is supported
      // which allows you to make keys do nothing when held for longer than the timeout
      return KC_NO;
  }
  return -2; // default - not an Auto Shift key
}

Keys can be added to AS without editing process_auto_shift.c
Custom keys can be set for when any key is held longer than the timout
Custom keys can override the action of an already enabled key (eg. one 
letter)
Support for KC_NO; one can make a key have no action when held
@IsaacElenbaas
Copy link
Contributor Author

@jcowgar

When pressing a modifier, then an Auto Shift key, then releasing the mod
before the AS key doesn't send the modifier. This is basically identical
to the behavior PERMISSIVE_HOLD is meant to fix, so I'm not putting it
in a separate #define.
@IsaacElenbaas IsaacElenbaas changed the title Support for custom keys/custom shifted keys in Autoshift Support for custom keys/custom shifted keys in Autoshift + Permissive Hold Feb 9, 2020
@ridingqwerty
Copy link
Contributor

There's a pending PR for a PERMISSIVE_HOLD_PER_KEY feature that you may need to take into consideration, at least around the parts in process_auto_shift.c where you are checking #ifdef PERMISSIVE_HOLD. Looks to be as simple as changing that to #if defined(PERMISSIVE_HOLD) || defined(PERMISSIVE_HOLD_PER_KEY)

Copy link
Contributor

@ridingqwerty ridingqwerty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a limited review surround how this would affect PR #7994. I'm going to take a more thorough look at this at a later time.

quantum/process_keycode/process_auto_shift.c Outdated Show resolved Hide resolved
quantum/process_keycode/process_auto_shift.c Outdated Show resolved Hide resolved
quantum/process_keycode/process_auto_shift.c Outdated Show resolved Hide resolved
@IsaacElenbaas
Copy link
Contributor Author

Talked a bunch with @ridingqwerty in Discord as well as tested a bit and PERMISSIVE_HOLD is quite different from what I'm trying to do (and actually already works with Auto Shift). What I was trying to add is the opposite of IGNORE_MOD_TAP_INTERRUPT, which should really be the default behavior. It is, however, a breaking change (as it isn't the default at the moment) and getting Auto Shift to work with IGNORE_MOD_TAP_INTERRUPT_PER_KEY is going to be quite tricky, so I'm removing those changes and will work on that and submit another PR once this is merged.

It was actually the opposite of IGNORE_MOD_TAP_INTERRUPT, which should 
be the default, but the mods for an Auto Shift key are evaluated on 
release and therefore depend on mod release order, which is what 
IGNORE_MOD_TAP_INTERRUPT is supposed to *enable*.
@IsaacElenbaas IsaacElenbaas changed the title Support for custom keys/custom shifted keys in Autoshift + Permissive Hold Support for custom keys/custom shifted keys in Autoshift Feb 11, 2020
@ridingqwerty ridingqwerty dismissed their stale review March 23, 2020 17:39

My original note no longer applies since 7994 was merged (and probably didn't in the first place upon looking a second time)

@drashna drashna requested a review from a team March 23, 2020 17:54
@tzarc tzarc changed the base branch from master to develop July 25, 2020 22:47
@tzarc
Copy link
Member

tzarc commented Jul 25, 2020

Retargeted to develop due to core changes.

@IsaacElenbaas
Copy link
Contributor Author

Hmm, could have sworn I'd closed this. I already have a replacement made for the major AS revamp that just got merged. Will open new pull in hopefully under a week.

@IsaacElenbaas IsaacElenbaas deleted the as_custom_shifts branch February 23, 2022 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants