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

Add option to use numpad for digits entry for unicode mode UC_WIN #14496

Merged
merged 12 commits into from
Sep 21, 2021

Conversation

mjvh80
Copy link

@mjvh80 mjvh80 commented Sep 18, 2021

Adds an option UNICODE_UC_WIN_USE_NUMPAD_IF_POSSIBLE to use the numpad for entering digits 0-9 of a hexadecimal unicode codepoint for unicode mode UC_WIN, improving reliability of this unicode mode on Windows.

Description

On Windows, if using the UC_WIN unicode mode, reliability of the alt entry succeeding is improved by using the numpad for entering the 0-9 digits of a hex code under numlock. This is because fewer apps hook alt+numpad digits for custom shortcuts. Of course this method of unicode entry still has issues if e.g. apps use menu mnemonics, though if they are disabled in for example VSCode the alt method becomes reliable if using the numpad instead of regular number keys.

The downside of this method is that numlock is required, thus entering a unicode character this way would make the numlock led flash (if it was off), which is one reason I used a preprocessor setting to not switch this on by default.

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: C, Python
  • I have read the PR Checklist document and have made the appropriate changes.
  • 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).

@github-actions github-actions bot added the core label Sep 18, 2021
@drashna drashna requested a review from a team September 18, 2021 20:07
@vomindoraan
Copy link
Contributor

In my opinion, it's okay if we make this the default behavior (without requiring the preprocessor setting). The UC_LNX implementation already toggles Caps Lock in order to ensure proper behavior, and it doesn't require a special define, so I think it's fine if the Windows hex numpad implementation does the same.

quantum/process_keycode/process_unicode_common.c Outdated Show resolved Hide resolved
quantum/process_keycode/process_unicode_common.c Outdated Show resolved Hide resolved
quantum/process_keycode/process_unicode_common.c Outdated Show resolved Hide resolved
quantum/process_keycode/process_unicode_common.c Outdated Show resolved Hide resolved
quantum/process_keycode/process_unicode_common.c Outdated Show resolved Hide resolved
quantum/process_keycode/process_unicode_common.c Outdated Show resolved Hide resolved
quantum/process_keycode/process_unicode_common.c Outdated Show resolved Hide resolved
@vomindoraan
Copy link
Contributor

vomindoraan commented Sep 19, 2021

I like that you opted to use the full keycode names: KC_NUMLOCK instead of KC_NLCK and KC_KP_1 instead of KC_P1. It makes the code more readable, in my opinion. Since this is core code and not a keymap, we aren't constrained to 7 characters per keycode, and readability counts (as well as consistency).

Do you mind updating the other keycodes in this file to also use the long variants?

  • KC_CAPS → KC_CAPSLOCK (3 occurrences)
  • KC_PPLSKC_KP_PLUS (1 occurence)
  • KC_SPCKC_SPACE (1 occurrence)
  • KC_ESCKC_ESCAPE (2 occurences)

Copy link
Contributor

@vomindoraan vomindoraan left a comment

Choose a reason for hiding this comment

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

Tested with the below changes and confirmed working (although the term “working” is relative when it comes to UC_WIN).

Setup: AVR board, Unicode Map, UC_WIN.

Tested in:

  • VS Code — Works, except for code points that overlap with menu mnemonics (e.g. Alt+E, Alt+F). Fixable through settings. Works better than current UC_WIN because digits don't cause tab switching with the default keymap.
  • Windows Terminal (bash, bash over ssh) — Works, except for code points that overlap with Unix shell shortcuts (e.g. Alt+B, Alt+F). Still, works better than current UC_WIN because at least the digits don't invoke argument repetition mode.
  • Firefox — Works, except for code points that overlap with browser and add-on shortcuts (e.g. Alt+D).
  • MS Word — No collisions with program shortcuts, but produces unpredictable output (Word doesn't play too well with hex numpad in the first place).
  • JetBrains IDEs — Collides with menu mnemonics, and when it doesn't, it produces completely unpredictable output. Actually, this one seems to work better without numpad digits — but it's still completely unusable, so I don't think that makes a difference.

quantum/process_keycode/process_unicode_common.c Outdated Show resolved Hide resolved
quantum/process_keycode/process_unicode_common.c Outdated Show resolved Hide resolved
quantum/process_keycode/process_unicode_common.c Outdated Show resolved Hide resolved
quantum/process_keycode/process_unicode_common.c Outdated Show resolved Hide resolved
quantum/process_keycode/process_unicode_common.c Outdated Show resolved Hide resolved
quantum/process_keycode/process_unicode_common.c Outdated Show resolved Hide resolved
@mjvh80
Copy link
Author

mjvh80 commented Sep 19, 2021

I tested with Visual Studio which I generally tend to use, and after disabling the usual mnemonics for A-F it works reliably there. I personally never use the mnemonics so don't lose anything.
I just tried JetBrains IntelliJ, I noticed that the default key bindings include alt+0-9 (which could of course be changed as well), there's also an option to disable menu mnemonics, disabling that made it work quite well for me (they seem to have one issue when codes are entered too quickly in succession).
Firefox also has the option to disable mnemonics through about:config and the options ui.key.menuAccessKey and ui.key.menuAccessKeyFocuses, which I set to 17 and false respectively.

Word doesn't work as you mentioned, they seem to have their own way of doing things (e.g. type 221e followed by alt+x).

I'll remove the preprocessor variable as you suggested.

@vomindoraan
Copy link
Contributor

Thanks for doing more testing! The changes LGTM now, apart from that small mistake I made.

@drashna
Copy link
Member

drashna commented Sep 21, 2021

Thanks!

@drashna drashna merged commit 8b6c16e into qmk:develop Sep 21, 2021
ptrxyz pushed a commit to ptrxyz/qmk_firmware that referenced this pull request Apr 9, 2022
BorisTestov pushed a commit to BorisTestov/qmk_firmware that referenced this pull request May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants