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

Improve consistency in UNICODEMAP code and docs, update docs/understanding_qmk #4774

Merged
merged 10 commits into from
Jan 7, 2019

Conversation

vomindoraan
Copy link
Contributor

@vomindoraan vomindoraan commented Jan 4, 2019

Rename some constants and functions pertaining to UNICODEMAP so they're consistent with the rest of the system. Also update the documentation accordingly. See below for details.

These changes should be non-breaking. I've taken care to update all usages of the renamed symbols.

Description

  • Remove unused UNICODE(n) macro (alias for UC(n), but no one was using it).

  • Rename QK_UNICODE_MAP constant to QK_UNICODEMAP (only used internally).

  • Rename unicode_map_input_error function to unicodemap_input_error (only used internally).

  • Rename process_unicode_map function to process_unicodemap (only used internally).

    Reasoning: UNICODEMAP is the name of the keymap definition method (hence UNICODEMAP_ENABLE, process_unicodemap etc.), whereas unicode_map refers to the mapping table itself, which is used by the method.

  • Refactor process_unicodemap code a bit to make it more readable.

  • Update links in docs/understanding_qmk and rearrange the list of process record functions so it matches the actual order in which they're called now (the order was slightly altered in Overhaul Unicode Common functionality #4325).

  • Various Unicode doc improvements.

Tested by compiling several keymaps that use UNICODEMAP.

P.S. When I say it's only used internally, I mean it's only used by QMK's internals and not directly in any userspaces/keymaps. That's why I think it's okay to rename these symbols. No “user facing” symbols were altered in the making of this PR 😛

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.
  • I have read the CONTRIBUTING document. (https://docs.qmk.fm/#/contributing)
  • 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).

This avoids the issue of the compiler sometimes complaining about the array index being out of range
@vomindoraan
Copy link
Contributor Author

@drashna I'd appreciate a review, fellow Unicodee 😄

#ifdef UNICODEMAP_ENABLE
#define X(n) (QK_UNICODE_MAP | (n))
// Allows Unicode input up to 0x10FFFF, requires unicode_map
#define X(i) (QK_UNICODEMAP | (i))
Copy link
Member

Choose a reason for hiding this comment

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

I forgot to add this myself, but I'd like to see an "else" for both of these (UC and X) that define them as empty functions, so they don't error out when compiling when the respective feature is disabled.

Copy link
Contributor Author

@vomindoraan vomindoraan Jan 6, 2019

Choose a reason for hiding this comment

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

They could be defined as KC_NONE in that case. But what's the use case? It seems to me like you'd want compilation to fail as fast as possible if you put UC or X in your keymap but forget to enable the corresponding feature.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure that failing is the best option here, to be honest.

Two reasons really come up for this:

  • Community Layouts
  • EEPROM storage of keymaps

Also, testing comes to mind, but that's an edge case.

The alternative is that if I want to do this locally, I would have to "ifdef" the keycodes ANYWAYS.

Copy link
Member

Choose a reason for hiding this comment

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

But for now, I'll just merge this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you elaborate on the community layouts bit? I think I know what you mean, but it'd be best if you could clarify just in case.

As far as keymap storage goes, UC and X themselves aren't part of the keycodes enum (they're just macros), so leaving them undefined doesn't affect other keycodes. What does get left out is QK_UNICODE and QK_UNICODEMAP, but if I'm not mistaken, those should be left out for the sake of feature flagging.

@drashna
Copy link
Member

drashna commented Jan 7, 2019

Thanks!

@drashna drashna merged commit cd9262d into qmk:master Jan 7, 2019
@vomindoraan vomindoraan deleted the unicodemap_consistency branch January 8, 2019 12:57
Shinichi-Ohki added a commit to Shinichi-Ohki/qmk_firmware that referenced this pull request Jan 10, 2019
* 'master' of https://github.com/qmk/qmk_firmware: (63 commits)
  Keymap: ave-63's iris layout (qmk#4812)
  Update bakingpy 4x12 keymap and add test mode for debugging/development (qmk#4810)
  Fix Mac mute keycode (qmk#4809)
  Add KBD75 keymap (qmk#4808)
  Fix pinout of split hand and LED, remove flip half option
  Tidy up Mod-Tap shortcuts (qmk#4806)
  Add missing parentheses to some important macros (qmk#4775)
  Keyboard: Downbubble refactor and Configurator fix (qmk#4798)
  Alternate keymap for Alpha keyboard, enjoy! (qmk#4797)
  Keymap: Added Model F-inspired layout for YMD[K]96 (qmk#4777)
  Improve consistency in UNICODEMAP code and docs, update docs/understanding_qmk (qmk#4774)
  Update to arm_atsam wait and timer routines
  Add Downbubble to Handwired repository (qmk#4794)
  Final HS60v2 changes. (qmk#4790)
  Keyboard: Fractal layout macro and readme cleanup (qmk#4789)
  Keymap: added my espectro keymap (qmk#4791)
  Keyboard: Numbrero: Configurator fix and code tidy (qmk#4787)
  Keyboard: Tradestation code tidy and readme refactor (qmk#4784)
  Keyboard: update readme with ps2avr flashing instructions (qmk#4776)
  add Pinky keyboard (qmk#4748)
  ...
rseymour pushed a commit to rseymour/qmk_firmware that referenced this pull request Mar 13, 2019
…nding_qmk (qmk#4774)

* Remove unused UNICODE(n) macro, update docs

* Add note about max length of unicode_map to docs

* QK_UNICODE_MAP → QK_UNICODEMAP

* Refactor process_unicode_map

* process_unicode_map → process_unicodemap

This is done for consistency: UNICODEMAP is the method (hence UNICODEMAP_ENABLE, process_unicodemap), whereas unicode_map is the mapping table itself.

* Update references and ordering in docs/understanding_qmk

* Add additional note to docs/understanding_qmk

* &unicode_map[index] → unicode_map + index

This avoids the issue of the compiler sometimes complaining about the array index being out of range

* Update docs/getting_started_make_guide

* Update method sections in docs/feature_unicode
djthread pushed a commit to djthread/qmk_firmware that referenced this pull request Mar 17, 2019
…nding_qmk (qmk#4774)

* Remove unused UNICODE(n) macro, update docs

* Add note about max length of unicode_map to docs

* QK_UNICODE_MAP → QK_UNICODEMAP

* Refactor process_unicode_map

* process_unicode_map → process_unicodemap

This is done for consistency: UNICODEMAP is the method (hence UNICODEMAP_ENABLE, process_unicodemap), whereas unicode_map is the mapping table itself.

* Update references and ordering in docs/understanding_qmk

* Add additional note to docs/understanding_qmk

* &unicode_map[index] → unicode_map + index

This avoids the issue of the compiler sometimes complaining about the array index being out of range

* Update docs/getting_started_make_guide

* Update method sections in docs/feature_unicode
dlhextall pushed a commit to dlhextall/qmk_firmware that referenced this pull request May 24, 2019
…nding_qmk (qmk#4774)

* Remove unused UNICODE(n) macro, update docs

* Add note about max length of unicode_map to docs

* QK_UNICODE_MAP → QK_UNICODEMAP

* Refactor process_unicode_map

* process_unicode_map → process_unicodemap

This is done for consistency: UNICODEMAP is the method (hence UNICODEMAP_ENABLE, process_unicodemap), whereas unicode_map is the mapping table itself.

* Update references and ordering in docs/understanding_qmk

* Add additional note to docs/understanding_qmk

* &unicode_map[index] → unicode_map + index

This avoids the issue of the compiler sometimes complaining about the array index being out of range

* Update docs/getting_started_make_guide

* Update method sections in docs/feature_unicode
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