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

Allow easy switching/cycling between Unicode input modes #4221

Closed
wants to merge 114 commits into from

Conversation

vomindoraan
Copy link
Contributor

@vomindoraan vomindoraan commented Oct 23, 2018

Note: drashna:make_unicode_init has been merged into this as #4325 will likely be merged soon.

If you are reviewing this, click here to view the changes from that branch to this one. Those are the actual changes that this PR will introduce once #4325 is merged.

The old changes are available on vomindoraan:cycle_unicode_input_mode_new_backup.


Using a board with multiple OS's is a common occurrence. This adds an easy, declarative way of choosing and switching between Unicode input modes when you move from OS to OS. Here's how:

  1. Add your preferred input modes to your config.h as follows: #define UNICODE_SELECTED_MODES UC_WINC, UC_LNX.
  2. Use the keycode UC_MOD (and optionally UC_RMOD) to switch between modes.

If you select more than two modes, QMK will go through them cyclically, in the order they were specified, starting with the first. UC_MOD cycles forward and UC_RMOD cycles in reverse. For example:

#define UNICODE_SELECTED_MODES UC_WINC, UC_LNX, UC_OSX
// with UC_MOD:   UC_WINC → UC_LNX → UC_OSX → UC_WINC → …
// with UC_RMOD:  UC_WINC → UC_OSX → UC_LNX → UC_WINC → …

As a consequence, you don't need to call set_unicode_input_mode() in eeconfig_init_user() anymore if you're using this feature, since the input mode will automatically be initialized to the first one you specified in the list (but you still can if you want to).

The changes are written to EEPROM by default. This means that you only need to switch the input mode when changing machines, as the last picked mode will be stored between uses on the same OS. You can disable this by adding #define UNICODE_CYCLE_PERSIST false to your config.h. Do this if you want to conserve your EEPROM, or want the board to always boot with the first input mode in your list. You can then call persist_unicode_input_mode() yourself if you want to save the input mode on demand.

Note: This PR only adds new functionality and shouldn't change existing Unicode behavior.

To-do

  • Update docs
  • Add new quantum keycodes for the behavior

@vomindoraan vomindoraan force-pushed the cycle_unicode_input_mode_new branch 6 times, most recently from d61e0b2 to 78083de Compare October 29, 2018 11:34
@bit-shifter
Copy link

Konstantin - this looks to provide the exact functionality that I need for unicode input mode cycling.

Is there anything that I can do to help get it over the line?

@vomindoraan
Copy link
Contributor Author

@bit-shifter I need to add the new functionality to the docs, but that shouldn't be a problem as it'll more or less be a copy-paste of the description I wrote in the PR comment. Just need to get around to doing it.

Other than that I've been thinking about adding a predefined keycode that calls cycle_unicode_input_mode() so that users don't have to make one themselves. I assume you would benefit from something like this?

@drashna
Copy link
Member

drashna commented Oct 31, 2018

Other than that I've been thinking about adding a predefined keycode that calls cycle_unicode_input_mode() so that users don't have to make one themselves. I assume you would benefit from something like this?

Honestly, I think that we need keycodes for all of the Unicode modes.

@vomindoraan
Copy link
Contributor Author

That sounds good too. Have keycodes that change to a specific input mode — as well as one that cycles through a predefined set of input modes selected by the user (the most common use case being toggling between two modes).

Should there be a keycode for persist_unicode_input_mode() as well, in case the user opts to disable writing cycle changes to EEPROM by default? Or is that use case niche enough that it doesn't warrant a keycode of its own?

@vomindoraan
Copy link
Contributor Author

I've separated this from the changes in #4217 and have rebased the branch onto the latest master.

If someone else could test it, that'd be much appreciated 😄

vomindoraan and others added 21 commits November 8, 2018 08:25
Co-Authored-By: drashna <[email protected]>
Co-Authored-By: drashna <[email protected]>
Co-Authored-By: drashna <[email protected]>
Co-Authored-By: drashna <[email protected]>
* case alignment

* process_record_unicode_common → process_unicode_common

* Move song arrays into function where they're used, align preprocessor directives

* Swap the order of UC_WIN and UC_BSD

* Update Unicode docs

* Reorder Unicode mode stuff to match the order of input mode constants

* Fix capitalization in doc subtitle

* Readd BSD and OSX_RALT songs

* Reword BSD note in docs

* Readd BSD keycode description

* Reword explanation of input on different platforms
Co-Authored-By: drashna <[email protected]>
// Comma-delimited, ordered list of input modes selected for use (e.g. in cycle)
// Example: #define UNICODE_SELECTED_MODES UC_WINC, UC_LNX
#ifndef UNICODE_SELECTED_MODES
#define UNICODE_SELECTED_MODES -1
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it be better default behavior to default all modes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, the default should be that the feature is disabled by default — that way it's opt-in only. This minimizes the chance of anything breaking. For example, if it were enabled by default, some boards that are close to the firmware size limit would break because the feature uses extra memory (namely the selected array).

drashna and others added 5 commits November 25, 2018 13:06
* Standardize the Unicode EEPROM code

* Remove unicode init from process_record_* functions

* Add unicode init to where it belongs: matrix_init_quantum

* Move Unicode proccessing to unicode common

* Add audio feedback to input mode keys to drive konstantin up a wall

* Tap_code cleanup

* Update keycodes

* Update unicode documentation

* Update unicode keycodes for consistency/easier merge

* Add Audio Feedback section

* Remove Functions from feature page

And link to the file instead.  Link to specific lines later on.

* Fix white spaces

Co-Authored-By: drashna <[email protected]>

* Fix spacing

Co-Authored-By: drashna <[email protected]>

* Because I missed it!

Co-Authored-By: drashna <[email protected]>

* Fix spacing

Co-Authored-By: drashna <[email protected]>

* SPAAAAAAAAAACing

Co-Authored-By: drashna <[email protected]>

* white spaces

Co-Authored-By: drashna <[email protected]>

* Add BSD for future compatibility

* Thought I fixed that!

Co-Authored-By: drashna <[email protected]>

* non-breaking

Co-Authored-By: drashna <[email protected]>

* Considered that

Co-Authored-By: drashna <[email protected]>

* Yuuup

Co-Authored-By: drashna <[email protected]>

* consistency

Co-Authored-By: drashna <[email protected]>

* white spaces .... copied from elsewhere

Co-Authored-By: drashna <[email protected]>

* white spaces

Co-Authored-By: drashna <[email protected]>

* white spaces

Co-Authored-By: drashna <[email protected]>

* Update keycode defines

* Fix Linux Song

* Update all of the songs

* Cleanup

* Move and update check to ensure only one unicode method is enabled

* Update quantum/quantum_keycodes.h

* Update documentation

* Wordsmithing and cleanup

* Format unicode_common (qmk#13)

* case alignment

* process_record_unicode_common → process_unicode_common

* Move song arrays into function where they're used, align preprocessor directives

* Swap the order of UC_WIN and UC_BSD

* Update Unicode docs

* Reorder Unicode mode stuff to match the order of input mode constants

* Fix capitalization in doc subtitle

* Readd BSD and OSX_RALT songs

* Reword BSD note in docs

* Readd BSD keycode description

* Reword explanation of input on different platforms

* Steal vomindoraan's input mode documentation

Co-Authored-By: vomindoraan ([email protected])

* Willingly give Drashna the rest of my Unicode doc improvements

* Wordsmithing

Co-Authored-By: drashna <[email protected]>

* Rearrange process_unicode_common functions

* Make Unicode input mode constants (UC_*) an enum

* Simplify unicode_input_start/finish code

* Make the key used for WinCompose configurable

* Remove UC_OSX_RALT in favor of setting the key with UNICODE_OSX_KEY

* Update Unicode input mode doc

* Add descriptions and rearrange definitions in process_unicode_common.h

* Add registry command to Unicode docs + misc updates

* Reword an explanation in Unicode docs

* Add TODO comment

* Remove trailing whitespace
@vomindoraan
Copy link
Contributor Author

vomindoraan commented Nov 25, 2018

These changes have been incorporated into #4325.

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.

3 participants