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.

1220 lines
41 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
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. #include "host.h"
  16. #include "keycode.h"
  17. #include "keyboard.h"
  18. #include "mousekey.h"
  19. #include "programmable_button.h"
  20. #include "command.h"
  21. #include "led.h"
  22. #include "action_layer.h"
  23. #include "action_tapping.h"
  24. #include "action_util.h"
  25. #include "action.h"
  26. #include "wait.h"
  27. #include "keycode_config.h"
  28. #include "debug.h"
  29. #include "quantum.h"
  30. #ifdef BACKLIGHT_ENABLE
  31. # include "backlight.h"
  32. #endif
  33. #ifdef POINTING_DEVICE_ENABLE
  34. # include "pointing_device.h"
  35. #endif
  36. #if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) && defined(SWAP_HANDS_ENABLE)
  37. # include "encoder.h"
  38. #endif
  39. int tp_buttons;
  40. #if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
  41. int retro_tapping_counter = 0;
  42. #endif
  43. #if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT) && !defined(NO_ACTION_TAPPING)
  44. # include "process_auto_shift.h"
  45. #endif
  46. #ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
  47. __attribute__((weak)) bool get_hold_on_other_key_press(uint16_t keycode, keyrecord_t *record) {
  48. return false;
  49. }
  50. #endif
  51. #ifdef RETRO_TAPPING_PER_KEY
  52. __attribute__((weak)) bool get_retro_tapping(uint16_t keycode, keyrecord_t *record) {
  53. return false;
  54. }
  55. #endif
  56. /** \brief Called to execute an action.
  57. *
  58. * FIXME: Needs documentation.
  59. */
  60. void action_exec(keyevent_t event) {
  61. if (IS_EVENT(event)) {
  62. ac_dprintf("\n---- action_exec: start -----\n");
  63. ac_dprintf("EVENT: ");
  64. debug_event(event);
  65. ac_dprintf("\n");
  66. #if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
  67. retro_tapping_counter++;
  68. #endif
  69. }
  70. if (event.pressed) {
  71. // clear the potential weak mods left by previously pressed keys
  72. clear_weak_mods();
  73. }
  74. #ifdef SWAP_HANDS_ENABLE
  75. // Swap hands handles both keys and encoders, if ENCODER_MAP_ENABLE is defined.
  76. if (IS_EVENT(event)) {
  77. process_hand_swap(&event);
  78. }
  79. #endif
  80. keyrecord_t record = {.event = event};
  81. #ifndef NO_ACTION_ONESHOT
  82. if (keymap_config.oneshot_enable) {
  83. # if (defined(ONESHOT_TIMEOUT) && (ONESHOT_TIMEOUT > 0))
  84. if (has_oneshot_layer_timed_out()) {
  85. clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
  86. }
  87. if (has_oneshot_mods_timed_out()) {
  88. clear_oneshot_mods();
  89. }
  90. # ifdef SWAP_HANDS_ENABLE
  91. if (has_oneshot_swaphands_timed_out()) {
  92. clear_oneshot_swaphands();
  93. }
  94. # endif
  95. # endif
  96. }
  97. #endif
  98. #ifndef NO_ACTION_TAPPING
  99. # if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
  100. if (event.pressed) {
  101. retroshift_poll_time(&event);
  102. }
  103. # endif
  104. if (IS_NOEVENT(record.event) || pre_process_record_quantum(&record)) {
  105. action_tapping_process(record);
  106. }
  107. #else
  108. if (IS_NOEVENT(record.event) || pre_process_record_quantum(&record)) {
  109. process_record(&record);
  110. }
  111. if (IS_EVENT(record.event)) {
  112. ac_dprintf("processed: ");
  113. debug_record(record);
  114. dprintln();
  115. }
  116. #endif
  117. }
  118. #ifdef SWAP_HANDS_ENABLE
  119. extern const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS];
  120. # ifdef ENCODER_MAP_ENABLE
  121. extern const uint8_t PROGMEM encoder_hand_swap_config[NUM_ENCODERS];
  122. # endif // ENCODER_MAP_ENABLE
  123. bool swap_hands = false;
  124. bool swap_held = false;
  125. bool should_swap_hands(size_t index, uint8_t *swap_state, bool pressed) {
  126. size_t array_index = index / (CHAR_BIT);
  127. size_t bit_index = index % (CHAR_BIT);
  128. uint8_t bit_val = 1 << bit_index;
  129. bool do_swap = pressed ? swap_hands : swap_state[array_index] & bit_val;
  130. return do_swap;
  131. }
  132. void set_swap_hands_state(size_t index, uint8_t *swap_state, bool on) {
  133. size_t array_index = index / (CHAR_BIT);
  134. size_t bit_index = index % (CHAR_BIT);
  135. uint8_t bit_val = 1 << bit_index;
  136. if (on) {
  137. swap_state[array_index] |= bit_val;
  138. } else {
  139. swap_state[array_index] &= ~bit_val;
  140. }
  141. }
  142. void swap_hands_on(void) {
  143. swap_hands = true;
  144. }
  145. void swap_hands_off(void) {
  146. swap_hands = false;
  147. }
  148. void swap_hands_toggle(void) {
  149. swap_hands = !swap_hands;
  150. }
  151. bool is_swap_hands_on(void) {
  152. return swap_hands;
  153. }
  154. /** \brief Process Hand Swap
  155. *
  156. * FIXME: Needs documentation.
  157. */
  158. void process_hand_swap(keyevent_t *event) {
  159. keypos_t pos = event->key;
  160. if (IS_KEYEVENT(*event) && pos.row < MATRIX_ROWS && pos.col < MATRIX_COLS) {
  161. static uint8_t matrix_swap_state[((MATRIX_ROWS * MATRIX_COLS) + (CHAR_BIT)-1) / (CHAR_BIT)];
  162. size_t index = (size_t)(pos.row * MATRIX_COLS) + pos.col;
  163. bool do_swap = should_swap_hands(index, matrix_swap_state, event->pressed);
  164. if (do_swap) {
  165. event->key.row = pgm_read_byte(&hand_swap_config[pos.row][pos.col].row);
  166. event->key.col = pgm_read_byte(&hand_swap_config[pos.row][pos.col].col);
  167. set_swap_hands_state(index, matrix_swap_state, true);
  168. } else {
  169. set_swap_hands_state(index, matrix_swap_state, false);
  170. }
  171. }
  172. # ifdef ENCODER_MAP_ENABLE
  173. else if (IS_ENCODEREVENT(*event) && (pos.row == KEYLOC_ENCODER_CW || pos.row == KEYLOC_ENCODER_CCW)) {
  174. static uint8_t encoder_swap_state[((NUM_ENCODERS) + (CHAR_BIT)-1) / (CHAR_BIT)];
  175. size_t index = pos.col;
  176. bool do_swap = should_swap_hands(index, encoder_swap_state, event->pressed);
  177. if (do_swap) {
  178. event->key.row = pos.row;
  179. event->key.col = pgm_read_byte(&encoder_hand_swap_config[pos.col]);
  180. set_swap_hands_state(index, encoder_swap_state, true);
  181. } else {
  182. set_swap_hands_state(index, encoder_swap_state, false);
  183. }
  184. }
  185. # endif // ENCODER_MAP_ENABLE
  186. }
  187. #endif
  188. #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
  189. bool disable_action_cache = false;
  190. void process_record_nocache(keyrecord_t *record) {
  191. disable_action_cache = true;
  192. process_record(record);
  193. disable_action_cache = false;
  194. }
  195. #else
  196. void process_record_nocache(keyrecord_t *record) {
  197. process_record(record);
  198. }
  199. #endif
  200. __attribute__((weak)) bool process_record_quantum(keyrecord_t *record) {
  201. return true;
  202. }
  203. __attribute__((weak)) void post_process_record_quantum(keyrecord_t *record) {}
  204. #ifndef NO_ACTION_TAPPING
  205. /** \brief Allows for handling tap-hold actions immediately instead of waiting for TAPPING_TERM or another keypress.
  206. *
  207. * FIXME: Needs documentation.
  208. */
  209. void process_record_tap_hint(keyrecord_t *record) {
  210. if (!IS_KEYEVENT(record->event)) {
  211. return;
  212. }
  213. action_t action = layer_switch_get_action(record->event.key);
  214. switch (action.kind.id) {
  215. # ifdef SWAP_HANDS_ENABLE
  216. case ACT_SWAP_HANDS:
  217. switch (action.swap.code) {
  218. case OP_SH_ONESHOT:
  219. break;
  220. case OP_SH_TAP_TOGGLE:
  221. default:
  222. swap_hands = !swap_hands;
  223. swap_held = true;
  224. }
  225. break;
  226. # endif
  227. }
  228. }
  229. #endif
  230. /** \brief Take a key event (key press or key release) and processes it.
  231. *
  232. * FIXME: Needs documentation.
  233. */
  234. void process_record(keyrecord_t *record) {
  235. if (IS_NOEVENT(record->event)) {
  236. return;
  237. }
  238. if (!process_record_quantum(record)) {
  239. #ifndef NO_ACTION_ONESHOT
  240. if (is_oneshot_layer_active() && record->event.pressed && keymap_config.oneshot_enable) {
  241. clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
  242. }
  243. #endif
  244. return;
  245. }
  246. process_record_handler(record);
  247. post_process_record_quantum(record);
  248. }
  249. void process_record_handler(keyrecord_t *record) {
  250. #if defined(COMBO_ENABLE) || defined(REPEAT_KEY_ENABLE)
  251. action_t action;
  252. if (record->keycode) {
  253. action = action_for_keycode(record->keycode);
  254. } else {
  255. action = store_or_get_action(record->event.pressed, record->event.key);
  256. }
  257. #else
  258. action_t action = store_or_get_action(record->event.pressed, record->event.key);
  259. #endif
  260. ac_dprintf("ACTION: ");
  261. debug_action(action);
  262. #ifndef NO_ACTION_LAYER
  263. ac_dprintf(" layer_state: ");
  264. layer_debug();
  265. ac_dprintf(" default_layer_state: ");
  266. default_layer_debug();
  267. #endif
  268. ac_dprintf("\n");
  269. process_action(record, action);
  270. }
  271. /**
  272. * @brief handles all the messy mouse stuff
  273. *
  274. * Handles all the edgecases and special stuff that is needed for coexistense
  275. * of the multiple mouse subsystems.
  276. *
  277. * @param mouse_keycode[in] uint8_t mouse keycode
  278. * @param pressed[in] bool
  279. */
  280. void register_mouse(uint8_t mouse_keycode, bool pressed) {
  281. #ifdef MOUSEKEY_ENABLE
  282. // if mousekeys is enabled, let it do the brunt of the work
  283. if (pressed) {
  284. mousekey_on(mouse_keycode);
  285. } else {
  286. mousekey_off(mouse_keycode);
  287. }
  288. // should mousekeys send report, or does something else handle this?
  289. switch (mouse_keycode) {
  290. # if defined(PS2_MOUSE_ENABLE) || defined(POINTING_DEVICE_ENABLE)
  291. case KC_MS_BTN1 ... KC_MS_BTN8:
  292. // let pointing device handle the buttons
  293. // expand if/when it handles more of the code
  294. # if defined(POINTING_DEVICE_ENABLE)
  295. pointing_device_keycode_handler(mouse_keycode, pressed);
  296. # endif
  297. break;
  298. # endif
  299. default:
  300. mousekey_send();
  301. break;
  302. }
  303. #elif defined(POINTING_DEVICE_ENABLE)
  304. // if mousekeys isn't enabled, and pointing device is enabled, then
  305. // let pointing device do all the heavy lifting, then
  306. if (IS_MOUSE_KEYCODE(mouse_keycode)) {
  307. pointing_device_keycode_handler(mouse_keycode, pressed);
  308. }
  309. #endif
  310. #ifdef PS2_MOUSE_ENABLE
  311. // make sure that ps2 mouse has button report synced
  312. if (KC_MS_BTN1 <= mouse_keycode && mouse_keycode <= KC_MS_BTN3) {
  313. uint8_t tmp_button_msk = MOUSE_BTN_MASK(mouse_keycode - KC_MS_BTN1);
  314. tp_buttons = pressed ? tp_buttons | tmp_button_msk : tp_buttons & ~tmp_button_msk;
  315. }
  316. #endif
  317. }
  318. /** \brief Take an action and processes it.
  319. *
  320. * FIXME: Needs documentation.
  321. */
  322. void process_action(keyrecord_t *record, action_t action) {
  323. keyevent_t event = record->event;
  324. #ifndef NO_ACTION_TAPPING
  325. uint8_t tap_count = record->tap.count;
  326. #endif
  327. #ifndef NO_ACTION_ONESHOT
  328. bool do_release_oneshot = false;
  329. // notice we only clear the one shot layer if the pressed key is not a modifier.
  330. if (is_oneshot_layer_active() && event.pressed &&
  331. (action.kind.id == ACT_USAGE || !(IS_MODIFIER_KEYCODE(action.key.code)
  332. # ifndef NO_ACTION_TAPPING
  333. || ((action.kind.id == ACT_LMODS_TAP || action.kind.id == ACT_RMODS_TAP) && (action.layer_tap.code <= MODS_TAP_TOGGLE || tap_count == 0))
  334. # endif
  335. ))
  336. # ifdef SWAP_HANDS_ENABLE
  337. && !(action.kind.id == ACT_SWAP_HANDS && action.swap.code == OP_SH_ONESHOT)
  338. # endif
  339. && keymap_config.oneshot_enable) {
  340. clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
  341. do_release_oneshot = !is_oneshot_layer_active();
  342. }
  343. #endif
  344. switch (action.kind.id) {
  345. /* Key and Mods */
  346. case ACT_LMODS:
  347. case ACT_RMODS: {
  348. uint8_t mods = (action.kind.id == ACT_LMODS) ? action.key.mods : action.key.mods << 4;
  349. if (event.pressed) {
  350. if (mods) {
  351. if (IS_MODIFIER_KEYCODE(action.key.code) || action.key.code == KC_NO) {
  352. // e.g. LSFT(KC_LEFT_GUI): we don't want the LSFT to be weak as it would make it useless.
  353. // This also makes LSFT(KC_LEFT_GUI) behave exactly the same as LGUI(KC_LEFT_SHIFT).
  354. // Same applies for some keys like KC_MEH which are declared as MEH(KC_NO).
  355. add_mods(mods);
  356. } else {
  357. add_weak_mods(mods);
  358. }
  359. send_keyboard_report();
  360. }
  361. register_code(action.key.code);
  362. } else {
  363. unregister_code(action.key.code);
  364. if (mods) {
  365. if (IS_MODIFIER_KEYCODE(action.key.code) || action.key.code == KC_NO) {
  366. del_mods(mods);
  367. } else {
  368. del_weak_mods(mods);
  369. }
  370. send_keyboard_report();
  371. }
  372. }
  373. } break;
  374. case ACT_LMODS_TAP:
  375. case ACT_RMODS_TAP: {
  376. #ifndef NO_ACTION_TAPPING
  377. uint8_t mods = (action.kind.id == ACT_LMODS_TAP) ? action.key.mods : action.key.mods << 4;
  378. switch (action.layer_tap.code) {
  379. # ifndef NO_ACTION_ONESHOT
  380. case MODS_ONESHOT:
  381. // Oneshot modifier
  382. if (!keymap_config.oneshot_enable) {
  383. if (event.pressed) {
  384. if (mods) {
  385. if (IS_MODIFIER_KEYCODE(action.key.code) || action.key.code == KC_NO) {
  386. // e.g. LSFT(KC_LGUI): we don't want the LSFT to be weak as it would make it useless.
  387. // This also makes LSFT(KC_LGUI) behave exactly the same as LGUI(KC_LSFT).
  388. // Same applies for some keys like KC_MEH which are declared as MEH(KC_NO).
  389. add_mods(mods);
  390. } else {
  391. add_weak_mods(mods);
  392. }
  393. send_keyboard_report();
  394. }
  395. register_code(action.key.code);
  396. } else {
  397. unregister_code(action.key.code);
  398. if (mods) {
  399. if (IS_MODIFIER_KEYCODE(action.key.code) || action.key.code == KC_NO) {
  400. del_mods(mods);
  401. } else {
  402. del_weak_mods(mods);
  403. }
  404. send_keyboard_report();
  405. }
  406. }
  407. } else {
  408. if (event.pressed) {
  409. if (tap_count == 0) {
  410. // Not a tap, but a hold: register the held mod
  411. ac_dprintf("MODS_TAP: Oneshot: 0\n");
  412. register_mods(mods);
  413. } else if (tap_count == 1) {
  414. ac_dprintf("MODS_TAP: Oneshot: start\n");
  415. add_oneshot_mods(mods);
  416. # if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1
  417. } else if (tap_count == ONESHOT_TAP_TOGGLE) {
  418. ac_dprintf("MODS_TAP: Toggling oneshot");
  419. register_mods(mods);
  420. del_oneshot_mods(mods);
  421. add_oneshot_locked_mods(mods);
  422. # endif
  423. }
  424. } else {
  425. if (tap_count == 0) {
  426. // Release hold: unregister the held mod and its variants
  427. unregister_mods(mods);
  428. del_oneshot_mods(mods);
  429. del_oneshot_locked_mods(mods);
  430. # if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1
  431. } else if (tap_count == 1 && (mods & get_mods())) {
  432. unregister_mods(mods);
  433. del_oneshot_mods(mods);
  434. del_oneshot_locked_mods(mods);
  435. # endif
  436. }
  437. }
  438. }
  439. break;
  440. # endif
  441. case MODS_TAP_TOGGLE:
  442. if (event.pressed) {
  443. if (tap_count <= TAPPING_TOGGLE) {
  444. register_mods(mods);
  445. }
  446. } else {
  447. if (tap_count < TAPPING_TOGGLE) {
  448. unregister_mods(mods);
  449. }
  450. }
  451. break;
  452. default:
  453. if (event.pressed) {
  454. if (tap_count > 0) {
  455. # ifdef HOLD_ON_OTHER_KEY_PRESS
  456. if (
  457. # ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
  458. get_hold_on_other_key_press(get_event_keycode(record->event, false), record) &&
  459. # endif
  460. record->tap.interrupted) {
  461. ac_dprintf("mods_tap: tap: cancel: add_mods\n");
  462. // ad hoc: set 0 to cancel tap
  463. record->tap.count = 0;
  464. register_mods(mods);
  465. } else
  466. # endif
  467. {
  468. ac_dprintf("MODS_TAP: Tap: register_code\n");
  469. register_code(action.key.code);
  470. }
  471. } else {
  472. ac_dprintf("MODS_TAP: No tap: add_mods\n");
  473. register_mods(mods);
  474. }
  475. } else {
  476. if (tap_count > 0) {
  477. ac_dprintf("MODS_TAP: Tap: unregister_code\n");
  478. if (action.layer_tap.code == KC_CAPS_LOCK) {
  479. wait_ms(TAP_HOLD_CAPS_DELAY);
  480. } else {
  481. wait_ms(TAP_CODE_DELAY);
  482. }
  483. unregister_code(action.key.code);
  484. } else {
  485. ac_dprintf("MODS_TAP: No tap: add_mods\n");
  486. # if defined(RETRO_TAPPING) && defined(DUMMY_MOD_NEUTRALIZER_KEYCODE)
  487. // Send a dummy keycode to neutralize flashing modifiers
  488. // if the key was held and then released with no interruptions.
  489. if (retro_tapping_counter == 2) {
  490. neutralize_flashing_modifiers(get_mods());
  491. }
  492. # endif
  493. unregister_mods(mods);
  494. }
  495. }
  496. break;
  497. }
  498. #endif // NO_ACTION_TAPPING
  499. } break;
  500. #ifdef EXTRAKEY_ENABLE
  501. /* other HID usage */
  502. case ACT_USAGE:
  503. switch (action.usage.page) {
  504. case PAGE_SYSTEM:
  505. host_system_send(event.pressed ? action.usage.code : 0);
  506. break;
  507. case PAGE_CONSUMER:
  508. host_consumer_send(event.pressed ? action.usage.code : 0);
  509. break;
  510. }
  511. break;
  512. #endif // EXTRAKEY_ENABLE
  513. /* Mouse key */
  514. case ACT_MOUSEKEY:
  515. register_mouse(action.key.code, event.pressed);
  516. break;
  517. #ifndef NO_ACTION_LAYER
  518. case ACT_LAYER:
  519. if (action.layer_bitop.on == 0) {
  520. /* Default Layer Bitwise Operation */
  521. if (!event.pressed) {
  522. uint8_t shift = action.layer_bitop.part * 4;
  523. layer_state_t bits = ((layer_state_t)action.layer_bitop.bits) << shift;
  524. layer_state_t mask = (action.layer_bitop.xbit) ? ~(((layer_state_t)0xf) << shift) : 0;
  525. switch (action.layer_bitop.op) {
  526. case OP_BIT_AND:
  527. default_layer_and(bits | mask);
  528. break;
  529. case OP_BIT_OR:
  530. default_layer_or(bits | mask);
  531. break;
  532. case OP_BIT_XOR:
  533. default_layer_xor(bits | mask);
  534. break;
  535. case OP_BIT_SET:
  536. default_layer_set(bits | mask);
  537. break;
  538. }
  539. }
  540. } else {
  541. /* Layer Bitwise Operation */
  542. if (event.pressed ? (action.layer_bitop.on & ON_PRESS) : (action.layer_bitop.on & ON_RELEASE)) {
  543. uint8_t shift = action.layer_bitop.part * 4;
  544. layer_state_t bits = ((layer_state_t)action.layer_bitop.bits) << shift;
  545. layer_state_t mask = (action.layer_bitop.xbit) ? ~(((layer_state_t)0xf) << shift) : 0;
  546. switch (action.layer_bitop.op) {
  547. case OP_BIT_AND:
  548. layer_and(bits | mask);
  549. break;
  550. case OP_BIT_OR:
  551. layer_or(bits | mask);
  552. break;
  553. case OP_BIT_XOR:
  554. layer_xor(bits | mask);
  555. break;
  556. case OP_BIT_SET:
  557. layer_state_set(bits | mask);
  558. break;
  559. }
  560. }
  561. }
  562. break;
  563. case ACT_LAYER_MODS:
  564. if (event.pressed) {
  565. layer_on(action.layer_mods.layer);
  566. register_mods(action.layer_mods.mods);
  567. } else {
  568. unregister_mods(action.layer_mods.mods);
  569. layer_off(action.layer_mods.layer);
  570. }
  571. break;
  572. case ACT_LAYER_TAP:
  573. case ACT_LAYER_TAP_EXT:
  574. switch (action.layer_tap.code) {
  575. # ifndef NO_ACTION_TAPPING
  576. case OP_TAP_TOGGLE:
  577. /* tap toggle */
  578. if (event.pressed) {
  579. if (tap_count < TAPPING_TOGGLE) {
  580. layer_invert(action.layer_tap.val);
  581. }
  582. } else {
  583. if (tap_count <= TAPPING_TOGGLE) {
  584. layer_invert(action.layer_tap.val);
  585. }
  586. }
  587. break;
  588. # endif
  589. case OP_ON_OFF:
  590. event.pressed ? layer_on(action.layer_tap.val) : layer_off(action.layer_tap.val);
  591. break;
  592. case OP_OFF_ON:
  593. event.pressed ? layer_off(action.layer_tap.val) : layer_on(action.layer_tap.val);
  594. break;
  595. case OP_SET_CLEAR:
  596. event.pressed ? layer_move(action.layer_tap.val) : layer_clear();
  597. break;
  598. # if !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING)
  599. case OP_ONESHOT:
  600. // Oneshot modifier
  601. if (!keymap_config.oneshot_enable) {
  602. if (event.pressed) {
  603. layer_on(action.layer_tap.val);
  604. } else {
  605. layer_off(action.layer_tap.val);
  606. }
  607. } else {
  608. # if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1
  609. do_release_oneshot = false;
  610. if (event.pressed) {
  611. if (get_oneshot_layer_state() == ONESHOT_TOGGLED) {
  612. reset_oneshot_layer();
  613. layer_off(action.layer_tap.val);
  614. break;
  615. } else if (tap_count < ONESHOT_TAP_TOGGLE) {
  616. layer_on(action.layer_tap.val);
  617. set_oneshot_layer(action.layer_tap.val, ONESHOT_START);
  618. }
  619. } else {
  620. if (tap_count >= ONESHOT_TAP_TOGGLE) {
  621. reset_oneshot_layer();
  622. set_oneshot_layer(action.layer_tap.val, ONESHOT_TOGGLED);
  623. } else {
  624. clear_oneshot_layer_state(ONESHOT_PRESSED);
  625. }
  626. }
  627. # else
  628. if (event.pressed) {
  629. layer_on(action.layer_tap.val);
  630. set_oneshot_layer(action.layer_tap.val, ONESHOT_START);
  631. } else {
  632. clear_oneshot_layer_state(ONESHOT_PRESSED);
  633. if (tap_count > 1) {
  634. clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED);
  635. }
  636. }
  637. # endif
  638. }
  639. # else // NO_ACTION_ONESHOT && NO_ACTION_TAPPING
  640. if (event.pressed) {
  641. layer_on(action.layer_tap.val);
  642. } else {
  643. layer_off(action.layer_tap.val);
  644. }
  645. # endif // !defined(NO_ACTION_ONESHOT) && !defined(NO_ACTION_TAPPING)
  646. break;
  647. default:
  648. # ifndef NO_ACTION_TAPPING /* tap key */
  649. if (event.pressed) {
  650. if (tap_count > 0) {
  651. ac_dprintf("KEYMAP_TAP_KEY: Tap: register_code\n");
  652. register_code(action.layer_tap.code);
  653. } else {
  654. ac_dprintf("KEYMAP_TAP_KEY: No tap: On on press\n");
  655. layer_on(action.layer_tap.val);
  656. }
  657. } else {
  658. if (tap_count > 0) {
  659. ac_dprintf("KEYMAP_TAP_KEY: Tap: unregister_code\n");
  660. if (action.layer_tap.code == KC_CAPS_LOCK) {
  661. wait_ms(TAP_HOLD_CAPS_DELAY);
  662. } else {
  663. wait_ms(TAP_CODE_DELAY);
  664. }
  665. unregister_code(action.layer_tap.code);
  666. } else {
  667. ac_dprintf("KEYMAP_TAP_KEY: No tap: Off on release\n");
  668. layer_off(action.layer_tap.val);
  669. }
  670. }
  671. # else
  672. if (event.pressed) {
  673. ac_dprintf("KEYMAP_TAP_KEY: Tap: register_code\n");
  674. register_code(action.layer_tap.code);
  675. } else {
  676. ac_dprintf("KEYMAP_TAP_KEY: Tap: unregister_code\n");
  677. if (action.layer_tap.code == KC_CAPS) {
  678. wait_ms(TAP_HOLD_CAPS_DELAY);
  679. } else {
  680. wait_ms(TAP_CODE_DELAY);
  681. }
  682. unregister_code(action.layer_tap.code);
  683. }
  684. # endif
  685. break;
  686. }
  687. break;
  688. #endif // NO_ACTION_LAYER
  689. #ifdef SWAP_HANDS_ENABLE
  690. case ACT_SWAP_HANDS:
  691. switch (action.swap.code) {
  692. case OP_SH_TOGGLE:
  693. if (event.pressed) {
  694. swap_hands = !swap_hands;
  695. }
  696. break;
  697. case OP_SH_ON_OFF:
  698. swap_hands = event.pressed;
  699. break;
  700. case OP_SH_OFF_ON:
  701. swap_hands = !event.pressed;
  702. break;
  703. case OP_SH_ON:
  704. if (!event.pressed) {
  705. swap_hands = true;
  706. }
  707. break;
  708. case OP_SH_OFF:
  709. if (!event.pressed) {
  710. swap_hands = false;
  711. }
  712. break;
  713. # ifndef NO_ACTION_ONESHOT
  714. case OP_SH_ONESHOT:
  715. if (event.pressed) {
  716. set_oneshot_swaphands();
  717. } else {
  718. release_oneshot_swaphands();
  719. }
  720. break;
  721. # endif
  722. # ifndef NO_ACTION_TAPPING
  723. case OP_SH_TAP_TOGGLE:
  724. /* tap toggle */
  725. if (event.pressed) {
  726. if (swap_held) {
  727. swap_held = false;
  728. } else {
  729. swap_hands = !swap_hands;
  730. }
  731. } else {
  732. if (tap_count < TAPPING_TOGGLE) {
  733. swap_hands = !swap_hands;
  734. }
  735. }
  736. break;
  737. default:
  738. /* tap key */
  739. if (tap_count > 0) {
  740. if (swap_held) {
  741. swap_hands = !swap_hands; // undo hold set up in _tap_hint
  742. swap_held = false;
  743. }
  744. if (event.pressed) {
  745. register_code(action.swap.code);
  746. } else {
  747. wait_ms(TAP_CODE_DELAY);
  748. unregister_code(action.swap.code);
  749. *record = (keyrecord_t){}; // hack: reset tap mode
  750. }
  751. } else {
  752. if (swap_held && !event.pressed) {
  753. swap_hands = !swap_hands; // undo hold set up in _tap_hint
  754. swap_held = false;
  755. }
  756. }
  757. # endif
  758. }
  759. #endif
  760. default:
  761. break;
  762. }
  763. #ifndef NO_ACTION_LAYER
  764. // if this event is a layer action, update the leds
  765. switch (action.kind.id) {
  766. case ACT_LAYER:
  767. case ACT_LAYER_MODS:
  768. # ifndef NO_ACTION_TAPPING
  769. case ACT_LAYER_TAP:
  770. case ACT_LAYER_TAP_EXT:
  771. # endif
  772. led_set(host_keyboard_leds());
  773. break;
  774. default:
  775. break;
  776. }
  777. #endif
  778. #ifndef NO_ACTION_TAPPING
  779. # if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
  780. if (!is_tap_action(action)) {
  781. retro_tapping_counter = 0;
  782. } else {
  783. if (event.pressed) {
  784. if (tap_count > 0) {
  785. retro_tapping_counter = 0;
  786. }
  787. } else {
  788. if (tap_count > 0) {
  789. retro_tapping_counter = 0;
  790. } else {
  791. if (
  792. # ifdef RETRO_TAPPING_PER_KEY
  793. get_retro_tapping(get_event_keycode(record->event, false), record) &&
  794. # endif
  795. retro_tapping_counter == 2) {
  796. # if defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT)
  797. process_auto_shift(action.layer_tap.code, record);
  798. # else
  799. tap_code(action.layer_tap.code);
  800. # endif
  801. }
  802. retro_tapping_counter = 0;
  803. }
  804. }
  805. }
  806. # endif
  807. #endif
  808. #ifdef SWAP_HANDS_ENABLE
  809. # ifndef NO_ACTION_ONESHOT
  810. if (event.pressed && !(action.kind.id == ACT_SWAP_HANDS && action.swap.code == OP_SH_ONESHOT)) {
  811. use_oneshot_swaphands();
  812. }
  813. # endif
  814. #endif
  815. #ifndef NO_ACTION_ONESHOT
  816. /* Because we switch layers after a oneshot event, we need to release the
  817. * key before we leave the layer or no key up event will be generated.
  818. */
  819. if (do_release_oneshot && !(get_oneshot_layer_state() & ONESHOT_PRESSED)) {
  820. record->event.pressed = false;
  821. layer_on(get_oneshot_layer());
  822. process_record(record);
  823. layer_off(get_oneshot_layer());
  824. }
  825. #endif
  826. }
  827. /** \brief Utilities for actions. (FIXME: Needs better description)
  828. *
  829. * FIXME: Needs documentation.
  830. */
  831. __attribute__((weak)) void register_code(uint8_t code) {
  832. if (code == KC_NO) {
  833. return;
  834. #ifdef LOCKING_SUPPORT_ENABLE
  835. } else if (KC_LOCKING_CAPS_LOCK == code) {
  836. # ifdef LOCKING_RESYNC_ENABLE
  837. // Resync: ignore if caps lock already is on
  838. if (host_keyboard_led_state().caps_lock) return;
  839. # endif
  840. add_key(KC_CAPS_LOCK);
  841. send_keyboard_report();
  842. wait_ms(TAP_HOLD_CAPS_DELAY);
  843. del_key(KC_CAPS_LOCK);
  844. send_keyboard_report();
  845. } else if (KC_LOCKING_NUM_LOCK == code) {
  846. # ifdef LOCKING_RESYNC_ENABLE
  847. if (host_keyboard_led_state().num_lock) return;
  848. # endif
  849. add_key(KC_NUM_LOCK);
  850. send_keyboard_report();
  851. wait_ms(100);
  852. del_key(KC_NUM_LOCK);
  853. send_keyboard_report();
  854. } else if (KC_LOCKING_SCROLL_LOCK == code) {
  855. # ifdef LOCKING_RESYNC_ENABLE
  856. if (host_keyboard_led_state().scroll_lock) return;
  857. # endif
  858. add_key(KC_SCROLL_LOCK);
  859. send_keyboard_report();
  860. wait_ms(100);
  861. del_key(KC_SCROLL_LOCK);
  862. send_keyboard_report();
  863. #endif
  864. } else if (IS_BASIC_KEYCODE(code)) {
  865. // TODO: should push command_proc out of this block?
  866. if (command_proc(code)) return;
  867. // Force a new key press if the key is already pressed
  868. // without this, keys with the same keycode, but different
  869. // modifiers will be reported incorrectly, see issue #1708
  870. if (is_key_pressed(code)) {
  871. del_key(code);
  872. send_keyboard_report();
  873. }
  874. add_key(code);
  875. send_keyboard_report();
  876. } else if (IS_MODIFIER_KEYCODE(code)) {
  877. add_mods(MOD_BIT(code));
  878. send_keyboard_report();
  879. #ifdef EXTRAKEY_ENABLE
  880. } else if (IS_SYSTEM_KEYCODE(code)) {
  881. host_system_send(KEYCODE2SYSTEM(code));
  882. } else if (IS_CONSUMER_KEYCODE(code)) {
  883. host_consumer_send(KEYCODE2CONSUMER(code));
  884. #endif
  885. } else if (IS_MOUSE_KEYCODE(code)) {
  886. register_mouse(code, true);
  887. }
  888. }
  889. /** \brief Utilities for actions. (FIXME: Needs better description)
  890. *
  891. * FIXME: Needs documentation.
  892. */
  893. __attribute__((weak)) void unregister_code(uint8_t code) {
  894. if (code == KC_NO) {
  895. return;
  896. #ifdef LOCKING_SUPPORT_ENABLE
  897. } else if (KC_LOCKING_CAPS_LOCK == code) {
  898. # ifdef LOCKING_RESYNC_ENABLE
  899. // Resync: ignore if caps lock already is off
  900. if (!host_keyboard_led_state().caps_lock) return;
  901. # endif
  902. add_key(KC_CAPS_LOCK);
  903. send_keyboard_report();
  904. del_key(KC_CAPS_LOCK);
  905. send_keyboard_report();
  906. } else if (KC_LOCKING_NUM_LOCK == code) {
  907. # ifdef LOCKING_RESYNC_ENABLE
  908. if (!host_keyboard_led_state().num_lock) return;
  909. # endif
  910. add_key(KC_NUM_LOCK);
  911. send_keyboard_report();
  912. del_key(KC_NUM_LOCK);
  913. send_keyboard_report();
  914. } else if (KC_LOCKING_SCROLL_LOCK == code) {
  915. # ifdef LOCKING_RESYNC_ENABLE
  916. if (!host_keyboard_led_state().scroll_lock) return;
  917. # endif
  918. add_key(KC_SCROLL_LOCK);
  919. send_keyboard_report();
  920. del_key(KC_SCROLL_LOCK);
  921. send_keyboard_report();
  922. #endif
  923. } else if (IS_BASIC_KEYCODE(code)) {
  924. del_key(code);
  925. send_keyboard_report();
  926. } else if (IS_MODIFIER_KEYCODE(code)) {
  927. del_mods(MOD_BIT(code));
  928. send_keyboard_report();
  929. #ifdef EXTRAKEY_ENABLE
  930. } else if (IS_SYSTEM_KEYCODE(code)) {
  931. host_system_send(0);
  932. } else if (IS_CONSUMER_KEYCODE(code)) {
  933. host_consumer_send(0);
  934. #endif
  935. } else if (IS_MOUSE_KEYCODE(code)) {
  936. register_mouse(code, false);
  937. }
  938. }
  939. /** \brief Tap a keycode with a delay.
  940. *
  941. * \param code The basic keycode to tap.
  942. * \param delay The amount of time in milliseconds to leave the keycode registered, before unregistering it.
  943. */
  944. __attribute__((weak)) void tap_code_delay(uint8_t code, uint16_t delay) {
  945. register_code(code);
  946. wait_ms(delay);
  947. unregister_code(code);
  948. }
  949. /** \brief Tap a keycode with the default delay.
  950. *
  951. * \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.
  952. */
  953. __attribute__((weak)) void tap_code(uint8_t code) {
  954. tap_code_delay(code, code == KC_CAPS_LOCK ? TAP_HOLD_CAPS_DELAY : TAP_CODE_DELAY);
  955. }
  956. /** \brief Adds the given physically pressed modifiers and sends a keyboard report immediately.
  957. *
  958. * \param mods A bitfield of modifiers to register.
  959. */
  960. __attribute__((weak)) void register_mods(uint8_t mods) {
  961. if (mods) {
  962. add_mods(mods);
  963. send_keyboard_report();
  964. }
  965. }
  966. /** \brief Removes the given physically pressed modifiers and sends a keyboard report immediately.
  967. *
  968. * \param mods A bitfield of modifiers to unregister.
  969. */
  970. __attribute__((weak)) void unregister_mods(uint8_t mods) {
  971. if (mods) {
  972. del_mods(mods);
  973. send_keyboard_report();
  974. }
  975. }
  976. /** \brief Adds the given weak modifiers and sends a keyboard report immediately.
  977. *
  978. * \param mods A bitfield of modifiers to register.
  979. */
  980. __attribute__((weak)) void register_weak_mods(uint8_t mods) {
  981. if (mods) {
  982. add_weak_mods(mods);
  983. send_keyboard_report();
  984. }
  985. }
  986. /** \brief Removes the given weak modifiers and sends a keyboard report immediately.
  987. *
  988. * \param mods A bitfield of modifiers to unregister.
  989. */
  990. __attribute__((weak)) void unregister_weak_mods(uint8_t mods) {
  991. if (mods) {
  992. del_weak_mods(mods);
  993. send_keyboard_report();
  994. }
  995. }
  996. /** \brief Utilities for actions. (FIXME: Needs better description)
  997. *
  998. * FIXME: Needs documentation.
  999. */
  1000. void clear_keyboard(void) {
  1001. clear_mods();
  1002. clear_keyboard_but_mods();
  1003. }
  1004. /** \brief Utilities for actions. (FIXME: Needs better description)
  1005. *
  1006. * FIXME: Needs documentation.
  1007. */
  1008. void clear_keyboard_but_mods(void) {
  1009. clear_keys();
  1010. clear_keyboard_but_mods_and_keys();
  1011. }
  1012. /** \brief Utilities for actions. (FIXME: Needs better description)
  1013. *
  1014. * FIXME: Needs documentation.
  1015. */
  1016. void clear_keyboard_but_mods_and_keys(void) {
  1017. #ifdef EXTRAKEY_ENABLE
  1018. host_system_send(0);
  1019. host_consumer_send(0);
  1020. #endif
  1021. clear_weak_mods();
  1022. send_keyboard_report();
  1023. #ifdef MOUSEKEY_ENABLE
  1024. mousekey_clear();
  1025. mousekey_send();
  1026. #endif
  1027. #ifdef PROGRAMMABLE_BUTTON_ENABLE
  1028. programmable_button_clear();
  1029. #endif
  1030. }
  1031. /** \brief Utilities for actions. (FIXME: Needs better description)
  1032. *
  1033. * FIXME: Needs documentation.
  1034. */
  1035. bool is_tap_record(keyrecord_t *record) {
  1036. if (IS_NOEVENT(record->event)) {
  1037. return false;
  1038. }
  1039. #if defined(COMBO_ENABLE) || defined(REPEAT_KEY_ENABLE)
  1040. action_t action;
  1041. if (record->keycode) {
  1042. action = action_for_keycode(record->keycode);
  1043. } else {
  1044. action = layer_switch_get_action(record->event.key);
  1045. }
  1046. #else
  1047. action_t action = layer_switch_get_action(record->event.key);
  1048. #endif
  1049. return is_tap_action(action);
  1050. }
  1051. /** \brief Utilities for actions. (FIXME: Needs better description)
  1052. *
  1053. * FIXME: Needs documentation.
  1054. */
  1055. bool is_tap_action(action_t action) {
  1056. switch (action.kind.id) {
  1057. case ACT_LMODS_TAP:
  1058. case ACT_RMODS_TAP:
  1059. case ACT_LAYER_TAP:
  1060. case ACT_LAYER_TAP_EXT:
  1061. switch (action.layer_tap.code) {
  1062. case KC_NO ... KC_RIGHT_GUI:
  1063. case OP_TAP_TOGGLE:
  1064. case OP_ONESHOT:
  1065. return true;
  1066. }
  1067. return false;
  1068. case ACT_SWAP_HANDS:
  1069. switch (action.swap.code) {
  1070. case KC_NO ... KC_RIGHT_GUI:
  1071. case OP_SH_TAP_TOGGLE:
  1072. return true;
  1073. }
  1074. return false;
  1075. }
  1076. return false;
  1077. }
  1078. /** \brief Debug print (FIXME: Needs better description)
  1079. *
  1080. * FIXME: Needs documentation.
  1081. */
  1082. void debug_event(keyevent_t event) {
  1083. ac_dprintf("%04X%c(%u)", (event.key.row << 8 | event.key.col), (event.pressed ? 'd' : 'u'), event.time);
  1084. }
  1085. /** \brief Debug print (FIXME: Needs better description)
  1086. *
  1087. * FIXME: Needs documentation.
  1088. */
  1089. void debug_record(keyrecord_t record) {
  1090. debug_event(record.event);
  1091. #ifndef NO_ACTION_TAPPING
  1092. ac_dprintf(":%u%c", record.tap.count, (record.tap.interrupted ? '-' : ' '));
  1093. #endif
  1094. }
  1095. /** \brief Debug print (FIXME: Needs better description)
  1096. *
  1097. * FIXME: Needs documentation.
  1098. */
  1099. void debug_action(action_t action) {
  1100. switch (action.kind.id) {
  1101. case ACT_LMODS:
  1102. ac_dprintf("ACT_LMODS");
  1103. break;
  1104. case ACT_RMODS:
  1105. ac_dprintf("ACT_RMODS");
  1106. break;
  1107. case ACT_LMODS_TAP:
  1108. ac_dprintf("ACT_LMODS_TAP");
  1109. break;
  1110. case ACT_RMODS_TAP:
  1111. ac_dprintf("ACT_RMODS_TAP");
  1112. break;
  1113. case ACT_USAGE:
  1114. ac_dprintf("ACT_USAGE");
  1115. break;
  1116. case ACT_MOUSEKEY:
  1117. ac_dprintf("ACT_MOUSEKEY");
  1118. break;
  1119. case ACT_LAYER:
  1120. ac_dprintf("ACT_LAYER");
  1121. break;
  1122. case ACT_LAYER_MODS:
  1123. ac_dprintf("ACT_LAYER_MODS");
  1124. break;
  1125. case ACT_LAYER_TAP:
  1126. ac_dprintf("ACT_LAYER_TAP");
  1127. break;
  1128. case ACT_LAYER_TAP_EXT:
  1129. ac_dprintf("ACT_LAYER_TAP_EXT");
  1130. break;
  1131. case ACT_SWAP_HANDS:
  1132. ac_dprintf("ACT_SWAP_HANDS");
  1133. break;
  1134. default:
  1135. ac_dprintf("UNKNOWN");
  1136. break;
  1137. }
  1138. ac_dprintf("[%X:%02X]", action.kind.param >> 8, action.kind.param & 0xff);
  1139. }