diff options
Diffstat (limited to 'quantum/process_keycode')
| -rw-r--r-- | quantum/process_keycode/process_auto_shift.c | 24 | ||||
| -rw-r--r-- | quantum/process_keycode/process_combo.c | 184 | ||||
| -rw-r--r-- | quantum/process_keycode/process_combo.h | 4 | ||||
| -rw-r--r-- | quantum/process_keycode/process_haptic.c | 30 | ||||
| -rw-r--r-- | quantum/process_keycode/process_music.c | 6 | ||||
| -rw-r--r-- | quantum/process_keycode/process_printer.c | 32 | ||||
| -rw-r--r-- | quantum/process_keycode/process_printer_bb.c | 32 | ||||
| -rw-r--r-- | quantum/process_keycode/process_programmable_button.c | 31 | ||||
| -rw-r--r-- | quantum/process_keycode/process_programmable_button.h | 23 | ||||
| -rw-r--r-- | quantum/process_keycode/process_space_cadet.c | 24 | ||||
| -rw-r--r-- | quantum/process_keycode/process_steno.c | 9 | ||||
| -rw-r--r-- | quantum/process_keycode/process_terminal.c | 10 | ||||
| -rw-r--r-- | quantum/process_keycode/process_ucis.c | 18 | ||||
| -rw-r--r-- | quantum/process_keycode/process_unicode_common.c | 53 | ||||
| -rw-r--r-- | quantum/process_keycode/process_unicode_common.h | 4 |
15 files changed, 289 insertions, 195 deletions
diff --git a/quantum/process_keycode/process_auto_shift.c b/quantum/process_keycode/process_auto_shift.c index 51b0efdb4..02af5174f 100644 --- a/quantum/process_keycode/process_auto_shift.c +++ b/quantum/process_keycode/process_auto_shift.c | |||
| @@ -21,6 +21,12 @@ | |||
| 21 | 21 | ||
| 22 | # include "process_auto_shift.h" | 22 | # include "process_auto_shift.h" |
| 23 | 23 | ||
| 24 | #ifndef AUTO_SHIFT_DISABLED_AT_STARTUP | ||
| 25 | # define AUTO_SHIFT_STARTUP_STATE true /* enabled */ | ||
| 26 | #else | ||
| 27 | # define AUTO_SHIFT_STARTUP_STATE false /* disabled */ | ||
| 28 | #endif | ||
| 29 | |||
| 24 | static uint16_t autoshift_time = 0; | 30 | static uint16_t autoshift_time = 0; |
| 25 | static uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT; | 31 | static uint16_t autoshift_timeout = AUTO_SHIFT_TIMEOUT; |
| 26 | static uint16_t autoshift_lastkey = KC_NO; | 32 | static uint16_t autoshift_lastkey = KC_NO; |
| @@ -34,7 +40,7 @@ static struct { | |||
| 34 | bool in_progress : 1; | 40 | bool in_progress : 1; |
| 35 | // Whether the auto-shifted keypress has been registered. | 41 | // Whether the auto-shifted keypress has been registered. |
| 36 | bool holding_shift : 1; | 42 | bool holding_shift : 1; |
| 37 | } autoshift_flags = {true, false, false, false}; | 43 | } autoshift_flags = {AUTO_SHIFT_STARTUP_STATE, false, false, false}; |
| 38 | 44 | ||
| 39 | /** \brief Record the press of an autoshiftable key | 45 | /** \brief Record the press of an autoshiftable key |
| 40 | * | 46 | * |
| @@ -61,7 +67,7 @@ static bool autoshift_press(uint16_t keycode, uint16_t now, keyrecord_t *record) | |||
| 61 | register_code(autoshift_lastkey); | 67 | register_code(autoshift_lastkey); |
| 62 | } else { | 68 | } else { |
| 63 | // Simulate pressing the shift key. | 69 | // Simulate pressing the shift key. |
| 64 | add_weak_mods(MOD_BIT(KC_LSFT)); | 70 | add_weak_mods(MOD_BIT(KC_LEFT_SHIFT)); |
| 65 | register_code(autoshift_lastkey); | 71 | register_code(autoshift_lastkey); |
| 66 | } | 72 | } |
| 67 | return false; | 73 | return false; |
| @@ -102,7 +108,7 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger) { | |||
| 102 | autoshift_flags.lastshifted = false; | 108 | autoshift_flags.lastshifted = false; |
| 103 | } else { | 109 | } else { |
| 104 | // Simulate pressing the shift key. | 110 | // Simulate pressing the shift key. |
| 105 | add_weak_mods(MOD_BIT(KC_LSFT)); | 111 | add_weak_mods(MOD_BIT(KC_LEFT_SHIFT)); |
| 106 | register_code(autoshift_lastkey); | 112 | register_code(autoshift_lastkey); |
| 107 | autoshift_flags.lastshifted = true; | 113 | autoshift_flags.lastshifted = true; |
| 108 | # if defined(AUTO_SHIFT_REPEAT) && !defined(AUTO_SHIFT_NO_AUTO_REPEAT) | 114 | # if defined(AUTO_SHIFT_REPEAT) && !defined(AUTO_SHIFT_NO_AUTO_REPEAT) |
| @@ -117,7 +123,7 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger) { | |||
| 117 | wait_ms(TAP_CODE_DELAY); | 123 | wait_ms(TAP_CODE_DELAY); |
| 118 | # endif | 124 | # endif |
| 119 | unregister_code(autoshift_lastkey); | 125 | unregister_code(autoshift_lastkey); |
| 120 | del_weak_mods(MOD_BIT(KC_LSFT)); | 126 | del_weak_mods(MOD_BIT(KC_LEFT_SHIFT)); |
| 121 | } else { | 127 | } else { |
| 122 | // Release after keyrepeat. | 128 | // Release after keyrepeat. |
| 123 | unregister_code(keycode); | 129 | unregister_code(keycode); |
| @@ -125,7 +131,7 @@ static void autoshift_end(uint16_t keycode, uint16_t now, bool matrix_trigger) { | |||
| 125 | // This will only fire when the key was the last auto-shiftable | 131 | // This will only fire when the key was the last auto-shiftable |
| 126 | // pressed. That prevents aaaaBBBB then releasing a from unshifting | 132 | // pressed. That prevents aaaaBBBB then releasing a from unshifting |
| 127 | // later Bs (if B wasn't auto-shiftable). | 133 | // later Bs (if B wasn't auto-shiftable). |
| 128 | del_weak_mods(MOD_BIT(KC_LSFT)); | 134 | del_weak_mods(MOD_BIT(KC_LEFT_SHIFT)); |
| 129 | } | 135 | } |
| 130 | } | 136 | } |
| 131 | send_keyboard_report(); // del_weak_mods doesn't send one. | 137 | send_keyboard_report(); // del_weak_mods doesn't send one. |
| @@ -151,14 +157,14 @@ void autoshift_matrix_scan(void) { | |||
| 151 | 157 | ||
| 152 | void autoshift_toggle(void) { | 158 | void autoshift_toggle(void) { |
| 153 | autoshift_flags.enabled = !autoshift_flags.enabled; | 159 | autoshift_flags.enabled = !autoshift_flags.enabled; |
| 154 | del_weak_mods(MOD_BIT(KC_LSFT)); | 160 | del_weak_mods(MOD_BIT(KC_LEFT_SHIFT)); |
| 155 | } | 161 | } |
| 156 | 162 | ||
| 157 | void autoshift_enable(void) { autoshift_flags.enabled = true; } | 163 | void autoshift_enable(void) { autoshift_flags.enabled = true; } |
| 158 | 164 | ||
| 159 | void autoshift_disable(void) { | 165 | void autoshift_disable(void) { |
| 160 | autoshift_flags.enabled = false; | 166 | autoshift_flags.enabled = false; |
| 161 | del_weak_mods(MOD_BIT(KC_LSFT)); | 167 | del_weak_mods(MOD_BIT(KC_LEFT_SHIFT)); |
| 162 | } | 168 | } |
| 163 | 169 | ||
| 164 | # ifndef AUTO_SHIFT_NO_SETUP | 170 | # ifndef AUTO_SHIFT_NO_SETUP |
| @@ -189,7 +195,7 @@ bool process_auto_shift(uint16_t keycode, keyrecord_t *record) { | |||
| 189 | autoshift_end(KC_NO, now, false); | 195 | autoshift_end(KC_NO, now, false); |
| 190 | } | 196 | } |
| 191 | // For pressing another key while keyrepeating shifted autoshift. | 197 | // For pressing another key while keyrepeating shifted autoshift. |
| 192 | del_weak_mods(MOD_BIT(KC_LSFT)); | 198 | del_weak_mods(MOD_BIT(KC_LEFT_SHIFT)); |
| 193 | 199 | ||
| 194 | switch (keycode) { | 200 | switch (keycode) { |
| 195 | case KC_ASTG: | 201 | case KC_ASTG: |
| @@ -238,7 +244,7 @@ __attribute__((weak)) bool get_auto_shifted_key(uint16_t keycode, keyrecord_t *r | |||
| 238 | # ifndef NO_AUTO_SHIFT_SPECIAL | 244 | # ifndef NO_AUTO_SHIFT_SPECIAL |
| 239 | case KC_TAB: | 245 | case KC_TAB: |
| 240 | case KC_MINUS ... KC_SLASH: | 246 | case KC_MINUS ... KC_SLASH: |
| 241 | case KC_NONUS_BSLASH: | 247 | case KC_NONUS_BACKSLASH: |
| 242 | # endif | 248 | # endif |
| 243 | return true; | 249 | return true; |
| 244 | } | 250 | } |
diff --git a/quantum/process_keycode/process_combo.c b/quantum/process_keycode/process_combo.c index e8661839c..a050161ed 100644 --- a/quantum/process_keycode/process_combo.c +++ b/quantum/process_keycode/process_combo.c | |||
| @@ -18,10 +18,9 @@ | |||
| 18 | #include "process_combo.h" | 18 | #include "process_combo.h" |
| 19 | #include "action_tapping.h" | 19 | #include "action_tapping.h" |
| 20 | 20 | ||
| 21 | |||
| 22 | #ifdef COMBO_COUNT | 21 | #ifdef COMBO_COUNT |
| 23 | __attribute__((weak)) combo_t key_combos[COMBO_COUNT]; | 22 | __attribute__((weak)) combo_t key_combos[COMBO_COUNT]; |
| 24 | uint16_t COMBO_LEN = COMBO_COUNT; | 23 | uint16_t COMBO_LEN = COMBO_COUNT; |
| 25 | #else | 24 | #else |
| 26 | extern combo_t key_combos[]; | 25 | extern combo_t key_combos[]; |
| 27 | extern uint16_t COMBO_LEN; | 26 | extern uint16_t COMBO_LEN; |
| @@ -46,64 +45,86 @@ __attribute__((weak)) bool process_combo_key_release(uint16_t combo_index, combo | |||
| 46 | #endif | 45 | #endif |
| 47 | 46 | ||
| 48 | #ifndef COMBO_NO_TIMER | 47 | #ifndef COMBO_NO_TIMER |
| 49 | static uint16_t timer = 0; | 48 | static uint16_t timer = 0; |
| 50 | #endif | 49 | #endif |
| 51 | static bool b_combo_enable = true; // defaults to enabled | 50 | static bool b_combo_enable = true; // defaults to enabled |
| 52 | static uint16_t longest_term = 0; | 51 | static uint16_t longest_term = 0; |
| 53 | 52 | ||
| 54 | typedef struct { | 53 | typedef struct { |
| 55 | keyrecord_t record; | 54 | keyrecord_t record; |
| 56 | uint16_t combo_index; | 55 | uint16_t combo_index; |
| 57 | uint16_t keycode; | 56 | uint16_t keycode; |
| 58 | } queued_record_t; | 57 | } queued_record_t; |
| 59 | static uint8_t key_buffer_size = 0; | 58 | static uint8_t key_buffer_size = 0; |
| 60 | static queued_record_t key_buffer[COMBO_KEY_BUFFER_LENGTH]; | 59 | static queued_record_t key_buffer[COMBO_KEY_BUFFER_LENGTH]; |
| 61 | 60 | ||
| 62 | typedef struct { | 61 | typedef struct { |
| 63 | uint16_t combo_index; | 62 | uint16_t combo_index; |
| 64 | } queued_combo_t; | 63 | } queued_combo_t; |
| 65 | static uint8_t combo_buffer_write= 0; | 64 | static uint8_t combo_buffer_write = 0; |
| 66 | static uint8_t combo_buffer_read = 0; | 65 | static uint8_t combo_buffer_read = 0; |
| 67 | static queued_combo_t combo_buffer[COMBO_BUFFER_LENGTH]; | 66 | static queued_combo_t combo_buffer[COMBO_BUFFER_LENGTH]; |
| 68 | 67 | ||
| 69 | #define INCREMENT_MOD(i) i = (i + 1) % COMBO_BUFFER_LENGTH | 68 | #define INCREMENT_MOD(i) i = (i + 1) % COMBO_BUFFER_LENGTH |
| 70 | 69 | ||
| 71 | #define COMBO_KEY_POS ((keypos_t){.col=254, .row=254}) | 70 | #define COMBO_KEY_POS ((keypos_t){.col = 254, .row = 254}) |
| 72 | |||
| 73 | 71 | ||
| 74 | #ifndef EXTRA_SHORT_COMBOS | 72 | #ifndef EXTRA_SHORT_COMBOS |
| 75 | /* flags are their own elements in combo_t struct. */ | 73 | /* flags are their own elements in combo_t struct. */ |
| 76 | # define COMBO_ACTIVE(combo) (combo->active) | 74 | # define COMBO_ACTIVE(combo) (combo->active) |
| 77 | # define COMBO_DISABLED(combo) (combo->disabled) | 75 | # define COMBO_DISABLED(combo) (combo->disabled) |
| 78 | # define COMBO_STATE(combo) (combo->state) | 76 | # define COMBO_STATE(combo) (combo->state) |
| 79 | 77 | ||
| 80 | # define ACTIVATE_COMBO(combo) do {combo->active = true;}while(0) | 78 | # define ACTIVATE_COMBO(combo) \ |
| 81 | # define DEACTIVATE_COMBO(combo) do {combo->active = false;}while(0) | 79 | do { \ |
| 82 | # define DISABLE_COMBO(combo) do {combo->disabled = true;}while(0) | 80 | combo->active = true; \ |
| 83 | # define RESET_COMBO_STATE(combo) do { \ | 81 | } while (0) |
| 84 | combo->disabled = false; \ | 82 | # define DEACTIVATE_COMBO(combo) \ |
| 85 | combo->state = 0; \ | 83 | do { \ |
| 86 | }while(0) | 84 | combo->active = false; \ |
| 85 | } while (0) | ||
| 86 | # define DISABLE_COMBO(combo) \ | ||
| 87 | do { \ | ||
| 88 | combo->disabled = true; \ | ||
| 89 | } while (0) | ||
| 90 | # define RESET_COMBO_STATE(combo) \ | ||
| 91 | do { \ | ||
| 92 | combo->disabled = false; \ | ||
| 93 | combo->state = 0; \ | ||
| 94 | } while (0) | ||
| 87 | #else | 95 | #else |
| 88 | /* flags are at the two high bits of state. */ | 96 | /* flags are at the two high bits of state. */ |
| 89 | # define COMBO_ACTIVE(combo) (combo->state & 0x80) | 97 | # define COMBO_ACTIVE(combo) (combo->state & 0x80) |
| 90 | # define COMBO_DISABLED(combo) (combo->state & 0x40) | 98 | # define COMBO_DISABLED(combo) (combo->state & 0x40) |
| 91 | # define COMBO_STATE(combo) (combo->state & 0x3F) | 99 | # define COMBO_STATE(combo) (combo->state & 0x3F) |
| 92 | 100 | ||
| 93 | # define ACTIVATE_COMBO(combo) do {combo->state |= 0x80;}while(0) | 101 | # define ACTIVATE_COMBO(combo) \ |
| 94 | # define DEACTIVATE_COMBO(combo) do {combo->state &= ~0x80;}while(0) | 102 | do { \ |
| 95 | # define DISABLE_COMBO(combo) do {combo->state |= 0x40;}while(0) | 103 | combo->state |= 0x80; \ |
| 96 | # define RESET_COMBO_STATE(combo) do {combo->state &= ~0x7F;}while(0) | 104 | } while (0) |
| 105 | # define DEACTIVATE_COMBO(combo) \ | ||
| 106 | do { \ | ||
| 107 | combo->state &= ~0x80; \ | ||
| 108 | } while (0) | ||
| 109 | # define DISABLE_COMBO(combo) \ | ||
| 110 | do { \ | ||
| 111 | combo->state |= 0x40; \ | ||
| 112 | } while (0) | ||
| 113 | # define RESET_COMBO_STATE(combo) \ | ||
| 114 | do { \ | ||
| 115 | combo->state &= ~0x7F; \ | ||
| 116 | } while (0) | ||
| 97 | #endif | 117 | #endif |
| 98 | 118 | ||
| 99 | static inline void release_combo(uint16_t combo_index, combo_t *combo) { | 119 | static inline void release_combo(uint16_t combo_index, combo_t *combo) { |
| 100 | if (combo->keycode) { | 120 | if (combo->keycode) { |
| 101 | keyrecord_t record = { | 121 | keyrecord_t record = { |
| 102 | .event = { | 122 | .event = |
| 103 | .key = COMBO_KEY_POS, | 123 | { |
| 104 | .time = timer_read()|1, | 124 | .key = COMBO_KEY_POS, |
| 105 | .pressed = false, | 125 | .time = timer_read() | 1, |
| 106 | }, | 126 | .pressed = false, |
| 127 | }, | ||
| 107 | .keycode = combo->keycode, | 128 | .keycode = combo->keycode, |
| 108 | }; | 129 | }; |
| 109 | #ifndef NO_ACTION_TAPPING | 130 | #ifndef NO_ACTION_TAPPING |
| @@ -123,18 +144,17 @@ static inline bool _get_combo_must_hold(uint16_t combo_index, combo_t *combo) { | |||
| 123 | #elif defined(COMBO_MUST_HOLD_PER_COMBO) | 144 | #elif defined(COMBO_MUST_HOLD_PER_COMBO) |
| 124 | return get_combo_must_hold(combo_index, combo); | 145 | return get_combo_must_hold(combo_index, combo); |
| 125 | #elif defined(COMBO_MUST_HOLD_MODS) | 146 | #elif defined(COMBO_MUST_HOLD_MODS) |
| 126 | return (KEYCODE_IS_MOD(combo->keycode) || | 147 | return (KEYCODE_IS_MOD(combo->keycode) || (combo->keycode >= QK_MOMENTARY && combo->keycode <= QK_MOMENTARY_MAX)); |
| 127 | (combo->keycode >= QK_MOMENTARY && combo->keycode <= QK_MOMENTARY_MAX)); | ||
| 128 | #endif | 148 | #endif |
| 129 | return false; | 149 | return false; |
| 130 | } | 150 | } |
| 131 | 151 | ||
| 132 | static inline uint16_t _get_wait_time(uint16_t combo_index, combo_t *combo ) { | 152 | static inline uint16_t _get_wait_time(uint16_t combo_index, combo_t *combo) { |
| 133 | if (_get_combo_must_hold(combo_index, combo) | 153 | if (_get_combo_must_hold(combo_index, combo) |
| 134 | #ifdef COMBO_MUST_TAP_PER_COMBO | 154 | #ifdef COMBO_MUST_TAP_PER_COMBO |
| 135 | || get_combo_must_tap(combo_index, combo) | 155 | || get_combo_must_tap(combo_index, combo) |
| 136 | #endif | 156 | #endif |
| 137 | ) { | 157 | ) { |
| 138 | if (longest_term < COMBO_HOLD_TERM) { | 158 | if (longest_term < COMBO_HOLD_TERM) { |
| 139 | return COMBO_HOLD_TERM; | 159 | return COMBO_HOLD_TERM; |
| 140 | } | 160 | } |
| @@ -144,9 +164,8 @@ static inline uint16_t _get_wait_time(uint16_t combo_index, combo_t *combo ) { | |||
| 144 | } | 164 | } |
| 145 | 165 | ||
| 146 | static inline uint16_t _get_combo_term(uint16_t combo_index, combo_t *combo) { | 166 | static inline uint16_t _get_combo_term(uint16_t combo_index, combo_t *combo) { |
| 147 | |||
| 148 | #if defined(COMBO_TERM_PER_COMBO) | 167 | #if defined(COMBO_TERM_PER_COMBO) |
| 149 | return get_combo_term(combo_index, combo); | 168 | return get_combo_term(combo_index, combo); |
| 150 | #endif | 169 | #endif |
| 151 | 170 | ||
| 152 | return COMBO_TERM; | 171 | return COMBO_TERM; |
| @@ -154,7 +173,7 @@ static inline uint16_t _get_combo_term(uint16_t combo_index, combo_t *combo) { | |||
| 154 | 173 | ||
| 155 | void clear_combos(void) { | 174 | void clear_combos(void) { |
| 156 | uint16_t index = 0; | 175 | uint16_t index = 0; |
| 157 | longest_term = 0; | 176 | longest_term = 0; |
| 158 | for (index = 0; index < COMBO_LEN; ++index) { | 177 | for (index = 0; index < COMBO_LEN; ++index) { |
| 159 | combo_t *combo = &key_combos[index]; | 178 | combo_t *combo = &key_combos[index]; |
| 160 | if (!COMBO_ACTIVE(combo)) { | 179 | if (!COMBO_ACTIVE(combo)) { |
| @@ -175,7 +194,7 @@ static inline void dump_key_buffer(void) { | |||
| 175 | key_buffer_next = key_buffer_i + 1; | 194 | key_buffer_next = key_buffer_i + 1; |
| 176 | 195 | ||
| 177 | queued_record_t *qrecord = &key_buffer[key_buffer_i]; | 196 | queued_record_t *qrecord = &key_buffer[key_buffer_i]; |
| 178 | keyrecord_t *record = &qrecord->record; | 197 | keyrecord_t * record = &qrecord->record; |
| 179 | 198 | ||
| 180 | if (IS_NOEVENT(record->event)) { | 199 | if (IS_NOEVENT(record->event)) { |
| 181 | continue; | 200 | continue; |
| @@ -185,9 +204,9 @@ static inline void dump_key_buffer(void) { | |||
| 185 | process_combo_event(qrecord->combo_index, true); | 204 | process_combo_event(qrecord->combo_index, true); |
| 186 | } else { | 205 | } else { |
| 187 | #ifndef NO_ACTION_TAPPING | 206 | #ifndef NO_ACTION_TAPPING |
| 188 | action_tapping_process(*record); | 207 | action_tapping_process(*record); |
| 189 | #else | 208 | #else |
| 190 | process_record(record); | 209 | process_record(record); |
| 191 | #endif | 210 | #endif |
| 192 | } | 211 | } |
| 193 | record->event.time = 0; | 212 | record->event.time = 0; |
| @@ -242,7 +261,9 @@ void apply_combo(uint16_t combo_index, combo_t *combo) { | |||
| 242 | /* Apply combo's result keycode to the last chord key of the combo and | 261 | /* Apply combo's result keycode to the last chord key of the combo and |
| 243 | * disable the other keys. */ | 262 | * disable the other keys. */ |
| 244 | 263 | ||
| 245 | if (COMBO_DISABLED(combo)) { return; } | 264 | if (COMBO_DISABLED(combo)) { |
| 265 | return; | ||
| 266 | } | ||
| 246 | 267 | ||
| 247 | // state to check against so we find the last key of the combo from the buffer | 268 | // state to check against so we find the last key of the combo from the buffer |
| 248 | #if defined(EXTRA_EXTRA_LONG_COMBOS) | 269 | #if defined(EXTRA_EXTRA_LONG_COMBOS) |
| @@ -254,12 +275,11 @@ void apply_combo(uint16_t combo_index, combo_t *combo) { | |||
| 254 | #endif | 275 | #endif |
| 255 | 276 | ||
| 256 | for (uint8_t key_buffer_i = 0; key_buffer_i < key_buffer_size; key_buffer_i++) { | 277 | for (uint8_t key_buffer_i = 0; key_buffer_i < key_buffer_size; key_buffer_i++) { |
| 257 | |||
| 258 | queued_record_t *qrecord = &key_buffer[key_buffer_i]; | 278 | queued_record_t *qrecord = &key_buffer[key_buffer_i]; |
| 259 | keyrecord_t *record = &qrecord->record; | 279 | keyrecord_t * record = &qrecord->record; |
| 260 | uint16_t keycode = qrecord->keycode; | 280 | uint16_t keycode = qrecord->keycode; |
| 261 | 281 | ||
| 262 | uint8_t key_count = 0; | 282 | uint8_t key_count = 0; |
| 263 | uint16_t key_index = -1; | 283 | uint16_t key_index = -1; |
| 264 | _find_key_index_and_count(combo->keys, keycode, &key_index, &key_count); | 284 | _find_key_index_and_count(combo->keys, keycode, &key_index, &key_count); |
| 265 | 285 | ||
| @@ -271,7 +291,7 @@ void apply_combo(uint16_t combo_index, combo_t *combo) { | |||
| 271 | KEY_STATE_DOWN(state, key_index); | 291 | KEY_STATE_DOWN(state, key_index); |
| 272 | if (ALL_COMBO_KEYS_ARE_DOWN(state, key_count)) { | 292 | if (ALL_COMBO_KEYS_ARE_DOWN(state, key_count)) { |
| 273 | // this in the end executes the combo when the key_buffer is dumped. | 293 | // this in the end executes the combo when the key_buffer is dumped. |
| 274 | record->keycode = combo->keycode; | 294 | record->keycode = combo->keycode; |
| 275 | record->event.key = COMBO_KEY_POS; | 295 | record->event.key = COMBO_KEY_POS; |
| 276 | 296 | ||
| 277 | qrecord->combo_index = combo_index; | 297 | qrecord->combo_index = combo_index; |
| @@ -283,19 +303,15 @@ void apply_combo(uint16_t combo_index, combo_t *combo) { | |||
| 283 | // by making it a TICK event. | 303 | // by making it a TICK event. |
| 284 | record->event.time = 0; | 304 | record->event.time = 0; |
| 285 | } | 305 | } |
| 286 | |||
| 287 | } | 306 | } |
| 288 | drop_combo_from_buffer(combo_index); | 307 | drop_combo_from_buffer(combo_index); |
| 289 | } | 308 | } |
| 290 | 309 | ||
| 291 | static inline void apply_combos(void) { | 310 | static inline void apply_combos(void) { |
| 292 | // Apply all buffered normal combos. | 311 | // Apply all buffered normal combos. |
| 293 | for (uint8_t i = combo_buffer_read; | 312 | for (uint8_t i = combo_buffer_read; i != combo_buffer_write; INCREMENT_MOD(i)) { |
| 294 | i != combo_buffer_write; | ||
| 295 | INCREMENT_MOD(i)) { | ||
| 296 | |||
| 297 | queued_combo_t *buffered_combo = &combo_buffer[i]; | 313 | queued_combo_t *buffered_combo = &combo_buffer[i]; |
| 298 | combo_t *combo = &key_combos[buffered_combo->combo_index]; | 314 | combo_t * combo = &key_combos[buffered_combo->combo_index]; |
| 299 | 315 | ||
| 300 | #ifdef COMBO_MUST_TAP_PER_COMBO | 316 | #ifdef COMBO_MUST_TAP_PER_COMBO |
| 301 | if (get_combo_must_tap(buffered_combo->combo_index, combo)) { | 317 | if (get_combo_must_tap(buffered_combo->combo_index, combo)) { |
| @@ -310,15 +326,15 @@ static inline void apply_combos(void) { | |||
| 310 | clear_combos(); | 326 | clear_combos(); |
| 311 | } | 327 | } |
| 312 | 328 | ||
| 313 | combo_t* overlaps(combo_t *combo1, combo_t *combo2) { | 329 | combo_t *overlaps(combo_t *combo1, combo_t *combo2) { |
| 314 | /* Checks if the combos overlap and returns the combo that should be | 330 | /* Checks if the combos overlap and returns the combo that should be |
| 315 | * dropped from the combo buffer. | 331 | * dropped from the combo buffer. |
| 316 | * The combo that has less keys will be dropped. If they have the same | 332 | * The combo that has less keys will be dropped. If they have the same |
| 317 | * amount of keys, drop combo1. */ | 333 | * amount of keys, drop combo1. */ |
| 318 | 334 | ||
| 319 | uint8_t idx1 = 0, idx2 = 0; | 335 | uint8_t idx1 = 0, idx2 = 0; |
| 320 | uint16_t key1, key2; | 336 | uint16_t key1, key2; |
| 321 | bool overlaps = false; | 337 | bool overlaps = false; |
| 322 | 338 | ||
| 323 | while ((key1 = pgm_read_word(&combo1->keys[idx1])) != COMBO_END) { | 339 | while ((key1 = pgm_read_word(&combo1->keys[idx1])) != COMBO_END) { |
| 324 | idx2 = 0; | 340 | idx2 = 0; |
| @@ -335,7 +351,7 @@ combo_t* overlaps(combo_t *combo1, combo_t *combo2) { | |||
| 335 | } | 351 | } |
| 336 | 352 | ||
| 337 | static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *record, uint16_t combo_index) { | 353 | static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *record, uint16_t combo_index) { |
| 338 | uint8_t key_count = 0; | 354 | uint8_t key_count = 0; |
| 339 | uint16_t key_index = -1; | 355 | uint16_t key_index = -1; |
| 340 | _find_key_index_and_count(combo->keys, keycode, &key_index, &key_count); | 356 | _find_key_index_and_count(combo->keys, keycode, &key_index, &key_count); |
| 341 | 357 | ||
| @@ -369,12 +385,9 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t * | |||
| 369 | 385 | ||
| 370 | // disable readied combos that overlap with this combo | 386 | // disable readied combos that overlap with this combo |
| 371 | combo_t *drop = NULL; | 387 | combo_t *drop = NULL; |
| 372 | for (uint8_t combo_buffer_i = combo_buffer_read; | 388 | for (uint8_t combo_buffer_i = combo_buffer_read; combo_buffer_i != combo_buffer_write; INCREMENT_MOD(combo_buffer_i)) { |
| 373 | combo_buffer_i != combo_buffer_write; | 389 | queued_combo_t *qcombo = &combo_buffer[combo_buffer_i]; |
| 374 | INCREMENT_MOD(combo_buffer_i)) { | 390 | combo_t * buffered_combo = &key_combos[qcombo->combo_index]; |
| 375 | |||
| 376 | queued_combo_t *qcombo = &combo_buffer[combo_buffer_i]; | ||
| 377 | combo_t *buffered_combo = &key_combos[qcombo->combo_index]; | ||
| 378 | 391 | ||
| 379 | if ((drop = overlaps(buffered_combo, combo))) { | 392 | if ((drop = overlaps(buffered_combo, combo))) { |
| 380 | DISABLE_COMBO(drop); | 393 | DISABLE_COMBO(drop); |
| @@ -387,21 +400,19 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t * | |||
| 387 | INCREMENT_MOD(combo_buffer_read); | 400 | INCREMENT_MOD(combo_buffer_read); |
| 388 | } | 401 | } |
| 389 | } | 402 | } |
| 390 | |||
| 391 | } | 403 | } |
| 392 | 404 | ||
| 393 | if (drop != combo) { | 405 | if (drop != combo) { |
| 394 | // save this combo to buffer | 406 | // save this combo to buffer |
| 395 | combo_buffer[combo_buffer_write] = (queued_combo_t){ | 407 | combo_buffer[combo_buffer_write] = (queued_combo_t){ |
| 396 | .combo_index=combo_index, | 408 | .combo_index = combo_index, |
| 397 | }; | 409 | }; |
| 398 | INCREMENT_MOD(combo_buffer_write); | 410 | INCREMENT_MOD(combo_buffer_write); |
| 399 | 411 | ||
| 400 | // get possible longer waiting time for tap-/hold-only combos. | 412 | // get possible longer waiting time for tap-/hold-only combos. |
| 401 | longest_term = _get_wait_time(combo_index, combo); | 413 | longest_term = _get_wait_time(combo_index, combo); |
| 402 | } | 414 | } |
| 403 | } // if timer elapsed end | 415 | } // if timer elapsed end |
| 404 | |||
| 405 | } | 416 | } |
| 406 | } else { | 417 | } else { |
| 407 | // chord releases | 418 | // chord releases |
| @@ -416,7 +427,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t * | |||
| 416 | else if (get_combo_must_tap(combo_index, combo)) { | 427 | else if (get_combo_must_tap(combo_index, combo)) { |
| 417 | // immediately apply tap-only combo | 428 | // immediately apply tap-only combo |
| 418 | apply_combo(combo_index, combo); | 429 | apply_combo(combo_index, combo); |
| 419 | apply_combos(); // also apply other prepared combos and dump key buffer | 430 | apply_combos(); // also apply other prepared combos and dump key buffer |
| 420 | # ifdef COMBO_PROCESS_KEY_RELEASE | 431 | # ifdef COMBO_PROCESS_KEY_RELEASE |
| 421 | if (process_combo_key_release(combo_index, combo, key_index, keycode)) { | 432 | if (process_combo_key_release(combo_index, combo, key_index, keycode)) { |
| 422 | release_combo(combo_index, combo); | 433 | release_combo(combo_index, combo); |
| @@ -424,10 +435,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t * | |||
| 424 | # endif | 435 | # endif |
| 425 | } | 436 | } |
| 426 | #endif | 437 | #endif |
| 427 | } else if (COMBO_ACTIVE(combo) | 438 | } else if (COMBO_ACTIVE(combo) && ONLY_ONE_KEY_IS_DOWN(COMBO_STATE(combo)) && KEY_NOT_YET_RELEASED(COMBO_STATE(combo), key_index)) { |
| 428 | && ONLY_ONE_KEY_IS_DOWN(COMBO_STATE(combo)) | ||
| 429 | && KEY_NOT_YET_RELEASED(COMBO_STATE(combo), key_index) | ||
| 430 | ) { | ||
| 431 | /* last key released */ | 439 | /* last key released */ |
| 432 | release_combo(combo_index, combo); | 440 | release_combo(combo_index, combo); |
| 433 | key_is_part_of_combo = true; | 441 | key_is_part_of_combo = true; |
| @@ -435,9 +443,7 @@ static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t * | |||
| 435 | #ifdef COMBO_PROCESS_KEY_RELEASE | 443 | #ifdef COMBO_PROCESS_KEY_RELEASE |
| 436 | process_combo_key_release(combo_index, combo, key_index, keycode); | 444 | process_combo_key_release(combo_index, combo, key_index, keycode); |
| 437 | #endif | 445 | #endif |
| 438 | } else if (COMBO_ACTIVE(combo) | 446 | } else if (COMBO_ACTIVE(combo) && KEY_NOT_YET_RELEASED(COMBO_STATE(combo), key_index)) { |
| 439 | && KEY_NOT_YET_RELEASED(COMBO_STATE(combo), key_index) | ||
| 440 | ) { | ||
| 441 | /* first or middle key released */ | 447 | /* first or middle key released */ |
| 442 | key_is_part_of_combo = true; | 448 | key_is_part_of_combo = true; |
| 443 | 449 | ||
| @@ -489,21 +495,21 @@ bool process_combo(uint16_t keycode, keyrecord_t *record) { | |||
| 489 | 495 | ||
| 490 | if (record->event.pressed && is_combo_key) { | 496 | if (record->event.pressed && is_combo_key) { |
| 491 | #ifndef COMBO_NO_TIMER | 497 | #ifndef COMBO_NO_TIMER |
| 492 | # ifdef COMBO_STRICT_TIMER | 498 | # ifdef COMBO_STRICT_TIMER |
| 493 | if (!timer) { | 499 | if (!timer) { |
| 494 | // timer is set only on the first key | 500 | // timer is set only on the first key |
| 495 | timer = timer_read(); | 501 | timer = timer_read(); |
| 496 | } | 502 | } |
| 497 | # else | 503 | # else |
| 498 | timer = timer_read(); | 504 | timer = timer_read(); |
| 499 | # endif | 505 | # endif |
| 500 | #endif | 506 | #endif |
| 501 | 507 | ||
| 502 | if (key_buffer_size < COMBO_KEY_BUFFER_LENGTH) { | 508 | if (key_buffer_size < COMBO_KEY_BUFFER_LENGTH) { |
| 503 | key_buffer[key_buffer_size++] = (queued_record_t){ | 509 | key_buffer[key_buffer_size++] = (queued_record_t){ |
| 504 | .record = *record, | 510 | .record = *record, |
| 505 | .keycode = keycode, | 511 | .keycode = keycode, |
| 506 | .combo_index = -1, // this will be set when applying combos | 512 | .combo_index = -1, // this will be set when applying combos |
| 507 | }; | 513 | }; |
| 508 | } | 514 | } |
| 509 | } else { | 515 | } else { |
| @@ -532,7 +538,7 @@ void combo_task(void) { | |||
| 532 | if (combo_buffer_read != combo_buffer_write) { | 538 | if (combo_buffer_read != combo_buffer_write) { |
| 533 | apply_combos(); | 539 | apply_combos(); |
| 534 | longest_term = 0; | 540 | longest_term = 0; |
| 535 | timer = 0; | 541 | timer = 0; |
| 536 | } else { | 542 | } else { |
| 537 | dump_key_buffer(); | 543 | dump_key_buffer(); |
| 538 | timer = 0; | 544 | timer = 0; |
| @@ -546,9 +552,9 @@ void combo_enable(void) { b_combo_enable = true; } | |||
| 546 | 552 | ||
| 547 | void combo_disable(void) { | 553 | void combo_disable(void) { |
| 548 | #ifndef COMBO_NO_TIMER | 554 | #ifndef COMBO_NO_TIMER |
| 549 | timer = 0; | 555 | timer = 0; |
| 550 | #endif | 556 | #endif |
| 551 | b_combo_enable = false; | 557 | b_combo_enable = false; |
| 552 | combo_buffer_read = combo_buffer_write; | 558 | combo_buffer_read = combo_buffer_write; |
| 553 | clear_combos(); | 559 | clear_combos(); |
| 554 | dump_key_buffer(); | 560 | dump_key_buffer(); |
diff --git a/quantum/process_keycode/process_combo.h b/quantum/process_keycode/process_combo.h index 43c36d79e..4c4e574e3 100644 --- a/quantum/process_keycode/process_combo.h +++ b/quantum/process_keycode/process_combo.h | |||
| @@ -43,8 +43,8 @@ typedef struct { | |||
| 43 | #ifdef EXTRA_SHORT_COMBOS | 43 | #ifdef EXTRA_SHORT_COMBOS |
| 44 | uint8_t state; | 44 | uint8_t state; |
| 45 | #else | 45 | #else |
| 46 | bool disabled; | 46 | bool disabled; |
| 47 | bool active; | 47 | bool active; |
| 48 | # if defined(EXTRA_EXTRA_LONG_COMBOS) | 48 | # if defined(EXTRA_EXTRA_LONG_COMBOS) |
| 49 | uint32_t state; | 49 | uint32_t state; |
| 50 | # elif defined(EXTRA_LONG_COMBOS) | 50 | # elif defined(EXTRA_LONG_COMBOS) |
diff --git a/quantum/process_keycode/process_haptic.c b/quantum/process_keycode/process_haptic.c index 64d455d00..85b2ffcdd 100644 --- a/quantum/process_keycode/process_haptic.c +++ b/quantum/process_keycode/process_haptic.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include "process_haptic.h" | 17 | #include "process_haptic.h" |
| 18 | #include "quantum_keycodes.h" | 18 | #include "quantum_keycodes.h" |
| 19 | #include "action_tapping.h" | 19 | #include "action_tapping.h" |
| 20 | #include "usb_device_state.h" | ||
| 20 | 21 | ||
| 21 | __attribute__((weak)) bool get_haptic_enabled_key(uint16_t keycode, keyrecord_t *record) { | 22 | __attribute__((weak)) bool get_haptic_enabled_key(uint16_t keycode, keyrecord_t *record) { |
| 22 | switch (keycode) { | 23 | switch (keycode) { |
| @@ -30,8 +31,9 @@ __attribute__((weak)) bool get_haptic_enabled_key(uint16_t keycode, keyrecord_t | |||
| 30 | case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: | 31 | case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: |
| 31 | if (record->tap.count == 0) return false; | 32 | if (record->tap.count == 0) return false; |
| 32 | break; | 33 | break; |
| 33 | case KC_LCTRL ... KC_RGUI: | 34 | case KC_LEFT_CTRL ... KC_RIGHT_GUI: |
| 34 | case QK_MOMENTARY ... QK_MOMENTARY_MAX: | 35 | case QK_MOMENTARY ... QK_MOMENTARY_MAX: |
| 36 | case QK_LAYER_MOD ... QK_LAYER_MOD_MAX: | ||
| 35 | #endif | 37 | #endif |
| 36 | #ifdef NO_HAPTIC_FN | 38 | #ifdef NO_HAPTIC_FN |
| 37 | case KC_FN0 ... KC_FN31: | 39 | case KC_FN0 ... KC_FN31: |
| @@ -42,34 +44,34 @@ __attribute__((weak)) bool get_haptic_enabled_key(uint16_t keycode, keyrecord_t | |||
| 42 | #ifdef NO_HAPTIC_PUNCTUATION | 44 | #ifdef NO_HAPTIC_PUNCTUATION |
| 43 | case KC_ENTER: | 45 | case KC_ENTER: |
| 44 | case KC_ESCAPE: | 46 | case KC_ESCAPE: |
| 45 | case KC_BSPACE: | 47 | case KC_BACKSPACE: |
| 46 | case KC_SPACE: | 48 | case KC_SPACE: |
| 47 | case KC_MINUS: | 49 | case KC_MINUS: |
| 48 | case KC_EQUAL: | 50 | case KC_EQUAL: |
| 49 | case KC_LBRACKET: | 51 | case KC_LEFT_BRACKET: |
| 50 | case KC_RBRACKET: | 52 | case KC_RIGHT_BRACKET: |
| 51 | case KC_BSLASH: | 53 | case KC_BACKSLASH: |
| 52 | case KC_NONUS_HASH: | 54 | case KC_NONUS_HASH: |
| 53 | case KC_SCOLON: | 55 | case KC_SEMICOLON: |
| 54 | case KC_QUOTE: | 56 | case KC_QUOTE: |
| 55 | case KC_GRAVE: | 57 | case KC_GRAVE: |
| 56 | case KC_COMMA: | 58 | case KC_COMMA: |
| 57 | case KC_SLASH: | 59 | case KC_SLASH: |
| 58 | case KC_DOT: | 60 | case KC_DOT: |
| 59 | case KC_NONUS_BSLASH: | 61 | case KC_NONUS_BACKSLASH: |
| 60 | #endif | 62 | #endif |
| 61 | #ifdef NO_HAPTIC_LOCKKEYS | 63 | #ifdef NO_HAPTIC_LOCKKEYS |
| 62 | case KC_CAPSLOCK: | 64 | case KC_CAPS_LOCK: |
| 63 | case KC_SCROLLLOCK: | 65 | case KC_SCROLL_LOCK: |
| 64 | case KC_NUMLOCK: | 66 | case KC_NUM_LOCK: |
| 65 | #endif | 67 | #endif |
| 66 | #ifdef NO_HAPTIC_NAV | 68 | #ifdef NO_HAPTIC_NAV |
| 67 | case KC_PSCREEN: | 69 | case KC_PRINT_SCREEN: |
| 68 | case KC_PAUSE: | 70 | case KC_PAUSE: |
| 69 | case KC_INSERT: | 71 | case KC_INSERT: |
| 70 | case KC_DELETE: | 72 | case KC_DELETE: |
| 71 | case KC_PGDOWN: | 73 | case KC_PAGE_DOWN: |
| 72 | case KC_PGUP: | 74 | case KC_PAGE_UP: |
| 73 | case KC_LEFT: | 75 | case KC_LEFT: |
| 74 | case KC_UP: | 76 | case KC_UP: |
| 75 | case KC_RIGHT: | 77 | case KC_RIGHT: |
| @@ -130,7 +132,7 @@ bool process_haptic(uint16_t keycode, keyrecord_t *record) { | |||
| 130 | } | 132 | } |
| 131 | } | 133 | } |
| 132 | 134 | ||
| 133 | if (haptic_get_enable()) { | 135 | if (haptic_get_enable() && ((!HAPTIC_OFF_IN_LOW_POWER) || (usb_device_state == USB_DEVICE_STATE_CONFIGURED))) { |
| 134 | if (record->event.pressed) { | 136 | if (record->event.pressed) { |
| 135 | // keypress | 137 | // keypress |
| 136 | if (haptic_get_feedback() < 2 && get_haptic_enabled_key(keycode, record)) { | 138 | if (haptic_get_feedback() < 2 && get_haptic_enabled_key(keycode, record)) { |
diff --git a/quantum/process_keycode/process_music.c b/quantum/process_keycode/process_music.c index 2beccbd8f..6822c5e28 100644 --- a/quantum/process_keycode/process_music.c +++ b/quantum/process_keycode/process_music.c | |||
| @@ -146,7 +146,7 @@ bool process_music(uint16_t keycode, keyrecord_t *record) { | |||
| 146 | 146 | ||
| 147 | if (music_activated || midi_activated) { | 147 | if (music_activated || midi_activated) { |
| 148 | if (record->event.pressed) { | 148 | if (record->event.pressed) { |
| 149 | if (keycode == KC_LCTL) { // Start recording | 149 | if (keycode == KC_LEFT_CTRL) { // Start recording |
| 150 | music_all_notes_off(); | 150 | music_all_notes_off(); |
| 151 | music_sequence_recording = true; | 151 | music_sequence_recording = true; |
| 152 | music_sequence_recorded = false; | 152 | music_sequence_recorded = false; |
| @@ -155,7 +155,7 @@ bool process_music(uint16_t keycode, keyrecord_t *record) { | |||
| 155 | return false; | 155 | return false; |
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | if (keycode == KC_LALT) { // Stop recording/playing | 158 | if (keycode == KC_LEFT_ALT) { // Stop recording/playing |
| 159 | music_all_notes_off(); | 159 | music_all_notes_off(); |
| 160 | if (music_sequence_recording) { // was recording | 160 | if (music_sequence_recording) { // was recording |
| 161 | music_sequence_recorded = true; | 161 | music_sequence_recorded = true; |
| @@ -165,7 +165,7 @@ bool process_music(uint16_t keycode, keyrecord_t *record) { | |||
| 165 | return false; | 165 | return false; |
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | if (keycode == KC_LGUI && music_sequence_recorded) { // Start playing | 168 | if (keycode == KC_LEFT_GUI && music_sequence_recorded) { // Start playing |
| 169 | music_all_notes_off(); | 169 | music_all_notes_off(); |
| 170 | music_sequence_recording = false; | 170 | music_sequence_recording = false; |
| 171 | music_sequence_playing = true; | 171 | music_sequence_playing = true; |
diff --git a/quantum/process_keycode/process_printer.c b/quantum/process_keycode/process_printer.c index 7c5e4169a..82528cc68 100644 --- a/quantum/process_keycode/process_printer.c +++ b/quantum/process_keycode/process_printer.c | |||
| @@ -31,7 +31,7 @@ uint8_t shifted_numbers[10] = {0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0 | |||
| 31 | 31 | ||
| 32 | // uint8_t keycode_to_ascii[0xFF][2]; | 32 | // uint8_t keycode_to_ascii[0xFF][2]; |
| 33 | 33 | ||
| 34 | // keycode_to_ascii[KC_MINS] = {0x2D, 0x5F}; | 34 | // keycode_to_ascii[KC_MINUS] = {0x2D, 0x5F}; |
| 35 | 35 | ||
| 36 | void print_char(char c) { | 36 | void print_char(char c) { |
| 37 | USB_Disable(); | 37 | USB_Disable(); |
| @@ -90,8 +90,8 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 90 | case KC_PIPE: | 90 | case KC_PIPE: |
| 91 | case KC_TILD: | 91 | case KC_TILD: |
| 92 | keycode &= 0xFF; | 92 | keycode &= 0xFF; |
| 93 | case KC_LSFT: | 93 | case KC_LEFT_SHIFT: |
| 94 | case KC_RSFT: | 94 | case KC_RIGHT_SHIFT: |
| 95 | if (record->event.pressed) { | 95 | if (record->event.pressed) { |
| 96 | character_shift++; | 96 | character_shift++; |
| 97 | } else { | 97 | } else { |
| @@ -107,13 +107,13 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 107 | print_box_string("This is a line of text!"); | 107 | print_box_string("This is a line of text!"); |
| 108 | } | 108 | } |
| 109 | return false; | 109 | return false; |
| 110 | case KC_ESC: | 110 | case KC_ESCAPE: |
| 111 | if (record->event.pressed) { | 111 | if (record->event.pressed) { |
| 112 | print_char(0x1B); | 112 | print_char(0x1B); |
| 113 | } | 113 | } |
| 114 | return false; | 114 | return false; |
| 115 | break; | 115 | break; |
| 116 | case KC_SPC: | 116 | case KC_SPACE: |
| 117 | if (record->event.pressed) { | 117 | if (record->event.pressed) { |
| 118 | print_char(0x20); | 118 | print_char(0x20); |
| 119 | } | 119 | } |
| @@ -139,7 +139,7 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 139 | } | 139 | } |
| 140 | return false; | 140 | return false; |
| 141 | break; | 141 | break; |
| 142 | case KC_ENT: | 142 | case KC_ENTER: |
| 143 | if (record->event.pressed) { | 143 | if (record->event.pressed) { |
| 144 | if (character_shift) { | 144 | if (character_shift) { |
| 145 | print_char(0x0C); | 145 | print_char(0x0C); |
| @@ -149,7 +149,7 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 149 | } | 149 | } |
| 150 | return false; | 150 | return false; |
| 151 | break; | 151 | break; |
| 152 | case KC_BSPC: | 152 | case KC_BACKSPACE: |
| 153 | if (record->event.pressed) { | 153 | if (record->event.pressed) { |
| 154 | if (character_shift) { | 154 | if (character_shift) { |
| 155 | print_char(0x18); | 155 | print_char(0x18); |
| @@ -169,7 +169,7 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 169 | } | 169 | } |
| 170 | return false; | 170 | return false; |
| 171 | break; | 171 | break; |
| 172 | case KC_COMM: | 172 | case KC_COMMA: |
| 173 | if (record->event.pressed) { | 173 | if (record->event.pressed) { |
| 174 | if (character_shift) { | 174 | if (character_shift) { |
| 175 | print_char(0x3C); | 175 | print_char(0x3C); |
| @@ -179,7 +179,7 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 179 | } | 179 | } |
| 180 | return false; | 180 | return false; |
| 181 | break; | 181 | break; |
| 182 | case KC_SLSH: | 182 | case KC_SLASH: |
| 183 | if (record->event.pressed) { | 183 | if (record->event.pressed) { |
| 184 | if (character_shift) { | 184 | if (character_shift) { |
| 185 | print_char(0x3F); | 185 | print_char(0x3F); |
| @@ -189,7 +189,7 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 189 | } | 189 | } |
| 190 | return false; | 190 | return false; |
| 191 | break; | 191 | break; |
| 192 | case KC_QUOT: | 192 | case KC_QUOTE: |
| 193 | if (record->event.pressed) { | 193 | if (record->event.pressed) { |
| 194 | if (character_shift) { | 194 | if (character_shift) { |
| 195 | print_char(0x22); | 195 | print_char(0x22); |
| @@ -199,7 +199,7 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 199 | } | 199 | } |
| 200 | return false; | 200 | return false; |
| 201 | break; | 201 | break; |
| 202 | case KC_GRV: | 202 | case KC_GRAVE: |
| 203 | if (record->event.pressed) { | 203 | if (record->event.pressed) { |
| 204 | if (character_shift) { | 204 | if (character_shift) { |
| 205 | print_char(0x7E); | 205 | print_char(0x7E); |
| @@ -209,7 +209,7 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 209 | } | 209 | } |
| 210 | return false; | 210 | return false; |
| 211 | break; | 211 | break; |
| 212 | case KC_MINS: | 212 | case KC_MINUS: |
| 213 | if (record->event.pressed) { | 213 | if (record->event.pressed) { |
| 214 | if (character_shift) { | 214 | if (character_shift) { |
| 215 | print_char(0x5F); | 215 | print_char(0x5F); |
| @@ -219,7 +219,7 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 219 | } | 219 | } |
| 220 | return false; | 220 | return false; |
| 221 | break; | 221 | break; |
| 222 | case KC_EQL: | 222 | case KC_EQUAL: |
| 223 | if (record->event.pressed) { | 223 | if (record->event.pressed) { |
| 224 | if (character_shift) { | 224 | if (character_shift) { |
| 225 | print_char(0x2B); | 225 | print_char(0x2B); |
| @@ -229,7 +229,7 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 229 | } | 229 | } |
| 230 | return false; | 230 | return false; |
| 231 | break; | 231 | break; |
| 232 | case KC_LBRC: | 232 | case KC_LEFT_BRACKET: |
| 233 | if (record->event.pressed) { | 233 | if (record->event.pressed) { |
| 234 | if (character_shift) { | 234 | if (character_shift) { |
| 235 | print_char(0x7B); | 235 | print_char(0x7B); |
| @@ -239,7 +239,7 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 239 | } | 239 | } |
| 240 | return false; | 240 | return false; |
| 241 | break; | 241 | break; |
| 242 | case KC_RBRC: | 242 | case KC_RIGHT_BRACKET: |
| 243 | if (record->event.pressed) { | 243 | if (record->event.pressed) { |
| 244 | if (character_shift) { | 244 | if (character_shift) { |
| 245 | print_char(0x7D); | 245 | print_char(0x7D); |
| @@ -249,7 +249,7 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 249 | } | 249 | } |
| 250 | return false; | 250 | return false; |
| 251 | break; | 251 | break; |
| 252 | case KC_BSLS: | 252 | case KC_BACKSLASH: |
| 253 | if (record->event.pressed) { | 253 | if (record->event.pressed) { |
| 254 | if (character_shift) { | 254 | if (character_shift) { |
| 255 | print_char(0x7C); | 255 | print_char(0x7C); |
diff --git a/quantum/process_keycode/process_printer_bb.c b/quantum/process_keycode/process_printer_bb.c index e482d8259..6c91bd27e 100644 --- a/quantum/process_keycode/process_printer_bb.c +++ b/quantum/process_keycode/process_printer_bb.c | |||
| @@ -45,7 +45,7 @@ uint8_t shifted_numbers[10] = {0x21, 0x40, 0x23, 0x24, 0x25, 0x5E, 0x26, 0x2A, 0 | |||
| 45 | 45 | ||
| 46 | // uint8_t keycode_to_ascii[0xFF][2]; | 46 | // uint8_t keycode_to_ascii[0xFF][2]; |
| 47 | 47 | ||
| 48 | // keycode_to_ascii[KC_MINS] = {0x2D, 0x5F}; | 48 | // keycode_to_ascii[KC_MINUS] = {0x2D, 0x5F}; |
| 49 | 49 | ||
| 50 | void print_char(char c) { | 50 | void print_char(char c) { |
| 51 | uint8_t b = 8; | 51 | uint8_t b = 8; |
| @@ -84,8 +84,8 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 84 | case KC_PIPE: | 84 | case KC_PIPE: |
| 85 | case KC_TILD: | 85 | case KC_TILD: |
| 86 | keycode &= 0xFF; | 86 | keycode &= 0xFF; |
| 87 | case KC_LSFT: | 87 | case KC_LEFT_SHIFT: |
| 88 | case KC_RSFT: | 88 | case KC_RIGHT_SHIFT: |
| 89 | if (record->event.pressed) { | 89 | if (record->event.pressed) { |
| 90 | character_shift++; | 90 | character_shift++; |
| 91 | } else { | 91 | } else { |
| @@ -101,13 +101,13 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 101 | print_string("This is a line of text!\n\n\n"); | 101 | print_string("This is a line of text!\n\n\n"); |
| 102 | } | 102 | } |
| 103 | return false; | 103 | return false; |
| 104 | case KC_ESC: | 104 | case KC_ESCAPE: |
| 105 | if (record->event.pressed) { | 105 | if (record->event.pressed) { |
| 106 | print_char(0x1B); | 106 | print_char(0x1B); |
| 107 | } | 107 | } |
| 108 | return false; | 108 | return false; |
| 109 | break; | 109 | break; |
| 110 | case KC_SPC: | 110 | case KC_SPACE: |
| 111 | if (record->event.pressed) { | 111 | if (record->event.pressed) { |
| 112 | print_char(0x20); | 112 | print_char(0x20); |
| 113 | } | 113 | } |
| @@ -133,7 +133,7 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 133 | } | 133 | } |
| 134 | return false; | 134 | return false; |
| 135 | break; | 135 | break; |
| 136 | case KC_ENT: | 136 | case KC_ENTER: |
| 137 | if (record->event.pressed) { | 137 | if (record->event.pressed) { |
| 138 | if (character_shift) { | 138 | if (character_shift) { |
| 139 | print_char(0x0C); | 139 | print_char(0x0C); |
| @@ -143,7 +143,7 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 143 | } | 143 | } |
| 144 | return false; | 144 | return false; |
| 145 | break; | 145 | break; |
| 146 | case KC_BSPC: | 146 | case KC_BACKSPACE: |
| 147 | if (record->event.pressed) { | 147 | if (record->event.pressed) { |
| 148 | if (character_shift) { | 148 | if (character_shift) { |
| 149 | print_char(0x18); | 149 | print_char(0x18); |
| @@ -163,7 +163,7 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 163 | } | 163 | } |
| 164 | return false; | 164 | return false; |
| 165 | break; | 165 | break; |
| 166 | case KC_COMM: | 166 | case KC_COMMA: |
| 167 | if (record->event.pressed) { | 167 | if (record->event.pressed) { |
| 168 | if (character_shift) { | 168 | if (character_shift) { |
| 169 | print_char(0x3C); | 169 | print_char(0x3C); |
| @@ -173,7 +173,7 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 173 | } | 173 | } |
| 174 | return false; | 174 | return false; |
| 175 | break; | 175 | break; |
| 176 | case KC_SLSH: | 176 | case KC_SLASH: |
| 177 | if (record->event.pressed) { | 177 | if (record->event.pressed) { |
| 178 | if (character_shift) { | 178 | if (character_shift) { |
| 179 | print_char(0x3F); | 179 | print_char(0x3F); |
| @@ -183,7 +183,7 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 183 | } | 183 | } |
| 184 | return false; | 184 | return false; |
| 185 | break; | 185 | break; |
| 186 | case KC_QUOT: | 186 | case KC_QUOTE: |
| 187 | if (record->event.pressed) { | 187 | if (record->event.pressed) { |
| 188 | if (character_shift) { | 188 | if (character_shift) { |
| 189 | print_char(0x22); | 189 | print_char(0x22); |
| @@ -193,7 +193,7 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 193 | } | 193 | } |
| 194 | return false; | 194 | return false; |
| 195 | break; | 195 | break; |
| 196 | case KC_GRV: | 196 | case KC_GRAVE: |
| 197 | if (record->event.pressed) { | 197 | if (record->event.pressed) { |
| 198 | if (character_shift) { | 198 | if (character_shift) { |
| 199 | print_char(0x7E); | 199 | print_char(0x7E); |
| @@ -203,7 +203,7 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 203 | } | 203 | } |
| 204 | return false; | 204 | return false; |
| 205 | break; | 205 | break; |
| 206 | case KC_MINS: | 206 | case KC_MINUS: |
| 207 | if (record->event.pressed) { | 207 | if (record->event.pressed) { |
| 208 | if (character_shift) { | 208 | if (character_shift) { |
| 209 | print_char(0x5F); | 209 | print_char(0x5F); |
| @@ -213,7 +213,7 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 213 | } | 213 | } |
| 214 | return false; | 214 | return false; |
| 215 | break; | 215 | break; |
| 216 | case KC_EQL: | 216 | case KC_EQUAL: |
| 217 | if (record->event.pressed) { | 217 | if (record->event.pressed) { |
| 218 | if (character_shift) { | 218 | if (character_shift) { |
| 219 | print_char(0x2B); | 219 | print_char(0x2B); |
| @@ -223,7 +223,7 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 223 | } | 223 | } |
| 224 | return false; | 224 | return false; |
| 225 | break; | 225 | break; |
| 226 | case KC_LBRC: | 226 | case KC_LEFT_BRACKET: |
| 227 | if (record->event.pressed) { | 227 | if (record->event.pressed) { |
| 228 | if (character_shift) { | 228 | if (character_shift) { |
| 229 | print_char(0x7B); | 229 | print_char(0x7B); |
| @@ -233,7 +233,7 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 233 | } | 233 | } |
| 234 | return false; | 234 | return false; |
| 235 | break; | 235 | break; |
| 236 | case KC_RBRC: | 236 | case KC_RIGHT_BRACKET: |
| 237 | if (record->event.pressed) { | 237 | if (record->event.pressed) { |
| 238 | if (character_shift) { | 238 | if (character_shift) { |
| 239 | print_char(0x7D); | 239 | print_char(0x7D); |
| @@ -243,7 +243,7 @@ bool process_printer(uint16_t keycode, keyrecord_t *record) { | |||
| 243 | } | 243 | } |
| 244 | return false; | 244 | return false; |
| 245 | break; | 245 | break; |
| 246 | case KC_BSLS: | 246 | case KC_BACKSLASH: |
| 247 | if (record->event.pressed) { | 247 | if (record->event.pressed) { |
| 248 | if (character_shift) { | 248 | if (character_shift) { |
| 249 | print_char(0x7C); | 249 | print_char(0x7C); |
diff --git a/quantum/process_keycode/process_programmable_button.c b/quantum/process_keycode/process_programmable_button.c new file mode 100644 index 000000000..c6e77faac --- /dev/null +++ b/quantum/process_keycode/process_programmable_button.c | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2021 Thomas Weißschuh <thomas@t-8ch.de> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include "process_programmable_button.h" | ||
| 19 | #include "programmable_button.h" | ||
| 20 | |||
| 21 | bool process_programmable_button(uint16_t keycode, keyrecord_t *record) { | ||
| 22 | if (keycode >= PROGRAMMABLE_BUTTON_MIN && keycode <= PROGRAMMABLE_BUTTON_MAX) { | ||
| 23 | uint8_t button = keycode - PROGRAMMABLE_BUTTON_MIN + 1; | ||
| 24 | if (record->event.pressed) { | ||
| 25 | programmable_button_on(button); | ||
| 26 | } else { | ||
| 27 | programmable_button_off(button); | ||
| 28 | } | ||
| 29 | } | ||
| 30 | return true; | ||
| 31 | } | ||
diff --git a/quantum/process_keycode/process_programmable_button.h b/quantum/process_keycode/process_programmable_button.h new file mode 100644 index 000000000..47c6ce561 --- /dev/null +++ b/quantum/process_keycode/process_programmable_button.h | |||
| @@ -0,0 +1,23 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2021 Thomas Weißschuh <thomas@t-8ch.de> | ||
| 3 | |||
| 4 | This program is free software: you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation, either version 2 of the License, or | ||
| 7 | (at your option) any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #pragma once | ||
| 19 | |||
| 20 | #include <stdint.h> | ||
| 21 | #include "quantum.h" | ||
| 22 | |||
| 23 | bool process_programmable_button(uint16_t keycode, keyrecord_t *record); | ||
diff --git a/quantum/process_keycode/process_space_cadet.c b/quantum/process_keycode/process_space_cadet.c index f99db2a87..46b2648c3 100644 --- a/quantum/process_keycode/process_space_cadet.c +++ b/quantum/process_keycode/process_space_cadet.c | |||
| @@ -27,53 +27,53 @@ | |||
| 27 | 27 | ||
| 28 | // Shift / Enter setup | 28 | // Shift / Enter setup |
| 29 | #ifndef SFTENT_KEY | 29 | #ifndef SFTENT_KEY |
| 30 | # define SFTENT_KEY KC_ENT | 30 | # define SFTENT_KEY KC_ENTER |
| 31 | #endif | 31 | #endif |
| 32 | 32 | ||
| 33 | #ifdef DISABLE_SPACE_CADET_MODIFIER | 33 | #ifdef DISABLE_SPACE_CADET_MODIFIER |
| 34 | # ifndef LSPO_MOD | 34 | # ifndef LSPO_MOD |
| 35 | # define LSPO_MOD KC_TRNS | 35 | # define LSPO_MOD KC_TRANSPARENT |
| 36 | # endif | 36 | # endif |
| 37 | # ifndef RSPC_MOD | 37 | # ifndef RSPC_MOD |
| 38 | # define RSPC_MOD KC_TRNS | 38 | # define RSPC_MOD KC_TRANSPARENT |
| 39 | # endif | 39 | # endif |
| 40 | #else | 40 | #else |
| 41 | # ifndef LSPO_MOD | 41 | # ifndef LSPO_MOD |
| 42 | # define LSPO_MOD KC_LSFT | 42 | # define LSPO_MOD KC_LEFT_SHIFT |
| 43 | # endif | 43 | # endif |
| 44 | # ifndef RSPC_MOD | 44 | # ifndef RSPC_MOD |
| 45 | # define RSPC_MOD KC_RSFT | 45 | # define RSPC_MOD KC_RIGHT_SHIFT |
| 46 | # endif | 46 | # endif |
| 47 | #endif | 47 | #endif |
| 48 | // ********************************************************** | 48 | // ********************************************************** |
| 49 | 49 | ||
| 50 | // Shift / paren setup | 50 | // Shift / paren setup |
| 51 | #ifndef LSPO_KEYS | 51 | #ifndef LSPO_KEYS |
| 52 | # define LSPO_KEYS KC_LSFT, LSPO_MOD, LSPO_KEY | 52 | # define LSPO_KEYS KC_LEFT_SHIFT, LSPO_MOD, LSPO_KEY |
| 53 | #endif | 53 | #endif |
| 54 | #ifndef RSPC_KEYS | 54 | #ifndef RSPC_KEYS |
| 55 | # define RSPC_KEYS KC_RSFT, RSPC_MOD, RSPC_KEY | 55 | # define RSPC_KEYS KC_RIGHT_SHIFT, RSPC_MOD, RSPC_KEY |
| 56 | #endif | 56 | #endif |
| 57 | 57 | ||
| 58 | // Control / paren setup | 58 | // Control / paren setup |
| 59 | #ifndef LCPO_KEYS | 59 | #ifndef LCPO_KEYS |
| 60 | # define LCPO_KEYS KC_LCTL, KC_LSFT, KC_9 | 60 | # define LCPO_KEYS KC_LEFT_CTRL, KC_LEFT_SHIFT, KC_9 |
| 61 | #endif | 61 | #endif |
| 62 | #ifndef RCPC_KEYS | 62 | #ifndef RCPC_KEYS |
| 63 | # define RCPC_KEYS KC_RCTL, KC_RSFT, KC_0 | 63 | # define RCPC_KEYS KC_RIGHT_CTRL, KC_RIGHT_SHIFT, KC_0 |
| 64 | #endif | 64 | #endif |
| 65 | 65 | ||
| 66 | // Alt / paren setup | 66 | // Alt / paren setup |
| 67 | #ifndef LAPO_KEYS | 67 | #ifndef LAPO_KEYS |
| 68 | # define LAPO_KEYS KC_LALT, KC_LSFT, KC_9 | 68 | # define LAPO_KEYS KC_LEFT_ALT, KC_LEFT_SHIFT, KC_9 |
| 69 | #endif | 69 | #endif |
| 70 | #ifndef RAPC_KEYS | 70 | #ifndef RAPC_KEYS |
| 71 | # define RAPC_KEYS KC_RALT, KC_RSFT, KC_0 | 71 | # define RAPC_KEYS KC_RIGHT_ALT, KC_RIGHT_SHIFT, KC_0 |
| 72 | #endif | 72 | #endif |
| 73 | 73 | ||
| 74 | // Shift / Enter setup | 74 | // Shift / Enter setup |
| 75 | #ifndef SFTENT_KEYS | 75 | #ifndef SFTENT_KEYS |
| 76 | # define SFTENT_KEYS KC_RSFT, KC_TRNS, SFTENT_KEY | 76 | # define SFTENT_KEYS KC_RIGHT_SHIFT, KC_TRANSPARENT, SFTENT_KEY |
| 77 | #endif | 77 | #endif |
| 78 | 78 | ||
| 79 | static uint8_t sc_last = 0; | 79 | static uint8_t sc_last = 0; |
diff --git a/quantum/process_keycode/process_steno.c b/quantum/process_keycode/process_steno.c index a964aead3..5d0bb313b 100644 --- a/quantum/process_keycode/process_steno.c +++ b/quantum/process_keycode/process_steno.c | |||
| @@ -67,7 +67,7 @@ static const uint8_t boltmap[64] PROGMEM = {TXB_NUL, TXB_NUM, TXB_NUM, TXB_NUM, | |||
| 67 | 67 | ||
| 68 | #ifdef STENO_COMBINEDMAP | 68 | #ifdef STENO_COMBINEDMAP |
| 69 | /* Used to look up when pressing the middle row key to combine two consonant or vowel keys */ | 69 | /* Used to look up when pressing the middle row key to combine two consonant or vowel keys */ |
| 70 | static const uint16_t combinedmap_first[] PROGMEM = {STN_S1, STN_TL, STN_PL, STN_HL, STN_FR, STN_PR, STN_LR, STN_TR, STN_DR, STN_A, STN_E}; | 70 | static const uint16_t combinedmap_first[] PROGMEM = {STN_S1, STN_TL, STN_PL, STN_HL, STN_FR, STN_PR, STN_LR, STN_TR, STN_DR, STN_A, STN_E}; |
| 71 | static const uint16_t combinedmap_second[] PROGMEM = {STN_S2, STN_KL, STN_WL, STN_RL, STN_RR, STN_BR, STN_GR, STN_SR, STN_ZR, STN_O, STN_U}; | 71 | static const uint16_t combinedmap_second[] PROGMEM = {STN_S2, STN_KL, STN_WL, STN_RL, STN_RR, STN_BR, STN_GR, STN_SR, STN_ZR, STN_O, STN_U}; |
| 72 | #endif | 72 | #endif |
| 73 | 73 | ||
| @@ -174,11 +174,10 @@ bool process_steno(uint16_t keycode, keyrecord_t *record) { | |||
| 174 | return false; | 174 | return false; |
| 175 | 175 | ||
| 176 | #ifdef STENO_COMBINEDMAP | 176 | #ifdef STENO_COMBINEDMAP |
| 177 | case QK_STENO_COMB ... QK_STENO_COMB_MAX: | 177 | case QK_STENO_COMB ... QK_STENO_COMB_MAX: { |
| 178 | { | ||
| 179 | uint8_t result; | 178 | uint8_t result; |
| 180 | result = process_steno(combinedmap_first[keycode-QK_STENO_COMB], record); | 179 | result = process_steno(combinedmap_first[keycode - QK_STENO_COMB], record); |
| 181 | result &= process_steno(combinedmap_second[keycode-QK_STENO_COMB], record); | 180 | result &= process_steno(combinedmap_second[keycode - QK_STENO_COMB], record); |
| 182 | return result; | 181 | return result; |
| 183 | } | 182 | } |
| 184 | #endif | 183 | #endif |
diff --git a/quantum/process_keycode/process_terminal.c b/quantum/process_keycode/process_terminal.c index 7d1eefa9e..a059f3a52 100644 --- a/quantum/process_keycode/process_terminal.c +++ b/quantum/process_keycode/process_terminal.c | |||
| @@ -257,12 +257,12 @@ bool process_terminal(uint16_t keycode, keyrecord_t *record) { | |||
| 257 | process_terminal_command(); | 257 | process_terminal_command(); |
| 258 | return false; | 258 | return false; |
| 259 | break; | 259 | break; |
| 260 | case KC_ESC: | 260 | case KC_ESCAPE: |
| 261 | SEND_STRING("\n"); | 261 | SEND_STRING("\n"); |
| 262 | enable_terminal(); | 262 | enable_terminal(); |
| 263 | return false; | 263 | return false; |
| 264 | break; | 264 | break; |
| 265 | case KC_BSPC: | 265 | case KC_BACKSPACE: |
| 266 | str_len = strlen(buffer); | 266 | str_len = strlen(buffer); |
| 267 | if (str_len > 0) { | 267 | if (str_len > 0) { |
| 268 | buffer[str_len - 1] = 0; | 268 | buffer[str_len - 1] = 0; |
| @@ -284,7 +284,7 @@ bool process_terminal(uint16_t keycode, keyrecord_t *record) { | |||
| 284 | str_len = strlen(buffer); | 284 | str_len = strlen(buffer); |
| 285 | for (int i = 0; i < str_len; ++i) { | 285 | for (int i = 0; i < str_len; ++i) { |
| 286 | send_string(SS_TAP(X_BSPACE)); // clear w/e is on the line already | 286 | send_string(SS_TAP(X_BSPACE)); // clear w/e is on the line already |
| 287 | // process_terminal(KC_BSPC,record); | 287 | // process_terminal(KC_BACKSPACE,record); |
| 288 | } | 288 | } |
| 289 | strncpy(buffer, cmd_buffer[current_cmd_buffer_pos], 80); | 289 | strncpy(buffer, cmd_buffer[current_cmd_buffer_pos], 80); |
| 290 | 290 | ||
| @@ -299,7 +299,7 @@ bool process_terminal(uint16_t keycode, keyrecord_t *record) { | |||
| 299 | str_len = strlen(buffer); | 299 | str_len = strlen(buffer); |
| 300 | for (int i = 0; i < str_len; ++i) { | 300 | for (int i = 0; i < str_len; ++i) { |
| 301 | send_string(SS_TAP(X_BSPACE)); // clear w/e is on the line already | 301 | send_string(SS_TAP(X_BSPACE)); // clear w/e is on the line already |
| 302 | // process_terminal(KC_BSPC,record); | 302 | // process_terminal(KC_BACKSPACE,record); |
| 303 | } | 303 | } |
| 304 | strncpy(buffer, cmd_buffer[current_cmd_buffer_pos], 79); | 304 | strncpy(buffer, cmd_buffer[current_cmd_buffer_pos], 79); |
| 305 | 305 | ||
| @@ -311,7 +311,7 @@ bool process_terminal(uint16_t keycode, keyrecord_t *record) { | |||
| 311 | default: | 311 | default: |
| 312 | if (keycode <= 58) { | 312 | if (keycode <= 58) { |
| 313 | char_to_add = 0; | 313 | char_to_add = 0; |
| 314 | if (get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) { | 314 | if (get_mods() & (MOD_BIT(KC_LEFT_SHIFT) | MOD_BIT(KC_RIGHT_SHIFT))) { |
| 315 | char_to_add = shifted_keycode_to_ascii_lut[keycode]; | 315 | char_to_add = shifted_keycode_to_ascii_lut[keycode]; |
| 316 | } else if (get_mods() == 0) { | 316 | } else if (get_mods() == 0) { |
| 317 | char_to_add = keycode_to_ascii_lut[keycode]; | 317 | char_to_add = keycode_to_ascii_lut[keycode]; |
diff --git a/quantum/process_keycode/process_ucis.c b/quantum/process_keycode/process_ucis.c index 12b0aba9b..d084d2b66 100644 --- a/quantum/process_keycode/process_ucis.c +++ b/quantum/process_keycode/process_ucis.c | |||
| @@ -46,7 +46,7 @@ static bool is_uni_seq(char *seq) { | |||
| 46 | return false; | 46 | return false; |
| 47 | } | 47 | } |
| 48 | } | 48 | } |
| 49 | return qk_ucis_state.codes[i] == KC_ENT || qk_ucis_state.codes[i] == KC_SPC; | 49 | return qk_ucis_state.codes[i] == KC_ENTER || qk_ucis_state.codes[i] == KC_SPACE; |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | __attribute__((weak)) void qk_ucis_symbol_fallback(void) { | 52 | __attribute__((weak)) void qk_ucis_symbol_fallback(void) { |
| @@ -72,7 +72,7 @@ bool process_ucis(uint16_t keycode, keyrecord_t *record) { | |||
| 72 | return true; | 72 | return true; |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | bool special = keycode == KC_SPC || keycode == KC_ENT || keycode == KC_ESC || keycode == KC_BSPC; | 75 | bool special = keycode == KC_SPACE || keycode == KC_ENTER || keycode == KC_ESCAPE || keycode == KC_BACKSPACE; |
| 76 | if (qk_ucis_state.count >= UCIS_MAX_SYMBOL_LENGTH && !special) { | 76 | if (qk_ucis_state.count >= UCIS_MAX_SYMBOL_LENGTH && !special) { |
| 77 | return false; | 77 | return false; |
| 78 | } | 78 | } |
| @@ -81,7 +81,7 @@ bool process_ucis(uint16_t keycode, keyrecord_t *record) { | |||
| 81 | qk_ucis_state.count++; | 81 | qk_ucis_state.count++; |
| 82 | 82 | ||
| 83 | switch (keycode) { | 83 | switch (keycode) { |
| 84 | case KC_BSPC: | 84 | case KC_BACKSPACE: |
| 85 | if (qk_ucis_state.count >= 2) { | 85 | if (qk_ucis_state.count >= 2) { |
| 86 | qk_ucis_state.count -= 2; | 86 | qk_ucis_state.count -= 2; |
| 87 | return true; | 87 | return true; |
| @@ -90,16 +90,16 @@ bool process_ucis(uint16_t keycode, keyrecord_t *record) { | |||
| 90 | return false; | 90 | return false; |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | case KC_SPC: | 93 | case KC_SPACE: |
| 94 | case KC_ENT: | 94 | case KC_ENTER: |
| 95 | case KC_ESC: | 95 | case KC_ESCAPE: |
| 96 | for (uint8_t i = 0; i < qk_ucis_state.count; i++) { | 96 | for (uint8_t i = 0; i < qk_ucis_state.count; i++) { |
| 97 | register_code(KC_BSPC); | 97 | register_code(KC_BACKSPACE); |
| 98 | unregister_code(KC_BSPC); | 98 | unregister_code(KC_BACKSPACE); |
| 99 | wait_ms(UNICODE_TYPE_DELAY); | 99 | wait_ms(UNICODE_TYPE_DELAY); |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | if (keycode == KC_ESC) { | 102 | if (keycode == KC_ESCAPE) { |
| 103 | qk_ucis_state.in_progress = false; | 103 | qk_ucis_state.in_progress = false; |
| 104 | qk_ucis_cancel(); | 104 | qk_ucis_cancel(); |
| 105 | return false; | 105 | return false; |
diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 46fcaaa86..9c82571c7 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | unicode_config_t unicode_config; | 22 | unicode_config_t unicode_config; |
| 23 | uint8_t unicode_saved_mods; | 23 | uint8_t unicode_saved_mods; |
| 24 | bool unicode_saved_caps_lock; | 24 | bool unicode_saved_caps_lock; |
| 25 | bool unicode_saved_num_lock; | ||
| 25 | 26 | ||
| 26 | #if UNICODE_SELECTED_MODES != -1 | 27 | #if UNICODE_SELECTED_MODES != -1 |
| 27 | static uint8_t selected[] = {UNICODE_SELECTED_MODES}; | 28 | static uint8_t selected[] = {UNICODE_SELECTED_MODES}; |
| @@ -79,13 +80,14 @@ void persist_unicode_input_mode(void) { eeprom_update_byte(EECONFIG_UNICODEMODE, | |||
| 79 | 80 | ||
| 80 | __attribute__((weak)) void unicode_input_start(void) { | 81 | __attribute__((weak)) void unicode_input_start(void) { |
| 81 | unicode_saved_caps_lock = host_keyboard_led_state().caps_lock; | 82 | unicode_saved_caps_lock = host_keyboard_led_state().caps_lock; |
| 83 | unicode_saved_num_lock = host_keyboard_led_state().num_lock; | ||
| 82 | 84 | ||
| 83 | // Note the order matters here! | 85 | // Note the order matters here! |
| 84 | // Need to do this before we mess around with the mods, or else | 86 | // Need to do this before we mess around with the mods, or else |
| 85 | // UNICODE_KEY_LNX (which is usually Ctrl-Shift-U) might not work | 87 | // UNICODE_KEY_LNX (which is usually Ctrl-Shift-U) might not work |
| 86 | // correctly in the shifted case. | 88 | // correctly in the shifted case. |
| 87 | if (unicode_config.input_mode == UC_LNX && unicode_saved_caps_lock) { | 89 | if (unicode_config.input_mode == UC_LNX && unicode_saved_caps_lock) { |
| 88 | tap_code(KC_CAPS); | 90 | tap_code(KC_CAPS_LOCK); |
| 89 | } | 91 | } |
| 90 | 92 | ||
| 91 | unicode_saved_mods = get_mods(); // Save current mods | 93 | unicode_saved_mods = get_mods(); // Save current mods |
| @@ -99,8 +101,12 @@ __attribute__((weak)) void unicode_input_start(void) { | |||
| 99 | tap_code16(UNICODE_KEY_LNX); | 101 | tap_code16(UNICODE_KEY_LNX); |
| 100 | break; | 102 | break; |
| 101 | case UC_WIN: | 103 | case UC_WIN: |
| 102 | register_code(KC_LALT); | 104 | // For increased reliability, use numpad keys for inputting digits |
| 103 | tap_code(KC_PPLS); | 105 | if (!unicode_saved_num_lock) { |
| 106 | tap_code(KC_NUM_LOCK); | ||
| 107 | } | ||
| 108 | register_code(KC_LEFT_ALT); | ||
| 109 | tap_code(KC_KP_PLUS); | ||
| 104 | break; | 110 | break; |
| 105 | case UC_WINC: | 111 | case UC_WINC: |
| 106 | tap_code(UNICODE_KEY_WINC); | 112 | tap_code(UNICODE_KEY_WINC); |
| @@ -117,13 +123,16 @@ __attribute__((weak)) void unicode_input_finish(void) { | |||
| 117 | unregister_code(UNICODE_KEY_MAC); | 123 | unregister_code(UNICODE_KEY_MAC); |
| 118 | break; | 124 | break; |
| 119 | case UC_LNX: | 125 | case UC_LNX: |
| 120 | tap_code(KC_SPC); | 126 | tap_code(KC_SPACE); |
| 121 | if (unicode_saved_caps_lock) { | 127 | if (unicode_saved_caps_lock) { |
| 122 | tap_code(KC_CAPS); | 128 | tap_code(KC_CAPS_LOCK); |
| 123 | } | 129 | } |
| 124 | break; | 130 | break; |
| 125 | case UC_WIN: | 131 | case UC_WIN: |
| 126 | unregister_code(KC_LALT); | 132 | unregister_code(KC_LEFT_ALT); |
| 133 | if (!unicode_saved_num_lock) { | ||
| 134 | tap_code(KC_NUM_LOCK); | ||
| 135 | } | ||
| 127 | break; | 136 | break; |
| 128 | case UC_WINC: | 137 | case UC_WINC: |
| 129 | tap_code(KC_ENTER); | 138 | tap_code(KC_ENTER); |
| @@ -139,26 +148,44 @@ __attribute__((weak)) void unicode_input_cancel(void) { | |||
| 139 | unregister_code(UNICODE_KEY_MAC); | 148 | unregister_code(UNICODE_KEY_MAC); |
| 140 | break; | 149 | break; |
| 141 | case UC_LNX: | 150 | case UC_LNX: |
| 142 | tap_code(KC_ESC); | 151 | tap_code(KC_ESCAPE); |
| 143 | if (unicode_saved_caps_lock) { | 152 | if (unicode_saved_caps_lock) { |
| 144 | tap_code(KC_CAPS); | 153 | tap_code(KC_CAPS_LOCK); |
| 145 | } | 154 | } |
| 146 | break; | 155 | break; |
| 147 | case UC_WINC: | 156 | case UC_WINC: |
| 148 | tap_code(KC_ESC); | 157 | tap_code(KC_ESCAPE); |
| 149 | break; | 158 | break; |
| 150 | case UC_WIN: | 159 | case UC_WIN: |
| 151 | unregister_code(KC_LALT); | 160 | unregister_code(KC_LEFT_ALT); |
| 161 | if (!unicode_saved_num_lock) { | ||
| 162 | tap_code(KC_NUM_LOCK); | ||
| 163 | } | ||
| 152 | break; | 164 | break; |
| 153 | } | 165 | } |
| 154 | 166 | ||
| 155 | set_mods(unicode_saved_mods); // Reregister previously set mods | 167 | set_mods(unicode_saved_mods); // Reregister previously set mods |
| 156 | } | 168 | } |
| 157 | 169 | ||
| 170 | // clang-format off | ||
| 171 | |||
| 172 | static void send_nibble_wrapper(uint8_t digit) { | ||
| 173 | if (unicode_config.input_mode == UC_WIN) { | ||
| 174 | uint8_t kc = digit < 10 | ||
| 175 | ? KC_KP_1 + (10 + digit - 1) % 10 | ||
| 176 | : KC_A + (digit - 10); | ||
| 177 | tap_code(kc); | ||
| 178 | return; | ||
| 179 | } | ||
| 180 | send_nibble(digit); | ||
| 181 | } | ||
| 182 | |||
| 183 | // clang-format on | ||
| 184 | |||
| 158 | void register_hex(uint16_t hex) { | 185 | void register_hex(uint16_t hex) { |
| 159 | for (int i = 3; i >= 0; i--) { | 186 | for (int i = 3; i >= 0; i--) { |
| 160 | uint8_t digit = ((hex >> (i * 4)) & 0xF); | 187 | uint8_t digit = ((hex >> (i * 4)) & 0xF); |
| 161 | send_nibble(digit); | 188 | send_nibble_wrapper(digit); |
| 162 | } | 189 | } |
| 163 | } | 190 | } |
| 164 | 191 | ||
| @@ -171,10 +198,10 @@ void register_hex32(uint32_t hex) { | |||
| 171 | uint8_t digit = ((hex >> (i * 4)) & 0xF); | 198 | uint8_t digit = ((hex >> (i * 4)) & 0xF); |
| 172 | if (digit == 0) { | 199 | if (digit == 0) { |
| 173 | if (!onzerostart) { | 200 | if (!onzerostart) { |
| 174 | send_nibble(digit); | 201 | send_nibble_wrapper(digit); |
| 175 | } | 202 | } |
| 176 | } else { | 203 | } else { |
| 177 | send_nibble(digit); | 204 | send_nibble_wrapper(digit); |
| 178 | onzerostart = false; | 205 | onzerostart = false; |
| 179 | } | 206 | } |
| 180 | } | 207 | } |
diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index c10e171ec..72defb445 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h | |||
| @@ -24,13 +24,13 @@ | |||
| 24 | 24 | ||
| 25 | // Keycodes used for starting Unicode input on different platforms | 25 | // Keycodes used for starting Unicode input on different platforms |
| 26 | #ifndef UNICODE_KEY_MAC | 26 | #ifndef UNICODE_KEY_MAC |
| 27 | # define UNICODE_KEY_MAC KC_LALT | 27 | # define UNICODE_KEY_MAC KC_LEFT_ALT |
| 28 | #endif | 28 | #endif |
| 29 | #ifndef UNICODE_KEY_LNX | 29 | #ifndef UNICODE_KEY_LNX |
| 30 | # define UNICODE_KEY_LNX LCTL(LSFT(KC_U)) | 30 | # define UNICODE_KEY_LNX LCTL(LSFT(KC_U)) |
| 31 | #endif | 31 | #endif |
| 32 | #ifndef UNICODE_KEY_WINC | 32 | #ifndef UNICODE_KEY_WINC |
| 33 | # define UNICODE_KEY_WINC KC_RALT | 33 | # define UNICODE_KEY_WINC KC_RIGHT_ALT |
| 34 | #endif | 34 | #endif |
| 35 | 35 | ||
| 36 | // Comma-delimited, ordered list of input modes selected for use (e.g. in cycle) | 36 | // Comma-delimited, ordered list of input modes selected for use (e.g. in cycle) |
