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) |
[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 e561224374..c7e938a341 100644 --- a/users/drashna/keyrecords/autocorrection/autocorrection.c +++ b/users/drashna/keyrecords/autocorrection/autocorrection.c @@ -17,6 +17,14 @@ # error Dictionary size excees maximum size permitted # endif +/** + * @brief Process handler for autocorrect feature + * + * @param keycode Keycode registered by matrix press, per keymap + * @param record keyrecord_t structure + * @return true Continue processing keycodes, and send to host + * @return false Stop processing keycodes, and don't send to host + */ bool process_autocorrection(uint16_t keycode, keyrecord_t* record) { static uint8_t typo_buffer[AUTOCORRECTION_MAX_LENGTH] = {KC_SPC}; static uint8_t typo_buffer_size = 1; @@ -53,6 +61,14 @@ bool process_autocorrection(uint16_t keycode, keyrecord_t* record) { keycode &= 0xFF; break; # endif +# ifdef SWAP_HANDS_ENABLE + case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX: + if (keycode >= 0x56F0 || record->event.pressed || !record->tap.count) { + return true; + } + keycode &= 0xFF; + break; +# endif # ifndef NO_ACTION_ONESHOT case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX: if ((keycode & 0xF) == MOD_LSFT) { @@ -70,7 +86,6 @@ bool process_autocorrection(uint16_t keycode, keyrecord_t* record) { } } - // Subtract buffer for Backspace key, reset for other non-alpha. if (!(KC_A <= keycode && keycode <= KC_Z)) { if (keycode == KC_BSPC) { @@ -83,7 +98,7 @@ bool process_autocorrection(uint16_t keycode, keyrecord_t* record) { // Set a word boundary if space, period, digit, etc. is pressed. // Behave more conservatively for the enter key. Reset, so that enter // can't be used on a word ending. - if (keycode == KC_ENT) { + if (keycode == KC_ENT || (keycode == KC_MINUS && (get_mods() | get_oneshot_mods()) & MOD_MASK_SHIFT)) { typo_buffer_size = 0; } keycode = KC_SPC; diff --git a/users/drashna/keyrecords/caps_word.c b/users/drashna/keyrecords/caps_word.c index cc9ca93b72..0c7cd6cfe5 100644 --- a/users/drashna/keyrecords/caps_word.c +++ b/users/drashna/keyrecords/caps_word.c @@ -10,6 +10,16 @@ bool caps_word_enabled = false; bool caps_word_shifted = false; +/** + * @brief Handler for Caps Word feature. + * + * This checks the keycodes, and applies shift to the correct keys, if and when needid. + * + * @param keycode Keycode from matrix + * @param record keyrecord_t data structure + * @return true Continue processing keycode and sent to host + * @return false Stop processing keycode, and do not send to host + */ bool process_caps_word(uint16_t keycode, keyrecord_t* record) { if (!caps_word_enabled) { // 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 f49ac6ef64..012a57f7e4 100644 --- a/users/drashna/keyrecords/process_records.c +++ b/users/drashna/keyrecords/process_records.c @@ -18,8 +18,24 @@ bool host_driver_disabled = false; // Defines actions tor my global custom keycodes. Defined in drashna.h file // Then runs the _keymap's record handier if not processed here +/** + * @brief Keycode handler for keymaps + * + * This handles the keycodes at the keymap level, useful for keyboard specific customization + */ __attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; } __attribute__((weak)) bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { return true; } + +/** + * @brief Main user keycode handler + * + * This handles all of the keycodes for the user, including calling feature handlers. + * + * @param keycode Keycode from matrix + * @param record keyrecord_t data structure + * @return true Continue processing keycode and send to host + * @return false Stop process keycode and do not send to host + */ bool process_record_user(uint16_t keycode, keyrecord_t *record) { // If console is enabled, it will print the matrix position and status of each key pressed #ifdef KEYLOGGER_ENABLE @@ -215,12 +231,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *re return false; case REBOOT: if (record->event.pressed) { - shutdown_user(); -#ifdef __AVR__ - wdt_enable(WDTO_250MS); -#else - NVIC_SystemReset(); -#endif + software_reset(); } return false; diff --git a/users/drashna/keyrecords/tap_dances.c b/users/drashna/keyrecords/tap_dances.c index 63eb0c3348..a1a7439164 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]; // Otherwise, you will need to hit a bunch of times, or hit the "clear" command uint8_t diablo_times[] = {0, 1, 3, 5, 10, 30}; -// Cycle through the times for the macro, starting at 0, for disabled. +/** + * @brief Main function for handling diable related tap dances. + * + * @param state Main data struction contining information about events + * @param user_data Local data for the dance. Allows customization to be passed on to function + */ void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data) { diable_keys_t *diablo_keys = (diable_keys_t *)user_data; // Sets the keycode based on the index @@ -43,7 +48,10 @@ qk_tap_dance_action_t tap_dance_actions[] = { [TD_D3_4] = ACTION_TAP_DANCE_DIABLO(3, KC_4), }; -// Checks each of the 4 timers/keys to see if enough time has elapsed +/** + * @brief Runs check to see if timer has elapsed for each dance, and sends keycodes, if it has. + * + */ void run_diablo_macro_check(void) { for (uint8_t index = 0; index < NUM_OF_DIABLO_KEYS; index++) { // 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 4010b9c1c6..db2058e5d1 100644 --- a/users/drashna/keyrecords/unicode.c +++ b/users/drashna/keyrecords/unicode.c @@ -8,6 +8,11 @@ uint16_t typing_mode; +/** + * @brief Registers the unicode keystrokes based on desired unicode + * + * @param glyph Unicode character, supports up to 0x1FFFF (or higher) + */ void tap_unicode_glyph_nomods(uint32_t glyph) { uint8_t temp_mod = get_mods(); clear_mods(); @@ -43,6 +48,15 @@ typedef uint32_t (*translator_function_t)(bool is_shifted, uint32_t keycode); return ret; \ } +/** + * @brief Handler function for outputting unicode. + * + * @param keycode Keycode from matrix. + * @param record keyrecord_t data structure + * @param translator translator lut for different unicode modes + * @return true Continue processing matrix press, and send to host + * @return false Replace keycode, and do not send to host + */ bool process_record_glyph_replacement(uint16_t keycode, keyrecord_t *record, translator_function_t translator) { uint8_t temp_mod = get_mods(); uint8_t temp_osm = get_oneshot_mods(); @@ -182,6 +196,15 @@ bool process_record_zalgo(uint16_t keycode, keyrecord_t *record) { return true; } +/** + * @brief Main handler for unicode input + * + * @param keycode Keycode from switch matrix + * @param record keyrecord_t data struture + * @return true Send keycode from matrix to host + * @return false Stop processing and do not send to host + */ + bool process_record_unicode(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case UC_FLIP: // (ノಠ痊ಠ)ノ彡┻━┻ @@ -265,6 +288,10 @@ bool process_record_unicode(uint16_t keycode, keyrecord_t *record) { return process_unicode_common(keycode, record); } +/** + * @brief Initialize the default unicode mode on firmware startu + * + */ void matrix_init_unicode(void) { unicode_input_mode_init(); } |