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

Extend allowed range of tappable keycodes to include modifiers #5809

Merged
merged 5 commits into from
Aug 8, 2019

Conversation

fauxpark
Copy link
Member

@fauxpark fauxpark commented May 7, 2019

Description

This should allow you to do things like LCTL_T(KC_LGUI) for a Control/GUI Mod-Tap.

Types of Changes

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

Issues Fixed or Closed by This PR

Checklist

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • 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).

Copy link
Member

@drashna drashna left a comment

Choose a reason for hiding this comment

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

LGTM

@yanfali
Copy link
Contributor

yanfali commented May 7, 2019

Are any documentation changes warranted? this seems like a great feature.

@fauxpark
Copy link
Member Author

fauxpark commented May 7, 2019

Not really, though perhaps it should be noted that it can't be extended further to include mousekeys too, as OP_TAP_TOGGLE and OP_ONESHOT are 0xF0 and 0xF4 respectively.

Copy link
Contributor

@yanfali yanfali left a comment

Choose a reason for hiding this comment

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

LGTM

@rgreenblatt
Copy link

At the moment, this PR doesn't fix use cases like MT(MOD_RCTL, KC_DOLLAR). This will still send 4 on tap instead of $. Is there any hope of this being addressed here?

@drashna
Copy link
Member

drashna commented Jun 2, 2019

@rgreenblatt no. No chance at all.

The problem is that there isn't enough space to be able to add the shifted notation to this. We would have to extend the keycodes.

Basic keycodes can and do use the 8 bit range, while extra stuff uses higher.

Here, for instance, the keycode is broken up a la:

ffff llll kkkk kkkk

The ffff being the special function, the llll being the layer number (and why LT is limited to 0-15), and kkkk kkkk is the specified keycode.

Shifted keycodes use the first 8 bits to mark what mod it's using, and the second 8 for the keycode. eg

rrrr mmmm kkkk kkkk

Where rrrr is right/left, mmmm is the bit for the mod (shift, ctrl, alt, gui/cmd), and the keycode.

Some of this info is from memory, so it may not be 100% accurate. But this should give you a good idea of why it's not possible.

We'd have to expand to 24 (or realistically) 32 bit keycodes. Which would double the size of the keymaps in the firmware (not insignificant) and would require a MASSIVE rewrite of the code.

@fauxpark
Copy link
Member Author

Bump :)

Copy link
Member

@noroadsleft noroadsleft left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@fauxpark
Copy link
Member Author

Turns out this doesn't actually fix the issue for LT(), as it conflicts with LM() (they both use ACT_LAYER_TAP). Thanks to @drashna for spotting 😄

@fauxpark
Copy link
Member Author

Here's my solution to the LM() problem - I've moved the handling out of the ACT_LAYER_TAP handling and into its own action. After all, it's not a hold/tap action, just a MO() with mods held. This seems to work great and stays within the already established limits of LM() imposed by the keycode size (layers 0-15, left mods only) so this shouldn't break VIA, or anything really.

Tested with:

LT(1, KC_RGUI)
MT(MOD_LCTL, KC_RGUI)
LM(1, MOD_LALT | MOD_RGUI)

The left/right bit is stripped from the RGUI in the LM define, turning it into an LGUI, but this is okay as it always did that anyway.

@drashna drashna removed the request for review from ezuk July 30, 2019 07:14
@drashna drashna requested review from a team and removed request for fredizzimo July 30, 2019 07:14
@drashna
Copy link
Member

drashna commented Jul 30, 2019

Not sure if this should be a breaking change or not.

@skullydazed ?

@fauxpark
Copy link
Member Author

I don't believe it is - it doesn't even change keycode values, so VIA is safe 😄

Copy link
Member

@skullydazed skullydazed left a comment

Choose a reason for hiding this comment

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

LGTM, not a breaking change.

@drashna drashna merged commit 2f6c068 into qmk:master Aug 8, 2019
@fauxpark fauxpark deleted the mt-extend-kc-range branch August 8, 2019 22:38
drashna pushed a commit to zsa/qmk_firmware that referenced this pull request Aug 8, 2019
)

* Extend allowed range of tappable keycodes to include modifiers

* Get rid of the magic numbers altogether

* Remove some more magic numbers

* Extract LM() functionality from ACT_LAYER_TAP

* Use ACTION() macro everywhere
fdidron pushed a commit to zsa/qmk_firmware that referenced this pull request Aug 13, 2019
)

* Extend allowed range of tappable keycodes to include modifiers

* Get rid of the magic numbers altogether

* Remove some more magic numbers

* Extract LM() functionality from ACT_LAYER_TAP

* Use ACTION() macro everywhere
incredibleweirdo pushed a commit to electricbrainreserve/qmk_firmware that referenced this pull request Aug 15, 2019
)

* Extend allowed range of tappable keycodes to include modifiers

* Get rid of the magic numbers altogether

* Remove some more magic numbers

* Extract LM() functionality from ACT_LAYER_TAP

* Use ACTION() macro everywhere
doughsay pushed a commit to doughsay/qmk_firmware that referenced this pull request Aug 31, 2019
)

* Extend allowed range of tappable keycodes to include modifiers

* Get rid of the magic numbers altogether

* Remove some more magic numbers

* Extract LM() functionality from ACT_LAYER_TAP

* Use ACTION() macro everywhere
swanmatch pushed a commit to swanmatch/qmk_firmware that referenced this pull request Sep 3, 2019
)

* Extend allowed range of tappable keycodes to include modifiers

* Get rid of the magic numbers altogether

* Remove some more magic numbers

* Extract LM() functionality from ACT_LAYER_TAP

* Use ACTION() macro everywhere
ripxorip pushed a commit to ripxorip/qmk_firmware that referenced this pull request Dec 3, 2019
)

* Extend allowed range of tappable keycodes to include modifiers

* Get rid of the magic numbers altogether

* Remove some more magic numbers

* Extract LM() functionality from ACT_LAYER_TAP

* Use ACTION() macro everywhere
ridingqwerty pushed a commit to ridingqwerty/qmk_firmware that referenced this pull request Jan 10, 2020
)

* Extend allowed range of tappable keycodes to include modifiers

* Get rid of the magic numbers altogether

* Remove some more magic numbers

* Extract LM() functionality from ACT_LAYER_TAP

* Use ACTION() macro everywhere
BorisTestov pushed a commit to BorisTestov/qmk_firmware that referenced this pull request May 23, 2024
)

* Extend allowed range of tappable keycodes to include modifiers

* Get rid of the magic numbers altogether

* Remove some more magic numbers

* Extract LM() functionality from ACT_LAYER_TAP

* Use ACTION() macro everywhere
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