From 0aa413af44b292e4b44d8f8aee1a92f2cb113438 Mon Sep 17 00:00:00 2001 From: Jonas Oberschweiber Date: Sat, 31 Dec 2016 19:37:56 +0100 Subject: Add support for supplementary planes for OS X --- quantum/process_keycode/process_unicode.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'quantum/process_keycode/process_unicode.c') diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c index cd3a610b4..2606cf0c8 100644 --- a/quantum/process_keycode/process_unicode.c +++ b/quantum/process_keycode/process_unicode.c @@ -116,7 +116,16 @@ bool process_unicode_map(uint16_t keycode, keyrecord_t *record) { const uint32_t* map = unicode_map; uint16_t index = keycode & 0x7FF; uint32_t code = pgm_read_dword_far(&map[index]); - if ((code > 0xFFFF && input_mode == UC_OSX) || (code > 0xFFFFF && input_mode == UC_LNX)) { + if (code > 0xFFFF && code <= 0x10ffff && input_mode == UC_OSX) { + // Convert to UTF-16 surrogate pair + code -= 0x10000; + uint32_t lo = code & 0x3ff; + uint32_t hi = (code & 0xffc00) >> 10; + unicode_input_start(); + register_hex32(hi + 0xd800); + register_hex32(lo + 0xdc00); + unicode_input_finish(); + } 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 { -- cgit v1.2.3-24-g4f1b From 30b80a23f3cafd846937b37b249f2df4411e1f5a Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo Date: Mon, 9 Jan 2017 02:59:10 +0700 Subject: Unregister all mods before inputting Unicode, and reregister afterwards --- quantum/process_keycode/process_unicode.c | 41 +++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 8 deletions(-) (limited to 'quantum/process_keycode/process_unicode.c') diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c index cd3a610b4..a30e93ae3 100644 --- a/quantum/process_keycode/process_unicode.c +++ b/quantum/process_keycode/process_unicode.c @@ -1,6 +1,8 @@ #include "process_unicode.h" +#include "action_util.h" static uint8_t input_mode; +uint8_t mods; __attribute__((weak)) uint16_t hex_to_keycode(uint8_t hex) @@ -25,6 +27,19 @@ uint8_t get_unicode_input_mode(void) { __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) { case UC_OSX: register_code(KC_LALT); @@ -54,15 +69,25 @@ void unicode_input_start (void) { __attribute__((weak)) void unicode_input_finish (void) { switch(input_mode) { - case UC_OSX: - case UC_WIN: - unregister_code(KC_LALT); - 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_LNX: + register_code(KC_SPC); + unregister_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); } void register_hex(uint16_t hex) { -- cgit v1.2.3-24-g4f1b From 97816df7e7aa8710c8a0837b2abe008e0c765f2a Mon Sep 17 00:00:00 2001 From: Priyadi Iman Nurcahyo Date: Fri, 10 Feb 2017 06:06:59 +0700 Subject: Implement tap mod dual role for right side mods. --- quantum/process_keycode/process_unicode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'quantum/process_keycode/process_unicode.c') diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c index 9995ba9bd..9d01a592d 100644 --- a/quantum/process_keycode/process_unicode.c +++ b/quantum/process_keycode/process_unicode.c @@ -139,7 +139,7 @@ void unicode_map_input_error() {} bool process_unicode_map(uint16_t keycode, keyrecord_t *record) { if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) { const uint32_t* map = unicode_map; - uint16_t index = keycode & 0x7FF; + uint16_t index = keycode - QK_UNICODE_MAP; uint32_t code = pgm_read_dword_far(&map[index]); if (code > 0xFFFF && code <= 0x10ffff && input_mode == UC_OSX) { // Convert to UTF-16 surrogate pair -- cgit v1.2.3-24-g4f1b From cbabb4d417ef58f5d484dc256b637f61619efaa8 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Wed, 15 Feb 2017 16:36:31 -0500 Subject: split up unicode systems into different files --- quantum/process_keycode/process_unicode.c | 200 ------------------------------ 1 file changed, 200 deletions(-) (limited to 'quantum/process_keycode/process_unicode.c') diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c index 9d01a592d..898e168a3 100644 --- a/quantum/process_keycode/process_unicode.c +++ b/quantum/process_keycode/process_unicode.c @@ -4,18 +4,6 @@ static uint8_t input_mode; uint8_t mods; -__attribute__((weak)) -uint16_t hex_to_keycode(uint8_t hex) -{ - if (hex == 0x0) { - return KC_0; - } else if (hex < 0xA) { - return KC_1 + (hex - 0x1); - } else { - return KC_A + (hex - 0xA); - } -} - void set_unicode_input_mode(uint8_t os_target) { input_mode = os_target; @@ -108,191 +96,3 @@ bool process_unicode(uint16_t keycode, keyrecord_t *record) { return true; } -#ifdef UNICODEMAP_ENABLE -__attribute__((weak)) -const uint32_t PROGMEM unicode_map[] = { -}; - -void register_hex32(uint32_t hex) { - uint8_t onzerostart = 1; - for(int i = 7; i >= 0; i--) { - if (i <= 3) { - onzerostart = 0; - } - uint8_t digit = ((hex >> (i*4)) & 0xF); - if (digit == 0) { - if (onzerostart == 0) { - register_code(hex_to_keycode(digit)); - unregister_code(hex_to_keycode(digit)); - } - } else { - register_code(hex_to_keycode(digit)); - unregister_code(hex_to_keycode(digit)); - onzerostart = 0; - } - } -} - -__attribute__((weak)) -void unicode_map_input_error() {} - -bool process_unicode_map(uint16_t keycode, keyrecord_t *record) { - if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) { - const uint32_t* map = unicode_map; - uint16_t index = keycode - QK_UNICODE_MAP; - uint32_t code = pgm_read_dword_far(&map[index]); - if (code > 0xFFFF && code <= 0x10ffff && input_mode == UC_OSX) { - // Convert to UTF-16 surrogate pair - code -= 0x10000; - uint32_t lo = code & 0x3ff; - uint32_t hi = (code & 0xffc00) >> 10; - unicode_input_start(); - register_hex32(hi + 0xd800); - register_hex32(lo + 0xdc00); - unicode_input_finish(); - } 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 { - unicode_input_start(); - register_hex32(code); - unicode_input_finish(); - } - } - return true; -} -#endif - -#ifdef UCIS_ENABLE -qk_ucis_state_t qk_ucis_state; - -void qk_ucis_start(void) { - qk_ucis_state.count = 0; - qk_ucis_state.in_progress = true; - - qk_ucis_start_user(); -} - -__attribute__((weak)) -void qk_ucis_start_user(void) { - unicode_input_start(); - register_hex(0x2328); - unicode_input_finish(); -} - -static bool is_uni_seq(char *seq) { - uint8_t i; - - for (i = 0; seq[i]; i++) { - uint16_t code; - if (('1' <= seq[i]) && (seq[i] <= '0')) - code = seq[i] - '1' + KC_1; - else - code = seq[i] - 'a' + KC_A; - - if (i > qk_ucis_state.count || qk_ucis_state.codes[i] != code) - return false; - } - - return (qk_ucis_state.codes[i] == KC_ENT || - qk_ucis_state.codes[i] == KC_SPC); -} - -__attribute__((weak)) -void qk_ucis_symbol_fallback (void) { - 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); - } -} - -void register_ucis(const char *hex) { - for(int i = 0; hex[i]; i++) { - uint8_t kc = 0; - char c = hex[i]; - - switch (c) { - case '0': - kc = KC_0; - break; - case '1' ... '9': - kc = c - '1' + KC_1; - break; - case 'a' ... 'f': - kc = c - 'a' + KC_A; - break; - case 'A' ... 'F': - kc = c - 'A' + KC_A; - break; - } - - if (kc) { - register_code (kc); - unregister_code (kc); - wait_ms (UNICODE_TYPE_DELAY); - } - } -} - -bool process_ucis (uint16_t keycode, keyrecord_t *record) { - uint8_t i; - - if (!qk_ucis_state.in_progress) - return true; - - if (qk_ucis_state.count >= UCIS_MAX_SYMBOL_LENGTH && - !(keycode == KC_BSPC || keycode == KC_ESC || keycode == KC_SPC || keycode == KC_ENT)) { - return false; - } - - if (!record->event.pressed) - return true; - - qk_ucis_state.codes[qk_ucis_state.count] = keycode; - qk_ucis_state.count++; - - if (keycode == KC_BSPC) { - if (qk_ucis_state.count >= 2) { - qk_ucis_state.count -= 2; - return true; - } else { - qk_ucis_state.count--; - return false; - } - } - - if (keycode == KC_ENT || keycode == KC_SPC || keycode == KC_ESC) { - bool symbol_found = false; - - for (i = qk_ucis_state.count; i > 0; i--) { - register_code (KC_BSPC); - unregister_code (KC_BSPC); - wait_ms(UNICODE_TYPE_DELAY); - } - - if (keycode == KC_ESC) { - qk_ucis_state.in_progress = false; - return false; - } - - unicode_input_start(); - for (i = 0; ucis_symbol_table[i].symbol; i++) { - if (is_uni_seq (ucis_symbol_table[i].symbol)) { - symbol_found = true; - register_ucis(ucis_symbol_table[i].code + 2); - break; - } - } - if (!symbol_found) { - qk_ucis_symbol_fallback(); - } - unicode_input_finish(); - - qk_ucis_state.in_progress = false; - return false; - } - return true; -} -#endif -- cgit v1.2.3-24-g4f1b From 09add35e7f0b17f720862bc9b0f8478763937328 Mon Sep 17 00:00:00 2001 From: Jack Humbert Date: Wed, 15 Feb 2017 17:09:35 -0500 Subject: add unicode common file, get names right --- quantum/process_keycode/process_unicode.c | 85 ------------------------------- 1 file changed, 85 deletions(-) (limited to 'quantum/process_keycode/process_unicode.c') diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c index 898e168a3..ccae6fdca 100644 --- a/quantum/process_keycode/process_unicode.c +++ b/quantum/process_keycode/process_unicode.c @@ -1,91 +1,6 @@ #include "process_unicode.h" #include "action_util.h" -static uint8_t input_mode; -uint8_t mods; - -void set_unicode_input_mode(uint8_t os_target) -{ - input_mode = os_target; -} - -uint8_t get_unicode_input_mode(void) { - return input_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); - - switch(input_mode) { - case UC_OSX: - register_code(KC_LALT); - break; - case UC_LNX: - register_code(KC_LCTL); - register_code(KC_LSFT); - register_code(KC_U); - unregister_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); - break; - case UC_WINC: - register_code(KC_RALT); - unregister_code(KC_RALT); - register_code(KC_U); - unregister_code(KC_U); - } - wait_ms(UNICODE_TYPE_DELAY); -} - -__attribute__((weak)) -void unicode_input_finish (void) { - switch(input_mode) { - case UC_OSX: - case UC_WIN: - unregister_code(KC_LALT); - break; - case UC_LNX: - register_code(KC_SPC); - unregister_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); -} - -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)); - } -} - bool process_unicode(uint16_t keycode, keyrecord_t *record) { if (keycode > QK_UNICODE && record->event.pressed) { uint16_t unicode = keycode & 0x7FFF; -- cgit v1.2.3-24-g4f1b From 23839b8c6d2f955e4da89b0981948c721346c528 Mon Sep 17 00:00:00 2001 From: skullydazed Date: Tue, 28 Mar 2017 15:20:36 -0700 Subject: Clarify the quantum license (#1042) * Clarify the license for files we have signoff on * Update against the currently signed off files * Remove unused and not clearly licensed headers * Replace an #endif I accidentally removed while resolving merge conflicts --- quantum/process_keycode/process_unicode.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'quantum/process_keycode/process_unicode.c') diff --git a/quantum/process_keycode/process_unicode.c b/quantum/process_keycode/process_unicode.c index ccae6fdca..26571ea03 100644 --- a/quantum/process_keycode/process_unicode.c +++ b/quantum/process_keycode/process_unicode.c @@ -1,3 +1,18 @@ +/* Copyright 2016 Jack Humbert + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #include "process_unicode.h" #include "action_util.h" -- cgit v1.2.3-24-g4f1b