aboutsummaryrefslogtreecommitdiff
path: root/quantum/process_keycode
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/process_keycode')
-rw-r--r--quantum/process_keycode/process_combo.c18
-rw-r--r--quantum/process_keycode/process_combo.h1
-rw-r--r--quantum/process_keycode/process_terminal.c6
-rw-r--r--quantum/process_keycode/process_unicode_common.c2
-rw-r--r--quantum/process_keycode/process_unicodemap.c33
-rw-r--r--quantum/process_keycode/process_unicodemap.h4
6 files changed, 35 insertions, 29 deletions
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c
index 6e9c28e4f..13f8bbb33 100644
--- a/quantum/process_keycode/process_combo.c
+++ b/quantum/process_keycode/process_combo.c
@@ -18,9 +18,6 @@
18#include "print.h" 18#include "print.h"
19 19
20 20
21#define COMBO_TIMER_ELAPSED -1
22
23
24__attribute__ ((weak)) 21__attribute__ ((weak))
25combo_t key_combos[COMBO_COUNT] = { 22combo_t key_combos[COMBO_COUNT] = {
26 23
@@ -65,7 +62,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
65 if (-1 == (int8_t)index) return false; 62 if (-1 == (int8_t)index) return false;
66 63
67 /* The combos timer is used to signal whether the combo is active */ 64 /* The combos timer is used to signal whether the combo is active */
68 bool is_combo_active = COMBO_TIMER_ELAPSED == combo->timer ? false : true; 65 bool is_combo_active = combo->is_active;
69 66
70 if (record->event.pressed) { 67 if (record->event.pressed) {
71 KEY_STATE_DOWN(index); 68 KEY_STATE_DOWN(index);
@@ -73,9 +70,10 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
73 if (is_combo_active) { 70 if (is_combo_active) {
74 if (ALL_COMBO_KEYS_ARE_DOWN) { /* Combo was pressed */ 71 if (ALL_COMBO_KEYS_ARE_DOWN) { /* Combo was pressed */
75 send_combo(combo->keycode, true); 72 send_combo(combo->keycode, true);
76 combo->timer = COMBO_TIMER_ELAPSED; 73 combo->is_active = false;
77 } else { /* Combo key was pressed */ 74 } else { /* Combo key was pressed */
78 combo->timer = timer_read(); 75 combo->timer = timer_read();
76 combo->is_active = true;
79#ifdef COMBO_ALLOW_ACTION_KEYS 77#ifdef COMBO_ALLOW_ACTION_KEYS
80 combo->prev_record = *record; 78 combo->prev_record = *record;
81#else 79#else
@@ -99,6 +97,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
99 send_keyboard_report(); 97 send_keyboard_report();
100 unregister_code16(keycode); 98 unregister_code16(keycode);
101#endif 99#endif
100 combo->is_active = false;
102 combo->timer = 0; 101 combo->timer = 0;
103 } 102 }
104 103
@@ -106,6 +105,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *
106 } 105 }
107 106
108 if (NO_COMBO_KEYS_ARE_DOWN) { 107 if (NO_COMBO_KEYS_ARE_DOWN) {
108 combo->is_active = true;
109 combo->timer = 0; 109 combo->timer = 0;
110 } 110 }
111 111
@@ -132,14 +132,14 @@ void matrix_scan_combo(void)
132 #pragma GCC diagnostic ignored "-Warray-bounds" 132 #pragma GCC diagnostic ignored "-Warray-bounds"
133 combo_t *combo = &key_combos[i]; 133 combo_t *combo = &key_combos[i];
134 #pragma GCC diagnostic pop 134 #pragma GCC diagnostic pop
135 if (combo->timer && 135 if (combo->is_active &&
136 combo->timer != COMBO_TIMER_ELAPSED && 136 combo->timer &&
137 timer_elapsed(combo->timer) > COMBO_TERM) { 137 timer_elapsed(combo->timer) > COMBO_TERM) {
138 138
139 /* This disables the combo, meaning key events for this 139 /* This disables the combo, meaning key events for this
140 * combo will be handled by the next processors in the chain 140 * combo will be handled by the next processors in the chain
141 */ 141 */
142 combo->timer = COMBO_TIMER_ELAPSED; 142 combo->is_active = false;
143 143
144#ifdef COMBO_ALLOW_ACTION_KEYS 144#ifdef COMBO_ALLOW_ACTION_KEYS
145 process_action(&combo->prev_record, 145 process_action(&combo->prev_record,
diff --git a/quantum/process_keycode/process_combo.h b/quantum/process_keycode/process_combo.h
index a5dbd788a..a5787c9ed 100644
--- a/quantum/process_keycode/process_combo.h
+++ b/quantum/process_keycode/process_combo.h
@@ -33,6 +33,7 @@ typedef struct
33 uint8_t state; 33 uint8_t state;
34#endif 34#endif
35 uint16_t timer; 35 uint16_t timer;
36 bool is_active;
36#ifdef COMBO_ALLOW_ACTION_KEYS 37#ifdef COMBO_ALLOW_ACTION_KEYS
37 keyrecord_t prev_record; 38 keyrecord_t prev_record;
38#else 39#else
diff --git a/quantum/process_keycode/process_terminal.c b/quantum/process_keycode/process_terminal.c
index 6998639f2..e791deffc 100644
--- a/quantum/process_keycode/process_terminal.c
+++ b/quantum/process_keycode/process_terminal.c
@@ -273,11 +273,17 @@ bool process_terminal(uint16_t keycode, keyrecord_t *record) {
273 disable_terminal(); 273 disable_terminal();
274 return false; 274 return false;
275 } 275 }
276
277 if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) {
278 keycode = keycode & 0xFF;
279 }
280
276 if (keycode < 256) { 281 if (keycode < 256) {
277 uint8_t str_len; 282 uint8_t str_len;
278 char char_to_add; 283 char char_to_add;
279 switch (keycode) { 284 switch (keycode) {
280 case KC_ENTER: 285 case KC_ENTER:
286 case KC_KP_ENTER:
281 push_to_cmd_buffer(); 287 push_to_cmd_buffer();
282 current_cmd_buffer_pos = 0; 288 current_cmd_buffer_pos = 0;
283 process_terminal_command(); 289 process_terminal_command();
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c
index 3286f45b5..b64feb700 100644
--- a/quantum/process_keycode/process_unicode_common.c
+++ b/quantum/process_keycode/process_unicode_common.c
@@ -216,7 +216,7 @@ bool process_unicode_common(uint16_t keycode, keyrecord_t *record) {
216#if defined(UNICODE_ENABLE) 216#if defined(UNICODE_ENABLE)
217 return process_unicode(keycode, record); 217 return process_unicode(keycode, record);
218#elif defined(UNICODEMAP_ENABLE) 218#elif defined(UNICODEMAP_ENABLE)
219 return process_unicode_map(keycode, record); 219 return process_unicodemap(keycode, record);
220#elif defined(UCIS_ENABLE) 220#elif defined(UCIS_ENABLE)
221 return process_ucis(keycode, record); 221 return process_ucis(keycode, record);
222#else 222#else
diff --git a/quantum/process_keycode/process_unicodemap.c b/quantum/process_keycode/process_unicodemap.c
index 75f35112b..cee9acb5f 100644
--- a/quantum/process_keycode/process_unicodemap.c
+++ b/quantum/process_keycode/process_unicodemap.c
@@ -18,8 +18,7 @@
18#include "process_unicode_common.h" 18#include "process_unicode_common.h"
19 19
20__attribute__((weak)) 20__attribute__((weak))
21const uint32_t PROGMEM unicode_map[] = { 21const uint32_t PROGMEM unicode_map[] = {};
22};
23 22
24void register_hex32(uint32_t hex) { 23void register_hex32(uint32_t hex) {
25 bool onzerostart = true; 24 bool onzerostart = true;
@@ -42,26 +41,26 @@ void register_hex32(uint32_t hex) {
42} 41}
43 42
44__attribute__((weak)) 43__attribute__((weak))
45void unicode_map_input_error() {} 44void unicodemap_input_error() {}
46 45
47bool process_unicode_map(uint16_t keycode, keyrecord_t *record) { 46bool process_unicodemap(uint16_t keycode, keyrecord_t *record) {
48 uint8_t input_mode = get_unicode_input_mode(); 47 if ((keycode & QK_UNICODEMAP) == QK_UNICODEMAP && record->event.pressed) {
49 if ((keycode & QK_UNICODE_MAP) == QK_UNICODE_MAP && record->event.pressed) { 48 uint16_t index = keycode - QK_UNICODEMAP;
50 const uint32_t* map = unicode_map; 49 uint32_t code = pgm_read_dword(unicode_map + index);
51 uint16_t index = keycode - QK_UNICODE_MAP; 50 uint8_t input_mode = get_unicode_input_mode();
52 uint32_t code = pgm_read_dword(&map[index]); 51
53 if (code > 0xFFFF && code <= 0x10ffff && input_mode == UC_OSX) { 52 if (code > 0xFFFF && code <= 0x10FFFF && input_mode == UC_OSX) {
54 // Convert to UTF-16 surrogate pair 53 // Convert to UTF-16 surrogate pair
55 code -= 0x10000; 54 code -= 0x10000;
56 uint32_t lo = code & 0x3ff; 55 uint32_t lo = code & 0x3FF, hi = (code & 0xFFC00) >> 10;
57 uint32_t hi = (code & 0xffc00) >> 10; 56
58 unicode_input_start(); 57 unicode_input_start();
59 register_hex32(hi + 0xd800); 58 register_hex32(hi + 0xD800);
60 register_hex32(lo + 0xdc00); 59 register_hex32(lo + 0xDC00);
61 unicode_input_finish(); 60 unicode_input_finish();
62 } else if ((code > 0x10ffff && input_mode == UC_OSX) || (code > 0xFFFFF && input_mode == UC_LNX)) { 61 } else if ((code > 0x10FFFF && input_mode == UC_OSX) || (code > 0xFFFFF && input_mode == UC_LNX)) {
63 // when character is out of range supported by the OS 62 // Character is out of range supported by the OS
64 unicode_map_input_error(); 63 unicodemap_input_error();
65 } else { 64 } else {
66 unicode_input_start(); 65 unicode_input_start();
67 register_hex32(code); 66 register_hex32(code);
diff --git a/quantum/process_keycode/process_unicodemap.h b/quantum/process_keycode/process_unicodemap.h
index f6d64bb86..5764697f8 100644
--- a/quantum/process_keycode/process_unicodemap.h
+++ b/quantum/process_keycode/process_unicodemap.h
@@ -19,5 +19,5 @@
19#include "quantum.h" 19#include "quantum.h"
20#include "process_unicode_common.h" 20#include "process_unicode_common.h"
21 21
22void unicode_map_input_error(void); 22void unicodemap_input_error(void);
23bool process_unicode_map(uint16_t keycode, keyrecord_t *record); 23bool process_unicodemap(uint16_t keycode, keyrecord_t *record);