Skip to content

Commit 3d667f0

Browse files
authored
Refactor Unicode feature (#18333)
1 parent 4087251 commit 3d667f0

15 files changed

+591
-506
lines changed

builddefs/common_features.mk

+3-1
Original file line numberDiff line numberDiff line change
@@ -773,8 +773,10 @@ endif
773773

774774
ifeq ($(strip $(UNICODE_COMMON)), yes)
775775
OPT_DEFS += -DUNICODE_COMMON_ENABLE
776+
COMMON_VPATH += $(QUANTUM_DIR)/unicode
776777
SRC += $(QUANTUM_DIR)/process_keycode/process_unicode_common.c \
777-
$(QUANTUM_DIR)/utf8.c
778+
$(QUANTUM_DIR)/unicode/unicode.c \
779+
$(QUANTUM_DIR)/unicode/utf8.c
778780
endif
779781

780782
MAGIC_ENABLE ?= yes

quantum/painter/rules.mk

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ VALID_QUANTUM_PAINTER_DRIVERS := ili9163_spi ili9341_spi ili9488_spi st7789_spi
88
#-------------------------------------------------------------------------------
99

1010
OPT_DEFS += -DQUANTUM_PAINTER_ENABLE
11-
COMMON_VPATH += $(QUANTUM_DIR)/painter
11+
COMMON_VPATH += $(QUANTUM_DIR)/painter \
12+
$(QUANTUM_DIR)/unicode
1213
SRC += \
13-
$(QUANTUM_DIR)/utf8.c \
14+
$(QUANTUM_DIR)/unicode/utf8.c \
1415
$(QUANTUM_DIR)/color.c \
1516
$(QUANTUM_DIR)/painter/qp.c \
1617
$(QUANTUM_DIR)/painter/qp_stream.c \

quantum/process_keycode/process_ucis.c

+6-11
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
*/
1616

1717
#include "process_ucis.h"
18+
#include "unicode.h"
19+
#include "keycode.h"
20+
#include "wait.h"
1821

1922
qk_ucis_state_t qk_ucis_state;
2023

@@ -26,9 +29,7 @@ void qk_ucis_start(void) {
2629
}
2730

2831
__attribute__((weak)) void qk_ucis_start_user(void) {
29-
unicode_input_start();
30-
register_hex(0x2328); // ⌨
31-
unicode_input_finish();
32+
register_unicode(0x2328); // ⌨
3233
}
3334

3435
__attribute__((weak)) void qk_ucis_success(uint8_t symbol_index) {}
@@ -51,10 +52,7 @@ static bool is_uni_seq(char *seq) {
5152

5253
__attribute__((weak)) void qk_ucis_symbol_fallback(void) {
5354
for (uint8_t i = 0; i < qk_ucis_state.count - 1; i++) {
54-
uint8_t keycode = qk_ucis_state.codes[i];
55-
register_code(keycode);
56-
unregister_code(keycode);
57-
wait_ms(UNICODE_TYPE_DELAY);
55+
tap_code(qk_ucis_state.codes[i]);
5856
}
5957
}
6058

@@ -63,7 +61,6 @@ __attribute__((weak)) void qk_ucis_cancel(void) {}
6361
void register_ucis(const uint32_t *code_points) {
6462
for (int i = 0; i < UCIS_MAX_CODE_POINTS && code_points[i]; i++) {
6563
register_unicode(code_points[i]);
66-
wait_ms(UNICODE_TYPE_DELAY);
6764
}
6865
}
6966

@@ -94,9 +91,7 @@ bool process_ucis(uint16_t keycode, keyrecord_t *record) {
9491
case KC_ENTER:
9592
case KC_ESCAPE:
9693
for (uint8_t i = 0; i < qk_ucis_state.count; i++) {
97-
register_code(KC_BACKSPACE);
98-
unregister_code(KC_BACKSPACE);
99-
wait_ms(UNICODE_TYPE_DELAY);
94+
tap_code(KC_BACKSPACE);
10095
}
10196

10297
if (keycode == KC_ESCAPE) {

quantum/process_keycode/process_ucis.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,10 @@
1616

1717
#pragma once
1818

19-
#include "quantum.h"
20-
#include "process_unicode_common.h"
19+
#include <stdbool.h>
20+
#include <stdint.h>
21+
22+
#include "action.h"
2123

2224
#ifndef UCIS_MAX_SYMBOL_LENGTH
2325
# define UCIS_MAX_SYMBOL_LENGTH 32

quantum/process_keycode/process_unicode.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
*/
1616

1717
#include "process_unicode.h"
18-
#include "action_util.h"
19-
#include "eeprom.h"
18+
#include "unicode.h"
19+
#include "quantum_keycodes.h"
2020

2121
bool process_unicode(uint16_t keycode, keyrecord_t *record) {
22-
if (keycode >= QK_UNICODE && keycode <= QK_UNICODE_MAX && record->event.pressed) {
23-
unicode_input_start();
24-
register_hex(keycode & 0x7FFF);
25-
unicode_input_finish();
22+
if (record->event.pressed) {
23+
if (keycode >= QK_UNICODE && keycode <= QK_UNICODE_MAX) {
24+
register_unicode(keycode & 0x7FFF);
25+
}
2626
}
2727
return true;
2828
}

quantum/process_keycode/process_unicode.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616

1717
#pragma once
1818

19-
#include "process_unicode_common.h"
19+
#include <stdbool.h>
20+
#include <stdint.h>
21+
22+
#include "action.h"
2023

2124
bool process_unicode(uint16_t keycode, keyrecord_t *record);

0 commit comments

Comments
 (0)