From 18fcde13ad0305e68e566922152542878651ecc5 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 08:37:38 -0700 Subject: [PATCH 01/38] Standardize the Unicode EEPROM code --- .../process_keycode/process_unicode_common.c | 44 +++++-------------- .../process_keycode/process_unicode_common.h | 9 +++- 2 files changed, 18 insertions(+), 35 deletions(-) diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 4285d20a19..c270d5119a 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -19,42 +19,28 @@ #include #include -static uint8_t input_mode; -uint8_t mods; +unicode_config_t unicode_config; +static uint8_t saved_mods; void set_unicode_input_mode(uint8_t os_target) { - input_mode = os_target; + unicode_config.input_mode = os_target; eeprom_update_byte(EECONFIG_UNICODEMODE, os_target); } uint8_t get_unicode_input_mode(void) { - return input_mode; + return unicode_config.input_mode; } void unicode_input_mode_init(void) { - static bool first_flag = false; - if (!first_flag) { - input_mode = eeprom_read_byte(EECONFIG_UNICODEMODE); - first_flag = true; - } + unicode_config.raw = eeprom_read_byte(EECONFIG_UNICODEMODE); } __attribute__((weak)) void unicode_input_start (void) { - // save current mods - mods = keyboard_report->mods; - - // unregister all mods to start from clean state - if (mods & MOD_BIT(KC_LSFT)) unregister_code(KC_LSFT); - if (mods & MOD_BIT(KC_RSFT)) unregister_code(KC_RSFT); - if (mods & MOD_BIT(KC_LCTL)) unregister_code(KC_LCTL); - if (mods & MOD_BIT(KC_RCTL)) unregister_code(KC_RCTL); - if (mods & MOD_BIT(KC_LALT)) unregister_code(KC_LALT); - if (mods & MOD_BIT(KC_RALT)) unregister_code(KC_RALT); - if (mods & MOD_BIT(KC_LGUI)) unregister_code(KC_LGUI); - if (mods & MOD_BIT(KC_RGUI)) unregister_code(KC_RGUI); - - switch(input_mode) { + saved_mods = get_mods(); // Save current mods + clear_mods(); // Unregister mods to start from a clean state + + switch(unicode_config.input_mode) { case UC_OSX: register_code(KC_LALT); break; @@ -85,7 +71,7 @@ void unicode_input_start (void) { __attribute__((weak)) void unicode_input_finish (void) { - switch(input_mode) { + switch(unicode_config.input_mode) { case UC_OSX: case UC_WIN: unregister_code(KC_LALT); @@ -99,15 +85,7 @@ void unicode_input_finish (void) { break; } - // reregister previously set mods - if (mods & MOD_BIT(KC_LSFT)) register_code(KC_LSFT); - if (mods & MOD_BIT(KC_RSFT)) register_code(KC_RSFT); - if (mods & MOD_BIT(KC_LCTL)) register_code(KC_LCTL); - if (mods & MOD_BIT(KC_RCTL)) register_code(KC_RCTL); - if (mods & MOD_BIT(KC_LALT)) register_code(KC_LALT); - if (mods & MOD_BIT(KC_RALT)) register_code(KC_RALT); - if (mods & MOD_BIT(KC_LGUI)) register_code(KC_LGUI); - if (mods & MOD_BIT(KC_RGUI)) register_code(KC_RGUI); + set_mods(saved_mods); // Reregister previously set mods } __attribute__((weak)) diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index e78e1cec6c..7f896461b6 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -23,8 +23,13 @@ #define UNICODE_TYPE_DELAY 10 #endif -__attribute__ ((unused)) -static uint8_t input_mode; +typedef union { + uint32_t raw; + struct { + uint8_t input_mode :8; + }; +} unicode_config_t; + void set_unicode_input_mode(uint8_t os_target); uint8_t get_unicode_input_mode(void); From 7b6391bd183a9208c48bcb87a54acd55c15ae528 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 08:41:55 -0700 Subject: [PATCH 02/38] Remove unicode init from process_record_* functions --- quantum/process_keycode/process_ucis.c | 1 - quantum/process_keycode/process_unicode.c | 2 -- quantum/process_keycode/process_unicodemap.c | 1 - 3 files changed, 4 deletions(-) diff --git a/quantum/process_keycode/process_ucis.c b/quantum/process_keycode/process_ucis.c index 380199771d..56544eca18 100644 --- a/quantum/process_keycode/process_ucis.c +++ b/quantum/process_keycode/process_ucis.c @@ -93,7 +93,6 @@ void register_ucis(const char *hex) { } bool process_ucis (uint16_t keycode, keyrecord_t *record) { - unicode_input_mode_init(); if (!qk_ucis_state.in_progress) return true; diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c index f39c4a36e1..19beb84520 100644 --- a/quantum/process_keycode/process_unicode.c +++ b/quantum/process_keycode/process_unicode.c @@ -20,11 +20,9 @@ bool process_unicode(uint16_t keycode, keyrecord_t *record) { if (keycode > QK_UNICODE && record->event.pressed) { uint16_t unicode = keycode & 0x7FFF; - unicode_input_mode_init(); unicode_input_start(); register_hex(unicode); unicode_input_finish(); } return true; } - diff --git a/quantum/process_keycode/process_unicodemap.c b/quantum/process_keycode/process_unicodemap.c index ab5717ba3a..47c27b9117 100644 --- a/quantum/process_keycode/process_unicodemap.c +++ b/quantum/process_keycode/process_unicodemap.c @@ -45,7 +45,6 @@ __attribute__((weak)) void unicode_map_input_error() {} bool process_unicode_map(uint16_t keycode, keyrecord_t *record) { - unicode_input_mode_init(); uint8_t input_mode = get_unicode_input_mode(); if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) { const uint32_t* map = unicode_map; From a6e66f09ca9c580b3f7ec0566d1e00197f1578a8 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 08:43:32 -0700 Subject: [PATCH 03/38] Add unicode init to where it belongs: matrix_init_quantum --- quantum/quantum.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/quantum/quantum.c b/quantum/quantum.c index 5f1a691c88..3770b0312b 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -997,6 +997,9 @@ void matrix_init_quantum() { #ifdef ENCODER_ENABLE encoder_init(); #endif + #if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE) + unicode_input_mode_init(); + #endif matrix_init_kb(); } From 9698e3f262fc4fe49b5f2a17837c023cc9be41a8 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 09:13:08 -0700 Subject: [PATCH 04/38] Move Unicode proccessing to unicode common --- .../process_keycode/process_unicode_common.c | 35 ++++++++++++++++++- .../process_keycode/process_unicode_common.h | 1 + quantum/quantum.c | 12 ++----- quantum/quantum_keycodes.h | 6 +++- 4 files changed, 43 insertions(+), 11 deletions(-) diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index c270d5119a..e8f5001380 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -22,6 +22,7 @@ unicode_config_t unicode_config; static uint8_t saved_mods; + void set_unicode_input_mode(uint8_t os_target) { unicode_config.input_mode = os_target; eeprom_update_byte(EECONFIG_UNICODEMODE, os_target); @@ -36,7 +37,7 @@ void unicode_input_mode_init(void) { } __attribute__((weak)) -void unicode_input_start (void) { +void unicode_input_start(void) { saved_mods = get_mods(); // Save current mods clear_mods(); // Unregister mods to start from a clean state @@ -131,3 +132,35 @@ void send_unicode_hex_string(const char *str) { str += n; // Move to the first ' ' (or '\0') after the current token } } + +bool process_record_unicode_common(uint16_t keycode, keyrecord_t *record) { + if (record->event.pressed) { + switch (keycode) { + case UNI_OSX: + set_unicode_input_mode(UC_OSX); + break; + case UNI_LINUX: + set_unicode_input_mode(UC_LNX); + break; + case UNI_WIN: + set_unicode_input_mode(UC_WIN); + break; + case UNI_WINC: + set_unicode_input_mode(UC_WINC); + break; + case UNI_OSX_RALT: + set_unicode_input_mode(UC_OSX_RALT); + break; + } + } + #ifdef UNICODE_ENABLE + return process_unicode(keycode, record); + #endif + #ifdef UCIS_ENABLE + return process_ucis(keycode, record); + #endif + #ifdef UNICODEMAP_ENABLE + return process_unicode_map(keycode, record); + #endif + return true; +} diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index 7f896461b6..b1fc8c0ac8 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -38,6 +38,7 @@ void unicode_input_start(void); void unicode_input_finish(void); void register_hex(uint16_t hex); void send_unicode_hex_string(const char *str); +bool process_record_unicode_common(uint16_t keycode, keyrecord_t *record); #define UC_OSX 0 // Mac OS X #define UC_LNX 1 // Linux diff --git a/quantum/quantum.c b/quantum/quantum.c index 3770b0312b..4267c1e036 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -256,27 +256,21 @@ bool process_record_quantum(keyrecord_t *record) { #ifdef TAP_DANCE_ENABLE process_tap_dance(keycode, record) && #endif + #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) + process_record_unicode_common(keycode, record) && + #endif #ifdef LEADER_ENABLE process_leader(keycode, record) && #endif #ifdef COMBO_ENABLE process_combo(keycode, record) && #endif - #ifdef UNICODE_ENABLE - process_unicode(keycode, record) && - #endif - #ifdef UCIS_ENABLE - process_ucis(keycode, record) && - #endif #ifdef PRINTING_ENABLE process_printer(keycode, record) && #endif #ifdef AUTO_SHIFT_ENABLE process_auto_shift(keycode, record) && #endif - #ifdef UNICODEMAP_ENABLE - process_unicode_map(keycode, record) && - #endif #ifdef TERMINAL_ENABLE process_terminal(keycode, record) && #endif diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index e983798f2b..6a3a6461bd 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -453,7 +453,11 @@ enum quantum_keycodes { TERM_ON, TERM_OFF, #endif - + UNI_OSX, + UNI_LINUX, + UNI_WIN, + UNI_WINC, + UNI_OSX_RALT, // always leave at the end SAFE_RANGE }; From 59bf691ce3a18a6461895bace724b7ecc7d1a9cc Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 09:29:24 -0700 Subject: [PATCH 05/38] Add audio feedback to input mode keys to drive konstantin up a wall --- .../process_keycode/process_unicode_common.c | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index e8f5001380..b69439d7f7 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -21,6 +21,23 @@ unicode_config_t unicode_config; static uint8_t saved_mods; +#ifdef AUDIO_ENABLE + #ifdef UNICODE_LINUX_SONG + float linux_song[][2] = UNICODE_LINUX_SONG; + #endif + #ifdef UNICODE_WINDOWS_SONG + float windows_song[][2] = UNICODE_WINDOWS_SONG; + #endif + #ifdef UNICODE_WIN_COMPOSE_SONG + float win_compose_song[][2] = UNICODE_WIN_COMPOSE_SONG; + #endif + #ifdef UNICODE_OSX_SONG + float osx_song[][2] = UNICODE_OSX_SONG; + #endif + #ifdef UNICODE_OSX_RALT_SONG + float osx_ralt_song[][2] = UNICODE_OSX_RALT_SONG; + #endif +#endif void set_unicode_input_mode(uint8_t os_target) { @@ -138,18 +155,33 @@ bool process_record_unicode_common(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case UNI_OSX: set_unicode_input_mode(UC_OSX); + #if defined(AUDIO_ENABLE) && defined(UNICODE_OSX_SONG) + PLAY_SONG(UNICODE_OSX_SONG); + #endif break; case UNI_LINUX: set_unicode_input_mode(UC_LNX); + #if defined(AUDIO_ENABLE) && defined(UNICODE_LINUX_SONG) + PLAY_SONG(UNICODE_LINUX_SONG); + #endif break; case UNI_WIN: set_unicode_input_mode(UC_WIN); + #if defined(AUDIO_ENABLE) && defined(UNICODE_WINDOWS_SONG) + PLAY_SONG(UNICODE_WINDOWS_SONG); + #endif break; case UNI_WINC: set_unicode_input_mode(UC_WINC); + #if defined(AUDIO_ENABLE) && defined(UNICODE_WIN_COMPOSE_SONG) + PLAY_SONG(UNICODE_WIN_COMPOSE_SONG); + #endif break; case UNI_OSX_RALT: set_unicode_input_mode(UC_OSX_RALT); + #if defined(AUDIO_ENABLE) && defined(UNICODE_OSX_RALT_SONG) + PLAY_SONG(UNICODE_OSX_RALT_SONG); + #endif break; } } From be2c6e70a7b4b0520dcbce6370de0906fc06f08f Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 09:35:45 -0700 Subject: [PATCH 06/38] Tap_code cleanup --- .../process_keycode/process_unicode_common.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index b69439d7f7..254f1a231c 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -68,21 +68,17 @@ void unicode_input_start(void) { case UC_LNX: register_code(KC_LCTL); register_code(KC_LSFT); - register_code(KC_U); - unregister_code(KC_U); + tap_code(KC_U); unregister_code(KC_LSFT); unregister_code(KC_LCTL); break; case UC_WIN: register_code(KC_LALT); - register_code(KC_PPLS); - unregister_code(KC_PPLS); + tap_code(KC_PPLS); break; case UC_WINC: - register_code(KC_RALT); - unregister_code(KC_RALT); - register_code(KC_U); - unregister_code(KC_U); + tap_code(KC_RALT); + tap_code(KC_U); } wait_ms(UNICODE_TYPE_DELAY); } @@ -98,8 +94,7 @@ void unicode_input_finish (void) { unregister_code(KC_RALT); break; case UC_LNX: - register_code(KC_SPC); - unregister_code(KC_SPC); + tap_code(KC_SPC); break; } @@ -120,8 +115,7 @@ uint16_t hex_to_keycode(uint8_t hex) { void register_hex(uint16_t hex) { for(int i = 3; i >= 0; i--) { uint8_t digit = ((hex >> (i*4)) & 0xF); - register_code(hex_to_keycode(digit)); - unregister_code(hex_to_keycode(digit)); + tap_code(hex_to_keycode(digit)); } } From 5015c2b4d231bb5ba1bc91298eacf647e1d7390d Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 10:09:45 -0700 Subject: [PATCH 07/38] Update keycodes --- .../process_keycode/process_unicode_common.c | 10 +++++----- quantum/quantum_keycodes.h | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 254f1a231c..a2fe688a30 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -147,31 +147,31 @@ void send_unicode_hex_string(const char *str) { bool process_record_unicode_common(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { switch (keycode) { - case UNI_OSX: + case UNICODE_MODE_OSX: set_unicode_input_mode(UC_OSX); #if defined(AUDIO_ENABLE) && defined(UNICODE_OSX_SONG) PLAY_SONG(UNICODE_OSX_SONG); #endif break; - case UNI_LINUX: + case UNICODE_MODE_LINUX: set_unicode_input_mode(UC_LNX); #if defined(AUDIO_ENABLE) && defined(UNICODE_LINUX_SONG) PLAY_SONG(UNICODE_LINUX_SONG); #endif break; - case UNI_WIN: + case UNICODE_MODE_WINDOWS: set_unicode_input_mode(UC_WIN); #if defined(AUDIO_ENABLE) && defined(UNICODE_WINDOWS_SONG) PLAY_SONG(UNICODE_WINDOWS_SONG); #endif break; - case UNI_WINC: + case UNICODE_MODE_WIN_COMPOSE: set_unicode_input_mode(UC_WINC); #if defined(AUDIO_ENABLE) && defined(UNICODE_WIN_COMPOSE_SONG) PLAY_SONG(UNICODE_WIN_COMPOSE_SONG); #endif break; - case UNI_OSX_RALT: + case UNICODE_MODE_OSX_RALT: set_unicode_input_mode(UC_OSX_RALT); #if defined(AUDIO_ENABLE) && defined(UNICODE_OSX_RALT_SONG) PLAY_SONG(UNICODE_OSX_RALT_SONG); diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 6a3a6461bd..394b47b2ca 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -453,11 +453,12 @@ enum quantum_keycodes { TERM_ON, TERM_OFF, #endif - UNI_OSX, - UNI_LINUX, - UNI_WIN, - UNI_WINC, - UNI_OSX_RALT, + UNICODE_MODE_OSX, + UNICODE_MODE_LINUX, + UNICODE_MODE_WINDOWS, + UNICODE_MODE_WIN_COMPOSE, + UNICODE_MODE_OSX_RALT, + // always leave at the end SAFE_RANGE }; @@ -685,6 +686,12 @@ enum quantum_keycodes { #define X(n) (QK_UNICODE_MAP | (n)) #endif +#define UC_M_OS UNICODE_MODE_OSX +#define UC_M_LN UNICODE_MODE_LINUX +#define UC_M_WI UNICODE_MODE_WINDOWS +#define UC_M_WC UNICODE_MODE_WINCOMPOSE +#define UC_M_OR UNICODE_MODE_OSX_RALT + #ifdef SWAP_HANDS_ENABLE #define SH_T(kc) (QK_SWAP_HANDS | (kc)) #define SH_TG (QK_SWAP_HANDS | OP_SH_TOGGLE) From 8087acdec1542ad36819b68a13f4910569cf9234 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 10:34:11 -0700 Subject: [PATCH 08/38] Update unicode documentation --- docs/feature_unicode.md | 71 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/docs/feature_unicode.md b/docs/feature_unicode.md index b1527b848a..0b17b349c3 100644 --- a/docs/feature_unicode.md +++ b/docs/feature_unicode.md @@ -80,7 +80,17 @@ void qk_ucis_symbol_fallback (void) { // falls back to manual unicode entry Unicode input in QMK works by inputting a sequence of characters to the OS, sort of like macro. Unfortunately, each OS has different ideas on how Unicode is input. -This is the current list of Unicode input method in QMK: +You can set the input method at any time. You can do this by using a keycode here. The Input method is listed next to the keycode for reference. + +|Key |Aliases |Input Method |Description | +|--------------------------|---------|--------------|---------------------------------------------------| +|`UNICODE_MODE_OSX` |`UC_M_OS`|`UC_OSX` |Sets the input method for MacOS X | +|`UNICODE_MODE_LNX` |`UC_M_LN`|`UC_LNX` |Sets the input method for Linux | +|`UNICODE_MODE_WIN` |`UC_M_WI`|`UC_WIN` |Sets the input method for Windows | +|`UNICODE_MODE_WINC` |`UC_M_WC`|`UC_WINC` |Sets the input method for Windows using WinCompose | +|`UNICODE_MODE_OSX_RALT` |`UC_M_OR`|`UC_OSX_RALT` |Sets the input method for MacOS X using RAlt/AltGr | + +You can also set the input method via `set_unicode_input_mode(x)`, and this functions the same way as the keycodes above. * __UC_OSX__: MacOS Unicode Hex Input support. Works only up to 0xFFFF. Disabled by default. To enable: go to System Preferences -> Keyboard -> Input Sources, and enable Unicode Hex. * __UC_OSX_RALT__: Same as UC_OSX, but sends the Right Alt key for unicode input @@ -88,7 +98,64 @@ This is the current list of Unicode input method in QMK: * __UC_WIN__: (not recommended) Windows built-in Unicode input. To enable: create registry key under `HKEY_CURRENT_USER\Control Panel\Input Method\EnableHexNumpad` of type `REG_SZ` called `EnableHexNumpad`, set its value to 1, and reboot. This method is not recommended because of reliability and compatibility issue, use WinCompose method below instead. * __UC_WINC__: Windows Unicode input using WinCompose. Requires [WinCompose](https://github.com/samhocevar/wincompose). Works reliably under many (all?) variations of Windows. -At some point, you need to call `set_unicode_input_mode(x)` to set the correct unicode method. This sets the method that is used to send the unicode, and stores it in EEPROM, so you only need to call this once. +?> Keep in mind that both methods write to EEPROM, and are loaded each time the keyboard starts. So you only need to hit this once. + +### Unicode Input Method Customization + +The "start" and "finish" functions for unicode method can be customized locally. A great use for this is to customize the input methods if you don't use the default keys. Or to add visual, or audio feedback when inputting unicode characters. + +* `void unicode_input_start(void)` - This is called to start the sequence to input unicode characters. It handles calling RAlt or whatever ever sequence you want. +* `void unicode_input_finish (void)` - This is called to cleanup things, such as releasing the RAlt key in some cases, or tapping a key to finish the sequence. + +The default functions are: + +```c +void unicode_input_start(void) { + saved_mods = get_mods(); // Save current mods + clear_mods(); // Unregister mods to start from a clean state + + switch(unicode_config.input_mode) { + case UC_OSX: + register_code(KC_LALT); + break; + case UC_OSX_RALT: + register_code(KC_RALT); + break; + case UC_LNX: + register_code(KC_LCTL); + register_code(KC_LSFT); + tap_code(KC_U); + unregister_code(KC_LSFT); + unregister_code(KC_LCTL); + break; + case UC_WIN: + register_code(KC_LALT); + tap_code(KC_PPLS); + break; + case UC_WINC: + tap_code(KC_RALT); + tap_code(KC_U); + } + wait_ms(UNICODE_TYPE_DELAY); +} + +void unicode_input_finish (void) { + switch(unicode_config.input_mode) { + case UC_OSX: + case UC_WIN: + unregister_code(KC_LALT); + break; + case UC_OSX_RALT: + unregister_code(KC_RALT); + break; + case UC_LNX: + tap_code(KC_SPC); + break; + } + + set_mods(saved_mods); // Reregister previously set mods +} +``` ## `send_unicode_hex_string` From 08bab8744452e9b3a513b33fa808eb9cddb91e28 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 10:35:48 -0700 Subject: [PATCH 09/38] Update unicode keycodes for consistency/easier merge --- quantum/process_keycode/process_unicode_common.c | 6 +++--- quantum/quantum_keycodes.h | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index a2fe688a30..4782c23baf 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -153,19 +153,19 @@ bool process_record_unicode_common(uint16_t keycode, keyrecord_t *record) { PLAY_SONG(UNICODE_OSX_SONG); #endif break; - case UNICODE_MODE_LINUX: + case UNICODE_MODE_LNX: set_unicode_input_mode(UC_LNX); #if defined(AUDIO_ENABLE) && defined(UNICODE_LINUX_SONG) PLAY_SONG(UNICODE_LINUX_SONG); #endif break; - case UNICODE_MODE_WINDOWS: + case UNICODE_MODE_WIN: set_unicode_input_mode(UC_WIN); #if defined(AUDIO_ENABLE) && defined(UNICODE_WINDOWS_SONG) PLAY_SONG(UNICODE_WINDOWS_SONG); #endif break; - case UNICODE_MODE_WIN_COMPOSE: + case UNICODE_MODE_WINC: set_unicode_input_mode(UC_WINC); #if defined(AUDIO_ENABLE) && defined(UNICODE_WIN_COMPOSE_SONG) PLAY_SONG(UNICODE_WIN_COMPOSE_SONG); diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 394b47b2ca..43b8bd60e7 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -454,9 +454,9 @@ enum quantum_keycodes { TERM_OFF, #endif UNICODE_MODE_OSX, - UNICODE_MODE_LINUX, - UNICODE_MODE_WINDOWS, - UNICODE_MODE_WIN_COMPOSE, + UNICODE_MODE_LNX, + UNICODE_MODE_WIN, + UNICODE_MODE_WINC, UNICODE_MODE_OSX_RALT, // always leave at the end @@ -687,9 +687,9 @@ enum quantum_keycodes { #endif #define UC_M_OS UNICODE_MODE_OSX -#define UC_M_LN UNICODE_MODE_LINUX -#define UC_M_WI UNICODE_MODE_WINDOWS -#define UC_M_WC UNICODE_MODE_WINCOMPOSE +#define UC_M_LN UNICODE_MODE_LNX +#define UC_M_WI UNICODE_MODE_WIN +#define UC_M_WC UNICODE_MODE_WINC #define UC_M_OR UNICODE_MODE_OSX_RALT #ifdef SWAP_HANDS_ENABLE From 1e3c0a96c441295b60f81d77667b48222abb3edc Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 10:44:09 -0700 Subject: [PATCH 10/38] Add Audio Feedback section --- docs/feature_unicode.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/feature_unicode.md b/docs/feature_unicode.md index 0b17b349c3..96c9a46f9f 100644 --- a/docs/feature_unicode.md +++ b/docs/feature_unicode.md @@ -100,6 +100,20 @@ You can also set the input method via `set_unicode_input_mode(x)`, and this func ?> Keep in mind that both methods write to EEPROM, and are loaded each time the keyboard starts. So you only need to hit this once. +### Audio Feedback for Input Mode keycodes + +If you have the [Audio feature](feature_audio.md) enabled on the board, you can set "songs" for them to play when pressed, so you have some audio feedback when switching modes. + +For instance, you can add these to your `config.h` file. + +```c +#define UNICODE_LINUX_SONG UNICODE_LINUX +#define UNICODE_WINDOWS_SONG UNICODE_WINDOWS +#define UNICODE_WIN_COMPOSE_SONG UNICODE_WINDOWS +#define UNICODE_OSX_SONG COIN_SOUND +#define UNICODE_OSX_RALT_SONGCOIN_SOUND +``` + ### Unicode Input Method Customization The "start" and "finish" functions for unicode method can be customized locally. A great use for this is to customize the input methods if you don't use the default keys. Or to add visual, or audio feedback when inputting unicode characters. From e7aee81aeaed6fc1e5951d6d18e4264941151281 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 12:43:43 -0700 Subject: [PATCH 11/38] Remove Functions from feature page And link to the file instead. Link to specific lines later on. --- docs/feature_unicode.md | 51 ++--------------------------------------- 1 file changed, 2 insertions(+), 49 deletions(-) diff --git a/docs/feature_unicode.md b/docs/feature_unicode.md index 96c9a46f9f..04aab2d767 100644 --- a/docs/feature_unicode.md +++ b/docs/feature_unicode.md @@ -118,58 +118,11 @@ For instance, you can add these to your `config.h` file. The "start" and "finish" functions for unicode method can be customized locally. A great use for this is to customize the input methods if you don't use the default keys. Or to add visual, or audio feedback when inputting unicode characters. -* `void unicode_input_start(void)` - This is called to start the sequence to input unicode characters. It handles calling RAlt or whatever ever sequence you want. +* `void unicode_input_start(void)` - This is called to start the sequence to input unicode characters. It handles calling RAlt or whatever ever sequence you want. * `void unicode_input_finish (void)` - This is called to cleanup things, such as releasing the RAlt key in some cases, or tapping a key to finish the sequence. -The default functions are: +You can find the default functions in [`process_unicode_common.c`](https://github.com/qmk/qmk_firmware/blob/master/quantum/process_keycode/process_unicode_common.c). -```c -void unicode_input_start(void) { - saved_mods = get_mods(); // Save current mods - clear_mods(); // Unregister mods to start from a clean state - - switch(unicode_config.input_mode) { - case UC_OSX: - register_code(KC_LALT); - break; - case UC_OSX_RALT: - register_code(KC_RALT); - break; - case UC_LNX: - register_code(KC_LCTL); - register_code(KC_LSFT); - tap_code(KC_U); - unregister_code(KC_LSFT); - unregister_code(KC_LCTL); - break; - case UC_WIN: - register_code(KC_LALT); - tap_code(KC_PPLS); - break; - case UC_WINC: - tap_code(KC_RALT); - tap_code(KC_U); - } - wait_ms(UNICODE_TYPE_DELAY); -} - -void unicode_input_finish (void) { - switch(unicode_config.input_mode) { - case UC_OSX: - case UC_WIN: - unregister_code(KC_LALT); - break; - case UC_OSX_RALT: - unregister_code(KC_RALT); - break; - case UC_LNX: - tap_code(KC_SPC); - break; - } - - set_mods(saved_mods); // Reregister previously set mods -} -``` ## `send_unicode_hex_string` From 44c238f8de6ccdfcc4672317538e1b3056896c68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Fri, 2 Nov 2018 12:45:06 -0700 Subject: [PATCH 12/38] Fix white spaces Co-Authored-By: drashna --- quantum/process_keycode/process_ucis.c | 1 - 1 file changed, 1 deletion(-) diff --git a/quantum/process_keycode/process_ucis.c b/quantum/process_keycode/process_ucis.c index 56544eca18..4efbe09540 100644 --- a/quantum/process_keycode/process_ucis.c +++ b/quantum/process_keycode/process_ucis.c @@ -93,7 +93,6 @@ void register_ucis(const char *hex) { } bool process_ucis (uint16_t keycode, keyrecord_t *record) { - if (!qk_ucis_state.in_progress) return true; From bf79667460c44c3fb8332c1ffc2ef969e086362c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Fri, 2 Nov 2018 12:45:19 -0700 Subject: [PATCH 13/38] Fix spacing Co-Authored-By: drashna --- quantum/process_keycode/process_unicode_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 4782c23baf..ed20efacac 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -50,7 +50,7 @@ uint8_t get_unicode_input_mode(void) { } void unicode_input_mode_init(void) { - unicode_config.raw = eeprom_read_byte(EECONFIG_UNICODEMODE); + unicode_config.raw = eeprom_read_byte(EECONFIG_UNICODEMODE); } __attribute__((weak)) From 122fbac89ca19707e1c3f568c28806c10a5fe034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Fri, 2 Nov 2018 12:45:48 -0700 Subject: [PATCH 14/38] Because I missed it! Co-Authored-By: drashna --- quantum/process_keycode/process_unicode_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index ed20efacac..950a45d44e 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -88,7 +88,7 @@ void unicode_input_finish (void) { switch(unicode_config.input_mode) { case UC_OSX: case UC_WIN: - unregister_code(KC_LALT); + unregister_code(KC_LALT); break; case UC_OSX_RALT: unregister_code(KC_RALT); From cfa4163d0664f90ef0b12116160e658eace6d407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Fri, 2 Nov 2018 12:46:04 -0700 Subject: [PATCH 15/38] Fix spacing Co-Authored-By: drashna --- quantum/process_keycode/process_unicode_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 950a45d44e..71673015e0 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -148,7 +148,7 @@ bool process_record_unicode_common(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { switch (keycode) { case UNICODE_MODE_OSX: - set_unicode_input_mode(UC_OSX); + set_unicode_input_mode(UC_OSX); #if defined(AUDIO_ENABLE) && defined(UNICODE_OSX_SONG) PLAY_SONG(UNICODE_OSX_SONG); #endif From 8d0954b811b835f44eb6d6c429c373d16f54e769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Fri, 2 Nov 2018 12:46:19 -0700 Subject: [PATCH 16/38] SPAAAAAAAAAACing Co-Authored-By: drashna --- quantum/process_keycode/process_unicode_common.h | 1 - 1 file changed, 1 deletion(-) diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index b1fc8c0ac8..6d3e080483 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -30,7 +30,6 @@ typedef union { }; } unicode_config_t; - void set_unicode_input_mode(uint8_t os_target); uint8_t get_unicode_input_mode(void); void unicode_input_mode_init(void); From 427a38fedfeedabe2a15eba52d35cf4dadbe0495 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Fri, 2 Nov 2018 12:46:40 -0700 Subject: [PATCH 17/38] white spaces Co-Authored-By: drashna --- quantum/quantum_keycodes.h | 1 + 1 file changed, 1 insertion(+) diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 43b8bd60e7..95e7b4ca99 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -453,6 +453,7 @@ enum quantum_keycodes { TERM_ON, TERM_OFF, #endif + UNICODE_MODE_OSX, UNICODE_MODE_LNX, UNICODE_MODE_WIN, From e5da49ca63a543503b8cad6034b42286aebf534f Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 12:47:48 -0700 Subject: [PATCH 18/38] Add BSD for future compatibility --- quantum/quantum_keycodes.h | 1 + 1 file changed, 1 insertion(+) diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 95e7b4ca99..4722fb07f7 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -456,6 +456,7 @@ enum quantum_keycodes { UNICODE_MODE_OSX, UNICODE_MODE_LNX, + UNICODE_MODE_BSD, UNICODE_MODE_WIN, UNICODE_MODE_WINC, UNICODE_MODE_OSX_RALT, From 4b2a0bc145c774bb94a0540983d9df1b6d16301b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Fri, 2 Nov 2018 12:48:01 -0700 Subject: [PATCH 19/38] Thought I fixed that! Co-Authored-By: drashna --- quantum/process_keycode/process_unicode_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 71673015e0..4609468fc2 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -84,7 +84,7 @@ void unicode_input_start(void) { } __attribute__((weak)) -void unicode_input_finish (void) { + void unicode_input_finish(void) { switch(unicode_config.input_mode) { case UC_OSX: case UC_WIN: From 95385670a3255adaa497d5d0e1736f728b6e4df8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Fri, 2 Nov 2018 12:48:28 -0700 Subject: [PATCH 20/38] non-breaking Co-Authored-By: drashna --- quantum/process_keycode/process_unicode_common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 4609468fc2..f27e77c52f 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -79,6 +79,7 @@ void unicode_input_start(void) { case UC_WINC: tap_code(KC_RALT); tap_code(KC_U); + break; } wait_ms(UNICODE_TYPE_DELAY); } From 68d1d5de1c875d2dc9444582abb4e2bcc87738e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Fri, 2 Nov 2018 12:48:43 -0700 Subject: [PATCH 21/38] Considered that Co-Authored-By: drashna --- docs/feature_unicode.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/feature_unicode.md b/docs/feature_unicode.md index 04aab2d767..bec76be1a0 100644 --- a/docs/feature_unicode.md +++ b/docs/feature_unicode.md @@ -107,7 +107,7 @@ If you have the [Audio feature](feature_audio.md) enabled on the board, you can For instance, you can add these to your `config.h` file. ```c -#define UNICODE_LINUX_SONG UNICODE_LINUX +#define UNICODE_SONG_LNX UNICODE_LINUX #define UNICODE_WINDOWS_SONG UNICODE_WINDOWS #define UNICODE_WIN_COMPOSE_SONG UNICODE_WINDOWS #define UNICODE_OSX_SONG COIN_SOUND From d4b881101373d5c9ceface9ab17fb0a7b3d23e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Fri, 2 Nov 2018 12:48:51 -0700 Subject: [PATCH 22/38] Yuuup Co-Authored-By: drashna --- quantum/process_keycode/process_unicode_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index f27e77c52f..7363a761f8 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -22,7 +22,7 @@ unicode_config_t unicode_config; static uint8_t saved_mods; #ifdef AUDIO_ENABLE - #ifdef UNICODE_LINUX_SONG + #ifdef UNICODE_SONG_LNX float linux_song[][2] = UNICODE_LINUX_SONG; #endif #ifdef UNICODE_WINDOWS_SONG From df4f58ef31265211469d5f395e04e52cd4a8d156 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Fri, 2 Nov 2018 12:49:00 -0700 Subject: [PATCH 23/38] consistency Co-Authored-By: drashna --- quantum/process_keycode/process_unicode_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 7363a761f8..0741ab0030 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -23,7 +23,7 @@ unicode_config_t unicode_config; static uint8_t saved_mods; #ifdef AUDIO_ENABLE #ifdef UNICODE_SONG_LNX - float linux_song[][2] = UNICODE_LINUX_SONG; + float song_lnx[][2] = UNICODE_SONG_LNX; #endif #ifdef UNICODE_WINDOWS_SONG float windows_song[][2] = UNICODE_WINDOWS_SONG; From eca3a411add38ffcb2835a817234b79d9f3d52fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Fri, 2 Nov 2018 12:49:27 -0700 Subject: [PATCH 24/38] white spaces .... copied from elsewhere Co-Authored-By: drashna --- quantum/process_keycode/process_unicode_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index 6d3e080483..8716b8bc56 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -26,7 +26,7 @@ typedef union { uint32_t raw; struct { - uint8_t input_mode :8; + uint8_t input_mode :8; }; } unicode_config_t; From eaa5efc6976fe80f7cf6c191d844da4b5517bad6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Fri, 2 Nov 2018 12:50:39 -0700 Subject: [PATCH 25/38] white spaces Co-Authored-By: drashna --- quantum/process_keycode/process_unicode_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 0741ab0030..1c8a723e2c 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -58,7 +58,7 @@ void unicode_input_start(void) { saved_mods = get_mods(); // Save current mods clear_mods(); // Unregister mods to start from a clean state - switch(unicode_config.input_mode) { + switch (unicode_config.input_mode) { case UC_OSX: register_code(KC_LALT); break; From 4860a8c6fc3a668f809133ea7e0ffd0c6c39bc7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Fri, 2 Nov 2018 12:50:51 -0700 Subject: [PATCH 26/38] white spaces Co-Authored-By: drashna --- quantum/process_keycode/process_unicode_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 1c8a723e2c..a329bf4514 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -86,7 +86,7 @@ void unicode_input_start(void) { __attribute__((weak)) void unicode_input_finish(void) { - switch(unicode_config.input_mode) { + switch (unicode_config.input_mode) { case UC_OSX: case UC_WIN: unregister_code(KC_LALT); From afad38786a0534c41142dc26d705dff5e7731466 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 12:52:04 -0700 Subject: [PATCH 27/38] Update keycode defines --- quantum/quantum_keycodes.h | 1 + 1 file changed, 1 insertion(+) diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 4722fb07f7..0ec29a4d2b 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -690,6 +690,7 @@ enum quantum_keycodes { #define UC_M_OS UNICODE_MODE_OSX #define UC_M_LN UNICODE_MODE_LNX +#define UC_M_BD UNICODE_MODE_BSD #define UC_M_WI UNICODE_MODE_WIN #define UC_M_WC UNICODE_MODE_WINC #define UC_M_OR UNICODE_MODE_OSX_RALT From 0d64e6548be80033d54cf1e034b523e9ac6bfc10 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 12:52:56 -0700 Subject: [PATCH 28/38] Fix Linux Song --- quantum/process_keycode/process_unicode_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index a329bf4514..f70d2b2f2f 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -157,7 +157,7 @@ bool process_record_unicode_common(uint16_t keycode, keyrecord_t *record) { case UNICODE_MODE_LNX: set_unicode_input_mode(UC_LNX); #if defined(AUDIO_ENABLE) && defined(UNICODE_LINUX_SONG) - PLAY_SONG(UNICODE_LINUX_SONG); + PLAY_SONG(song_lnx); #endif break; case UNICODE_MODE_WIN: From 6840d80855087cc7d75775fabf2ee124efb2520a Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 12:57:04 -0700 Subject: [PATCH 29/38] Update all of the songs --- .../process_keycode/process_unicode_common.c | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index f70d2b2f2f..0f79e42c48 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -22,20 +22,23 @@ unicode_config_t unicode_config; static uint8_t saved_mods; #ifdef AUDIO_ENABLE + #ifdef UNICODE_SONG_OSX + float osx_song[][2] = UNICODE_SONG_OSX; + #endif #ifdef UNICODE_SONG_LNX float song_lnx[][2] = UNICODE_SONG_LNX; #endif - #ifdef UNICODE_WINDOWS_SONG - float windows_song[][2] = UNICODE_WINDOWS_SONG; + #ifdef UNICODE_SONG_BSD + float song_bsd[][2] = UNICODE_SONG_BSD; #endif - #ifdef UNICODE_WIN_COMPOSE_SONG - float win_compose_song[][2] = UNICODE_WIN_COMPOSE_SONG; + #ifdef UNICODE_SONG_WINDOWS + float windows_song[][2] = UNICODE_SONG_WINDOWS; #endif - #ifdef UNICODE_OSX_SONG - float osx_song[][2] = UNICODE_OSX_SONG; + #ifdef UNICODE_SONG_WIN_COMPOSE + float win_compose_song[][2] = UNICODE_SONG_WIN_COMPOSE; #endif - #ifdef UNICODE_OSX_RALT_SONG - float osx_ralt_song[][2] = UNICODE_OSX_RALT_SONG; + #ifdef UNICODE_SONG_OSX_RALT + float osx_ralt_song[][2] = UNICODE_SONG_OSX_RALT; #endif #endif @@ -150,32 +153,38 @@ bool process_record_unicode_common(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case UNICODE_MODE_OSX: set_unicode_input_mode(UC_OSX); - #if defined(AUDIO_ENABLE) && defined(UNICODE_OSX_SONG) - PLAY_SONG(UNICODE_OSX_SONG); + #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_OSX) + PLAY_SONG(osx_song); #endif break; case UNICODE_MODE_LNX: set_unicode_input_mode(UC_LNX); - #if defined(AUDIO_ENABLE) && defined(UNICODE_LINUX_SONG) + #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_LNX) PLAY_SONG(song_lnx); #endif break; + case UNICODE_MODE_BSD: + set_unicode_input_mode(UC_BSD); + #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_BSD) + PLAY_SONG(song_bsd); + #endif + break; case UNICODE_MODE_WIN: set_unicode_input_mode(UC_WIN); - #if defined(AUDIO_ENABLE) && defined(UNICODE_WINDOWS_SONG) - PLAY_SONG(UNICODE_WINDOWS_SONG); + #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WINDOWS) + PLAY_SONG(windows_song); #endif break; case UNICODE_MODE_WINC: set_unicode_input_mode(UC_WINC); - #if defined(AUDIO_ENABLE) && defined(UNICODE_WIN_COMPOSE_SONG) - PLAY_SONG(UNICODE_WIN_COMPOSE_SONG); + #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WIN_COMPOSE) + PLAY_SONG(win_compose_song); #endif break; case UNICODE_MODE_OSX_RALT: set_unicode_input_mode(UC_OSX_RALT); - #if defined(AUDIO_ENABLE) && defined(UNICODE_OSX_RALT_SONG) - PLAY_SONG(UNICODE_OSX_RALT_SONG); + #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_OSX_RALT) + PLAY_SONG(osx_ralt_song); #endif break; } From 0b403a4c4cb75c3355a0b7c4c9e6e7974a0e123a Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 13:29:23 -0700 Subject: [PATCH 30/38] Cleanup --- quantum/process_keycode/process_ucis.h | 5 +---- quantum/process_keycode/process_unicode.h | 5 +---- quantum/process_keycode/process_unicode_common.c | 2 +- quantum/process_keycode/process_unicode_common.h | 7 +++---- quantum/process_keycode/process_unicodemap.h | 4 +--- 5 files changed, 7 insertions(+), 16 deletions(-) diff --git a/quantum/process_keycode/process_ucis.h b/quantum/process_keycode/process_ucis.h index d4aa34cde7..b114d839ab 100644 --- a/quantum/process_keycode/process_ucis.h +++ b/quantum/process_keycode/process_ucis.h @@ -14,8 +14,7 @@ * along with this program. If not, see . */ -#ifndef PROCESS_UCIS_H -#define PROCESS_UCIS_H +#pragma once #include "quantum.h" #include "process_unicode_common.h" @@ -48,5 +47,3 @@ void qk_ucis_symbol_fallback (void); void qk_ucis_success(uint8_t symbol_index); void register_ucis(const char *hex); bool process_ucis (uint16_t keycode, keyrecord_t *record); - -#endif diff --git a/quantum/process_keycode/process_unicode.h b/quantum/process_keycode/process_unicode.h index c525b74f03..0913e99107 100644 --- a/quantum/process_keycode/process_unicode.h +++ b/quantum/process_keycode/process_unicode.h @@ -13,12 +13,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifndef PROCESS_UNICODE_H -#define PROCESS_UNICODE_H +#pragma once #include "quantum.h" #include "process_unicode_common.h" bool process_unicode(uint16_t keycode, keyrecord_t *record); - -#endif diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 0f79e42c48..1adf70eaa0 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -88,7 +88,7 @@ void unicode_input_start(void) { } __attribute__((weak)) - void unicode_input_finish(void) { +void unicode_input_finish(void) { switch (unicode_config.input_mode) { case UC_OSX: case UC_WIN: diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index 8716b8bc56..54f867a499 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -14,8 +14,7 @@ * along with this program. If not, see . */ -#ifndef PROCESS_UNICODE_COMMON_H -#define PROCESS_UNICODE_COMMON_H +#pragma once #include "quantum.h" @@ -30,6 +29,8 @@ typedef union { }; } unicode_config_t; +extern unicode_config_t unicode_config; + void set_unicode_input_mode(uint8_t os_target); uint8_t get_unicode_input_mode(void); void unicode_input_mode_init(void); @@ -152,5 +153,3 @@ bool process_record_unicode_common(uint16_t keycode, keyrecord_t *record); #define UC_RCBR UC(0x007D) #define UC_TILD UC(0x007E) #define UC_DEL UC(0x007F) - -#endif diff --git a/quantum/process_keycode/process_unicodemap.h b/quantum/process_keycode/process_unicodemap.h index 929c88c0b6..f6d64bb86b 100644 --- a/quantum/process_keycode/process_unicodemap.h +++ b/quantum/process_keycode/process_unicodemap.h @@ -14,12 +14,10 @@ * along with this program. If not, see . */ -#ifndef PROCESS_UNICODEMAP_H -#define PROCESS_UNICODEMAP_H +#pragma once #include "quantum.h" #include "process_unicode_common.h" void unicode_map_input_error(void); bool process_unicode_map(uint16_t keycode, keyrecord_t *record); -#endif From c0cd867155338fb2754ab219a4a964102b5c3b49 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 13:39:07 -0700 Subject: [PATCH 31/38] Move and update check to ensure only one unicode method is enabled --- quantum/process_keycode/process_unicode_common.h | 4 ++++ quantum/quantum_keycodes.h | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index 54f867a499..8a1f809eb7 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -18,6 +18,10 @@ #include "quantum.h" +#if defined(UNICODE_ENABLE) + defined(UNICODEMAP_ENABLE) + defined(UCIS_ENABLE) > 1 + #error "Cannot enable more than one unicode method (UNICODE, UNICODEMAP, UCIS) at the same time" +#endif + #ifndef UNICODE_TYPE_DELAY #define UNICODE_TYPE_DELAY 10 #endif diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 0ec29a4d2b..51fb1b06e4 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -81,9 +81,6 @@ enum quantum_keycodes { #endif QK_MOD_TAP = 0x6000, QK_MOD_TAP_MAX = 0x7FFF, -#if defined(UNICODEMAP_ENABLE) && defined(UNICODE_ENABLE) - #error "Cannot enable both UNICODEMAP && UNICODE" -#endif #ifdef UNICODE_ENABLE QK_UNICODE = 0x8000, QK_UNICODE_MAX = 0xFFFF, From b053a75600aa992433409ba7644a00df4a84470b Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 13:41:48 -0700 Subject: [PATCH 32/38] Update quantum/quantum_keycodes.h --- quantum/quantum_keycodes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 51fb1b06e4..58e11a8466 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -687,7 +687,7 @@ enum quantum_keycodes { #define UC_M_OS UNICODE_MODE_OSX #define UC_M_LN UNICODE_MODE_LNX -#define UC_M_BD UNICODE_MODE_BSD +#define UC_M_BS UNICODE_MODE_BSD #define UC_M_WI UNICODE_MODE_WIN #define UC_M_WC UNICODE_MODE_WINC #define UC_M_OR UNICODE_MODE_OSX_RALT From 455c143b32d871d6560335d91ccc5d7c7249e7ee Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 13:44:53 -0700 Subject: [PATCH 33/38] Update documentation --- docs/feature_unicode.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/feature_unicode.md b/docs/feature_unicode.md index bec76be1a0..cbf5633302 100644 --- a/docs/feature_unicode.md +++ b/docs/feature_unicode.md @@ -100,6 +100,8 @@ You can also set the input method via `set_unicode_input_mode(x)`, and this func ?> Keep in mind that both methods write to EEPROM, and are loaded each time the keyboard starts. So you only need to hit this once. +!> There are options for BSD, but it is not actually supported at this time. If you use BSD and want support for this, please [open an issue on GitHub](https://github.com/qmk/qmk_firmware/issues) + ### Audio Feedback for Input Mode keycodes If you have the [Audio feature](feature_audio.md) enabled on the board, you can set "songs" for them to play when pressed, so you have some audio feedback when switching modes. @@ -107,11 +109,11 @@ If you have the [Audio feature](feature_audio.md) enabled on the board, you can For instance, you can add these to your `config.h` file. ```c +#define UNICODE_SONG_OSX COIN_SOUND #define UNICODE_SONG_LNX UNICODE_LINUX -#define UNICODE_WINDOWS_SONG UNICODE_WINDOWS -#define UNICODE_WIN_COMPOSE_SONG UNICODE_WINDOWS -#define UNICODE_OSX_SONG COIN_SOUND -#define UNICODE_OSX_RALT_SONGCOIN_SOUND +#define UNICODE_SONG_WINDOWS UNICODE_WINDOWS +#define UNICODE_SONG_WIN_COMPOSE UNICODE_WINDOWS +#define UNICODE_SONG_OSX_RALT COIN_SOUND ``` ### Unicode Input Method Customization From 7b729ede72c838d09b4469b181a369d90976617c Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Sat, 3 Nov 2018 09:22:46 -0700 Subject: [PATCH 34/38] Wordsmithing and cleanup --- docs/feature_unicode.md | 58 ++++++++++--------- .../process_keycode/process_unicode_common.c | 30 +++++----- .../process_keycode/process_unicode_common.h | 2 +- quantum/quantum.c | 2 +- quantum/quantum_keycodes.h | 4 +- 5 files changed, 52 insertions(+), 44 deletions(-) diff --git a/docs/feature_unicode.md b/docs/feature_unicode.md index cbf5633302..0ccd545880 100644 --- a/docs/feature_unicode.md +++ b/docs/feature_unicode.md @@ -13,16 +13,16 @@ Supports Unicode up to 0xFFFFFFFF. You need to maintain a separate mapping table And you may want to have an enum to make reference easier. So you'd want to add something like this to your keymap: ```c -enum unicode_name { +enum unicode_names { BANG, // ‽ IRONY, // ⸮ SNEK // snke 🐍 }; const uint32_t PROGMEM unicode_map[] = { - [BANG] = 0x0203D, // ‽ - [IRONY] = 0x02E2E, // ⸮ - [SNEK] = 0x1F40D // snke 🐍 + [BANG] = 0x0203D, // ‽ + [IRONY] = 0x02E2E, // ⸮ + [SNEK] = 0x1F40D // snke 🐍 }: ``` @@ -75,44 +75,50 @@ void qk_ucis_symbol_fallback (void) { // falls back to manual unicode entry } ``` -## Unicode Input methods +## Input Modes -Unicode input in QMK works by inputting a sequence of characters to the OS, -sort of like macro. Unfortunately, each OS has different ideas on how Unicode is input. +Unicode input in QMK works by inputting a sequence of characters to the OS, sort of like a macro. Unfortunately, each OS has different ideas on how Unicode is input. Specifically, each OS has one (or more) key sequences that it requires to input unicode characters. -You can set the input method at any time. You can do this by using a keycode here. The Input method is listed next to the keycode for reference. +There are two ways to set the input mode for Unicode, by keycode or by function. + +Keep in mind that both methods write to persistant storage (EEPROM), and are loaded each time the keyboard starts. So once you've set it once, you do not need to set it again unless you need to change it or you've reset the EEPROM settings. + +!> There are options for BSD here, but it is not implemented at this time. If you use BSD and want to help in adding support for this, please [open an issue on GitHub](https://github.com/qmk/qmk_firmware/issues) -|Key |Aliases |Input Method |Description | -|--------------------------|---------|--------------|---------------------------------------------------| -|`UNICODE_MODE_OSX` |`UC_M_OS`|`UC_OSX` |Sets the input method for MacOS X | -|`UNICODE_MODE_LNX` |`UC_M_LN`|`UC_LNX` |Sets the input method for Linux | -|`UNICODE_MODE_WIN` |`UC_M_WI`|`UC_WIN` |Sets the input method for Windows | -|`UNICODE_MODE_WINC` |`UC_M_WC`|`UC_WINC` |Sets the input method for Windows using WinCompose | -|`UNICODE_MODE_OSX_RALT` |`UC_M_OR`|`UC_OSX_RALT` |Sets the input method for MacOS X using RAlt/AltGr | -You can also set the input method via `set_unicode_input_mode(x)`, and this functions the same way as the keycodes above. +### Functions + +You can also switch the input mode by calling `set_unicode_input_mode(x)` in your code, and this works the same way as the keycodes below. * __UC_OSX__: MacOS Unicode Hex Input support. Works only up to 0xFFFF. Disabled by default. To enable: go to System Preferences -> Keyboard -> Input Sources, and enable Unicode Hex. * __UC_OSX_RALT__: Same as UC_OSX, but sends the Right Alt key for unicode input * __UC_LNX__: Unicode input method under Linux. Works up to 0xFFFFF. Should work almost anywhere on ibus enabled distros. Without ibus, this works under GTK apps, but rarely anywhere else. +* __UC_BSD__: (non operational) Unicode input method under BSD. * __UC_WIN__: (not recommended) Windows built-in Unicode input. To enable: create registry key under `HKEY_CURRENT_USER\Control Panel\Input Method\EnableHexNumpad` of type `REG_SZ` called `EnableHexNumpad`, set its value to 1, and reboot. This method is not recommended because of reliability and compatibility issue, use WinCompose method below instead. * __UC_WINC__: Windows Unicode input using WinCompose. Requires [WinCompose](https://github.com/samhocevar/wincompose). Works reliably under many (all?) variations of Windows. -?> Keep in mind that both methods write to EEPROM, and are loaded each time the keyboard starts. So you only need to hit this once. - -!> There are options for BSD, but it is not actually supported at this time. If you use BSD and want support for this, please [open an issue on GitHub](https://github.com/qmk/qmk_firmware/issues) +### Keycodes +|Key |Aliases |Input Method |Description | +|--------------------------|---------|--------------|---------------------------------------------------| +|`UNICODE_MODE_OSX` |`UC_M_OS`|`UC_OSX` |Sets the input method for MacOS X | +|`UNICODE_MODE_LNX` |`UC_M_LN`|`UC_LNX` |Sets the input method for Linux | +|`UNICODE_MODE_BSD` |`UC_M_BS`|`UC_BSD` |Sets the input method for BSD (Non-Operational) | +|`UNICODE_MODE_WIN` |`UC_M_WI`|`UC_WIN` |Sets the input method for Windows | +|`UNICODE_MODE_WINC` |`UC_M_WC`|`UC_WINC` |Sets the input method for Windows using WinCompose | +|`UNICODE_MODE_OSX_RALT` |`UC_M_OR`|`UC_OSX_RALT` |Sets the input method for MacOS X using RAlt/AltGr | ### Audio Feedback for Input Mode keycodes -If you have the [Audio feature](feature_audio.md) enabled on the board, you can set "songs" for them to play when pressed, so you have some audio feedback when switching modes. +If you have the [Audio feature](feature_audio.md) enabled on the board, you can set melodies to be played when you press the above keys. That way you can have some audio feedback when switching input modes. For instance, you can add these to your `config.h` file. ```c -#define UNICODE_SONG_OSX COIN_SOUND +#define UNICODE_SONG_OSX COIN_SOUND #define UNICODE_SONG_LNX UNICODE_LINUX -#define UNICODE_SONG_WINDOWS UNICODE_WINDOWS -#define UNICODE_SONG_WIN_COMPOSE UNICODE_WINDOWS +#define UNICODE_SONG_BSD MARIO_GAMEOVER +#define UNICODE_SONG_WIN UNICODE_WINDOWS +#define UNICODE_SONG_WINC UNICODE_WINDOWS #define UNICODE_SONG_OSX_RALT COIN_SOUND ``` @@ -120,10 +126,10 @@ For instance, you can add these to your `config.h` file. The "start" and "finish" functions for unicode method can be customized locally. A great use for this is to customize the input methods if you don't use the default keys. Or to add visual, or audio feedback when inputting unicode characters. -* `void unicode_input_start(void)` - This is called to start the sequence to input unicode characters. It handles calling RAlt or whatever ever sequence you want. -* `void unicode_input_finish (void)` - This is called to cleanup things, such as releasing the RAlt key in some cases, or tapping a key to finish the sequence. +* `void unicode_input_start(void)` - This sends the initial sequence that tells your platform to enter Unicode input mode. For example, it presses Ctrl+Shift+U on Linux and holds the Option key on Mac. +* `void unicode_input_finish (void)` - his is called to exit Unicode input mode, for example by pressing Space or releasing the Option key. -You can find the default functions in [`process_unicode_common.c`](https://github.com/qmk/qmk_firmware/blob/master/quantum/process_keycode/process_unicode_common.c). +You can find the default implementations of these functions in [`process_unicode_common.c`](https://github.com/qmk/qmk_firmware/blob/master/quantum/process_keycode/process_unicode_common.c). ## `send_unicode_hex_string` diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 1adf70eaa0..65afc37859 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -28,14 +28,14 @@ static uint8_t saved_mods; #ifdef UNICODE_SONG_LNX float song_lnx[][2] = UNICODE_SONG_LNX; #endif + #ifdef UNICODE_SONG_WIN + float windows_song[][2] = UNICODE_SONG_WIN; + #endif #ifdef UNICODE_SONG_BSD float song_bsd[][2] = UNICODE_SONG_BSD; #endif - #ifdef UNICODE_SONG_WINDOWS - float windows_song[][2] = UNICODE_SONG_WINDOWS; - #endif - #ifdef UNICODE_SONG_WIN_COMPOSE - float win_compose_song[][2] = UNICODE_SONG_WIN_COMPOSE; + #ifdef UNICODE_SONG_WINC + float win_compose_song[][2] = UNICODE_SONG_WINC; #endif #ifdef UNICODE_SONG_OSX_RALT float osx_ralt_song[][2] = UNICODE_SONG_OSX_RALT; @@ -75,6 +75,8 @@ void unicode_input_start(void) { unregister_code(KC_LSFT); unregister_code(KC_LCTL); break; + case UC_BSD: + break; case UC_WIN: register_code(KC_LALT); tap_code(KC_PPLS); @@ -92,7 +94,7 @@ void unicode_input_finish(void) { switch (unicode_config.input_mode) { case UC_OSX: case UC_WIN: - unregister_code(KC_LALT); + unregister_code(KC_LALT); break; case UC_OSX_RALT: unregister_code(KC_RALT); @@ -148,7 +150,7 @@ void send_unicode_hex_string(const char *str) { } } -bool process_record_unicode_common(uint16_t keycode, keyrecord_t *record) { +bool process_unicode_common(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { switch (keycode) { case UNICODE_MODE_OSX: @@ -163,21 +165,21 @@ bool process_record_unicode_common(uint16_t keycode, keyrecord_t *record) { PLAY_SONG(song_lnx); #endif break; + case UNICODE_MODE_WIN: + set_unicode_input_mode(UC_WIN); + #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WIN) + PLAY_SONG(windows_song); + #endif + break; case UNICODE_MODE_BSD: set_unicode_input_mode(UC_BSD); #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_BSD) PLAY_SONG(song_bsd); #endif break; - case UNICODE_MODE_WIN: - set_unicode_input_mode(UC_WIN); - #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WINDOWS) - PLAY_SONG(windows_song); - #endif - break; case UNICODE_MODE_WINC: set_unicode_input_mode(UC_WINC); - #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WIN_COMPOSE) + #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WINC) PLAY_SONG(win_compose_song); #endif break; diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index 8a1f809eb7..1beeda467e 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -42,7 +42,7 @@ void unicode_input_start(void); void unicode_input_finish(void); void register_hex(uint16_t hex); void send_unicode_hex_string(const char *str); -bool process_record_unicode_common(uint16_t keycode, keyrecord_t *record); +bool process_unicode_common(uint16_t keycode, keyrecord_t *record); #define UC_OSX 0 // Mac OS X #define UC_LNX 1 // Linux diff --git a/quantum/quantum.c b/quantum/quantum.c index 4267c1e036..3ff361eabf 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -257,7 +257,7 @@ bool process_record_quantum(keyrecord_t *record) { process_tap_dance(keycode, record) && #endif #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) - process_record_unicode_common(keycode, record) && + process_unicode_common(keycode, record) && #endif #ifdef LEADER_ENABLE process_leader(keycode, record) && diff --git a/quantum/quantum_keycodes.h b/quantum/quantum_keycodes.h index 58e11a8466..b428eabbec 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -453,8 +453,8 @@ enum quantum_keycodes { UNICODE_MODE_OSX, UNICODE_MODE_LNX, - UNICODE_MODE_BSD, UNICODE_MODE_WIN, + UNICODE_MODE_BSD, UNICODE_MODE_WINC, UNICODE_MODE_OSX_RALT, @@ -687,8 +687,8 @@ enum quantum_keycodes { #define UC_M_OS UNICODE_MODE_OSX #define UC_M_LN UNICODE_MODE_LNX -#define UC_M_BS UNICODE_MODE_BSD #define UC_M_WI UNICODE_MODE_WIN +#define UC_M_BS UNICODE_MODE_BSD #define UC_M_WC UNICODE_MODE_WINC #define UC_M_OR UNICODE_MODE_OSX_RALT From 919c90eab3165ede8e6ab64cb49ba8d2a1731ca7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Sat, 3 Nov 2018 18:24:24 +0100 Subject: [PATCH 35/38] Format unicode_common (#13) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- docs/feature_unicode.md | 67 +++++---- .../process_keycode/process_unicode_common.c | 134 ++++++++---------- .../process_keycode/process_unicode_common.h | 4 +- quantum/quantum.c | 6 +- 4 files changed, 97 insertions(+), 114 deletions(-) diff --git a/docs/feature_unicode.md b/docs/feature_unicode.md index 0ccd545880..653e84822f 100644 --- a/docs/feature_unicode.md +++ b/docs/feature_unicode.md @@ -1,6 +1,6 @@ # Unicode Support -There are three Unicode keymap definition method available in QMK: +There are three Unicode keymap definition methods available in QMK: ## UNICODE_ENABLE @@ -14,15 +14,15 @@ And you may want to have an enum to make reference easier. So you'd want to add ```c enum unicode_names { - BANG, // ‽ - IRONY, // ⸮ - SNEK // snke 🐍 + BANG, + IRONY, + SNEK, }; const uint32_t PROGMEM unicode_map[] = { - [BANG] = 0x0203D, // ‽ - [IRONY] = 0x02E2E, // ⸮ - [SNEK] = 0x1F40D // snke 🐍 + [BANG] = 0x203D, // ‽ + [IRONY] = 0x2E2E, // ⸮ + [SNEK] = 0x1F40D, // 🐍 }: ``` @@ -77,18 +77,9 @@ void qk_ucis_symbol_fallback (void) { // falls back to manual unicode entry ## Input Modes -Unicode input in QMK works by inputting a sequence of characters to the OS, sort of like a macro. Unfortunately, each OS has different ideas on how Unicode is input. Specifically, each OS has one (or more) key sequences that it requires to input unicode characters. +Unicode input in QMK works by inputting a sequence of characters to the OS, sort of like a macro. Unfortunately, the way this is done differs for each platform. Specifically, each platform requires a different combination of keys to trigger Unicode input. Therefore, a corresponding input mode has to be set in QMK. -There are two ways to set the input mode for Unicode, by keycode or by function. - -Keep in mind that both methods write to persistant storage (EEPROM), and are loaded each time the keyboard starts. So once you've set it once, you do not need to set it again unless you need to change it or you've reset the EEPROM settings. - -!> There are options for BSD here, but it is not implemented at this time. If you use BSD and want to help in adding support for this, please [open an issue on GitHub](https://github.com/qmk/qmk_firmware/issues) - - -### Functions - -You can also switch the input mode by calling `set_unicode_input_mode(x)` in your code, and this works the same way as the keycodes below. +The following input modes are available: * __UC_OSX__: MacOS Unicode Hex Input support. Works only up to 0xFFFF. Disabled by default. To enable: go to System Preferences -> Keyboard -> Input Sources, and enable Unicode Hex. * __UC_OSX_RALT__: Same as UC_OSX, but sends the Right Alt key for unicode input @@ -97,21 +88,30 @@ You can also switch the input mode by calling `set_unicode_input_mode(x)` in you * __UC_WIN__: (not recommended) Windows built-in Unicode input. To enable: create registry key under `HKEY_CURRENT_USER\Control Panel\Input Method\EnableHexNumpad` of type `REG_SZ` called `EnableHexNumpad`, set its value to 1, and reboot. This method is not recommended because of reliability and compatibility issue, use WinCompose method below instead. * __UC_WINC__: Windows Unicode input using WinCompose. Requires [WinCompose](https://github.com/samhocevar/wincompose). Works reliably under many (all?) variations of Windows. -### Keycodes +!> There is an input mode option for BSD, but it's not implemented at this time. If you use BSD and want to help with adding support for it, please [open an issue on GitHub](https://github.com/qmk/qmk_firmware/issues). + +### Switching Input Modes -|Key |Aliases |Input Method |Description | -|--------------------------|---------|--------------|---------------------------------------------------| -|`UNICODE_MODE_OSX` |`UC_M_OS`|`UC_OSX` |Sets the input method for MacOS X | -|`UNICODE_MODE_LNX` |`UC_M_LN`|`UC_LNX` |Sets the input method for Linux | -|`UNICODE_MODE_BSD` |`UC_M_BS`|`UC_BSD` |Sets the input method for BSD (Non-Operational) | -|`UNICODE_MODE_WIN` |`UC_M_WI`|`UC_WIN` |Sets the input method for Windows | -|`UNICODE_MODE_WINC` |`UC_M_WC`|`UC_WINC` |Sets the input method for Windows using WinCompose | -|`UNICODE_MODE_OSX_RALT` |`UC_M_OR`|`UC_OSX_RALT` |Sets the input method for MacOS X using RAlt/AltGr | -### Audio Feedback for Input Mode keycodes +There are two ways to set the input mode for Unicode: by keycode or by function. Keep in mind that both methods write to persistent storage (EEPROM), and are loaded each time the keyboard starts. So once you've set it once, you don't need to set it again unless you want to change it, or you've reset the EEPROM settings. + +You can switch the input mode at any time by using one of the following keycodes. The easiest way is to add the ones you use to your keymap. + +|Keycode |Alias |Input mode |Description | +|-----------------------|---------|-------------|-----------------------------------------| +|`UNICODE_MODE_OSX` |`UC_M_OS`|`UC_OSX` |Switch to Mac OS X input. | +|`UNICODE_MODE_LNX` |`UC_M_LN`|`UC_LNX` |Switch to Linux input. | +|`UNICODE_MODE_WIN` |`UC_M_WI`|`UC_WIN` |Switch to Windows input. | +|`UNICODE_MODE_BSD` |`UC_M_BS`|`UC_BSD` |Switch to BSD input (not implemented). | +|`UNICODE_MODE_WINC` |`UC_M_WC`|`UC_WINC` |Switch to Windows input using WinCompose.| +|`UNICODE_MODE_OSX_RALT`|`UC_M_OR`|`UC_OSX_RALT`|Switch to Mac OS X input using Right Alt.| + +You can also switch the input mode by calling `set_unicode_input_mode(x)` in your code, and this works the same way as the above keycodes. + +### Audio Feedback If you have the [Audio feature](feature_audio.md) enabled on the board, you can set melodies to be played when you press the above keys. That way you can have some audio feedback when switching input modes. -For instance, you can add these to your `config.h` file. +For instance, you can add these definitions to your `config.h` file: ```c #define UNICODE_SONG_OSX COIN_SOUND @@ -122,16 +122,15 @@ For instance, you can add these to your `config.h` file. #define UNICODE_SONG_OSX_RALT COIN_SOUND ``` -### Unicode Input Method Customization +### Additional Customization -The "start" and "finish" functions for unicode method can be customized locally. A great use for this is to customize the input methods if you don't use the default keys. Or to add visual, or audio feedback when inputting unicode characters. +The functions for starting and finishing Unicode input on your platform can be overridden locally. Possible uses include customizing input mode behavior if you don't use the default keys, or adding extra visual/audio feedback to Unicode input. -* `void unicode_input_start(void)` - This sends the initial sequence that tells your platform to enter Unicode input mode. For example, it presses Ctrl+Shift+U on Linux and holds the Option key on Mac. -* `void unicode_input_finish (void)` - his is called to exit Unicode input mode, for example by pressing Space or releasing the Option key. +* `void unicode_input_start(void)` – This sends the initial sequence that tells your platform to enter Unicode input mode. For example, it presses Ctrl+Shift+U on Linux and holds the Option key on Mac. +* `void unicode_input_finish(void)` – This is called to exit Unicode input mode, for example by pressing Space or releasing the Option key. You can find the default implementations of these functions in [`process_unicode_common.c`](https://github.com/qmk/qmk_firmware/blob/master/quantum/process_keycode/process_unicode_common.c). - ## `send_unicode_hex_string` To type multiple characters for things like (ノಠ痊ಠ)ノ彡┻━┻, you can use `send_unicode_hex_string()` much like `SEND_STRING()` except you would use hex values separate by spaces. diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 65afc37859..12315c0922 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -21,27 +21,6 @@ unicode_config_t unicode_config; static uint8_t saved_mods; -#ifdef AUDIO_ENABLE - #ifdef UNICODE_SONG_OSX - float osx_song[][2] = UNICODE_SONG_OSX; - #endif - #ifdef UNICODE_SONG_LNX - float song_lnx[][2] = UNICODE_SONG_LNX; - #endif - #ifdef UNICODE_SONG_WIN - float windows_song[][2] = UNICODE_SONG_WIN; - #endif - #ifdef UNICODE_SONG_BSD - float song_bsd[][2] = UNICODE_SONG_BSD; - #endif - #ifdef UNICODE_SONG_WINC - float win_compose_song[][2] = UNICODE_SONG_WINC; - #endif - #ifdef UNICODE_SONG_OSX_RALT - float osx_ralt_song[][2] = UNICODE_SONG_OSX_RALT; - #endif -#endif - void set_unicode_input_mode(uint8_t os_target) { unicode_config.input_mode = os_target; @@ -92,16 +71,16 @@ void unicode_input_start(void) { __attribute__((weak)) void unicode_input_finish(void) { switch (unicode_config.input_mode) { - case UC_OSX: - case UC_WIN: - unregister_code(KC_LALT); - break; - case UC_OSX_RALT: - unregister_code(KC_RALT); - break; - case UC_LNX: - tap_code(KC_SPC); - break; + case UC_OSX: + case UC_WIN: + unregister_code(KC_LALT); + break; + case UC_OSX_RALT: + unregister_code(KC_RALT); + break; + case UC_LNX: + tap_code(KC_SPC); + break; } set_mods(saved_mods); // Reregister previously set mods @@ -153,52 +132,57 @@ void send_unicode_hex_string(const char *str) { bool process_unicode_common(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { switch (keycode) { - case UNICODE_MODE_OSX: + case UNICODE_MODE_OSX: set_unicode_input_mode(UC_OSX); - #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_OSX) - PLAY_SONG(osx_song); - #endif - break; - case UNICODE_MODE_LNX: - set_unicode_input_mode(UC_LNX); - #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_LNX) - PLAY_SONG(song_lnx); - #endif - break; - case UNICODE_MODE_WIN: - set_unicode_input_mode(UC_WIN); - #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WIN) - PLAY_SONG(windows_song); - #endif - break; - case UNICODE_MODE_BSD: - set_unicode_input_mode(UC_BSD); - #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_BSD) - PLAY_SONG(song_bsd); - #endif - break; - case UNICODE_MODE_WINC: - set_unicode_input_mode(UC_WINC); - #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WINC) - PLAY_SONG(win_compose_song); - #endif - break; - case UNICODE_MODE_OSX_RALT: - set_unicode_input_mode(UC_OSX_RALT); - #if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_OSX_RALT) - PLAY_SONG(osx_ralt_song); - #endif - break; +#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_OSX) + static float song_osx[][2] = UNICODE_SONG_OSX; + PLAY_SONG(song_osx); +#endif + break; + case UNICODE_MODE_LNX: + set_unicode_input_mode(UC_LNX); +#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_LNX) + static float song_lnx[][2] = UNICODE_SONG_LNX; + PLAY_SONG(song_lnx); +#endif + break; + case UNICODE_MODE_WIN: + set_unicode_input_mode(UC_WIN); +#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WIN) + static float song_win[][2] = UNICODE_SONG_WIN; + PLAY_SONG(song_win); +#endif + break; + case UNICODE_MODE_BSD: + set_unicode_input_mode(UC_BSD); +#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_BSD) + static float song_bsd[][2] = UNICODE_SONG_BSD; + PLAY_SONG(song_bsd); +#endif + break; + case UNICODE_MODE_WINC: + set_unicode_input_mode(UC_WINC); +#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_WINC) + static float song_winc[][2] = UNICODE_SONG_WINC; + PLAY_SONG(song_winc); +#endif + break; + case UNICODE_MODE_OSX_RALT: + set_unicode_input_mode(UC_OSX_RALT); +#if defined(AUDIO_ENABLE) && defined(UNICODE_SONG_OSX_RALT) + static float song_osx_ralt[][2] = UNICODE_SONG_OSX_RALT; + PLAY_SONG(song_osx_ralt); +#endif + break; } } - #ifdef UNICODE_ENABLE - return process_unicode(keycode, record); - #endif - #ifdef UCIS_ENABLE - return process_ucis(keycode, record); - #endif - #ifdef UNICODEMAP_ENABLE - return process_unicode_map(keycode, record); - #endif +#if defined(UNICODE_ENABLE) + return process_unicode(keycode, record); +#elif defined(UNICODEMAP_ENABLE) + return process_unicode_map(keycode, record); +#elif defined(UCIS_ENABLE) + return process_ucis(keycode, record); +#else return true; +#endif } diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index 1beeda467e..8fdc312eb3 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -19,11 +19,11 @@ #include "quantum.h" #if defined(UNICODE_ENABLE) + defined(UNICODEMAP_ENABLE) + defined(UCIS_ENABLE) > 1 - #error "Cannot enable more than one unicode method (UNICODE, UNICODEMAP, UCIS) at the same time" + #error "Cannot enable more than one Unicode method (UNICODE, UNICODEMAP, UCIS) at the same time" #endif #ifndef UNICODE_TYPE_DELAY -#define UNICODE_TYPE_DELAY 10 + #define UNICODE_TYPE_DELAY 10 #endif typedef union { diff --git a/quantum/quantum.c b/quantum/quantum.c index 3ff361eabf..3f0e7e2b25 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -235,7 +235,7 @@ bool process_record_quantum(keyrecord_t *record) { process_key_lock(&keycode, record) && #endif #if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY) - process_clicky(keycode, record) && + process_clicky(keycode, record) && #endif //AUDIO_CLICKY process_record_kb(keycode, record) && #if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_KEYPRESSES) @@ -250,13 +250,13 @@ bool process_record_quantum(keyrecord_t *record) { #ifdef STENO_ENABLE process_steno(keycode, record) && #endif - #if ( defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))) && !defined(NO_MUSIC_MODE) + #if (defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))) && !defined(NO_MUSIC_MODE) process_music(keycode, record) && #endif #ifdef TAP_DANCE_ENABLE process_tap_dance(keycode, record) && #endif - #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) + #if defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE) process_unicode_common(keycode, record) && #endif #ifdef LEADER_ENABLE From 96fd5e9ad26b7d88c7b47ebf52aae57cd6726e0c Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Sat, 3 Nov 2018 11:21:01 -0700 Subject: [PATCH 36/38] Steal vomindoraan's input mode documentation Co-Authored-By: vomindoraan (vomindoraan@gmail.com) --- docs/feature_unicode.md | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/docs/feature_unicode.md b/docs/feature_unicode.md index 653e84822f..7824eb15d3 100644 --- a/docs/feature_unicode.md +++ b/docs/feature_unicode.md @@ -81,12 +81,27 @@ Unicode input in QMK works by inputting a sequence of characters to the OS, sort The following input modes are available: -* __UC_OSX__: MacOS Unicode Hex Input support. Works only up to 0xFFFF. Disabled by default. To enable: go to System Preferences -> Keyboard -> Input Sources, and enable Unicode Hex. -* __UC_OSX_RALT__: Same as UC_OSX, but sends the Right Alt key for unicode input -* __UC_LNX__: Unicode input method under Linux. Works up to 0xFFFFF. Should work almost anywhere on ibus enabled distros. Without ibus, this works under GTK apps, but rarely anywhere else. -* __UC_BSD__: (non operational) Unicode input method under BSD. -* __UC_WIN__: (not recommended) Windows built-in Unicode input. To enable: create registry key under `HKEY_CURRENT_USER\Control Panel\Input Method\EnableHexNumpad` of type `REG_SZ` called `EnableHexNumpad`, set its value to 1, and reboot. This method is not recommended because of reliability and compatibility issue, use WinCompose method below instead. -* __UC_WINC__: Windows Unicode input using WinCompose. Requires [WinCompose](https://github.com/samhocevar/wincompose). Works reliably under many (all?) variations of Windows. +* **`UC_OSX`**: Mac OS X built-in Unicode hex input. Supports code points up to `0xFFFF` (`0x10FFFF` with `UNICODEMAP`). + + To enable, go to _System Preferences > Keyboard > Input Sources_, add _Unicode Hex Input_ to the list (it's under _Other_), then activate it from the input dropdown in the Menu Bar. + +* **`UC_OSX_RALT`**: Same as UC_OSX, but sends the Right Alt key for unicode input + +* **`UC_LNX`**: Linux built-in IBus Unicode input. Supports all possible code points (`0x10FFFF`). + + Enabled by default and works almost anywhere on IBus-enabled distros. Without IBus, this mode works under GTK apps, but rarely anywhere else. + +* **`UC_BSD`**: (non operational) Unicode input method under BSD. + +* **`UC_WIN`**: _(not recommended)_ Windows built-in hex numpad Unicode input. Supports code points up to `0xFFFF`. + + To enable, create a registry key under `HKEY_CURRENT_USER\Control Panel\Input Method\EnableHexNumpad` of type `REG_SZ` called `EnableHexNumpad` and set its value to `1`. This can be done from the Command Prompt by running `reg add "HKCU\Control Panel\Input Method" -v EnableHexNumpad -t REG_SZ -d 1` with administrator privileges. Afterwards, reboot. + This mode is not recommended because of reliability and compatibility issues; use the `UC_WINC` mode instead. + +* **`UC_WINC`**: Windows Unicode input using [WinCompose](https://github.com/samhocevar/wincompose). As of v0.8.2, supports code points up to `0xFFFFF`. + + To enable, install the [latest release](https://github.com/samhocevar/wincompose/releases/latest). Once installed, WinCompose will automatically run on startup. Works reliably under all version of Windows supported by the app. + This mode uses the right Alt key (`KC_RALT`), and this needs to be set to this in WinCompose's settings. !> There is an input mode option for BSD, but it's not implemented at this time. If you use BSD and want to help with adding support for it, please [open an issue on GitHub](https://github.com/qmk/qmk_firmware/issues). From 4c63b3b96f9642cc5c65608122e67ea431c1dff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Sat, 3 Nov 2018 22:26:08 +0100 Subject: [PATCH 37/38] Willingly give Drashna the rest of my Unicode doc improvements --- docs/feature_unicode.md | 46 ++++++++++++++--------------------------- 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/docs/feature_unicode.md b/docs/feature_unicode.md index 7824eb15d3..b03514ab7b 100644 --- a/docs/feature_unicode.md +++ b/docs/feature_unicode.md @@ -4,11 +4,11 @@ There are three Unicode keymap definition methods available in QMK: ## UNICODE_ENABLE -Supports Unicode input up to 0xFFFF. The keycode function is `UC(n)` in keymap file, where *n* is a 4 digit hexadecimal. +Supports Unicode up to `0xFFFF`. The keycode function is `UC(n)` in the keymap file, where _n_ is a 4 digit hexadecimal number. ## UNICODEMAP_ENABLE -Supports Unicode up to 0xFFFFFFFF. You need to maintain a separate mapping table `const uint32_t PROGMEM unicode_map[] = {...}` in your keymap file. The keycode function is `X(n)` where *n* is the array index of the mapping table. +Supports Unicode up to `0x10FFFF` (all possible code points). You need to maintain a separate mapping table `const uint32_t PROGMEM unicode_map[] = {...}` in your keymap file. The keycode function is `X(n)`, where _n_ is an array index into the mapping table. And you may want to have an enum to make reference easier. So you'd want to add something like this to your keymap: @@ -30,7 +30,7 @@ Make sure that the order for both matches. ## UCIS_ENABLE -Supports Unicode up to 0xFFFFFFFF. As with `UNICODE_MAP`, you may want to main a mapping table in your keymap file. However, there is no keycodes for this feature, you will have to add a keycode or function to call `qk_ucis_start()`. Once you've run that, you can just type the text for your unicode, and then hit space or enter to complete it, or ESC to cancel it. And if it matches an entry in your table, it will automatically "backspace" the trigger word (from your table) and then will input the unicode sequence. +Supports Unicode up to `0x10FFFF` (all possible code points). As with `UNICODEMAP`, you may want to maintain a mapping table in your keymap file. However, there are no built-in keycodes for this feature — you will have to add a keycode or function that calls `qk_ucis_start()`. Once it's been called, you can type the mnemonic for your character, then hit Space or Enter to complete it or Esc to cancel. If the mnemonic matches an entry in your table, the typed text will automatically be erased and the corresponding Unicode sequence inserted. For instance, you would need to have a table like this in your keymap: @@ -53,27 +53,7 @@ There are several functions that you can add to your keymap to customize the fun * `void qk_ucis_success(uint8_t symbol_index)` - This runs when the unicode input has matched something, and has completed. Default doesn't do anything. * `void qk_ucis_symbol_fallback (void)` - This runs if the input text doesn't match anything. The default function falls back to trying that input as a unicode code. -The default code for these are: - -```c -void qk_ucis_start_user(void) { // outputs keyboard emoji - unicode_input_start(); - register_hex(0x2328); - unicode_input_finish(); -} - -void qk_ucis_success(uint8_t symbol_index) { -} - -void qk_ucis_symbol_fallback (void) { // falls back to manual unicode entry - for (uint8_t i = 0; i < qk_ucis_state.count - 1; i++) { - uint8_t code = qk_ucis_state.codes[i]; - register_code(code); - unregister_code(code); - wait_ms(UNICODE_TYPE_DELAY); - } -} -``` +You can find the default implementations of these functions in [`process_ucis.c`](https://github.com/qmk/qmk_firmware/blob/master/quantum/process_keycode/process_ucis.c). ## Input Modes @@ -85,25 +65,23 @@ The following input modes are available: To enable, go to _System Preferences > Keyboard > Input Sources_, add _Unicode Hex Input_ to the list (it's under _Other_), then activate it from the input dropdown in the Menu Bar. -* **`UC_OSX_RALT`**: Same as UC_OSX, but sends the Right Alt key for unicode input +* **`UC_OSX_RALT`**: Same as `UC_OSX`, but sends the Right Alt/Option key for Unicode input. * **`UC_LNX`**: Linux built-in IBus Unicode input. Supports all possible code points (`0x10FFFF`). Enabled by default and works almost anywhere on IBus-enabled distros. Without IBus, this mode works under GTK apps, but rarely anywhere else. -* **`UC_BSD`**: (non operational) Unicode input method under BSD. - * **`UC_WIN`**: _(not recommended)_ Windows built-in hex numpad Unicode input. Supports code points up to `0xFFFF`. To enable, create a registry key under `HKEY_CURRENT_USER\Control Panel\Input Method\EnableHexNumpad` of type `REG_SZ` called `EnableHexNumpad` and set its value to `1`. This can be done from the Command Prompt by running `reg add "HKCU\Control Panel\Input Method" -v EnableHexNumpad -t REG_SZ -d 1` with administrator privileges. Afterwards, reboot. This mode is not recommended because of reliability and compatibility issues; use the `UC_WINC` mode instead. +* **`UC_BSD`**: _(non implemented)_ Unicode input under BSD. Not implemented at this time. If you're a BSD user and want to help add support for it, please [open an issue on GitHub](https://github.com/qmk/qmk_firmware/issues). + * **`UC_WINC`**: Windows Unicode input using [WinCompose](https://github.com/samhocevar/wincompose). As of v0.8.2, supports code points up to `0xFFFFF`. To enable, install the [latest release](https://github.com/samhocevar/wincompose/releases/latest). Once installed, WinCompose will automatically run on startup. Works reliably under all version of Windows supported by the app. - This mode uses the right Alt key (`KC_RALT`), and this needs to be set to this in WinCompose's settings. - -!> There is an input mode option for BSD, but it's not implemented at this time. If you use BSD and want to help with adding support for it, please [open an issue on GitHub](https://github.com/qmk/qmk_firmware/issues). + This mode relies on the Compose key being set to Right Alt (`KC_RALT`). If you change it to something else in the WinCompose settings, this mode will not work. ### Switching Input Modes @@ -120,7 +98,13 @@ You can switch the input mode at any time by using one of the following keycodes |`UNICODE_MODE_WINC` |`UC_M_WC`|`UC_WINC` |Switch to Windows input using WinCompose.| |`UNICODE_MODE_OSX_RALT`|`UC_M_OR`|`UC_OSX_RALT`|Switch to Mac OS X input using Right Alt.| -You can also switch the input mode by calling `set_unicode_input_mode(x)` in your code, and this works the same way as the above keycodes. +You can also switch the input mode by calling `set_unicode_input_mode(x)` in your code, where _x_ is one of the above input mode constants (e.g. `UC_LNX`). Since the function only needs to be called once, it's recommended that you do it in `eeconfig_init_user` (or a similar function). For example: + +```c +void eeconfig_init_user(void) { + set_unicode_input_mode(UC_LNX); +} +``` ### Audio Feedback From 36fce29ab1ab25d93601656638c679405a56c038 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Sat, 3 Nov 2018 14:52:32 -0700 Subject: [PATCH 38/38] Wordsmithing Co-Authored-By: drashna --- docs/feature_unicode.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/feature_unicode.md b/docs/feature_unicode.md index b03514ab7b..86923a54ec 100644 --- a/docs/feature_unicode.md +++ b/docs/feature_unicode.md @@ -85,7 +85,7 @@ The following input modes are available: ### Switching Input Modes -There are two ways to set the input mode for Unicode: by keycode or by function. Keep in mind that both methods write to persistent storage (EEPROM), and are loaded each time the keyboard starts. So once you've set it once, you don't need to set it again unless you want to change it, or you've reset the EEPROM settings. +There are two ways to set the input mode for Unicode: by keycode or by function. Keep in mind that both methods write to persistent storage (EEPROM), and are loaded each time the keyboard starts. So once you've set it the first time, you don't need to set it again unless you want to change it, or you've reset the EEPROM settings. You can switch the input mode at any time by using one of the following keycodes. The easiest way is to add the ones you use to your keymap.