summaryrefslogtreecommitdiff
path: root/quantum
diff options
context:
space:
mode:
authorRyan <fauxpark@gmail.com>2020-02-25 12:54:51 +1100
committerGitHub <noreply@github.com>2020-02-25 12:54:51 +1100
commitbb8d4b4d23ee04f6034f8880b8a9f93fa4673c38 (patch)
tree369bef3cc7ed134775fe25ef81948289023779ec /quantum
parent93c5307fd60c35780921570ccf41a1806847eb9c (diff)
`send_unicode_string()`: Add support for code points > 0xFFFF (#8236)
Diffstat (limited to 'quantum')
-rw-r--r--quantum/process_keycode/process_unicode_common.c24
-rw-r--r--quantum/process_keycode/process_unicode_common.h1
-rw-r--r--quantum/process_keycode/process_unicodemap.c20
-rw-r--r--quantum/process_keycode/process_unicodemap.h1
4 files changed, 21 insertions, 25 deletions
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c
index 4ac305e661..fc392813ae 100644
--- a/quantum/process_keycode/process_unicode_common.c
+++ b/quantum/process_keycode/process_unicode_common.c
@@ -150,6 +150,24 @@ void register_hex(uint16_t hex) {
}
}
+void register_hex32(uint32_t hex) {
+ bool onzerostart = true;
+ for (int i = 7; i >= 0; i--) {
+ if (i <= 3) {
+ onzerostart = false;
+ }
+ uint8_t digit = ((hex >> (i * 4)) & 0xF);
+ if (digit == 0) {
+ if (!onzerostart) {
+ tap_code(hex_to_keycode(digit));
+ }
+ } else {
+ tap_code(hex_to_keycode(digit));
+ onzerostart = false;
+ }
+ }
+}
+
void send_unicode_hex_string(const char *str) {
if (!str) {
return;
@@ -192,9 +210,7 @@ const char *decode_utf8(const char *str, int32_t *code_point) {
*code_point = ((int32_t)(str[0] & 0x0F) << 12) | ((int32_t)(str[1] & 0x3F) << 6) | ((int32_t)(str[2] & 0x3F) << 0);
next = str + 3;
} else if ((str[0] & 0xF8) == 0xF0 && (str[0] <= 0xF4)) { // U+10000-10FFFF
- // Skip for now - register_hex() only takes a uint16
- //*code_point = ((int32_t)(str[0] & 0x07) << 18) | ((int32_t)(str[1] & 0x3F) << 12) | ((int32_t)(str[2] & 0x3F) << 6) | ((int32_t)(str[3] & 0x3F) << 0);
- *code_point = -1;
+ *code_point = ((int32_t)(str[0] & 0x07) << 18) | ((int32_t)(str[1] & 0x3F) << 12) | ((int32_t)(str[2] & 0x3F) << 6) | ((int32_t)(str[3] & 0x3F) << 0);
next = str + 4;
} else {
*code_point = -1;
@@ -221,7 +237,7 @@ void send_unicode_string(const char *str) {
if (code_point >= 0) {
unicode_input_start();
- register_hex(code_point);
+ register_hex32(code_point);
unicode_input_finish();
}
}
diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h
index 393db2d99e..13b6431bf0 100644
--- a/quantum/process_keycode/process_unicode_common.h
+++ b/quantum/process_keycode/process_unicode_common.h
@@ -79,6 +79,7 @@ void unicode_input_finish(void);
void unicode_input_cancel(void);
void register_hex(uint16_t hex);
+void register_hex32(uint32_t hex);
void send_unicode_hex_string(const char *str);
void send_unicode_string(const char *str);
diff --git a/quantum/process_keycode/process_unicodemap.c b/quantum/process_keycode/process_unicodemap.c
index 4364f156c4..1be51a995c 100644
--- a/quantum/process_keycode/process_unicodemap.c
+++ b/quantum/process_keycode/process_unicodemap.c
@@ -16,26 +16,6 @@
#include "process_unicodemap.h"
-void register_hex32(uint32_t hex) {
- bool onzerostart = true;
- for (int i = 7; i >= 0; i--) {
- if (i <= 3) {
- onzerostart = false;
- }
- uint8_t digit = ((hex >> (i * 4)) & 0xF);
- if (digit == 0) {
- if (!onzerostart) {
- 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 = false;
- }
- }
-}
-
__attribute__((weak)) uint16_t unicodemap_index(uint16_t keycode) {
if (keycode >= QK_UNICODEMAP_PAIR) {
// Keycode is a pair: extract index based on Shift / Caps Lock state
diff --git a/quantum/process_keycode/process_unicodemap.h b/quantum/process_keycode/process_unicodemap.h
index a4b6d77f3a..c429859bbb 100644
--- a/quantum/process_keycode/process_unicodemap.h
+++ b/quantum/process_keycode/process_unicodemap.h
@@ -20,6 +20,5 @@
extern const uint32_t PROGMEM unicode_map[];
-void register_hex32(uint32_t hex);
uint16_t unicodemap_index(uint16_t keycode);
bool process_unicodemap(uint16_t keycode, keyrecord_t *record);