summaryrefslogtreecommitdiff
path: root/quantum/process_keycode
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r--quantum/process_keycode/process_leader.c2
-rw-r--r--quantum/process_keycode/process_unicode_common.c19
-rw-r--r--quantum/process_keycode/process_unicode_common.h3
3 files changed, 22 insertions, 2 deletions
diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c
index ae00b3227a..3593f75f0d 100644
--- a/quantum/process_keycode/process_leader.c
+++ b/quantum/process_keycode/process_leader.c
@@ -58,7 +58,7 @@ bool process_leader(uint16_t keycode, keyrecord_t *record) {
keycode = keycode & 0xFF;
}
# endif // LEADER_KEY_STRICT_KEY_PROCESSING
- if (leader_sequence_size < (sizeof(leader_sequence) / sizeof(leader_sequence[0]))) {
+ if (leader_sequence_size < ARRAY_SIZE(leader_sequence)) {
leader_sequence[leader_sequence_size] = keycode;
leader_sequence_size++;
} else {
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c
index 8de31c055c..94809cf029 100644
--- a/quantum/process_keycode/process_unicode_common.c
+++ b/quantum/process_keycode/process_unicode_common.c
@@ -25,10 +25,24 @@ bool unicode_saved_num_lock;
#if UNICODE_SELECTED_MODES != -1
static uint8_t selected[] = {UNICODE_SELECTED_MODES};
-static int8_t selected_count = sizeof selected / sizeof *selected;
+static int8_t selected_count = ARRAY_SIZE(selected);
static int8_t selected_index;
#endif
+/** \brief Uunicode input mode set at user level
+ *
+ * Run user code on unicode input mode change
+ */
+__attribute__((weak)) void unicode_input_mode_set_user(uint8_t input_mode) {}
+
+/** \brief unicode input mode set at keyboard level
+ *
+ * Run keyboard code on unicode input mode change
+ */
+__attribute__((weak)) void unicode_input_mode_set_kb(uint8_t input_mode) {
+ unicode_input_mode_set_user(input_mode);
+}
+
void unicode_input_mode_init(void) {
unicode_config.raw = eeprom_read_byte(EECONFIG_UNICODEMODE);
#if UNICODE_SELECTED_MODES != -1
@@ -50,6 +64,7 @@ void unicode_input_mode_init(void) {
unicode_config.input_mode = selected[selected_index = 0];
# endif
#endif
+ unicode_input_mode_set_kb(unicode_config.input_mode);
dprintf("Unicode input mode init to: %u\n", unicode_config.input_mode);
}
@@ -60,6 +75,7 @@ uint8_t get_unicode_input_mode(void) {
void set_unicode_input_mode(uint8_t mode) {
unicode_config.input_mode = mode;
persist_unicode_input_mode();
+ unicode_input_mode_set_kb(mode);
dprintf("Unicode input mode set to: %u\n", unicode_config.input_mode);
}
@@ -73,6 +89,7 @@ void cycle_unicode_input_mode(int8_t offset) {
# if UNICODE_CYCLE_PERSIST
persist_unicode_input_mode();
# endif
+ unicode_input_mode_set_kb(unicode_config.input_mode);
dprintf("Unicode input mode cycle to: %u\n", unicode_config.input_mode);
#endif
}
diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h
index 15e798dbb3..bdc7a1dedd 100644
--- a/quantum/process_keycode/process_unicode_common.h
+++ b/quantum/process_keycode/process_unicode_common.h
@@ -87,6 +87,9 @@ void unicode_input_start(void);
void unicode_input_finish(void);
void unicode_input_cancel(void);
+void unicode_input_mode_set_user(uint8_t input_mode);
+void unicode_input_mode_set_kb(uint8_t input_mode);
+
void register_hex(uint16_t hex);
void register_hex32(uint32_t hex);
void register_unicode(uint32_t code_point);