You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1208 lines
40 KiB

2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
Process combos earlier & overlapping combos (#8591) * Combo processing improvements. Now it is possible to use ModTap and LayerTap keys as part of combos. Overlapping combos also don't trigger all the combos, just exactly the one that you press. New settings: - COMBO_MUST_HOLD_MODS - COMBO_MOD_TERM - COMBO_TERM_PER_COMBO - COMBO_MUST_HOLD_PER_COMBO - COMBO_STRICT_TIMER - COMBO_NO_TIMER * Remove the size flags from combo_t struct boolean members. This in the end actually saves space as the members are accessed so many times. The amount of operations needed to access the bits uses more memory than setting the size saves. * Fix `process_combo_key_release` not called correctly with tap-only combos * Fix not passing a pointer when NO_ACTION_TAPPING is defined. * Docs for `COMBO_ONLY_FROM_LAYER` * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update quantum/process_keycode/process_combo.c Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Add `EXTRA_SHORT_COMBOS` option. Stuff combo's `disabled` and `active` flags into `state`. Possibly can save some space. * Add more examples and clarify things with dict management system. - Simple examples now has a combo that has modifiers included. - The slightly more advanced examples now are actually more advanced instead of just `tap_code16(<modded-keycode>)`. - Added a note that `COMBO_ACTION`s are not needed anymore as you can just use custom keycodes. - Added a note that the `g/keymap_combo.h` macros use the `process_combo_event` function and that it is not usable in one's keymap afterwards. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Change "the" combo action example to "email" example. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Fix sneaky infinite loop with `combo_disable()` No need to call `dump_key_buffer` when disabling combos because the buffer is either being dumped if a combo-key was pressed, or the buffer is empty if a non-combo-key is pressed. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: Drashna Jaelre <drashna@live.com>
2 years ago
Process combos earlier & overlapping combos (#8591) * Combo processing improvements. Now it is possible to use ModTap and LayerTap keys as part of combos. Overlapping combos also don't trigger all the combos, just exactly the one that you press. New settings: - COMBO_MUST_HOLD_MODS - COMBO_MOD_TERM - COMBO_TERM_PER_COMBO - COMBO_MUST_HOLD_PER_COMBO - COMBO_STRICT_TIMER - COMBO_NO_TIMER * Remove the size flags from combo_t struct boolean members. This in the end actually saves space as the members are accessed so many times. The amount of operations needed to access the bits uses more memory than setting the size saves. * Fix `process_combo_key_release` not called correctly with tap-only combos * Fix not passing a pointer when NO_ACTION_TAPPING is defined. * Docs for `COMBO_ONLY_FROM_LAYER` * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update quantum/process_keycode/process_combo.c Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Add `EXTRA_SHORT_COMBOS` option. Stuff combo's `disabled` and `active` flags into `state`. Possibly can save some space. * Add more examples and clarify things with dict management system. - Simple examples now has a combo that has modifiers included. - The slightly more advanced examples now are actually more advanced instead of just `tap_code16(<modded-keycode>)`. - Added a note that `COMBO_ACTION`s are not needed anymore as you can just use custom keycodes. - Added a note that the `g/keymap_combo.h` macros use the `process_combo_event` function and that it is not usable in one's keymap afterwards. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Change "the" combo action example to "email" example. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Fix sneaky infinite loop with `combo_disable()` No need to call `dump_key_buffer` when disabling combos because the buffer is either being dumped if a combo-key was pressed, or the buffer is empty if a non-combo-key is pressed. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: Drashna Jaelre <drashna@live.com>
2 years ago
Process combos earlier & overlapping combos (#8591) * Combo processing improvements. Now it is possible to use ModTap and LayerTap keys as part of combos. Overlapping combos also don't trigger all the combos, just exactly the one that you press. New settings: - COMBO_MUST_HOLD_MODS - COMBO_MOD_TERM - COMBO_TERM_PER_COMBO - COMBO_MUST_HOLD_PER_COMBO - COMBO_STRICT_TIMER - COMBO_NO_TIMER * Remove the size flags from combo_t struct boolean members. This in the end actually saves space as the members are accessed so many times. The amount of operations needed to access the bits uses more memory than setting the size saves. * Fix `process_combo_key_release` not called correctly with tap-only combos * Fix not passing a pointer when NO_ACTION_TAPPING is defined. * Docs for `COMBO_ONLY_FROM_LAYER` * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update quantum/process_keycode/process_combo.c Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Add `EXTRA_SHORT_COMBOS` option. Stuff combo's `disabled` and `active` flags into `state`. Possibly can save some space. * Add more examples and clarify things with dict management system. - Simple examples now has a combo that has modifiers included. - The slightly more advanced examples now are actually more advanced instead of just `tap_code16(<modded-keycode>)`. - Added a note that `COMBO_ACTION`s are not needed anymore as you can just use custom keycodes. - Added a note that the `g/keymap_combo.h` macros use the `process_combo_event` function and that it is not usable in one's keymap afterwards. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Change "the" combo action example to "email" example. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Fix sneaky infinite loop with `combo_disable()` No need to call `dump_key_buffer` when disabling combos because the buffer is either being dumped if a combo-key was pressed, or the buffer is empty if a non-combo-key is pressed. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: Drashna Jaelre <drashna@live.com>
2 years ago
Process combos earlier & overlapping combos (#8591) * Combo processing improvements. Now it is possible to use ModTap and LayerTap keys as part of combos. Overlapping combos also don't trigger all the combos, just exactly the one that you press. New settings: - COMBO_MUST_HOLD_MODS - COMBO_MOD_TERM - COMBO_TERM_PER_COMBO - COMBO_MUST_HOLD_PER_COMBO - COMBO_STRICT_TIMER - COMBO_NO_TIMER * Remove the size flags from combo_t struct boolean members. This in the end actually saves space as the members are accessed so many times. The amount of operations needed to access the bits uses more memory than setting the size saves. * Fix `process_combo_key_release` not called correctly with tap-only combos * Fix not passing a pointer when NO_ACTION_TAPPING is defined. * Docs for `COMBO_ONLY_FROM_LAYER` * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update quantum/process_keycode/process_combo.c Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Add `EXTRA_SHORT_COMBOS` option. Stuff combo's `disabled` and `active` flags into `state`. Possibly can save some space. * Add more examples and clarify things with dict management system. - Simple examples now has a combo that has modifiers included. - The slightly more advanced examples now are actually more advanced instead of just `tap_code16(<modded-keycode>)`. - Added a note that `COMBO_ACTION`s are not needed anymore as you can just use custom keycodes. - Added a note that the `g/keymap_combo.h` macros use the `process_combo_event` function and that it is not usable in one's keymap afterwards. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Change "the" combo action example to "email" example. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Fix sneaky infinite loop with `combo_disable()` No need to call `dump_key_buffer` when disabling combos because the buffer is either being dumped if a combo-key was pressed, or the buffer is empty if a non-combo-key is pressed. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: Drashna Jaelre <drashna@live.com>
2 years ago
Process combos earlier & overlapping combos (#8591) * Combo processing improvements. Now it is possible to use ModTap and LayerTap keys as part of combos. Overlapping combos also don't trigger all the combos, just exactly the one that you press. New settings: - COMBO_MUST_HOLD_MODS - COMBO_MOD_TERM - COMBO_TERM_PER_COMBO - COMBO_MUST_HOLD_PER_COMBO - COMBO_STRICT_TIMER - COMBO_NO_TIMER * Remove the size flags from combo_t struct boolean members. This in the end actually saves space as the members are accessed so many times. The amount of operations needed to access the bits uses more memory than setting the size saves. * Fix `process_combo_key_release` not called correctly with tap-only combos * Fix not passing a pointer when NO_ACTION_TAPPING is defined. * Docs for `COMBO_ONLY_FROM_LAYER` * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update quantum/process_keycode/process_combo.c Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Add `EXTRA_SHORT_COMBOS` option. Stuff combo's `disabled` and `active` flags into `state`. Possibly can save some space. * Add more examples and clarify things with dict management system. - Simple examples now has a combo that has modifiers included. - The slightly more advanced examples now are actually more advanced instead of just `tap_code16(<modded-keycode>)`. - Added a note that `COMBO_ACTION`s are not needed anymore as you can just use custom keycodes. - Added a note that the `g/keymap_combo.h` macros use the `process_combo_event` function and that it is not usable in one's keymap afterwards. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Change "the" combo action example to "email" example. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Fix sneaky infinite loop with `combo_disable()` No need to call `dump_key_buffer` when disabling combos because the buffer is either being dumped if a combo-key was pressed, or the buffer is empty if a non-combo-key is pressed. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: Drashna Jaelre <drashna@live.com>
2 years ago
2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
2020 November 28 Breaking Changes Update (#11053) * Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
3 years ago
Process combos earlier & overlapping combos (#8591) * Combo processing improvements. Now it is possible to use ModTap and LayerTap keys as part of combos. Overlapping combos also don't trigger all the combos, just exactly the one that you press. New settings: - COMBO_MUST_HOLD_MODS - COMBO_MOD_TERM - COMBO_TERM_PER_COMBO - COMBO_MUST_HOLD_PER_COMBO - COMBO_STRICT_TIMER - COMBO_NO_TIMER * Remove the size flags from combo_t struct boolean members. This in the end actually saves space as the members are accessed so many times. The amount of operations needed to access the bits uses more memory than setting the size saves. * Fix `process_combo_key_release` not called correctly with tap-only combos * Fix not passing a pointer when NO_ACTION_TAPPING is defined. * Docs for `COMBO_ONLY_FROM_LAYER` * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update quantum/process_keycode/process_combo.c Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Add `EXTRA_SHORT_COMBOS` option. Stuff combo's `disabled` and `active` flags into `state`. Possibly can save some space. * Add more examples and clarify things with dict management system. - Simple examples now has a combo that has modifiers included. - The slightly more advanced examples now are actually more advanced instead of just `tap_code16(<modded-keycode>)`. - Added a note that `COMBO_ACTION`s are not needed anymore as you can just use custom keycodes. - Added a note that the `g/keymap_combo.h` macros use the `process_combo_event` function and that it is not usable in one's keymap afterwards. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Change "the" combo action example to "email" example. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Fix sneaky infinite loop with `combo_disable()` No need to call `dump_key_buffer` when disabling combos because the buffer is either being dumped if a combo-key was pressed, or the buffer is empty if a non-combo-key is pressed. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: Drashna Jaelre <drashna@live.com>
2 years ago
Process combos earlier & overlapping combos (#8591) * Combo processing improvements. Now it is possible to use ModTap and LayerTap keys as part of combos. Overlapping combos also don't trigger all the combos, just exactly the one that you press. New settings: - COMBO_MUST_HOLD_MODS - COMBO_MOD_TERM - COMBO_TERM_PER_COMBO - COMBO_MUST_HOLD_PER_COMBO - COMBO_STRICT_TIMER - COMBO_NO_TIMER * Remove the size flags from combo_t struct boolean members. This in the end actually saves space as the members are accessed so many times. The amount of operations needed to access the bits uses more memory than setting the size saves. * Fix `process_combo_key_release` not called correctly with tap-only combos * Fix not passing a pointer when NO_ACTION_TAPPING is defined. * Docs for `COMBO_ONLY_FROM_LAYER` * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update quantum/process_keycode/process_combo.c Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Add `EXTRA_SHORT_COMBOS` option. Stuff combo's `disabled` and `active` flags into `state`. Possibly can save some space. * Add more examples and clarify things with dict management system. - Simple examples now has a combo that has modifiers included. - The slightly more advanced examples now are actually more advanced instead of just `tap_code16(<modded-keycode>)`. - Added a note that `COMBO_ACTION`s are not needed anymore as you can just use custom keycodes. - Added a note that the `g/keymap_combo.h` macros use the `process_combo_event` function and that it is not usable in one's keymap afterwards. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Change "the" combo action example to "email" example. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Fix sneaky infinite loop with `combo_disable()` No need to call `dump_key_buffer` when disabling combos because the buffer is either being dumped if a combo-key was pressed, or the buffer is empty if a non-combo-key is pressed. * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> * Update docs/feature_combo.md Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: precondition <57645186+precondition@users.noreply.github.com> Co-authored-by: Drashna Jaelre <drashna@live.com>
2 years ago
  1. /*
  2. Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include <limits.h>
  15. #ifdef DEBUG_ACTION
  16. # include "debug.h"
  17. #else
  18. # include "nodebug.h"
  19. #endif
  20. #include "host.h"
  21. #include "keycode.h"
  22. #include "keyboard.h"
  23. #include "keymap.h"
  24. #include "mousekey.h"
  25. #include "programmable_button.h"
  26. #include "command.h"
  27. #include "led.h"
  28. #include "action_layer.h"
  29. #include "action_tapping.h"
  30. #include "action_util.h"
  31. #include "action.h"
  32. #include "wait.h"
  33. #include "keycode_config.h"
  34. #ifdef BACKLIGHT_ENABLE
  35. # include "backlight.h"
  36. #endif
  37. #ifdef POINTING_DEVICE_ENABLE
  38. # include "pointing_device.h"
  39. #endif
  40. int tp_buttons;
  41. #if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
  42. int retro_tapping_counter = 0;
  43. #endif
  44. #if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING)
  45. # include "process_auto_shift.h"
  46. #endif
  47. #ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY
  48. __attribute__((weak)) bool get_ignore_mod_tap_interrupt(uint16_t keycode, keyrecord_t *record) {
  49. return false;
  50. }
  51. #endif
  52. #ifdef RETRO_TAPPING_PER_KEY
  53. __attribute__((weak)) bool get_retro_tapping(uint16_t keycode, keyrecord_t *record) {
  54. return false;
  55. }
  56. #endif
  57. __attribute__((weak)) bool pre_process_record_quantum(keyrecord_t *record) {
  58. return true;
  59. }
  60. /** \brief Called to execute an action.
  61. *
  62. * FIXME: Needs documentation.
  63. */
  64. void action_exec(keyevent_t event) {
  65. if (!IS_NOEVENT(event)) {
  66. dprint("\n---- action_exec: start -----\n");
  67. dprint("EVENT: ");
  68. debug_event(event);
  69. dprintln();
  70. #if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
  71. retro_tapping_counter++;
  72. #endif
  73. }
  74. if (event.pressed) {
  75. // clear the potential weak mods left by previously pressed keys
  76. clear_weak_mods();
  77. }
  78. #ifdef SWAP_HANDS_ENABLE
  79. // Swap hands handles both keys and encoders, if ENCODER_MAP_ENABLE is defined.
  80. if (!IS_NOEVENT(event)) {
  81. process_hand_swap(&event);
  82. }
  83. #endif
  84. keyrecord_t record = {.event = event};
  85. #ifndef NO_ACTION_ONESHOT
  86. if (keymap_config.oneshot_enable) {
  87. # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
  88. if (has_oneshot_layer_timed_out()) {
  89. clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
  90. }
  91. if (has_oneshot_mods_timed_out()) {
  92. clear_oneshot_mods();
  93. }
  94. # ifdef SWAP_HANDS_ENABLE
  95. if (has_oneshot_swaphands_timed_out()) {
  96. clear_oneshot_swaphands();
  97. }
  98. # endif
  99. # endif
  100. }
  101. #endif
  102. #ifndef NO_ACTION_TAPPING
  103. # if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
  104. if (event.pressed) {
  105. retroshift_poll_time(&event);
  106. }
  107. # endif
  108. if (IS_NOEVENT(record.event) || pre_process_record_quantum(&record)) {
  109. action_tapping_process(record);
  110. }
  111. #else
  112. if (IS_NOEVENT(record.event) || pre_process_record_quantum(&record)) {
  113. process_record(&record);
  114. }
  115. if (!IS_NOEVENT(record.event)) {
  116. dprint("processed: ");
  117. debug_record(record);
  118. dprintln();
  119. }
  120. #endif
  121. }
  122. #ifdef SWAP_HANDS_ENABLE
  123. extern const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS];
  124. # ifdef ENCODER_MAP_ENABLE
  125. extern const uint8_t PROGMEM encoder_hand_swap_config[NUM_ENCODERS];
  126. # endif // ENCODER_MAP_ENABLE
  127. bool swap_hands = false;
  128. bool swap_held = false;
  129. bool should_swap_hands(size_t index, uint8_t *swap_state, bool pressed) {
  130. size_t array_index = index / (CHAR_BIT);
  131. size_t bit_index = index % (CHAR_BIT);
  132. uint8_t bit_val = 1 << bit_index;
  133. bool do_swap = pressed ? swap_hands : swap_state[array_index] & bit_val;
  134. return do_swap;
  135. }
  136. void set_swap_hands_state(size_t index, uint8_t *swap_state, bool on) {
  137. size_t array_index = index / (CHAR_BIT);
  138. size_t bit_index = index % (CHAR_BIT);
  139. uint8_t bit_val = 1 << bit_index;
  140. if (on) {
  141. swap_state[array_index] |= bit_val;
  142. } else {
  143. swap_state[array_index] &= ~bit_val;
  144. }
  145. }
  146. /** \brief Process Hand Swap
  147. *
  148. * FIXME: Needs documentation.
  149. */
  150. void process_hand_swap(keyevent_t *event) {
  151. keypos_t pos = event->key;
  152. if (pos.row < MATRIX_ROWS && pos.col < MATRIX_COLS) {
  153. static uint8_t matrix_swap_state[((MATRIX_ROWS * MATRIX_COLS) + (CHAR_BIT)-1) / (CHAR_BIT)];
  154. size_t index = (size_t)(pos.row * MATRIX_COLS) + pos.col;
  155. bool do_swap = should_swap_hands(index, matrix_swap_state, event->pressed);
  156. if (do_swap) {
  157. event->key.row = pgm_read_byte(&hand_swap_config[pos.row][pos.col].row);
  158. event->key.col = pgm_read_byte(&hand_swap_config[pos.row][pos.col].col);
  159. set_swap_hands_state(index, matrix_swap_state, true);
  160. } else {
  161. set_swap_hands_state(index, matrix_swap_state, false);
  162. }
  163. }
  164. # ifdef ENCODER_MAP_ENABLE
  165. else if (pos.row == KEYLOC_ENCODER_CW || pos.row == KEYLOC_ENCODER_CCW) {
  166. static uint8_t encoder_swap_state[((NUM_ENCODERS) + (CHAR_BIT)-1) / (CHAR_BIT)];
  167. size_t index = pos.col;
  168. bool do_swap = should_swap_hands(index, encoder_swap_state, event->pressed);
  169. if (do_swap) {
  170. event->key.row = pos.row;
  171. event->key.col = pgm_read_byte(&encoder_hand_swap_config[pos.col]);
  172. set_swap_hands_state(index, encoder_swap_state, true);
  173. } else {
  174. set_swap_hands_state(index, encoder_swap_state, false);
  175. }
  176. }
  177. # endif // ENCODER_MAP_ENABLE
  178. }
  179. #endif
  180. #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
  181. bool disable_action_cache = false;
  182. void process_record_nocache(keyrecord_t *record) {
  183. disable_action_cache = true;
  184. process_record(record);
  185. disable_action_cache = false;
  186. }
  187. #else
  188. void process_record_nocache(keyrecord_t *record) {
  189. process_record(record);
  190. }
  191. #endif
  192. __attribute__((weak)) bool process_record_quantum(keyrecord_t *record) {
  193. return true;
  194. }
  195. __attribute__((weak)) void post_process_record_quantum(keyrecord_t *record) {}
  196. #ifndef NO_ACTION_TAPPING
  197. /** \brief Allows for handling tap-hold actions immediately instead of waiting for TAPPING_TERM or another keypress.
  198. *
  199. * FIXME: Needs documentation.
  200. */
  201. void process_record_tap_hint(keyrecord_t *record) {
  202. action_t action = layer_switch_get_action(record->event.key);
  203. switch (action.kind.id) {
  204. # ifdef SWAP_HANDS_ENABLE
  205. case ACT_SWAP_HANDS:
  206. switch (action.swap.code) {
  207. case OP_SH_ONESHOT:
  208. break;
  209. case OP_SH_TAP_TOGGLE:
  210. default:
  211. swap_hands = !swap_hands;
  212. swap_held = true;
  213. }
  214. break;
  215. # endif
  216. }
  217. }
  218. #endif
  219. /** \brief Take a key event (key press or key release) and processes it.
  220. *
  221. * FIXME: Needs documentation.
  222. */
  223. void process_record(keyrecord_t *record) {
  224. if (IS_NOEVENT(record->event)) {
  225. return;
  226. }
  227. if (!process_record_quantum(record)) {
  228. #ifndef NO_ACTION_ONESHOT
  229. if (is_oneshot_layer_active() && record->event.pressed && keymap_config.oneshot_enable) {
  230. clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
  231. }
  232. #endif
  233. return;
  234. }
  235. process_record_handler(record);
  236. post_process_record_quantum(record);
  237. }
  238. void process_record_handler(keyrecord_t *record) {
  239. #ifdef COMBO_ENABLE
  240. action_t action;
  241. if (record->keycode) {
  242. action = action_for_keycode(record->keycode);
  243. } else {
  244. action = store_or_get_action(record->event.pressed, record->event.key);
  245. }
  246. #else
  247. action_t action = store_or_get_action(record->event.pressed, record->event.key);
  248. #endif
  249. dprint("ACTION: ");
  250. debug_action(action);
  251. #ifndef NO_ACTION_LAYER
  252. dprint(" layer_state: ");
  253. layer_debug();
  254. dprint(" default_layer_state: ");
  255. default_layer_debug();
  256. #endif
  257. dprintln();
  258. process_action(record, action);
  259. }
  260. #if defined(PS2_MOUSE_ENABLE) || defined(POINTING_DEVICE_ENABLE)
  261. void register_button(bool pressed, enum mouse_buttons button) {
  262. # ifdef PS2_MOUSE_ENABLE
  263. tp_buttons = pressed ? tp_buttons | button : tp_buttons & ~button;
  264. # endif
  265. # ifdef POINTING_DEVICE_ENABLE
  266. report_mouse_t currentReport = pointing_device_get_report();
  267. currentReport.buttons = pressed ? currentReport.buttons | button : currentReport.buttons & ~button;
  268. pointing_device_set_report(currentReport);
  269. # endif
  270. }
  271. #endif
  272. /** \brief Take an action and processes it.
  273. *
  274. * FIXME: Needs documentation.
  275. */
  276. void process_action(keyrecord_t *record, action_t action) {
  277. keyevent_t event = record->event;
  278. #ifndef NO_ACTION_TAPPING
  279. uint8_t tap_count = record->tap.count;
  280. #endif
  281. #ifndef NO_ACTION_ONESHOT
  282. bool do_release_oneshot = false;
  283. // notice we only clear the one shot layer if the pressed key is not a modifier.
  284. if (is_oneshot_layer_active() && event.pressed && (action.kind.id == ACT_USAGE || !IS_MOD(action.key.code))
  285. # ifdef SWAP_HANDS_ENABLE
  286. && !(action.kind.id == ACT_SWAP_HANDS && action.swap.code == OP_SH_ONESHOT)
  287. # endif
  288. && keymap_config.oneshot_enable) {
  289. clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
  290. do_release_oneshot = !is_oneshot_layer_active();
  291. }
  292. #endif
  293. switch (action.kind.id) {
  294. /* Key and Mods */
  295. case ACT_LMODS:
  296. case ACT_RMODS: {
  297. uint8_t mods = (action.kind.id == ACT_LMODS) ? action.key.mods : action.key.mods << 4;
  298. if (event.pressed) {
  299. if (mods) {
  300. if (IS_MOD(action.key.code) || action.key.code == KC_NO) {
  301. // e.g. LSFT(KC_LEFT_GUI): we don't want the LSFT to be weak as it would make it useless.
  302. // This also makes LSFT(KC_LEFT_GUI) behave exactly the same as LGUI(KC_LEFT_SHIFT).
  303. // Same applies for some keys like KC_MEH which are declared as MEH(KC_NO).
  304. add_mods(mods);
  305. } else {
  306. add_weak_mods(mods);
  307. }
  308. send_keyboard_report();
  309. }
  310. register_code(action.key.code);
  311. } else {
  312. unregister_code(action.key.code);
  313. if (mods) {
  314. if (IS_MOD(action.key.code) || action.key.code == KC_NO) {
  315. del_mods(mods);
  316. } else {
  317. del_weak_mods(mods);
  318. }
  319. send_keyboard_report();
  320. }
  321. }
  322. } break;
  323. #ifndef NO_ACTION_TAPPING
  324. case ACT_LMODS_TAP:
  325. case ACT_RMODS_TAP: {
  326. uint8_t mods = (action.kind.id == ACT_LMODS_TAP) ? action.key.mods : action.key.mods << 4;
  327. switch (action.layer_tap.code) {
  328. # ifndef NO_ACTION_ONESHOT
  329. case MODS_ONESHOT:
  330. // Oneshot modifier
  331. if (!keymap_config.oneshot_enable) {
  332. if (event.pressed) {
  333. if (mods) {
  334. if (IS_MOD(action.key.code) || action.key.code == KC_NO) {
  335. // e.g. LSFT(KC_LGUI): we don't want the LSFT to be weak as it would make it useless.
  336. // This also makes LSFT(KC_LGUI) behave exactly the same as LGUI(KC_LSFT).
  337. // Same applies for some keys like KC_MEH which are declared as MEH(KC_NO).
  338. add_mods(mods);
  339. } else {
  340. add_weak_mods(mods);
  341. }
  342. send_keyboard_report();
  343. }
  344. register_code(action.key.code);
  345. } else {
  346. unregister_code(action.key.code);
  347. if (mods) {
  348. if (IS_MOD(action.key.code) || action.key.code == KC_NO) {
  349. del_mods(mods);
  350. } else {
  351. del_weak_mods(mods);
  352. }
  353. send_keyboard_report();
  354. }
  355. }
  356. } else {
  357. if (event.pressed) {
  358. if (tap_count == 0) {
  359. dprint("MODS_TAP: Oneshot: 0\n");
  360. register_mods(mods | get_oneshot_mods());
  361. } else if (tap_count == 1) {
  362. dprint("MODS_TAP: Oneshot: start\n");
  363. set_oneshot_mods(mods | get_oneshot_mods());
  364. # if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1
  365. } else if (tap_count == ONESHOT_TAP_TOGGLE) {
  366. dprint("MODS_TAP: Toggling oneshot");
  367. register_mods(mods);
  368. clear_oneshot_mods();
  369. set_oneshot_locked_mods(mods | get_oneshot_locked_mods());
  370. # endif
  371. } else {
  372. register_mods(mods | get_oneshot_mods());
  373. }
  374. } else {
  375. if (tap_count == 0) {
  376. clear_oneshot_mods();
  377. unregister_mods(mods);
  378. } else if (tap_count == 1) {
  379. // Retain Oneshot mods
  380. # if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1
  381. if (mods & get_mods()) {
  382. unregister_mods(mods);
  383. clear_oneshot_mods();
  384. set_oneshot_locked_mods(~mods & get_oneshot_locked_mods());
  385. }
  386. } else if (tap_count == ONESHOT_TAP_TOGGLE) {
  387. // Toggle Oneshot Layer
  388. # endif
  389. } else {
  390. unregister_mods(mods);
  391. clear_oneshot_mods();
  392. }
  393. }
  394. }
  395. break;
  396. # endif
  397. case MODS_TAP_TOGGLE:
  398. if (event.pressed) {
  399. if (tap_count <= TAPPING_TOGGLE) {
  400. register_mods(mods);
  401. }
  402. } else {
  403. if (tap_count < TAPPING_TOGGLE) {
  404. unregister_mods(mods);
  405. }
  406. }
  407. break;
  408. default:
  409. if (event.pressed) {
  410. if (tap_count > 0) {
  411. # if !defined(IGNORE_MOD_TAP_INTERRUPT) || defined(IGNORE_MOD_TAP_INTERRUPT_PER_KEY)
  412. if (
  413. # ifdef IGNORE_MOD_TAP_INTERRUPT_PER_KEY
  414. !get_ignore_mod_tap_interrupt(get_event_keycode(record->event, false), record) &&
  415. # endif
  416. record->tap.interrupted) {
  417. dprint("mods_tap: tap: cancel: add_mods\n");
  418. // ad hoc: set 0 to cancel tap
  419. record->tap.count = 0;
  420. register_mods(mods);
  421. } else
  422. # endif
  423. {
  424. dprint("MODS_TAP: Tap: register_code\n");
  425. register_code(action.key.code);
  426. }
  427. } else {
  428. dprint("MODS_TAP: No tap: add_mods\n");
  429. register_mods(mods);
  430. }
  431. } else {
  432. if (tap_count > 0) {
  433. dprint("MODS_TAP: Tap: unregister_code\n");
  434. if (action.layer_tap.code == KC_CAPS_LOCK) {
  435. wait_ms(TAP_HOLD_CAPS_DELAY);
  436. } else {
  437. wait_ms(TAP_CODE_DELAY);
  438. }
  439. unregister_code(action.key.code);
  440. } else {
  441. dprint("MODS_TAP: No tap: add_mods\n");
  442. unregister_mods(mods);
  443. }
  444. }
  445. break;
  446. }
  447. } break;
  448. #endif
  449. #ifdef EXTRAKEY_ENABLE
  450. /* other HID usage */
  451. case ACT_USAGE:
  452. switch (action.usage.page) {
  453. case PAGE_SYSTEM:
  454. if (event.pressed) {
  455. host_system_send(action.usage.code);
  456. } else {
  457. host_system_send(0);
  458. }
  459. break;
  460. case PAGE_CONSUMER:
  461. if (event.pressed) {
  462. host_consumer_send(action.usage.code);
  463. } else {
  464. host_consumer_send(0);
  465. }
  466. break;
  467. }
  468. break;
  469. #endif
  470. #ifdef MOUSEKEY_ENABLE
  471. /* Mouse key */
  472. case ACT_MOUSEKEY:
  473. if (event.pressed) {
  474. mousekey_on(action.key.code);
  475. } else {
  476. mousekey_off(action.key.code);
  477. }
  478. switch (action.key.code) {
  479. # if defined(PS2_MOUSE_ENABLE) || defined(POINTING_DEVICE_ENABLE)
  480. # ifdef POINTING_DEVICE_ENABLE
  481. case KC_MS_BTN1 ... KC_MS_BTN8:
  482. # else
  483. case KC_MS_BTN1 ... KC_MS_BTN3:
  484. # endif
  485. register_button(event.pressed, MOUSE_BTN_MASK(action.key.code - KC_MS_BTN1));
  486. break;
  487. # endif
  488. default:
  489. mousekey_send();
  490. break;
  491. }
  492. break;
  493. #endif
  494. #ifndef NO_ACTION_LAYER
  495. case ACT_LAYER:
  496. if (action.layer_bitop.on == 0) {
  497. /* Default Layer Bitwise Operation */
  498. if (!event.pressed) {
  499. uint8_t shift = action.layer_bitop.part * 4;
  500. layer_state_t bits = ((layer_state_t)action.layer_bitop.bits) << shift;
  501. layer_state_t mask = (action.layer_bitop.xbit) ? ~(((layer_state_t)0xf) << shift) : 0;
  502. switch (action.layer_bitop.op) {
  503. case OP_BIT_AND:
  504. default_layer_and(bits | mask);
  505. break;
  506. case OP_BIT_OR:
  507. default_layer_or(bits | mask);
  508. break;
  509. case OP_BIT_XOR:
  510. default_layer_xor(bits | mask);
  511. break;
  512. case OP_BIT_SET:
  513. default_layer_set(bits | mask);
  514. break;
  515. }
  516. }
  517. } else {
  518. /* Layer Bitwise Operation */
  519. if (event.pressed ? (action.layer_bitop.on & ON_PRESS) : (action.layer_bitop.on & ON_RELEASE)) {
  520. uint8_t shift = action.layer_bitop.part * 4;
  521. layer_state_t bits = ((layer_state_t)action.layer_bitop.bits) << shift;
  522. layer_state_t mask = (action.layer_bitop.xbit) ? ~(((layer_state_t)0xf) << shift) : 0;
  523. switch (action.layer_bitop.op) {
  524. case OP_BIT_AND:
  525. layer_and(bits | mask);
  526. break;
  527. case OP_BIT_OR:
  528. layer_or(bits | mask);
  529. break;
  530. case OP_BIT_XOR:
  531. layer_xor(bits | mask);
  532. break;
  533. case OP_BIT_SET:
  534. layer_state_set(bits | mask);
  535. break;
  536. }
  537. }
  538. }
  539. break;
  540. case ACT_LAYER_MODS:
  541. if (event.pressed) {
  542. layer_on(action.layer_mods.layer);
  543. register_mods(action.layer_mods.mods);
  544. } else {
  545. unregister_mods(action.layer_mods.mods);
  546. layer_off(action.layer_mods.layer);
  547. }
  548. break;
  549. # ifndef NO_ACTION_TAPPING
  550. case ACT_LAYER_TAP:
  551. case ACT_LAYER_TAP_EXT:
  552. switch (action.layer_tap.code) {
  553. case OP_TAP_TOGGLE:
  554. /* tap toggle */
  555. if (event.pressed) {
  556. if (tap_count < TAPPING_TOGGLE) {
  557. layer_invert(action.layer_tap.val);
  558. }
  559. } else {
  560. if (tap_count <= TAPPING_TOGGLE) {
  561. layer_invert(action.layer_tap.val);
  562. }
  563. }
  564. break;
  565. case OP_ON_OFF:
  566. event.pressed ? layer_on(action.layer_tap.val) : layer_off(action.layer_tap.val);
  567. break;
  568. case OP_OFF_ON:
  569. event.pressed ? layer_off(action.layer_tap.val) : layer_on(action.layer_tap.val);
  570. break;
  571. case OP_SET_CLEAR:
  572. event.pressed ? layer_move(action.layer_tap.val) : layer_clear();
  573. break;
  574. # ifndef NO_ACTION_ONESHOT
  575. case OP_ONESHOT:
  576. // Oneshot modifier
  577. if (!keymap_config.oneshot_enable) {
  578. if (event.pressed) {
  579. layer_on(action.layer_tap.val);
  580. } else {
  581. layer_off(action.layer_tap.val);
  582. }
  583. } else {
  584. # if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1
  585. do_release_oneshot = false;
  586. if (event.pressed) {
  587. if (get_oneshot_layer_state() == ONESHOT_TOGGLED) {
  588. reset_oneshot_layer();
  589. layer_off(action.layer_tap.val);
  590. break;
  591. } else if (tap_count < ONESHOT_TAP_TOGGLE) {
  592. layer_on(action.layer_tap.val);
  593. set_oneshot_layer(action.layer_tap.val, ONESHOT_START);
  594. }
  595. } else {
  596. if (tap_count >= ONESHOT_TAP_TOGGLE) {
  597. reset_oneshot_layer();
  598. set_oneshot_layer(action.layer_tap.val, ONESHOT_TOGGLED);
  599. } else {
  600. clear_oneshot_layer_state(ONESHOT_PRESSED);
  601. }
  602. }
  603. # else
  604. if (event.pressed) {
  605. layer_on(action.layer_tap.val);
  606. set_oneshot_layer(action.layer_tap.val, ONESHOT_START);
  607. } else {
  608. clear_oneshot_layer_state(ONESHOT_PRESSED);
  609. if (tap_count > 1) {
  610. clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
  611. }
  612. }
  613. # endif
  614. }
  615. break;
  616. # endif
  617. default:
  618. /* tap key */
  619. if (event.pressed) {
  620. if (tap_count > 0) {
  621. dprint("KEYMAP_TAP_KEY: Tap: register_code\n");
  622. register_code(action.layer_tap.code);
  623. } else {
  624. dprint("KEYMAP_TAP_KEY: No tap: On on press\n");
  625. layer_on(action.layer_tap.val);
  626. }
  627. } else {
  628. if (tap_count > 0) {
  629. dprint("KEYMAP_TAP_KEY: Tap: unregister_code\n");
  630. if (action.layer_tap.code == KC_CAPS_LOCK) {
  631. wait_ms(TAP_HOLD_CAPS_DELAY);
  632. } else {
  633. wait_ms(TAP_CODE_DELAY);
  634. }
  635. unregister_code(action.layer_tap.code);
  636. } else {
  637. dprint("KEYMAP_TAP_KEY: No tap: Off on release\n");
  638. layer_off(action.layer_tap.val);
  639. }
  640. }
  641. break;
  642. }
  643. break;
  644. # endif
  645. #endif
  646. #ifdef SWAP_HANDS_ENABLE
  647. case ACT_SWAP_HANDS:
  648. switch (action.swap.code) {
  649. case OP_SH_TOGGLE:
  650. if (event.pressed) {
  651. swap_hands = !swap_hands;
  652. }
  653. break;
  654. case OP_SH_ON_OFF:
  655. swap_hands = event.pressed;
  656. break;
  657. case OP_SH_OFF_ON:
  658. swap_hands = !event.pressed;
  659. break;
  660. case OP_SH_ON:
  661. if (!event.pressed) {
  662. swap_hands = true;
  663. }
  664. break;
  665. case OP_SH_OFF:
  666. if (!event.pressed) {
  667. swap_hands = false;
  668. }
  669. break;
  670. # ifndef NO_ACTION_ONESHOT
  671. case OP_SH_ONESHOT:
  672. if (event.pressed) {
  673. set_oneshot_swaphands();
  674. } else {
  675. release_oneshot_swaphands();
  676. }
  677. break;
  678. # endif
  679. # ifndef NO_ACTION_TAPPING
  680. case OP_SH_TAP_TOGGLE:
  681. /* tap toggle */
  682. if (event.pressed) {
  683. if (swap_held) {
  684. swap_held = false;
  685. } else {
  686. swap_hands = !swap_hands;
  687. }
  688. } else {
  689. if (tap_count < TAPPING_TOGGLE) {
  690. swap_hands = !swap_hands;
  691. }
  692. }
  693. break;
  694. default:
  695. /* tap key */
  696. if (tap_count > 0) {
  697. if (swap_held) {
  698. swap_hands = !swap_hands; // undo hold set up in _tap_hint
  699. swap_held = false;
  700. }
  701. if (event.pressed) {
  702. register_code(action.swap.code);
  703. } else {
  704. wait_ms(TAP_CODE_DELAY);
  705. unregister_code(action.swap.code);
  706. *record = (keyrecord_t){}; // hack: reset tap mode
  707. }
  708. } else {
  709. if (swap_held && !event.pressed) {
  710. swap_hands = !swap_hands; // undo hold set up in _tap_hint
  711. swap_held = false;
  712. }
  713. }
  714. # endif
  715. }
  716. #endif
  717. default:
  718. break;
  719. }
  720. #ifndef NO_ACTION_LAYER
  721. // if this event is a layer action, update the leds
  722. switch (action.kind.id) {
  723. case ACT_LAYER:
  724. case ACT_LAYER_MODS:
  725. # ifndef NO_ACTION_TAPPING
  726. case ACT_LAYER_TAP:
  727. case ACT_LAYER_TAP_EXT:
  728. # endif
  729. led_set(host_keyboard_leds());
  730. break;
  731. default:
  732. break;
  733. }
  734. #endif
  735. #ifndef NO_ACTION_TAPPING
  736. # if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
  737. if (!is_tap_action(action)) {
  738. retro_tapping_counter = 0;
  739. } else {
  740. if (event.pressed) {
  741. if (tap_count > 0) {
  742. retro_tapping_counter = 0;
  743. }
  744. } else {
  745. if (tap_count > 0) {
  746. retro_tapping_counter = 0;
  747. } else {
  748. if (
  749. # ifdef RETRO_TAPPING_PER_KEY
  750. get_retro_tapping(get_event_keycode(record->event, false), record) &&
  751. # endif
  752. retro_tapping_counter == 2) {
  753. # if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
  754. process_auto_shift(action.layer_tap.code, record);
  755. # else
  756. tap_code(action.layer_tap.code);
  757. # endif
  758. }
  759. retro_tapping_counter = 0;
  760. }
  761. }
  762. }
  763. # endif
  764. #endif
  765. #ifdef SWAP_HANDS_ENABLE
  766. # ifndef NO_ACTION_ONESHOT
  767. if (event.pressed && !(action.kind.id == ACT_SWAP_HANDS && action.swap.code == OP_SH_ONESHOT)) {
  768. use_oneshot_swaphands();
  769. }
  770. # endif
  771. #endif
  772. #ifndef NO_ACTION_ONESHOT
  773. /* Because we switch layers after a oneshot event, we need to release the
  774. * key before we leave the layer or no key up event will be generated.
  775. */
  776. if (do_release_oneshot && !(get_oneshot_layer_state() & ONESHOT_PRESSED)) {
  777. record->event.pressed = false;
  778. layer_on(get_oneshot_layer());
  779. process_record(record);
  780. layer_off(get_oneshot_layer());
  781. }
  782. #endif
  783. }
  784. /** \brief Utilities for actions. (FIXME: Needs better description)
  785. *
  786. * FIXME: Needs documentation.
  787. */
  788. __attribute__((weak)) void register_code(uint8_t code) {
  789. if (code == KC_NO) {
  790. return;
  791. }
  792. #ifdef LOCKING_SUPPORT_ENABLE
  793. else if (KC_LOCKING_CAPS_LOCK == code) {
  794. # ifdef LOCKING_RESYNC_ENABLE
  795. // Resync: ignore if caps lock already is on
  796. if (host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK)) return;
  797. # endif
  798. add_key(KC_CAPS_LOCK);
  799. send_keyboard_report();
  800. wait_ms(TAP_HOLD_CAPS_DELAY);
  801. del_key(KC_CAPS_LOCK);
  802. send_keyboard_report();
  803. }
  804. else if (KC_LOCKING_NUM_LOCK == code) {
  805. # ifdef LOCKING_RESYNC_ENABLE
  806. if (host_keyboard_leds() & (1 << USB_LED_NUM_LOCK)) return;
  807. # endif
  808. add_key(KC_NUM_LOCK);
  809. send_keyboard_report();
  810. wait_ms(100);
  811. del_key(KC_NUM_LOCK);
  812. send_keyboard_report();
  813. }
  814. else if (KC_LOCKING_SCROLL_LOCK == code) {
  815. # ifdef LOCKING_RESYNC_ENABLE
  816. if (host_keyboard_leds() & (1 << USB_LED_SCROLL_LOCK)) return;
  817. # endif
  818. add_key(KC_SCROLL_LOCK);
  819. send_keyboard_report();
  820. wait_ms(100);
  821. del_key(KC_SCROLL_LOCK);
  822. send_keyboard_report();
  823. }
  824. #endif
  825. else if IS_KEY (code) {
  826. // TODO: should push command_proc out of this block?
  827. if (command_proc(code)) return;
  828. #ifndef NO_ACTION_ONESHOT
  829. /* TODO: remove
  830. if (oneshot_state.mods && !oneshot_state.disabled) {
  831. uint8_t tmp_mods = get_mods();
  832. add_mods(oneshot_state.mods);
  833. add_key(code);
  834. send_keyboard_report();
  835. set_mods(tmp_mods);
  836. send_keyboard_report();
  837. oneshot_cancel();
  838. } else
  839. */
  840. #endif
  841. {
  842. // Force a new key press if the key is already pressed
  843. // without this, keys with the same keycode, but different
  844. // modifiers will be reported incorrectly, see issue #1708
  845. if (is_key_pressed(keyboard_report, code)) {
  846. del_key(code);
  847. send_keyboard_report();
  848. }
  849. add_key(code);
  850. send_keyboard_report();
  851. }
  852. } else if IS_MOD (code) {
  853. add_mods(MOD_BIT(code));
  854. send_keyboard_report();
  855. }
  856. #ifdef EXTRAKEY_ENABLE
  857. else if IS_SYSTEM (code) {
  858. host_system_send(KEYCODE2SYSTEM(code));
  859. } else if IS_CONSUMER (code) {
  860. host_consumer_send(KEYCODE2CONSUMER(code));
  861. }
  862. #endif
  863. #ifdef MOUSEKEY_ENABLE
  864. else if IS_MOUSEKEY (code) {
  865. mousekey_on(code);
  866. mousekey_send();
  867. }
  868. #elif defined(POINTING_DEVICE_ENABLE)
  869. else if IS_MOUSEKEY (code) {
  870. pointing_device_keycode_handler(code, true);
  871. }
  872. #endif
  873. }
  874. /** \brief Utilities for actions. (FIXME: Needs better description)
  875. *
  876. * FIXME: Needs documentation.
  877. */
  878. __attribute__((weak)) void unregister_code(uint8_t code) {
  879. if (code == KC_NO) {
  880. return;
  881. }
  882. #ifdef LOCKING_SUPPORT_ENABLE
  883. else if (KC_LOCKING_CAPS_LOCK == code) {
  884. # ifdef LOCKING_RESYNC_ENABLE
  885. // Resync: ignore if caps lock already is off
  886. if (!(host_keyboard_leds() & (1 << USB_LED_CAPS_LOCK))) return;
  887. # endif
  888. add_key(KC_CAPS_LOCK);
  889. send_keyboard_report();
  890. del_key(KC_CAPS_LOCK);
  891. send_keyboard_report();
  892. }
  893. else if (KC_LOCKING_NUM_LOCK == code) {
  894. # ifdef LOCKING_RESYNC_ENABLE
  895. if (!(host_keyboard_leds() & (1 << USB_LED_NUM_LOCK))) return;
  896. # endif
  897. add_key(KC_NUM_LOCK);
  898. send_keyboard_report();
  899. del_key(KC_NUM_LOCK);
  900. send_keyboard_report();
  901. }
  902. else if (KC_LOCKING_SCROLL_LOCK == code) {
  903. # ifdef LOCKING_RESYNC_ENABLE
  904. if (!(host_keyboard_leds() & (1 << USB_LED_SCROLL_LOCK))) return;
  905. # endif
  906. add_key(KC_SCROLL_LOCK);
  907. send_keyboard_report();
  908. del_key(KC_SCROLL_LOCK);
  909. send_keyboard_report();
  910. }
  911. #endif
  912. else if IS_KEY (code) {
  913. del_key(code);
  914. send_keyboard_report();
  915. } else if IS_MOD (code) {
  916. del_mods(MOD_BIT(code));
  917. send_keyboard_report();
  918. } else if IS_SYSTEM (code) {
  919. host_system_send(0);
  920. } else if IS_CONSUMER (code) {
  921. host_consumer_send(0);
  922. }
  923. #ifdef MOUSEKEY_ENABLE
  924. else if IS_MOUSEKEY (code) {
  925. mousekey_off(code);
  926. mousekey_send();
  927. }
  928. #elif defined(POINTING_DEVICE_ENABLE)
  929. else if IS_MOUSEKEY (code) {
  930. pointing_device_keycode_handler(code, false);
  931. }
  932. #endif
  933. }
  934. /** \brief Tap a keycode with a delay.
  935. *
  936. * \param code The basic keycode to tap.
  937. * \param delay The amount of time in milliseconds to leave the keycode registered, before unregistering it.
  938. */
  939. __attribute__((weak)) void tap_code_delay(uint8_t code, uint16_t delay) {
  940. register_code(code);
  941. for (uint16_t i = delay; i > 0; i--) {
  942. wait_ms(1);
  943. }
  944. unregister_code(code);
  945. }
  946. /** \brief Tap a keycode with the default delay.
  947. *
  948. * \param code The basic keycode to tap. If `code` is `KC_CAPS_LOCK`, the delay will be `TAP_HOLD_CAPS_DELAY`, otherwise `TAP_CODE_DELAY`, if defined.
  949. */
  950. __attribute__((weak)) void tap_code(uint8_t code) {
  951. tap_code_delay(code, code == KC_CAPS_LOCK ? TAP_HOLD_CAPS_DELAY : TAP_CODE_DELAY);
  952. }
  953. /** \brief Adds the given physically pressed modifiers and sends a keyboard report immediately.
  954. *
  955. * \param mods A bitfield of modifiers to register.
  956. */
  957. __attribute__((weak)) void register_mods(uint8_t mods) {
  958. if (mods) {
  959. add_mods(mods);
  960. send_keyboard_report();
  961. }
  962. }
  963. /** \brief Removes the given physically pressed modifiers and sends a keyboard report immediately.
  964. *
  965. * \param mods A bitfield of modifiers to unregister.
  966. */
  967. __attribute__((weak)) void unregister_mods(uint8_t mods) {
  968. if (mods) {
  969. del_mods(mods);
  970. send_keyboard_report();
  971. }
  972. }
  973. /** \brief Adds the given weak modifiers and sends a keyboard report immediately.
  974. *
  975. * \param mods A bitfield of modifiers to register.
  976. */
  977. __attribute__((weak)) void register_weak_mods(uint8_t mods) {
  978. if (mods) {
  979. add_weak_mods(mods);
  980. send_keyboard_report();
  981. }
  982. }
  983. /** \brief Removes the given weak modifiers and sends a keyboard report immediately.
  984. *
  985. * \param mods A bitfield of modifiers to unregister.
  986. */
  987. __attribute__((weak)) void unregister_weak_mods(uint8_t mods) {
  988. if (mods) {
  989. del_weak_mods(mods);
  990. send_keyboard_report();
  991. }
  992. }
  993. /** \brief Utilities for actions. (FIXME: Needs better description)
  994. *
  995. * FIXME: Needs documentation.
  996. */
  997. void clear_keyboard(void) {
  998. clear_mods();
  999. clear_keyboard_but_mods();
  1000. }
  1001. /** \brief Utilities for actions. (FIXME: Needs better description)
  1002. *
  1003. * FIXME: Needs documentation.
  1004. */
  1005. void clear_keyboard_but_mods(void) {
  1006. clear_keys();
  1007. clear_keyboard_but_mods_and_keys();
  1008. }
  1009. /** \brief Utilities for actions. (FIXME: Needs better description)
  1010. *
  1011. * FIXME: Needs documentation.
  1012. */
  1013. void clear_keyboard_but_mods_and_keys() {
  1014. #ifdef EXTRAKEY_ENABLE
  1015. host_system_send(0);
  1016. host_consumer_send(0);
  1017. #endif
  1018. clear_weak_mods();
  1019. send_keyboard_report();
  1020. #ifdef MOUSEKEY_ENABLE
  1021. mousekey_clear();
  1022. mousekey_send();
  1023. #endif
  1024. #ifdef PROGRAMMABLE_BUTTON_ENABLE
  1025. programmable_button_clear();
  1026. programmable_button_send();
  1027. #endif
  1028. }
  1029. /** \brief Utilities for actions. (FIXME: Needs better description)
  1030. *
  1031. * FIXME: Needs documentation.
  1032. */
  1033. bool is_tap_record(keyrecord_t *record) {
  1034. if (IS_NOEVENT(record->event)) {
  1035. return false;
  1036. }
  1037. #ifdef COMBO_ENABLE
  1038. action_t action;
  1039. if (record->keycode) {
  1040. action = action_for_keycode(record->keycode);
  1041. } else {
  1042. action = layer_switch_get_action(record->event.key);
  1043. }
  1044. #else
  1045. action_t action = layer_switch_get_action(record->event.key);
  1046. #endif
  1047. return is_tap_action(action);
  1048. }
  1049. /** \brief Utilities for actions. (FIXME: Needs better description)
  1050. *
  1051. * FIXME: Needs documentation.
  1052. */
  1053. bool is_tap_action(action_t action) {
  1054. switch (action.kind.id) {
  1055. case ACT_LMODS_TAP:
  1056. case ACT_RMODS_TAP:
  1057. case ACT_LAYER_TAP:
  1058. case ACT_LAYER_TAP_EXT:
  1059. switch (action.layer_tap.code) {
  1060. case KC_NO ... KC_RIGHT_GUI:
  1061. case OP_TAP_TOGGLE:
  1062. case OP_ONESHOT:
  1063. return true;
  1064. }
  1065. return false;
  1066. case ACT_SWAP_HANDS:
  1067. switch (action.swap.code) {
  1068. case KC_NO ... KC_RIGHT_GUI:
  1069. case OP_SH_TAP_TOGGLE:
  1070. return true;
  1071. }
  1072. return false;
  1073. }
  1074. return false;
  1075. }
  1076. /** \brief Debug print (FIXME: Needs better description)
  1077. *
  1078. * FIXME: Needs documentation.
  1079. */
  1080. void debug_event(keyevent_t event) {
  1081. dprintf("%04X%c(%u)", (event.key.row << 8 | event.key.col), (event.pressed ? 'd' : 'u'), event.time);
  1082. }
  1083. /** \brief Debug print (FIXME: Needs better description)
  1084. *
  1085. * FIXME: Needs documentation.
  1086. */
  1087. void debug_record(keyrecord_t record) {
  1088. debug_event(record.event);
  1089. #ifndef NO_ACTION_TAPPING
  1090. dprintf(":%u%c", record.tap.count, (record.tap.interrupted ? '-' : ' '));
  1091. #endif
  1092. }
  1093. /** \brief Debug print (FIXME: Needs better description)
  1094. *
  1095. * FIXME: Needs documentation.
  1096. */
  1097. void debug_action(action_t action) {
  1098. switch (action.kind.id) {
  1099. case ACT_LMODS:
  1100. dprint("ACT_LMODS");
  1101. break;
  1102. case ACT_RMODS:
  1103. dprint("ACT_RMODS");
  1104. break;
  1105. case ACT_LMODS_TAP:
  1106. dprint("ACT_LMODS_TAP");
  1107. break;
  1108. case ACT_RMODS_TAP:
  1109. dprint("ACT_RMODS_TAP");
  1110. break;
  1111. case ACT_USAGE:
  1112. dprint("ACT_USAGE");
  1113. break;
  1114. case ACT_MOUSEKEY:
  1115. dprint("ACT_MOUSEKEY");
  1116. break;
  1117. case ACT_LAYER:
  1118. dprint("ACT_LAYER");
  1119. break;
  1120. case ACT_LAYER_MODS:
  1121. dprint("ACT_LAYER_MODS");
  1122. break;
  1123. case ACT_LAYER_TAP:
  1124. dprint("ACT_LAYER_TAP");
  1125. break;
  1126. case ACT_LAYER_TAP_EXT:
  1127. dprint("ACT_LAYER_TAP_EXT");
  1128. break;
  1129. case ACT_SWAP_HANDS:
  1130. dprint("ACT_SWAP_HANDS");
  1131. break;
  1132. default:
  1133. dprint("UNKNOWN");
  1134. break;
  1135. }
  1136. dprintf("[%X:%02X]", action.kind.param >> 8, action.kind.param & 0xff);
  1137. }