From 18fcde13ad0305e68e566922152542878651ecc5 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 08:37:38 -0700 Subject: [PATCH 01/87] 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 4285d20a19fb..c270d5119acc 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 e78e1cec6ce9..7f896461b6ae 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/87] 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 380199771db6..56544eca1899 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 f39c4a36e1b6..19beb84520b9 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 ab5717ba3aff..47c27b911716 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/87] 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 5f1a691c8841..3770b0312b5b 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/87] 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 c270d5119acc..e8f5001380c3 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 7f896461b6ae..b1fc8c0ac834 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 3770b0312b5b..4267c1e0361b 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 e983798f2ba6..6a3a6461bdc1 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/87] 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 e8f5001380c3..b69439d7f7e4 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/87] 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 b69439d7f7e4..254f1a231c7e 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/87] 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 254f1a231c7e..a2fe688a302c 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 6a3a6461bdc1..394b47b2cafc 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/87] 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 b1527b848ae5..0b17b349c30a 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/87] 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 a2fe688a302c..4782c23bafc3 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 394b47b2cafc..43b8bd60e74e 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/87] 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 0b17b349c30a..96c9a46f9f1b 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/87] 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 96c9a46f9f1b..04aab2d76775 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/87] 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 56544eca1899..4efbe09540e1 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/87] 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 4782c23bafc3..ed20efacac0d 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/87] 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 ed20efacac0d..950a45d44e2c 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/87] 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 950a45d44e2c..71673015e061 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/87] 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 b1fc8c0ac834..6d3e08048373 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/87] 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 43b8bd60e74e..95e7b4ca998d 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/87] 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 95e7b4ca998d..4722fb07f7bb 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/87] 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 71673015e061..4609468fc20d 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/87] 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 4609468fc20d..f27e77c52f23 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/87] 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 04aab2d76775..bec76be1a008 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/87] 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 f27e77c52f23..7363a761f819 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/87] 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 7363a761f819..0741ab003000 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/87] 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 6d3e08048373..8716b8bc5659 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/87] 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 0741ab003000..1c8a723e2cf0 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/87] 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 1c8a723e2cf0..a329bf451479 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/87] 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 4722fb07f7bb..0ec29a4d2b61 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/87] 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 a329bf451479..f70d2b2f2f37 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/87] 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 f70d2b2f2f37..0f79e42c487c 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/87] 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 d4aa34cde73a..b114d839ab8d 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 c525b74f03fe..0913e991075c 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 0f79e42c487c..1adf70eaa004 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 8716b8bc5659..54f867a4998a 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 929c88c0b616..f6d64bb86b02 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/87] 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 54f867a4998a..8a1f809eb7aa 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 0ec29a4d2b61..51fb1b06e490 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/87] 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 51fb1b06e490..58e11a846673 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/87] 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 bec76be1a008..cbf5633302fa 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/87] 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 cbf5633302fa..0ccd54588044 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 1adf70eaa004..65afc3785995 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 8a1f809eb7aa..1beeda467e33 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 4267c1e0361b..3ff361eabfa6 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 58e11a846673..b428eabbec9e 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/87] 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 0ccd54588044..653e84822f03 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 65afc3785995..12315c0922ba 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 1beeda467e33..8fdc312eb32e 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 3ff361eabfa6..3f0e7e2b25e4 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/87] 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 653e84822f03..7824eb15d333 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/87] 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 7824eb15d333..b03514ab7b19 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/87] 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 b03514ab7b19..86923a54ec59 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. From f0020642e9dd94d1c48243c6efb712cd4a8be05c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Mon, 22 Oct 2018 16:09:44 +0200 Subject: [PATCH 39/87] Rearrange process_unicode_common functions --- .../process_keycode/process_unicode_common.c | 20 +++++++++---------- .../process_keycode/process_unicode_common.h | 7 ++----- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 4285d20a19fb..02d3f325a3d0 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -16,21 +16,12 @@ #include "process_unicode_common.h" #include "eeprom.h" -#include #include +#include static uint8_t input_mode; uint8_t mods; -void set_unicode_input_mode(uint8_t os_target) { - input_mode = os_target; - eeprom_update_byte(EECONFIG_UNICODEMODE, os_target); -} - -uint8_t get_unicode_input_mode(void) { - return input_mode; -} - void unicode_input_mode_init(void) { static bool first_flag = false; if (!first_flag) { @@ -39,6 +30,15 @@ void unicode_input_mode_init(void) { } } +uint8_t get_unicode_input_mode(void) { + return input_mode; +} + +void set_unicode_input_mode(uint8_t mode) { + input_mode = mode; + eeprom_update_byte(EECONFIG_UNICODEMODE, mode); +} + __attribute__((weak)) void unicode_input_start (void) { // save current mods diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index e78e1cec6ce9..916d37e2e1f6 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -23,12 +23,9 @@ #define UNICODE_TYPE_DELAY 10 #endif -__attribute__ ((unused)) -static uint8_t input_mode; - -void set_unicode_input_mode(uint8_t os_target); -uint8_t get_unicode_input_mode(void); void unicode_input_mode_init(void); +uint8_t get_unicode_input_mode(void); +void set_unicode_input_mode(uint8_t mode); void unicode_input_start(void); void unicode_input_finish(void); void register_hex(uint16_t hex); From dabe0c1b6fafdb48eac85e2fc325cfaeefd002a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Tue, 23 Oct 2018 10:16:42 +0200 Subject: [PATCH 40/87] Simplify unicode_input_start/finish code --- .../process_keycode/process_unicode_common.c | 67 +++++++------------ 1 file changed, 23 insertions(+), 44 deletions(-) diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 02d3f325a3d0..1d3169a5ffa4 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -20,7 +20,7 @@ #include static uint8_t input_mode; -uint8_t mods; +static uint8_t saved_mods; void unicode_input_mode_init(void) { static bool first_flag = false; @@ -40,19 +40,9 @@ void set_unicode_input_mode(uint8_t mode) { } __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); +void unicode_input_start(void) { + saved_mods = get_mods(); // Save current mods + clear_mods(); // Unregister mods to start from a clean state switch(input_mode) { case UC_OSX: @@ -64,50 +54,39 @@ 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); + break; } + wait_ms(UNICODE_TYPE_DELAY); } __attribute__((weak)) -void unicode_input_finish (void) { +void unicode_input_finish(void) { switch(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: - register_code(KC_SPC); - unregister_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; } - // 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)) @@ -130,7 +109,7 @@ void register_hex(uint16_t hex) { } void send_unicode_hex_string(const char *str) { - if (!str) { return; } // Safety net + if (!str) { return; } while (*str) { // Find the next code point (token) in the string From a5b9d402d5138b702931bedb3a73b6eb9a276970 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Tue, 18 Sep 2018 20:19:33 +0200 Subject: [PATCH 41/87] Make Unicode input mode constants (UC_*) an enum --- quantum/process_keycode/process_unicode_common.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index 916d37e2e1f6..e9a4fb15fe76 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -31,12 +31,15 @@ void unicode_input_finish(void); void register_hex(uint16_t hex); void send_unicode_hex_string(const char *str); -#define UC_OSX 0 // Mac OS X -#define UC_LNX 1 // Linux -#define UC_WIN 2 // Windows 'HexNumpad' -#define UC_BSD 3 // BSD (not implemented) -#define UC_WINC 4 // WinCompose https://github.com/samhocevar/wincompose -#define UC_OSX_RALT 5 // Mac OS X using Right Alt key for Unicode Compose +enum unicode_input_modes { + UC_OSX, // Mac OS X using Unicode Hex Input + UC_LNX, // Linux using IBus + UC_WIN, // Windows using EnableHexNumpad + UC_BSD, // BSD (not implemented) + UC_WINC, // Windows using WinCompose (https://github.com/samhocevar/wincompose) + UC_OSX_RALT, // Mac OS X using Unicode Hex Input (right Option) + UC__COUNT // Number of available input modes (always leave at the end) +}; #define UC_BSPC UC(0x0008) From 93b15db9a19da06c9accf3cff0066f143d74dd43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Tue, 23 Oct 2018 11:00:34 +0200 Subject: [PATCH 42/87] Make the key used for WinCompose configurable --- docs/feature_unicode.md | 6 +++--- quantum/process_keycode/process_unicode_common.c | 2 +- quantum/process_keycode/process_unicode_common.h | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/docs/feature_unicode.md b/docs/feature_unicode.md index b1527b848ae5..37d2cbe2c673 100644 --- a/docs/feature_unicode.md +++ b/docs/feature_unicode.md @@ -82,11 +82,11 @@ sort of like macro. Unfortunately, each OS has different ideas on how Unicode is This is the current list of Unicode input method in QMK: -* __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_OSX__: Mac OS X 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 Input. +* __UC_OSX_RALT__: Same as UC_OSX, but sends the right Option key for Unicode input instead of left Option. * __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_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_WINC__: Windows Unicode input using WinCompose. Requires [WinCompose](https://github.com/samhocevar/wincompose). Works reliably under many (all?) variations of Windows. Uses right Alt (`KC_RALT`) by default, but this can be changed in the WinCompose options and by defining `UNICODE_WINC_KEY` with another keycode. 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. diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 1d3169a5ffa4..07acc59a7a76 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -63,7 +63,7 @@ void unicode_input_start(void) { tap_code(KC_PPLS); break; case UC_WINC: - tap_code(KC_RALT); + tap_code(UNICODE_WINC_KEY); tap_code(KC_U); break; } diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index e9a4fb15fe76..ce7f33eaa182 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -19,6 +19,9 @@ #include "quantum.h" +#ifndef UNICODE_WINC_KEY +#define UNICODE_WINC_KEY KC_RALT +#endif #ifndef UNICODE_TYPE_DELAY #define UNICODE_TYPE_DELAY 10 #endif From f47d6548d7309735163a5bcbb94751be8eec7b62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Tue, 23 Oct 2018 12:01:52 +0200 Subject: [PATCH 43/87] Remove UC_OSX_RALT in favor of setting the key with UNICODE_OSX_KEY --- docs/feature_unicode.md | 3 +-- quantum/process_keycode/process_unicode_common.c | 10 +++------- quantum/process_keycode/process_unicode_common.h | 16 +++++++++------- quantum/process_keycode/process_unicodemap.c | 4 ++-- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/docs/feature_unicode.md b/docs/feature_unicode.md index 37d2cbe2c673..dfb7f7e0691c 100644 --- a/docs/feature_unicode.md +++ b/docs/feature_unicode.md @@ -82,8 +82,7 @@ sort of like macro. Unfortunately, each OS has different ideas on how Unicode is This is the current list of Unicode input method in QMK: -* __UC_OSX__: Mac OS X 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 Input. -* __UC_OSX_RALT__: Same as UC_OSX, but sends the right Option key for Unicode input instead of left Option. +* __UC_OSX__: Mac OS X 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 Input. Sends the left Option key (`KC_LALT`) by default, but this can be changed by defining `UNICODE_OSX_KEY` with another keycode. * __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_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. Uses right Alt (`KC_RALT`) by default, but this can be changed in the WinCompose options and by defining `UNICODE_WINC_KEY` with another keycode. diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 07acc59a7a76..e27628d38be0 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -46,10 +46,7 @@ void unicode_input_start(void) { switch(input_mode) { case UC_OSX: - register_code(KC_LALT); - break; - case UC_OSX_RALT: - register_code(KC_RALT); + register_code(UNICODE_OSX_KEY); break; case UC_LNX: register_code(KC_LCTL); @@ -75,12 +72,11 @@ __attribute__((weak)) void unicode_input_finish(void) { switch(input_mode) { case UC_OSX: + unregister_code(UNICODE_OSX_KEY); + break; 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; diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index ce7f33eaa182..e79ff3d3b2e0 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -19,6 +19,9 @@ #include "quantum.h" +#ifndef UNICODE_OSX_KEY +#define UNICODE_OSX_KEY KC_LALT +#endif #ifndef UNICODE_WINC_KEY #define UNICODE_WINC_KEY KC_RALT #endif @@ -35,13 +38,12 @@ void register_hex(uint16_t hex); void send_unicode_hex_string(const char *str); enum unicode_input_modes { - UC_OSX, // Mac OS X using Unicode Hex Input - UC_LNX, // Linux using IBus - UC_WIN, // Windows using EnableHexNumpad - UC_BSD, // BSD (not implemented) - UC_WINC, // Windows using WinCompose (https://github.com/samhocevar/wincompose) - UC_OSX_RALT, // Mac OS X using Unicode Hex Input (right Option) - UC__COUNT // Number of available input modes (always leave at the end) + UC_OSX, // Mac OS X using Unicode Hex Input + UC_LNX, // Linux using IBus + UC_WIN, // Windows using EnableHexNumpad + UC_BSD, // BSD (not implemented) + UC_WINC, // Windows using WinCompose (https://github.com/samhocevar/wincompose) + UC__COUNT // Number of available input modes (always leave at the end) }; #define UC_BSPC UC(0x0008) diff --git a/quantum/process_keycode/process_unicodemap.c b/quantum/process_keycode/process_unicodemap.c index ab5717ba3aff..4585e3a8884d 100644 --- a/quantum/process_keycode/process_unicodemap.c +++ b/quantum/process_keycode/process_unicodemap.c @@ -51,7 +51,7 @@ bool process_unicode_map(uint16_t keycode, keyrecord_t *record) { const uint32_t* map = unicode_map; uint16_t index = keycode - QK_UNICODE_MAP; uint32_t code = pgm_read_dword(&map[index]); - if (code > 0xFFFF && code <= 0x10ffff && (input_mode == UC_OSX || input_mode == UC_OSX_RALT)) { + if (code > 0xFFFF && code <= 0x10ffff && input_mode == UC_OSX) { // Convert to UTF-16 surrogate pair code -= 0x10000; uint32_t lo = code & 0x3ff; @@ -60,7 +60,7 @@ bool process_unicode_map(uint16_t keycode, keyrecord_t *record) { register_hex32(hi + 0xd800); register_hex32(lo + 0xdc00); unicode_input_finish(); - } else if ((code > 0x10ffff && (input_mode == UC_OSX || input_mode == UC_OSX_RALT)) || (code > 0xFFFFF && input_mode == UC_LNX)) { + } else if ((code > 0x10ffff && input_mode == UC_OSX) || (code > 0xFFFFF && input_mode == UC_LNX)) { // when character is out of range supported by the OS unicode_map_input_error(); } else { From 7e84383f957d1f4caa3ad39d86ea920644f3351c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Tue, 23 Oct 2018 14:50:33 +0200 Subject: [PATCH 44/87] Update Unicode input mode doc --- docs/feature_unicode.md | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/docs/feature_unicode.md b/docs/feature_unicode.md index dfb7f7e0691c..11f850691d32 100644 --- a/docs/feature_unicode.md +++ b/docs/feature_unicode.md @@ -75,19 +75,24 @@ 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, the way this is done differs for each OS, so a corresponding input mode has to be set. -This is the current list of Unicode input method in QMK: +The following input modes are available: -* __UC_OSX__: Mac OS X 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 Input. Sends the left Option key (`KC_LALT`) by default, but this can be changed by defining `UNICODE_OSX_KEY` with another keycode. -* __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_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. Uses right Alt (`KC_RALT`) by default, but this can be changed in the WinCompose options and by defining `UNICODE_WINC_KEY` with another keycode. +* **`UC_OSX`**: Mac OS X built-in Unicode hex input. Works up to 0xFFFF. 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. By default, this mode uses the left Option key (`KC_LALT`), but this can be changed by defining `UNICODE_OSX_KEY` with another keycode. +* **`UC_LNX`**: Linux built-in IBus Unicode input. Works up to 0xFFFFF. Enabled by default and works almost anywhere on IBus-enabled distros. Without IBus, this mode works under GTK apps, but rarely anywhere else. +* **`UC_WIN`**: _(not recommended)_ Windows built-in Unicode hex numpad input. To enable, create a 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 mode is not recommended because of reliability and compatibility issue; use the `UC_WINC` mode instead. +* **`UC_WINC`**: Windows Unicode input using [WinCompose](https://github.com/samhocevar/wincompose). Works reliably under all version of Windows supported by the app. To enable, install [WinCompose](https://github.com/samhocevar/wincompose/releases/latest) (it will run automatically on startup). By default, this mode uses the right Alt key (`KC_RALT`), but this can be changed in the WinCompose settings and by defining `UNICODE_WINC_KEY` with another keycode. -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. +At some point you need to call `set_unicode_input_mode(X)` in your code to set the appropriate mode. Since the setting is stored in EEPROM, this only needs to be called once, so it's recommended that you do it in `matrix_init_user` (or a similar function). For example: + +```c +void matrix_init_user(void) { + set_unicode_input_mode(UC_LNX); +} +``` ## `send_unicode_hex_string` From b92c115759161d74df694f52e94ded6288cafade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Tue, 23 Oct 2018 17:27:09 +0200 Subject: [PATCH 45/87] Add descriptions and rearrange definitions in process_unicode_common.h --- .../process_keycode/process_unicode_common.h | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index e79ff3d3b2e0..68902d04566d 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -19,24 +19,19 @@ #include "quantum.h" +// Keycodes used for starting Unicode input on different platforms #ifndef UNICODE_OSX_KEY -#define UNICODE_OSX_KEY KC_LALT +#define UNICODE_OSX_KEY KC_LALT #endif #ifndef UNICODE_WINC_KEY -#define UNICODE_WINC_KEY KC_RALT +#define UNICODE_WINC_KEY KC_RALT #endif + +// Delay between starting Unicode input and sending a sequence, in ms #ifndef UNICODE_TYPE_DELAY #define UNICODE_TYPE_DELAY 10 #endif -void unicode_input_mode_init(void); -uint8_t get_unicode_input_mode(void); -void set_unicode_input_mode(uint8_t mode); -void unicode_input_start(void); -void unicode_input_finish(void); -void register_hex(uint16_t hex); -void send_unicode_hex_string(const char *str); - enum unicode_input_modes { UC_OSX, // Mac OS X using Unicode Hex Input UC_LNX, // Linux using IBus @@ -46,8 +41,17 @@ enum unicode_input_modes { UC__COUNT // Number of available input modes (always leave at the end) }; -#define UC_BSPC UC(0x0008) +void unicode_input_mode_init(void); +uint8_t get_unicode_input_mode(void); +void set_unicode_input_mode(uint8_t mode); + +void unicode_input_start(void); +void unicode_input_finish(void); +void register_hex(uint16_t hex); +void send_unicode_hex_string(const char *str); + +#define UC_BSPC UC(0x0008) #define UC_SPC UC(0x0020) #define UC_EXLM UC(0x0021) From 120ccd1366b0dd354b547181b090b357c62932d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Tue, 23 Oct 2018 18:09:06 +0200 Subject: [PATCH 46/87] Add registry command to Unicode docs + misc updates --- docs/feature_unicode.md | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/docs/feature_unicode.md b/docs/feature_unicode.md index 11f850691d32..1670f021d845 100644 --- a/docs/feature_unicode.md +++ b/docs/feature_unicode.md @@ -1,14 +1,14 @@ # Unicode Support -There are three Unicode keymap definition method available in QMK: +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 the array index of 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 it matches an entry in your table, it will automatically erase the typed mnemonic and then input the Unicode sequence. For instance, you would need to have a table like this in your keymap: @@ -81,10 +81,24 @@ Unicode input in QMK works by inputting a sequence of characters to the OS, sort The following input modes are available: -* **`UC_OSX`**: Mac OS X built-in Unicode hex input. Works up to 0xFFFF. 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. By default, this mode uses the left Option key (`KC_LALT`), but this can be changed by defining `UNICODE_OSX_KEY` with another keycode. -* **`UC_LNX`**: Linux built-in IBus Unicode input. Works up to 0xFFFFF. Enabled by default and works almost anywhere on IBus-enabled distros. Without IBus, this mode works under GTK apps, but rarely anywhere else. -* **`UC_WIN`**: _(not recommended)_ Windows built-in Unicode hex numpad input. To enable, create a 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 mode is not recommended because of reliability and compatibility issue; use the `UC_WINC` mode instead. -* **`UC_WINC`**: Windows Unicode input using [WinCompose](https://github.com/samhocevar/wincompose). Works reliably under all version of Windows supported by the app. To enable, install [WinCompose](https://github.com/samhocevar/wincompose/releases/latest) (it will run automatically on startup). By default, this mode uses the right Alt key (`KC_RALT`), but this can be changed in the WinCompose settings and by defining `UNICODE_WINC_KEY` with another keycode. +* **`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. + By default, this mode uses the left Option key (`KC_LALT`), but this can be changed by defining `UNICODE_OSX_KEY` with another keycode. + +* **`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_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. + By default, this mode uses the right Alt key (`KC_RALT`), but this can be changed in the WinCompose settings and by defining `UNICODE_WINC_KEY` with another keycode. At some point you need to call `set_unicode_input_mode(X)` in your code to set the appropriate mode. Since the setting is stored in EEPROM, this only needs to be called once, so it's recommended that you do it in `matrix_init_user` (or a similar function). For example: From 1e7ab5e926f986f7f5d3f85c3d0609b71725b3ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Fri, 2 Nov 2018 14:25:04 +0100 Subject: [PATCH 47/87] Reword an explanation in Unicode docs --- docs/feature_unicode.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/feature_unicode.md b/docs/feature_unicode.md index 1670f021d845..438023ba4689 100644 --- a/docs/feature_unicode.md +++ b/docs/feature_unicode.md @@ -8,7 +8,7 @@ Supports Unicode up to `0xFFFF`. The keycode function is `UC(n)` in the keymap f ## UNICODEMAP_ENABLE -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 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 `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 it matches an entry in your table, it will automatically erase the typed mnemonic and then 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: @@ -77,7 +77,7 @@ 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, the way this is done differs for each OS, so a corresponding input mode has to be set. +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, so a corresponding input mode has to be set. The following input modes are available: From ac2183e09a0de632433d82a00331507fa5b406fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Mon, 5 Nov 2018 13:29:04 +0100 Subject: [PATCH 48/87] Add TODO comment --- 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 e27628d38be0..67d4f007b730 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -51,7 +51,7 @@ void unicode_input_start(void) { case UC_LNX: register_code(KC_LCTL); register_code(KC_LSFT); - tap_code(KC_U); + tap_code(KC_U); // TODO: Replace with tap_code16(LCTL(LSFT(KC_U))); and test unregister_code(KC_LSFT); unregister_code(KC_LCTL); break; From e5892a7e047e7838df05d73769fa75153012e1f6 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 08:37:38 -0700 Subject: [PATCH 49/87] 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 4285d20a19fb..c270d5119acc 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 e78e1cec6ce9..7f896461b6ae 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 b1022d2a079d33fa6c1b41503b5c2137069ba709 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 08:41:55 -0700 Subject: [PATCH 50/87] 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 380199771db6..56544eca1899 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 f39c4a36e1b6..19beb84520b9 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 ab5717ba3aff..47c27b911716 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 201e2445215d8eacee675e5a2b18c6675f447b94 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 08:43:32 -0700 Subject: [PATCH 51/87] 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 69692233ebe4..d23a2970e5a7 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -1002,6 +1002,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 4d746e06c5ba88cd33476d74e3c1f4211fe35738 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 09:13:08 -0700 Subject: [PATCH 52/87] 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, 44 insertions(+), 10 deletions(-) diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index c270d5119acc..e8f5001380c3 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 7f896461b6ae..b1fc8c0ac834 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 d23a2970e5a7..1fb6a15ac753 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 14f8c2b812a9..5fcd0dc1fbd2 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -456,6 +456,12 @@ enum quantum_keycodes { EEPROM_RESET, + UNI_OSX, + UNI_LINUX, + UNI_WIN, + UNI_WINC, + UNI_OSX_RALT, + // always leave at the end SAFE_RANGE }; From df3fd019dac82c138e11092ecc7068b37e945848 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 09:29:24 -0700 Subject: [PATCH 53/87] 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 e8f5001380c3..b69439d7f7e4 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 207a88603b5172f0c26b480fe466b43d78dc4178 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 09:35:45 -0700 Subject: [PATCH 54/87] 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 b69439d7f7e4..254f1a231c7e 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 63ad7af9f287a0110bdbe80ca02f45c747f152e6 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 10:09:45 -0700 Subject: [PATCH 55/87] Update keycodes --- quantum/process_keycode/process_unicode_common.c | 10 +++++----- quantum/quantum_keycodes.h | 16 +++++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 254f1a231c7e..a2fe688a302c 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 5fcd0dc1fbd2..fa02314eb32a 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -456,11 +456,11 @@ enum quantum_keycodes { EEPROM_RESET, - 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 @@ -690,6 +690,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 baaabd58353fab38a1a76775dac94179aa8d9ae8 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 10:34:11 -0700 Subject: [PATCH 56/87] 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 b1527b848ae5..0b17b349c30a 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 1f2ee0b5ee8ab213623864049a336b69536fecf4 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 10:35:48 -0700 Subject: [PATCH 57/87] 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 a2fe688a302c..4782c23bafc3 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 fa02314eb32a..233a9e679480 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -457,9 +457,9 @@ enum quantum_keycodes { EEPROM_RESET, 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 @@ -691,9 +691,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 602ef66a4396ddb464fe34ac42a42844fb9373fc Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 10:44:09 -0700 Subject: [PATCH 58/87] 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 0b17b349c30a..96c9a46f9f1b 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 9f9e4e5d6a86216137002848f0bbb7afc95e2f7a Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 12:43:43 -0700 Subject: [PATCH 59/87] 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 96c9a46f9f1b..04aab2d76775 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 ed472ee4f6bd0020ed52401248bd06a30a832d37 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 60/87] 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 56544eca1899..4efbe09540e1 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 69a5bb6f7bb0e17c2bd6458eaf650a810ec510b8 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 61/87] 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 4782c23bafc3..ed20efacac0d 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 2d7bfae00dc72a3663ceefebcf99ba75734d37a4 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 62/87] 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 ed20efacac0d..950a45d44e2c 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 168d73acfc279c9fd7ad04309d2352b9b7f57ac8 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 63/87] 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 950a45d44e2c..71673015e061 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 be055a0bac31972eff8495ce826004dfe97b3046 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 64/87] 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 b1fc8c0ac834..6d3e08048373 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 120a0570c82de7e3518d3f30c014eca7aa2c2024 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 12:47:48 -0700 Subject: [PATCH 65/87] 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 233a9e679480..539a41c3b9bd 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -458,6 +458,7 @@ enum quantum_keycodes { UNICODE_MODE_OSX, UNICODE_MODE_LNX, + UNICODE_MODE_BSD, UNICODE_MODE_WIN, UNICODE_MODE_WINC, UNICODE_MODE_OSX_RALT, From 0a13b30e6d7eec9069e127f2a07ec8f728fce889 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 66/87] 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 71673015e061..4609468fc20d 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 8a571969a103a791810724540d403f1216fd9146 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 67/87] 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 4609468fc20d..f27e77c52f23 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 0e29431623630c1e2b629fc4397aaa6dcd2a05f6 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 68/87] 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 04aab2d76775..bec76be1a008 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 4b93ba86412a6a14a2df27692c0e1dd99461a1db 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 69/87] 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 f27e77c52f23..7363a761f819 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 4b155461b7c062fbe68331a5b6fb9bed06fe7363 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 70/87] 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 7363a761f819..0741ab003000 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 5a4d99deec4759d04619e8422519693a35e64561 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 71/87] 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 6d3e08048373..8716b8bc5659 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 55174dbbade8eca527a32f96a367867e38028c21 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 72/87] 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 0741ab003000..1c8a723e2cf0 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 97ac5335c5ae95a50bda192b1d6b21a84cc69a4a 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 73/87] 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 1c8a723e2cf0..a329bf451479 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 01451ce54224f11cd7d45e798d1b4fc391d533d0 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 12:52:04 -0700 Subject: [PATCH 74/87] 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 539a41c3b9bd..b8e479fa7ca2 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -693,6 +693,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 66d1a8ff42aad1436b76ad046201992665817698 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 12:52:56 -0700 Subject: [PATCH 75/87] 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 a329bf451479..f70d2b2f2f37 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 d0b0e37d46c3c55a51755d776c4fb1685f8a7961 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 12:57:04 -0700 Subject: [PATCH 76/87] 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 f70d2b2f2f37..0f79e42c487c 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 218745f755650f2c8a35a11b056cf3227a4f5b26 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 13:29:23 -0700 Subject: [PATCH 77/87] 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 d4aa34cde73a..b114d839ab8d 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 c525b74f03fe..0913e991075c 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 0f79e42c487c..1adf70eaa004 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 8716b8bc5659..54f867a4998a 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 929c88c0b616..f6d64bb86b02 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 7979442171dca3a801b0832a9d9fab70dfb88d54 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 13:39:07 -0700 Subject: [PATCH 78/87] 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 54f867a4998a..8a1f809eb7aa 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 b8e479fa7ca2..9d73a7d7d863 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 204421502aa25012398af3ce28bd7fef2e45b969 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 13:41:48 -0700 Subject: [PATCH 79/87] 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 9d73a7d7d863..7bc2900c3280 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -690,7 +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_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 0d3f980d3196ef2a4ce4b8167367d2ef81e3e599 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Fri, 2 Nov 2018 13:44:53 -0700 Subject: [PATCH 80/87] 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 bec76be1a008..cbf5633302fa 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 b15fa4a3aed5eb149571a4970ec984266ba514bb Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Sat, 3 Nov 2018 09:22:46 -0700 Subject: [PATCH 81/87] 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 cbf5633302fa..0ccd54588044 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 1adf70eaa004..65afc3785995 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 8a1f809eb7aa..1beeda467e33 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 1fb6a15ac753..6923b633bd0b 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 7bc2900c3280..1e800698d569 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -455,8 +455,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, @@ -690,8 +690,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 9b14dfd053e97d571fbe5b6136175aea2b526dda 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 82/87] 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 0ccd54588044..653e84822f03 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 65afc3785995..12315c0922ba 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 1beeda467e33..8fdc312eb32e 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 6923b633bd0b..5f40b590c07f 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 0b0cfc2264d26471d96fdb2dbf4a853b74918b22 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Sat, 3 Nov 2018 11:21:01 -0700 Subject: [PATCH 83/87] 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 653e84822f03..7824eb15d333 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 e402234c693589dde969bf1b7059e61e7dcad3fa 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 84/87] 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 7824eb15d333..b03514ab7b19 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 0f006dc058e58bb0c15261f572b77d1a1d8c696c 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 85/87] 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 b03514ab7b19..86923a54ec59 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. From b2f4fe68385e9f1e698b8b6793780c734752d53e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Fri, 16 Nov 2018 18:01:58 +0100 Subject: [PATCH 86/87] Remove trailing whitespace --- 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 4dc1861bffe4..1e800698d569 100644 --- a/quantum/quantum_keycodes.h +++ b/quantum/quantum_keycodes.h @@ -452,7 +452,7 @@ enum quantum_keycodes { #endif EEPROM_RESET, - + UNICODE_MODE_OSX, UNICODE_MODE_LNX, UNICODE_MODE_WIN, From de4dc0fe80a49d72c7fdedc4f55a1e26e52d76f1 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Sun, 25 Nov 2018 11:44:06 -0800 Subject: [PATCH 87/87] remove merge artifacts --- quantum/process_keycode/process_ucis.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/quantum/process_keycode/process_ucis.c b/quantum/process_keycode/process_ucis.c index 8deb24a86747..5de2e41fc305 100644 --- a/quantum/process_keycode/process_ucis.c +++ b/quantum/process_keycode/process_ucis.c @@ -95,8 +95,6 @@ void register_ucis(const char *hex) { bool process_ucis (uint16_t keycode, keyrecord_t *record) { uint8_t i; - unicode_input_mode_init(); - if (!qk_ucis_state.in_progress) return true;