diff options
| author | Nick Brassel <nick@tzarc.org> | 2022-04-13 18:00:18 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-13 18:00:18 +1000 |
| commit | 1f2b1dedccdf21b629c45ece80b4ca32f6653296 (patch) | |
| tree | a4283b928fe11c6662be10067314531f12774152 /quantum/process_keycode/process_unicode_common.c | |
| parent | 1dbbd2b6b068b9f921ebc0341c890df16a491007 (diff) | |
Quantum Painter (#10174)
* Install dependencies before executing unit tests.
* Split out UTF-8 decoder.
* Fixup python formatting rules.
* Add documentation for QGF/QFF and the RLE format used.
* Add CLI commands for converting images and fonts.
* Add stub rules.mk for QP.
* Add stream type.
* Add base driver and comms interfaces.
* Add support for SPI, SPI+D/C comms drivers.
* Include <qp.h> when enabled.
* Add base support for SPI+D/C+RST panels, as well as concrete implementation of ST7789.
* Add support for GC9A01.
* Add support for ILI9341.
* Add support for ILI9163.
* Add support for SSD1351.
* Implement qp_setpixel, including pixdata buffer management.
* Implement qp_line.
* Implement qp_rect.
* Implement qp_circle.
* Implement qp_ellipse.
* Implement palette interpolation.
* Allow for streams to work with either flash or RAM.
* Image loading.
* Font loading.
* QGF palette loading.
* Progressive decoder of pixel data supporting Raw+RLE, 1-,2-,4-,8-bpp monochrome and palette-based images.
* Image drawing.
* Animations.
* Font rendering.
* Check against 256 colours, dump out the loaded palette if debugging enabled.
* Fix build.
* AVR is not the intended audience.
* `qmk format-c`
* Generation fix.
* First batch of docs.
* More docs and examples.
* Review comments.
* Public API documentation.
Diffstat (limited to 'quantum/process_keycode/process_unicode_common.c')
| -rw-r--r-- | quantum/process_keycode/process_unicode_common.c | 30 |
1 files changed, 1 insertions, 29 deletions
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 2606ea1f37..652becbc9a 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | 16 | ||
| 17 | #include "process_unicode_common.h" | 17 | #include "process_unicode_common.h" |
| 18 | #include "eeprom.h" | 18 | #include "eeprom.h" |
| 19 | #include "utf8.h" | ||
| 19 | 20 | ||
| 20 | unicode_config_t unicode_config; | 21 | unicode_config_t unicode_config; |
| 21 | uint8_t unicode_saved_mods; | 22 | uint8_t unicode_saved_mods; |
| @@ -229,35 +230,6 @@ void register_unicode(uint32_t code_point) { | |||
| 229 | unicode_input_finish(); | 230 | unicode_input_finish(); |
| 230 | } | 231 | } |
| 231 | 232 | ||
| 232 | // Borrowed from https://nullprogram.com/blog/2017/10/06/ | ||
| 233 | static const char *decode_utf8(const char *str, int32_t *code_point) { | ||
| 234 | const char *next; | ||
| 235 | |||
| 236 | if (str[0] < 0x80) { // U+0000-007F | ||
| 237 | *code_point = str[0]; | ||
| 238 | next = str + 1; | ||
| 239 | } else if ((str[0] & 0xE0) == 0xC0) { // U+0080-07FF | ||
| 240 | *code_point = ((int32_t)(str[0] & 0x1F) << 6) | ((int32_t)(str[1] & 0x3F) << 0); | ||
| 241 | next = str + 2; | ||
| 242 | } else if ((str[0] & 0xF0) == 0xE0) { // U+0800-FFFF | ||
| 243 | *code_point = ((int32_t)(str[0] & 0x0F) << 12) | ((int32_t)(str[1] & 0x3F) << 6) | ((int32_t)(str[2] & 0x3F) << 0); | ||
| 244 | next = str + 3; | ||
| 245 | } else if ((str[0] & 0xF8) == 0xF0 && (str[0] <= 0xF4)) { // U+10000-10FFFF | ||
| 246 | *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); | ||
| 247 | next = str + 4; | ||
| 248 | } else { | ||
| 249 | *code_point = -1; | ||
| 250 | next = str + 1; | ||
| 251 | } | ||
| 252 | |||
| 253 | // part of a UTF-16 surrogate pair - invalid | ||
| 254 | if (*code_point >= 0xD800 && *code_point <= 0xDFFF) { | ||
| 255 | *code_point = -1; | ||
| 256 | } | ||
| 257 | |||
| 258 | return next; | ||
| 259 | } | ||
| 260 | |||
| 261 | void send_unicode_string(const char *str) { | 233 | void send_unicode_string(const char *str) { |
| 262 | if (!str) { | 234 | if (!str) { |
| 263 | return; | 235 | return; |
