diff options
| author | Drashna Jaelre <drashna@live.com> | 2022-01-21 19:36:52 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-21 19:36:52 -0800 |
| commit | b090ff03ed4391f27e8e3d9a843f529bedd08e19 (patch) | |
| tree | e734aa4541f05ed4f919f86ff36d85cbd17f795a /users/drashna/keyrecords | |
| parent | 8901c9eca1db8d10b06f544553a5fc941eda51ae (diff) | |
| download | qmk_firmware-b090ff03ed4391f27e8e3d9a843f529bedd08e19.tar.gz qmk_firmware-b090ff03ed4391f27e8e3d9a843f529bedd08e19.zip | |
[Keymap] Drashna's OLED rewrite (#15981)
Diffstat (limited to 'users/drashna/keyrecords')
| -rw-r--r-- | users/drashna/keyrecords/autocorrection/autocorrection.c | 19 | ||||
| -rw-r--r-- | users/drashna/keyrecords/caps_word.c | 10 | ||||
| -rw-r--r-- | users/drashna/keyrecords/process_records.c | 23 | ||||
| -rw-r--r-- | users/drashna/keyrecords/tap_dances.c | 12 | ||||
| -rw-r--r-- | users/drashna/keyrecords/unicode.c | 27 |
5 files changed, 81 insertions, 10 deletions
diff --git a/users/drashna/keyrecords/autocorrection/autocorrection.c b/users/drashna/keyrecords/autocorrection/autocorrection.c index e56122437..c7e938a34 100644 --- a/users/drashna/keyrecords/autocorrection/autocorrection.c +++ b/users/drashna/keyrecords/autocorrection/autocorrection.c | |||
| @@ -17,6 +17,14 @@ | |||
| 17 | # error Dictionary size excees maximum size permitted | 17 | # error Dictionary size excees maximum size permitted |
| 18 | # endif | 18 | # endif |
| 19 | 19 | ||
| 20 | /** | ||
| 21 | * @brief Process handler for autocorrect feature | ||
| 22 | * | ||
| 23 | * @param keycode Keycode registered by matrix press, per keymap | ||
| 24 | * @param record keyrecord_t structure | ||
| 25 | * @return true Continue processing keycodes, and send to host | ||
| 26 | * @return false Stop processing keycodes, and don't send to host | ||
| 27 | */ | ||
| 20 | bool process_autocorrection(uint16_t keycode, keyrecord_t* record) { | 28 | bool process_autocorrection(uint16_t keycode, keyrecord_t* record) { |
| 21 | static uint8_t typo_buffer[AUTOCORRECTION_MAX_LENGTH] = {KC_SPC}; | 29 | static uint8_t typo_buffer[AUTOCORRECTION_MAX_LENGTH] = {KC_SPC}; |
| 22 | static uint8_t typo_buffer_size = 1; | 30 | static uint8_t typo_buffer_size = 1; |
| @@ -53,6 +61,14 @@ bool process_autocorrection(uint16_t keycode, keyrecord_t* record) { | |||
| 53 | keycode &= 0xFF; | 61 | keycode &= 0xFF; |
| 54 | break; | 62 | break; |
| 55 | # endif | 63 | # endif |
| 64 | # ifdef SWAP_HANDS_ENABLE | ||
| 65 | case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX: | ||
| 66 | if (keycode >= 0x56F0 || record->event.pressed || !record->tap.count) { | ||
| 67 | return true; | ||
| 68 | } | ||
| 69 | keycode &= 0xFF; | ||
| 70 | break; | ||
| 71 | # endif | ||
| 56 | # ifndef NO_ACTION_ONESHOT | 72 | # ifndef NO_ACTION_ONESHOT |
| 57 | case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX: | 73 | case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX: |
| 58 | if ((keycode & 0xF) == MOD_LSFT) { | 74 | if ((keycode & 0xF) == MOD_LSFT) { |
| @@ -70,7 +86,6 @@ bool process_autocorrection(uint16_t keycode, keyrecord_t* record) { | |||
| 70 | } | 86 | } |
| 71 | } | 87 | } |
| 72 | 88 | ||
| 73 | |||
| 74 | // Subtract buffer for Backspace key, reset for other non-alpha. | 89 | // Subtract buffer for Backspace key, reset for other non-alpha. |
| 75 | if (!(KC_A <= keycode && keycode <= KC_Z)) { | 90 | if (!(KC_A <= keycode && keycode <= KC_Z)) { |
| 76 | if (keycode == KC_BSPC) { | 91 | if (keycode == KC_BSPC) { |
| @@ -83,7 +98,7 @@ bool process_autocorrection(uint16_t keycode, keyrecord_t* record) { | |||
| 83 | // Set a word boundary if space, period, digit, etc. is pressed. | 98 | // Set a word boundary if space, period, digit, etc. is pressed. |
| 84 | // Behave more conservatively for the enter key. Reset, so that enter | 99 | // Behave more conservatively for the enter key. Reset, so that enter |
| 85 | // can't be used on a word ending. | 100 | // can't be used on a word ending. |
| 86 | if (keycode == KC_ENT) { | 101 | if (keycode == KC_ENT || (keycode == KC_MINUS && (get_mods() | get_oneshot_mods()) & MOD_MASK_SHIFT)) { |
| 87 | typo_buffer_size = 0; | 102 | typo_buffer_size = 0; |
| 88 | } | 103 | } |
| 89 | keycode = KC_SPC; | 104 | keycode = KC_SPC; |
diff --git a/users/drashna/keyrecords/caps_word.c b/users/drashna/keyrecords/caps_word.c index cc9ca93b7..0c7cd6cfe 100644 --- a/users/drashna/keyrecords/caps_word.c +++ b/users/drashna/keyrecords/caps_word.c | |||
| @@ -10,6 +10,16 @@ | |||
| 10 | bool caps_word_enabled = false; | 10 | bool caps_word_enabled = false; |
| 11 | bool caps_word_shifted = false; | 11 | bool caps_word_shifted = false; |
| 12 | 12 | ||
| 13 | /** | ||
| 14 | * @brief Handler for Caps Word feature. | ||
| 15 | * | ||
| 16 | * This checks the keycodes, and applies shift to the correct keys, if and when needid. | ||
| 17 | * | ||
| 18 | * @param keycode Keycode from matrix | ||
| 19 | * @param record keyrecord_t data structure | ||
| 20 | * @return true Continue processing keycode and sent to host | ||
| 21 | * @return false Stop processing keycode, and do not send to host | ||
| 22 | */ | ||
| 13 | bool process_caps_word(uint16_t keycode, keyrecord_t* record) { | 23 | bool process_caps_word(uint16_t keycode, keyrecord_t* record) { |
| 14 | if (!caps_word_enabled) { | 24 | if (!caps_word_enabled) { |
| 15 | // Pressing both shift keys at the same time enables caps word. | 25 | // Pressing both shift keys at the same time enables caps word. |
diff --git a/users/drashna/keyrecords/process_records.c b/users/drashna/keyrecords/process_records.c index f49ac6ef6..012a57f7e 100644 --- a/users/drashna/keyrecords/process_records.c +++ b/users/drashna/keyrecords/process_records.c | |||
| @@ -18,8 +18,24 @@ bool host_driver_disabled = false; | |||
| 18 | // Defines actions tor my global custom keycodes. Defined in drashna.h file | 18 | // Defines actions tor my global custom keycodes. Defined in drashna.h file |
| 19 | // Then runs the _keymap's record handier if not processed here | 19 | // Then runs the _keymap's record handier if not processed here |
| 20 | 20 | ||
| 21 | /** | ||
| 22 | * @brief Keycode handler for keymaps | ||
| 23 | * | ||
| 24 | * This handles the keycodes at the keymap level, useful for keyboard specific customization | ||
| 25 | */ | ||
| 21 | __attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; } | 26 | __attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; } |
| 22 | __attribute__((weak)) bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { return true; } | 27 | __attribute__((weak)) bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { return true; } |
| 28 | |||
| 29 | /** | ||
| 30 | * @brief Main user keycode handler | ||
| 31 | * | ||
| 32 | * This handles all of the keycodes for the user, including calling feature handlers. | ||
| 33 | * | ||
| 34 | * @param keycode Keycode from matrix | ||
| 35 | * @param record keyrecord_t data structure | ||
| 36 | * @return true Continue processing keycode and send to host | ||
| 37 | * @return false Stop process keycode and do not send to host | ||
| 38 | */ | ||
| 23 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | 39 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { |
| 24 | // If console is enabled, it will print the matrix position and status of each key pressed | 40 | // If console is enabled, it will print the matrix position and status of each key pressed |
| 25 | #ifdef KEYLOGGER_ENABLE | 41 | #ifdef KEYLOGGER_ENABLE |
| @@ -215,12 +231,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *re | |||
| 215 | return false; | 231 | return false; |
| 216 | case REBOOT: | 232 | case REBOOT: |
| 217 | if (record->event.pressed) { | 233 | if (record->event.pressed) { |
| 218 | shutdown_user(); | 234 | software_reset(); |
| 219 | #ifdef __AVR__ | ||
| 220 | wdt_enable(WDTO_250MS); | ||
| 221 | #else | ||
| 222 | NVIC_SystemReset(); | ||
| 223 | #endif | ||
| 224 | } | 235 | } |
| 225 | return false; | 236 | return false; |
| 226 | 237 | ||
diff --git a/users/drashna/keyrecords/tap_dances.c b/users/drashna/keyrecords/tap_dances.c index 63eb0c334..a1a743916 100644 --- a/users/drashna/keyrecords/tap_dances.c +++ b/users/drashna/keyrecords/tap_dances.c | |||
| @@ -11,7 +11,12 @@ diablo_timer_t diablo_timer[NUM_OF_DIABLO_KEYS]; | |||
| 11 | // Otherwise, you will need to hit a bunch of times, or hit the "clear" command | 11 | // Otherwise, you will need to hit a bunch of times, or hit the "clear" command |
| 12 | uint8_t diablo_times[] = {0, 1, 3, 5, 10, 30}; | 12 | uint8_t diablo_times[] = {0, 1, 3, 5, 10, 30}; |
| 13 | 13 | ||
| 14 | // Cycle through the times for the macro, starting at 0, for disabled. | 14 | /** |
| 15 | * @brief Main function for handling diable related tap dances. | ||
| 16 | * | ||
| 17 | * @param state Main data struction contining information about events | ||
| 18 | * @param user_data Local data for the dance. Allows customization to be passed on to function | ||
| 19 | */ | ||
| 15 | void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data) { | 20 | void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data) { |
| 16 | diable_keys_t *diablo_keys = (diable_keys_t *)user_data; | 21 | diable_keys_t *diablo_keys = (diable_keys_t *)user_data; |
| 17 | // Sets the keycode based on the index | 22 | // Sets the keycode based on the index |
| @@ -43,7 +48,10 @@ qk_tap_dance_action_t tap_dance_actions[] = { | |||
| 43 | [TD_D3_4] = ACTION_TAP_DANCE_DIABLO(3, KC_4), | 48 | [TD_D3_4] = ACTION_TAP_DANCE_DIABLO(3, KC_4), |
| 44 | }; | 49 | }; |
| 45 | 50 | ||
| 46 | // Checks each of the 4 timers/keys to see if enough time has elapsed | 51 | /** |
| 52 | * @brief Runs check to see if timer has elapsed for each dance, and sends keycodes, if it has. | ||
| 53 | * | ||
| 54 | */ | ||
| 47 | void run_diablo_macro_check(void) { | 55 | void run_diablo_macro_check(void) { |
| 48 | for (uint8_t index = 0; index < NUM_OF_DIABLO_KEYS; index++) { | 56 | for (uint8_t index = 0; index < NUM_OF_DIABLO_KEYS; index++) { |
| 49 | // if key_interval is 0, it's disabled, so only run if it's set. If it's set, check the timer. | 57 | // if key_interval is 0, it's disabled, so only run if it's set. If it's set, check the timer. |
diff --git a/users/drashna/keyrecords/unicode.c b/users/drashna/keyrecords/unicode.c index 4010b9c1c..db2058e5d 100644 --- a/users/drashna/keyrecords/unicode.c +++ b/users/drashna/keyrecords/unicode.c | |||
| @@ -8,6 +8,11 @@ | |||
| 8 | 8 | ||
| 9 | uint16_t typing_mode; | 9 | uint16_t typing_mode; |
| 10 | 10 | ||
| 11 | /** | ||
| 12 | * @brief Registers the unicode keystrokes based on desired unicode | ||
| 13 | * | ||
| 14 | * @param glyph Unicode character, supports up to 0x1FFFF (or higher) | ||
| 15 | */ | ||
| 11 | void tap_unicode_glyph_nomods(uint32_t glyph) { | 16 | void tap_unicode_glyph_nomods(uint32_t glyph) { |
| 12 | uint8_t temp_mod = get_mods(); | 17 | uint8_t temp_mod = get_mods(); |
| 13 | clear_mods(); | 18 | clear_mods(); |
| @@ -43,6 +48,15 @@ typedef uint32_t (*translator_function_t)(bool is_shifted, uint32_t keycode); | |||
| 43 | return ret; \ | 48 | return ret; \ |
| 44 | } | 49 | } |
| 45 | 50 | ||
| 51 | /** | ||
| 52 | * @brief Handler function for outputting unicode. | ||
| 53 | * | ||
| 54 | * @param keycode Keycode from matrix. | ||
| 55 | * @param record keyrecord_t data structure | ||
| 56 | * @param translator translator lut for different unicode modes | ||
| 57 | * @return true Continue processing matrix press, and send to host | ||
| 58 | * @return false Replace keycode, and do not send to host | ||
| 59 | */ | ||
| 46 | bool process_record_glyph_replacement(uint16_t keycode, keyrecord_t *record, translator_function_t translator) { | 60 | bool process_record_glyph_replacement(uint16_t keycode, keyrecord_t *record, translator_function_t translator) { |
| 47 | uint8_t temp_mod = get_mods(); | 61 | uint8_t temp_mod = get_mods(); |
| 48 | uint8_t temp_osm = get_oneshot_mods(); | 62 | uint8_t temp_osm = get_oneshot_mods(); |
| @@ -182,6 +196,15 @@ bool process_record_zalgo(uint16_t keycode, keyrecord_t *record) { | |||
| 182 | return true; | 196 | return true; |
| 183 | } | 197 | } |
| 184 | 198 | ||
| 199 | /** | ||
| 200 | * @brief Main handler for unicode input | ||
| 201 | * | ||
| 202 | * @param keycode Keycode from switch matrix | ||
| 203 | * @param record keyrecord_t data struture | ||
| 204 | * @return true Send keycode from matrix to host | ||
| 205 | * @return false Stop processing and do not send to host | ||
| 206 | */ | ||
| 207 | |||
| 185 | bool process_record_unicode(uint16_t keycode, keyrecord_t *record) { | 208 | bool process_record_unicode(uint16_t keycode, keyrecord_t *record) { |
| 186 | switch (keycode) { | 209 | switch (keycode) { |
| 187 | case UC_FLIP: // (ノಠ痊ಠ)ノ彡┻━┻ | 210 | case UC_FLIP: // (ノಠ痊ಠ)ノ彡┻━┻ |
| @@ -265,6 +288,10 @@ bool process_record_unicode(uint16_t keycode, keyrecord_t *record) { | |||
| 265 | return process_unicode_common(keycode, record); | 288 | return process_unicode_common(keycode, record); |
| 266 | } | 289 | } |
| 267 | 290 | ||
| 291 | /** | ||
| 292 | * @brief Initialize the default unicode mode on firmware startu | ||
| 293 | * | ||
| 294 | */ | ||
| 268 | void matrix_init_unicode(void) { | 295 | void matrix_init_unicode(void) { |
| 269 | unicode_input_mode_init(); | 296 | unicode_input_mode_init(); |
| 270 | } | 297 | } |
