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.

610 lines
18 KiB

Merge ChibiOS and LUFA descriptor support (#2362) * Move lufa descriptor to protocol/usb_descriptor * Try to compile usb_descriptor on ChibiOS * Add lufa_utils for ChibiOS Lufa USB descriptors for ChibiOS * More lufa_util compatibility fixes * First compiling version of shared USB descriptor * Send the usb descriptors * Fix the CONSOLE output on ChibiOS * Add errors for unsupported interfaces * Enable support for vitual serial port USB descriptors * Implement virtual serial port for ChibiOS * Cleanup the lufa_utils Use the default lufa header files * Add raw hid support for ChibiOS This is completely untested * Enable midi compilation on ChibiOS * Move midi functionality out of lufa.c * Don't register sysex callback when not needed * ChibiOS compilation fixes * Update ChibiOS submodule * Fix the Midi USB descriptor It didn't work properly when both Midi and Virtual serial port was enabled. * Add MIDI support for ChibiOS * Fix USB descriptor strings on ChibiOS * Use serial usb driver for raw hid * Generalize the ChibiOS stream like drivers This makes the initialization much more simple and eliminates a lot of the code duplication. * Convert console output to chibios stream driver * Fixes for ChibiOS update * Update the ChibiOS contrib submodule To include the usb data toggle synchronization fixes * Fix duplicate reset enumeration on ChibiOS * Add missing include * Add number of endpoints check for ChibiOS * Enable serial USB driver on all keyboards * Add missing includes when API is enabled withot midi * Add another missing inlcude
6 years ago
Merge ChibiOS and LUFA descriptor support (#2362) * Move lufa descriptor to protocol/usb_descriptor * Try to compile usb_descriptor on ChibiOS * Add lufa_utils for ChibiOS Lufa USB descriptors for ChibiOS * More lufa_util compatibility fixes * First compiling version of shared USB descriptor * Send the usb descriptors * Fix the CONSOLE output on ChibiOS * Add errors for unsupported interfaces * Enable support for vitual serial port USB descriptors * Implement virtual serial port for ChibiOS * Cleanup the lufa_utils Use the default lufa header files * Add raw hid support for ChibiOS This is completely untested * Enable midi compilation on ChibiOS * Move midi functionality out of lufa.c * Don't register sysex callback when not needed * ChibiOS compilation fixes * Update ChibiOS submodule * Fix the Midi USB descriptor It didn't work properly when both Midi and Virtual serial port was enabled. * Add MIDI support for ChibiOS * Fix USB descriptor strings on ChibiOS * Use serial usb driver for raw hid * Generalize the ChibiOS stream like drivers This makes the initialization much more simple and eliminates a lot of the code duplication. * Convert console output to chibios stream driver * Fixes for ChibiOS update * Update the ChibiOS contrib submodule To include the usb data toggle synchronization fixes * Fix duplicate reset enumeration on ChibiOS * Add missing include * Add number of endpoints check for ChibiOS * Enable serial USB driver on all keyboards * Add missing includes when API is enabled withot midi * Add another missing inlcude
6 years ago
Velocikey: Match RGB animation speed to typing speed (#3754) * Draft commit of typing speed RGB control * More information in the readme * Support all RGB animation modes (Fixes #1) * Added support for all RGB light modes to use typing speed Except christmas lights because that is seizure-inducing at high speeds! * Introduced a value range specific to each RGB mode Because some modes are a little too much when running at full speed! * Update readme.md * Update readme.md * Re-arrange typing_speed definitions (Fixes #5) (#6) * Re-arrange variable definitions to avoid including quantum.h from rgblight.c * Fix a compilation error when trying to run make test:all * Tweaks to the typing speed decay rate * Renamed to momentum; moved implementation into dedicated files * Groundwork for toggling momentum on/off (currently always on) * Add EEPROM toggle for momentum-matching * Moved momentum out of RGBLIGHT_ENABLE toggles so it's more generic * Move momentum decay task out of rgblight_task() * Fix missing momentum.h in lufa.c * Experimental LED support (untested) * Draft commit of typing speed RGB control * More information in the readme * Support all RGB animation modes (Fixes #1) * Added support for all RGB light modes to use typing speed Except christmas lights because that is seizure-inducing at high speeds! * Introduced a value range specific to each RGB mode Because some modes are a little too much when running at full speed! * Update readme.md * Update readme.md * Re-arrange typing_speed definitions (Fixes #5) (#6) * Re-arrange variable definitions to avoid including quantum.h from rgblight.c * Fix a compilation error when trying to run make test:all * Tweaks to the typing speed decay rate * Renamed to momentum; moved implementation into dedicated files * Groundwork for toggling momentum on/off (currently always on) * Add EEPROM toggle for momentum-matching * Moved momentum out of RGBLIGHT_ENABLE toggles so it's more generic * Move momentum decay task out of rgblight_task() * Fix missing momentum.h in lufa.c * Added documentation * Renamed feature to velocikey * Reverted readme to original state * Correct the readme title * Updated feature name in the docs * Update EECONFIG name * Add compile-time toggles for velocikey * Update feature documentation * Revert "Merge branch 'led-support' into master" This reverts commit e123ff5febf61639b9a9020748e1c2e2313460ff, reversing changes made to df111a55b9d4929182e16108b1c0ead15b16df97. * Move velocikey EECONFIG definition to depend on VELOCIKEY_ENABLE * Rename decay_task function to decelerate * Apply suggestions from code review Co-Authored-By: chrislewisdev <chris@chrislewisdev.com> * Re-order eeconfig definitions * Apply coding conventions * Apply #ifdef check in lufa.c * Refactored interval time checks into one functionc * Small rename * Fix unused function error for layouts not using all rgb effects * Only update EEPROM if Velocikey is enabled * Incorporate code review feedback * Small adjustment to top-end decay rate * Add Velocikey documentation to table of contents * Bring tetris:default keymap size down by disabling audio
5 years ago
Velocikey: Match RGB animation speed to typing speed (#3754) * Draft commit of typing speed RGB control * More information in the readme * Support all RGB animation modes (Fixes #1) * Added support for all RGB light modes to use typing speed Except christmas lights because that is seizure-inducing at high speeds! * Introduced a value range specific to each RGB mode Because some modes are a little too much when running at full speed! * Update readme.md * Update readme.md * Re-arrange typing_speed definitions (Fixes #5) (#6) * Re-arrange variable definitions to avoid including quantum.h from rgblight.c * Fix a compilation error when trying to run make test:all * Tweaks to the typing speed decay rate * Renamed to momentum; moved implementation into dedicated files * Groundwork for toggling momentum on/off (currently always on) * Add EEPROM toggle for momentum-matching * Moved momentum out of RGBLIGHT_ENABLE toggles so it's more generic * Move momentum decay task out of rgblight_task() * Fix missing momentum.h in lufa.c * Experimental LED support (untested) * Draft commit of typing speed RGB control * More information in the readme * Support all RGB animation modes (Fixes #1) * Added support for all RGB light modes to use typing speed Except christmas lights because that is seizure-inducing at high speeds! * Introduced a value range specific to each RGB mode Because some modes are a little too much when running at full speed! * Update readme.md * Update readme.md * Re-arrange typing_speed definitions (Fixes #5) (#6) * Re-arrange variable definitions to avoid including quantum.h from rgblight.c * Fix a compilation error when trying to run make test:all * Tweaks to the typing speed decay rate * Renamed to momentum; moved implementation into dedicated files * Groundwork for toggling momentum on/off (currently always on) * Add EEPROM toggle for momentum-matching * Moved momentum out of RGBLIGHT_ENABLE toggles so it's more generic * Move momentum decay task out of rgblight_task() * Fix missing momentum.h in lufa.c * Added documentation * Renamed feature to velocikey * Reverted readme to original state * Correct the readme title * Updated feature name in the docs * Update EECONFIG name * Add compile-time toggles for velocikey * Update feature documentation * Revert "Merge branch 'led-support' into master" This reverts commit e123ff5febf61639b9a9020748e1c2e2313460ff, reversing changes made to df111a55b9d4929182e16108b1c0ead15b16df97. * Move velocikey EECONFIG definition to depend on VELOCIKEY_ENABLE * Rename decay_task function to decelerate * Apply suggestions from code review Co-Authored-By: chrislewisdev <chris@chrislewisdev.com> * Re-order eeconfig definitions * Apply coding conventions * Apply #ifdef check in lufa.c * Refactored interval time checks into one functionc * Small rename * Fix unused function error for layouts not using all rgb effects * Only update EEPROM if Velocikey is enabled * Incorporate code review feedback * Small adjustment to top-end decay rate * Add Velocikey documentation to table of contents * Bring tetris:default keymap size down by disabling audio
5 years ago
Backlighting for JJ40 and underglow initialisation code (#2260) * Cleanup Mechmini keymap. Once the custom RGB function is defined, there is no need to manually handle RGB code. * Change default to KEYMAP_MIT, not KEYMAP_OFFSET * Add custom RGB code for JJ40 * Reset Mechmini advertised power draw to 500. Will have to test actual maximum power draw later. * RGB working on JJ40. * Fix: saturation increase/decrease flipped * Add new directory for my custom keymap with RGB keycodes * Swap LAlt and LGUI * Update JJ40 max power draw with measured value * Update: fun40 rules.mk to enable underglow; earlier failed Travis CI * Fix: init RGB LEDs on boot. Also added HHKB-like keymap for XD60. * Super rudimentary backlight test, init RGB LEDs on boot * Backlighting works - stays on for now * Toggling working * Now can override backlight.c functions. Problem was functions in backlight.c weren't called before due to a lack of matrix_scan_quantum() in matrix.c * Timers not working * Delete global.h * Cleanup * Compiles * Good sign: LEDs stop working again * Handle timer1 overflow * Progress: fix: forgot to init * Backlighting fully working now except breathing. * Revert keymap to original keycodes * Update XD60 keymap README * Update JJ40 keymap with backlight toggles * Breathing working just fine. * Update references * Add backlight_set() call * Cleanup code to disable backlight * Fix: does not compile * Fix: missing call to rgblight_task. * Testing with BACKLIGHT_BREATHING * Cleanup * Cleanup comments * More commenting cleanup. * Do not enable BACKLIGHT_BREATHING by default
6 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
Velocikey: Match RGB animation speed to typing speed (#3754) * Draft commit of typing speed RGB control * More information in the readme * Support all RGB animation modes (Fixes #1) * Added support for all RGB light modes to use typing speed Except christmas lights because that is seizure-inducing at high speeds! * Introduced a value range specific to each RGB mode Because some modes are a little too much when running at full speed! * Update readme.md * Update readme.md * Re-arrange typing_speed definitions (Fixes #5) (#6) * Re-arrange variable definitions to avoid including quantum.h from rgblight.c * Fix a compilation error when trying to run make test:all * Tweaks to the typing speed decay rate * Renamed to momentum; moved implementation into dedicated files * Groundwork for toggling momentum on/off (currently always on) * Add EEPROM toggle for momentum-matching * Moved momentum out of RGBLIGHT_ENABLE toggles so it's more generic * Move momentum decay task out of rgblight_task() * Fix missing momentum.h in lufa.c * Experimental LED support (untested) * Draft commit of typing speed RGB control * More information in the readme * Support all RGB animation modes (Fixes #1) * Added support for all RGB light modes to use typing speed Except christmas lights because that is seizure-inducing at high speeds! * Introduced a value range specific to each RGB mode Because some modes are a little too much when running at full speed! * Update readme.md * Update readme.md * Re-arrange typing_speed definitions (Fixes #5) (#6) * Re-arrange variable definitions to avoid including quantum.h from rgblight.c * Fix a compilation error when trying to run make test:all * Tweaks to the typing speed decay rate * Renamed to momentum; moved implementation into dedicated files * Groundwork for toggling momentum on/off (currently always on) * Add EEPROM toggle for momentum-matching * Moved momentum out of RGBLIGHT_ENABLE toggles so it's more generic * Move momentum decay task out of rgblight_task() * Fix missing momentum.h in lufa.c * Added documentation * Renamed feature to velocikey * Reverted readme to original state * Correct the readme title * Updated feature name in the docs * Update EECONFIG name * Add compile-time toggles for velocikey * Update feature documentation * Revert "Merge branch 'led-support' into master" This reverts commit e123ff5febf61639b9a9020748e1c2e2313460ff, reversing changes made to df111a55b9d4929182e16108b1c0ead15b16df97. * Move velocikey EECONFIG definition to depend on VELOCIKEY_ENABLE * Rename decay_task function to decelerate * Apply suggestions from code review Co-Authored-By: chrislewisdev <chris@chrislewisdev.com> * Re-order eeconfig definitions * Apply coding conventions * Apply #ifdef check in lufa.c * Refactored interval time checks into one functionc * Small rename * Fix unused function error for layouts not using all rgb effects * Only update EEPROM if Velocikey is enabled * Incorporate code review feedback * Small adjustment to top-end decay rate * Add Velocikey documentation to table of contents * Bring tetris:default keymap size down by disabling audio
5 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
Fix and add unit tests for Caps Word to work with Unicode Map, Auto Shift, Retro Shift. (#17284) * Fix Caps Word and Unicode Map * Tests for Caps Word + Auto Shift and Unicode Map. * Fix formatting * Add additional keyboard report expectation macros This commit defines five test utilities, EXPECT_REPORT, EXPECT_UNICODE, EXPECT_EMPTY_REPORT, EXPECT_ANY_REPORT and EXPECT_NO_REPORT for use with TestDriver. EXPECT_REPORT sets a gmock expectation that a given keyboard report will be sent. For instance, EXPECT_REPORT(driver, (KC_LSFT, KC_A)); is shorthand for EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A))); EXPECT_UNICODE sets a gmock expectation that a given Unicode code point will be sent using UC_LNX input mode. For instance for U+2013, EXPECT_UNICODE(driver, 0x2013); expects the sequence of keys: "Ctrl+Shift+U, 2, 0, 1, 3, space". EXPECT_EMPTY_REPORT sets a gmock expectation that a given keyboard report will be sent. For instance EXPECT_EMPTY_REPORT(driver); expects a single report without keypresses or modifiers. EXPECT_ANY_REPORT sets a gmock expectation that a arbitrary keyboard report will be sent, without matching its contents. For instance EXPECT_ANY_REPORT(driver).Times(1); expects a single arbitrary keyboard report will be sent. EXPECT_NO_REPORT sets a gmock expectation that no keyboard report will be sent at all. * Add tap_key() and tap_keys() to TestFixture. This commit adds a `tap_key(key)` method to TestFixture that taps a given KeymapKey, optionally with a specified delay between press and release. Similarly, the method `tap_keys(key_a, key_b, key_c)` taps a sequence of KeymapKeys. * Use EXPECT_REPORT, tap_keys, etc. in most tests. This commit uses EXPECT_REPORT, EXPECT_UNICODE, EXPECT_EMPTY_REPORT, EXPECT_NO_REPORT, tap_key() and tap_keys() test utilities from the previous two commits in most tests. Particularly the EXPECT_REPORT macro is frequently useful and makes a nice reduction in boilerplate needed to express many tests. Co-authored-by: David Kosorin <david@kosorin.net>
2 years ago
Hid joystick interface (#4226) * add support for hid gamepad interface add documentation for HID joystick Add joystick_task to read analog axes values even when no key is pressed or release. update doc Update docs/feature_joystick.md Manage pin setup and read to maintain matrix scan after analog read * Incorporates patches and changes to HID reporting There are some patches provided by @a-chol incorporated on this commit, and also some changes I made to the HID Report structure. The most interesting is the one dealing with number of buttons: Linux doesn't seem to care, but Windows requires the HID structure to be byte aligned (that's in the spec). So if one declares 8/16/32... buttons they should not have any issues, but this is what happens when you have 9 buttons: ``` bits |0|1|2|3|4|5|6|7| |*|*|*|*|*|*|*|*| axis 0 (report size 8) |*|*|*|*|*|*|*|*| ... |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| |*|*|*|*|*|*|*|*| axis 6 |*|*|*|*|*|*|*|*| first 8 buttons (report size 1) |*| | | | | | | | last of 9 buttons, not aligned ``` So for that I added a conditonal that will add a number of reports with size 1 to make sure it aligns to the next multiple of 8. Those reports send dummy inputs that don't do anything aside from aligning the data. Tested on Linux, Windows 10 and Street Fighter (where the joystick is recognized as direct-input) * Add save and restore of each pin used in reading joystick (AVR). Allow output pin to be JS_VIRTUAL_AXIS if the axis is connected to Vcc instead of an output pin from the MCU. Fix joystick report id Fix broken v-usb hid joystick interface. Make it more resilient to unusual settings (none multiple of eight button count, 0 buttons or 0 axes) Correct adc reading for multiple axes. Piecewise range conversion for uncentered raw value range. Input, output and ground pin configuration per axis. Documentation fixes * Fix port addressing for joystick analog read * The other required set of changes As per the PR, the changes still holding it up. Add onekey for testing. Fix ARM builds. Fix device descriptor when either axes or buttons is zero. Add compile-time check for at least one axis or button. Move definition to try to fix conflict. PR review comments. qmk cformat * avoid float functions to compute range mapping for axis adc reading * Remove V-USB support for now. Updated docs accordingly. * Update tmk_core/protocol/lufa/lufa.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/usb_descriptor.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Add support for joystick adc reading for stm32 MCUs. Fix joystick hid report sending for chibios * Fix HID joystick report sending for ChibiOS. Add one analog axis to the onekey:joystick keymap. Fix pin state save and restore during joystick analog read for STM32 MCUs. * Update tmk_core/protocol/chibios/usb_main.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Update tmk_core/protocol/lufa/lufa.c Co-Authored-By: Ryan <fauxpark@gmail.com> * Add missing mcuconf.h and halconf.h to onekey:joystick keymap. Add suggested fixes from PR. * Switch saveState and restoreState signature to use pin_t type. onekey:joystick : add a second axis, virtual and programmatically animated. * Update docs/feature_joystick.md Co-Authored-By: Ryan <fauxpark@gmail.com> * Update docs/feature_joystick.md Co-Authored-By: Ryan <fauxpark@gmail.com> * Add PR corrections * Remove halconf.h and mcuconf.h from onekey keymaps * Change ADC_PIN to A0 Co-authored-by: achol <allecooll@hotmail.com> Co-authored-by: José Júnior <jose.junior@gmail.com> Co-authored-by: a-chol <achol@notamail.com> Co-authored-by: Nick Brassel <nick@tzarc.org> Co-authored-by: Ryan <fauxpark@gmail.com>
3 years ago
  1. /* Copyright 2016-2017 Jack Humbert
  2. *
  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. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "quantum.h"
  17. #ifdef BLUETOOTH_ENABLE
  18. # include "outputselect.h"
  19. #endif
  20. #ifdef BACKLIGHT_ENABLE
  21. # include "backlight.h"
  22. #endif
  23. #ifdef MIDI_ENABLE
  24. # include "process_midi.h"
  25. #endif
  26. #ifdef VELOCIKEY_ENABLE
  27. # include "velocikey.h"
  28. #endif
  29. #ifdef HAPTIC_ENABLE
  30. # include "haptic.h"
  31. #endif
  32. #ifdef AUDIO_ENABLE
  33. # ifndef GOODBYE_SONG
  34. # define GOODBYE_SONG SONG(GOODBYE_SOUND)
  35. # endif
  36. float goodbye_song[][2] = GOODBYE_SONG;
  37. # ifdef DEFAULT_LAYER_SONGS
  38. float default_layer_songs[][16][2] = DEFAULT_LAYER_SONGS;
  39. # endif
  40. #endif
  41. uint8_t extract_mod_bits(uint16_t code) {
  42. switch (code) {
  43. case QK_MODS ... QK_MODS_MAX:
  44. break;
  45. default:
  46. return 0;
  47. }
  48. uint8_t mods_to_send = 0;
  49. if (code & QK_RMODS_MIN) { // Right mod flag is set
  50. if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_RIGHT_CTRL);
  51. if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_RIGHT_SHIFT);
  52. if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_RIGHT_ALT);
  53. if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_RIGHT_GUI);
  54. } else {
  55. if (code & QK_LCTL) mods_to_send |= MOD_BIT(KC_LEFT_CTRL);
  56. if (code & QK_LSFT) mods_to_send |= MOD_BIT(KC_LEFT_SHIFT);
  57. if (code & QK_LALT) mods_to_send |= MOD_BIT(KC_LEFT_ALT);
  58. if (code & QK_LGUI) mods_to_send |= MOD_BIT(KC_LEFT_GUI);
  59. }
  60. return mods_to_send;
  61. }
  62. void do_code16(uint16_t code, void (*f)(uint8_t)) {
  63. f(extract_mod_bits(code));
  64. }
  65. __attribute__((weak)) void register_code16(uint16_t code) {
  66. if (IS_MOD(code) || code == KC_NO) {
  67. do_code16(code, register_mods);
  68. } else {
  69. do_code16(code, register_weak_mods);
  70. }
  71. register_code(code);
  72. }
  73. __attribute__((weak)) void unregister_code16(uint16_t code) {
  74. unregister_code(code);
  75. if (IS_MOD(code) || code == KC_NO) {
  76. do_code16(code, unregister_mods);
  77. } else {
  78. do_code16(code, unregister_weak_mods);
  79. }
  80. }
  81. /** \brief Tap a keycode with a delay.
  82. *
  83. * \param code The modded keycode to tap.
  84. * \param delay The amount of time in milliseconds to leave the keycode registered, before unregistering it.
  85. */
  86. __attribute__((weak)) void tap_code16_delay(uint16_t code, uint16_t delay) {
  87. register_code16(code);
  88. for (uint16_t i = delay; i > 0; i--) {
  89. wait_ms(1);
  90. }
  91. unregister_code16(code);
  92. }
  93. /** \brief Tap a keycode with the default delay.
  94. *
  95. * \param code The modded keycode to tap. If `code` is `KC_CAPS_LOCK`, the delay will be `TAP_HOLD_CAPS_DELAY`, otherwise `TAP_CODE_DELAY`, if defined.
  96. */
  97. __attribute__((weak)) void tap_code16(uint16_t code) {
  98. tap_code16_delay(code, code == KC_CAPS_LOCK ? TAP_HOLD_CAPS_DELAY : TAP_CODE_DELAY);
  99. }
  100. __attribute__((weak)) bool process_action_kb(keyrecord_t *record) {
  101. return true;
  102. }
  103. __attribute__((weak)) bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
  104. return process_record_user(keycode, record);
  105. }
  106. __attribute__((weak)) bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  107. return true;
  108. }
  109. __attribute__((weak)) void post_process_record_kb(uint16_t keycode, keyrecord_t *record) {
  110. post_process_record_user(keycode, record);
  111. }
  112. __attribute__((weak)) void post_process_record_user(uint16_t keycode, keyrecord_t *record) {}
  113. void shutdown_quantum(void) {
  114. clear_keyboard();
  115. #if defined(MIDI_ENABLE) && defined(MIDI_BASIC)
  116. process_midi_all_notes_off();
  117. #endif
  118. #ifdef AUDIO_ENABLE
  119. # ifndef NO_MUSIC_MODE
  120. music_all_notes_off();
  121. # endif
  122. uint16_t timer_start = timer_read();
  123. PLAY_SONG(goodbye_song);
  124. shutdown_user();
  125. while (timer_elapsed(timer_start) < 250)
  126. wait_ms(1);
  127. stop_all_notes();
  128. #else
  129. shutdown_user();
  130. wait_ms(250);
  131. #endif
  132. #ifdef HAPTIC_ENABLE
  133. haptic_shutdown();
  134. #endif
  135. }
  136. void reset_keyboard(void) {
  137. shutdown_quantum();
  138. bootloader_jump();
  139. }
  140. void soft_reset_keyboard(void) {
  141. shutdown_quantum();
  142. mcu_reset();
  143. }
  144. /* Convert record into usable keycode via the contained event. */
  145. uint16_t get_record_keycode(keyrecord_t *record, bool update_layer_cache) {
  146. #ifdef COMBO_ENABLE
  147. if (record->keycode) {
  148. return record->keycode;
  149. }
  150. #endif
  151. return get_event_keycode(record->event, update_layer_cache);
  152. }
  153. /* Convert event into usable keycode. Checks the layer cache to ensure that it
  154. * retains the correct keycode after a layer change, if the key is still pressed.
  155. * "update_layer_cache" is to ensure that it only updates the layer cache when
  156. * appropriate, otherwise, it will update it and cause layer tap (and other keys)
  157. * from triggering properly.
  158. */
  159. uint16_t get_event_keycode(keyevent_t event, bool update_layer_cache) {
  160. #if !defined(NO_ACTION_LAYER) && !defined(STRICT_LAYER_RELEASE)
  161. /* TODO: Use store_or_get_action() or a similar function. */
  162. if (!disable_action_cache) {
  163. uint8_t layer;
  164. if (event.pressed && update_layer_cache) {
  165. layer = layer_switch_get_layer(event.key);
  166. update_source_layers_cache(event.key, layer);
  167. } else {
  168. layer = read_source_layers_cache(event.key);
  169. }
  170. return keymap_key_to_keycode(layer, event.key);
  171. } else
  172. #endif
  173. return keymap_key_to_keycode(layer_switch_get_layer(event.key), event.key);
  174. }
  175. /* Get keycode, and then process pre tapping functionality */
  176. bool pre_process_record_quantum(keyrecord_t *record) {
  177. if (!(
  178. #ifdef COMBO_ENABLE
  179. process_combo(get_record_keycode(record, true), record) &&
  180. #endif
  181. true)) {
  182. return false;
  183. }
  184. return true; // continue processing
  185. }
  186. /* Get keycode, and then call keyboard function */
  187. void post_process_record_quantum(keyrecord_t *record) {
  188. uint16_t keycode = get_record_keycode(record, false);
  189. post_process_record_kb(keycode, record);
  190. }
  191. /* Core keycode function, hands off handling to other functions,
  192. then processes internal quantum keycodes, and then processes
  193. ACTIONs. */
  194. bool process_record_quantum(keyrecord_t *record) {
  195. uint16_t keycode = get_record_keycode(record, true);
  196. // This is how you use actions here
  197. // if (keycode == QK_LEADER) {
  198. // action_t action;
  199. // action.code = ACTION_DEFAULT_LAYER_SET(0);
  200. // process_action(record, action);
  201. // return false;
  202. // }
  203. #if defined(SECURE_ENABLE)
  204. if (!preprocess_secure(keycode, record)) {
  205. return false;
  206. }
  207. #endif
  208. #ifdef VELOCIKEY_ENABLE
  209. if (velocikey_enabled() && record->event.pressed) {
  210. velocikey_accelerate();
  211. }
  212. #endif
  213. #ifdef WPM_ENABLE
  214. if (record->event.pressed) {
  215. update_wpm(keycode);
  216. }
  217. #endif
  218. #ifdef TAP_DANCE_ENABLE
  219. if (preprocess_tap_dance(keycode, record)) {
  220. // The tap dance might have updated the layer state, therefore the
  221. // result of the keycode lookup might change.
  222. keycode = get_record_keycode(record, true);
  223. }
  224. #endif
  225. if (!(
  226. #if defined(KEY_LOCK_ENABLE)
  227. // Must run first to be able to mask key_up events.
  228. process_key_lock(&keycode, record) &&
  229. #endif
  230. #if defined(DYNAMIC_MACRO_ENABLE) && !defined(DYNAMIC_MACRO_USER_CALL)
  231. // Must run asap to ensure all keypresses are recorded.
  232. process_dynamic_macro(keycode, record) &&
  233. #endif
  234. #if defined(AUDIO_ENABLE) && defined(AUDIO_CLICKY)
  235. process_clicky(keycode, record) &&
  236. #endif
  237. #ifdef HAPTIC_ENABLE
  238. process_haptic(keycode, record) &&
  239. #endif
  240. #if defined(VIA_ENABLE)
  241. process_record_via(keycode, record) &&
  242. #endif
  243. #if defined(POINTING_DEVICE_ENABLE) && defined(POINTING_DEVICE_AUTO_MOUSE_ENABLE)
  244. process_auto_mouse(keycode, record) &&
  245. #endif
  246. process_record_kb(keycode, record) &&
  247. #if defined(SECURE_ENABLE)
  248. process_secure(keycode, record) &&
  249. #endif
  250. #if defined(SEQUENCER_ENABLE)
  251. process_sequencer(keycode, record) &&
  252. #endif
  253. #if defined(MIDI_ENABLE) && defined(MIDI_ADVANCED)
  254. process_midi(keycode, record) &&
  255. #endif
  256. #ifdef AUDIO_ENABLE
  257. process_audio(keycode, record) &&
  258. #endif
  259. #if defined(BACKLIGHT_ENABLE) || defined(LED_MATRIX_ENABLE)
  260. process_backlight(keycode, record) &&
  261. #endif
  262. #ifdef STENO_ENABLE
  263. process_steno(keycode, record) &&
  264. #endif
  265. #if (defined(AUDIO_ENABLE) || (defined(MIDI_ENABLE) && defined(MIDI_BASIC))) && !defined(NO_MUSIC_MODE)
  266. process_music(keycode, record) &&
  267. #endif
  268. #ifdef KEY_OVERRIDE_ENABLE
  269. process_key_override(keycode, record) &&
  270. #endif
  271. #ifdef TAP_DANCE_ENABLE
  272. process_tap_dance(keycode, record) &&
  273. #endif
  274. #ifdef CAPS_WORD_ENABLE
  275. process_caps_word(keycode, record) &&
  276. #endif
  277. #if defined(UNICODE_COMMON_ENABLE)
  278. process_unicode_common(keycode, record) &&
  279. #endif
  280. #ifdef LEADER_ENABLE
  281. process_leader(keycode, record) &&
  282. #endif
  283. #ifdef AUTO_SHIFT_ENABLE
  284. process_auto_shift(keycode, record) &&
  285. #endif
  286. #ifdef DYNAMIC_TAPPING_TERM_ENABLE
  287. process_dynamic_tapping_term(keycode, record) &&
  288. #endif
  289. #ifdef SPACE_CADET_ENABLE
  290. process_space_cadet(keycode, record) &&
  291. #endif
  292. #ifdef MAGIC_KEYCODE_ENABLE
  293. process_magic(keycode, record) &&
  294. #endif
  295. #ifdef GRAVE_ESC_ENABLE
  296. process_grave_esc(keycode, record) &&
  297. #endif
  298. #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
  299. process_rgb(keycode, record) &&
  300. #endif
  301. #ifdef JOYSTICK_ENABLE
  302. process_joystick(keycode, record) &&
  303. #endif
  304. #ifdef PROGRAMMABLE_BUTTON_ENABLE
  305. process_programmable_button(keycode, record) &&
  306. #endif
  307. #ifdef AUTOCORRECT_ENABLE
  308. process_autocorrect(keycode, record) &&
  309. #endif
  310. true)) {
  311. return false;
  312. }
  313. if (record->event.pressed) {
  314. switch (keycode) {
  315. #ifndef NO_RESET
  316. case QK_BOOTLOADER:
  317. reset_keyboard();
  318. return false;
  319. case QK_REBOOT:
  320. soft_reset_keyboard();
  321. return false;
  322. #endif
  323. #ifndef NO_DEBUG
  324. case QK_DEBUG_TOGGLE:
  325. debug_enable ^= 1;
  326. if (debug_enable) {
  327. print("DEBUG: enabled.\n");
  328. } else {
  329. print("DEBUG: disabled.\n");
  330. }
  331. #endif
  332. return false;
  333. case QK_CLEAR_EEPROM:
  334. #ifdef NO_RESET
  335. eeconfig_init();
  336. #else
  337. eeconfig_disable();
  338. soft_reset_keyboard();
  339. #endif
  340. return false;
  341. #ifdef VELOCIKEY_ENABLE
  342. case QK_VELOCIKEY_TOGGLE:
  343. velocikey_toggle();
  344. return false;
  345. #endif
  346. #ifdef BLUETOOTH_ENABLE
  347. case QK_OUTPUT_AUTO:
  348. set_output(OUTPUT_AUTO);
  349. return false;
  350. case QK_OUTPUT_USB:
  351. set_output(OUTPUT_USB);
  352. return false;
  353. case QK_OUTPUT_BLUETOOTH:
  354. set_output(OUTPUT_BLUETOOTH);
  355. return false;
  356. #endif
  357. #ifndef NO_ACTION_ONESHOT
  358. case QK_ONE_SHOT_TOGGLE:
  359. oneshot_toggle();
  360. break;
  361. case QK_ONE_SHOT_ON:
  362. oneshot_enable();
  363. break;
  364. case QK_ONE_SHOT_OFF:
  365. oneshot_disable();
  366. break;
  367. #endif
  368. #ifdef ENABLE_COMPILE_KEYCODE
  369. case QK_MAKE: // Compiles the firmware, and adds the flash command based on keyboard bootloader
  370. {
  371. # ifdef NO_ACTION_ONESHOT
  372. const uint8_t temp_mod = mod_config(get_mods());
  373. # else
  374. const uint8_t temp_mod = mod_config(get_mods() | get_oneshot_mods());
  375. clear_oneshot_mods();
  376. # endif
  377. clear_mods();
  378. SEND_STRING_DELAY("qmk", TAP_CODE_DELAY);
  379. if (temp_mod & MOD_MASK_SHIFT) { // if shift is held, flash rather than compile
  380. SEND_STRING_DELAY(" flash ", TAP_CODE_DELAY);
  381. } else {
  382. SEND_STRING_DELAY(" compile ", TAP_CODE_DELAY);
  383. }
  384. # if defined(CONVERTER_ENABLED)
  385. SEND_STRING_DELAY("-kb " QMK_KEYBOARD " -km " QMK_KEYMAP " -e CONVERT_TO=" CONVERTER_TARGET SS_TAP(X_ENTER), TAP_CODE_DELAY);
  386. # else
  387. SEND_STRING_DELAY("-kb " QMK_KEYBOARD " -km " QMK_KEYMAP SS_TAP(X_ENTER), TAP_CODE_DELAY);
  388. # endif
  389. if (temp_mod & MOD_MASK_SHIFT && temp_mod & MOD_MASK_CTRL) {
  390. reset_keyboard();
  391. }
  392. }
  393. #endif
  394. }
  395. }
  396. return process_action_kb(record);
  397. }
  398. void set_single_persistent_default_layer(uint8_t default_layer) {
  399. #if defined(AUDIO_ENABLE) && defined(DEFAULT_LAYER_SONGS)
  400. PLAY_SONG(default_layer_songs[default_layer]);
  401. #endif
  402. eeconfig_update_default_layer((layer_state_t)1 << default_layer);
  403. default_layer_set((layer_state_t)1 << default_layer);
  404. }
  405. layer_state_t update_tri_layer_state(layer_state_t state, uint8_t layer1, uint8_t layer2, uint8_t layer3) {
  406. layer_state_t mask12 = ((layer_state_t)1 << layer1) | ((layer_state_t)1 << layer2);
  407. layer_state_t mask3 = (layer_state_t)1 << layer3;
  408. return (state & mask12) == mask12 ? (state | mask3) : (state & ~mask3);
  409. }
  410. void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
  411. layer_state_set(update_tri_layer_state(layer_state, layer1, layer2, layer3));
  412. }
  413. // TODO: remove legacy api
  414. void matrix_init_quantum() {
  415. matrix_init_kb();
  416. }
  417. void matrix_scan_quantum() {
  418. matrix_scan_kb();
  419. }
  420. //------------------------------------------------------------------------------
  421. // Override these functions in your keymap file to play different tunes on
  422. // different events such as startup and bootloader jump
  423. __attribute__((weak)) void startup_user() {}
  424. __attribute__((weak)) void shutdown_user() {}
  425. void suspend_power_down_quantum(void) {
  426. suspend_power_down_kb();
  427. #ifndef NO_SUSPEND_POWER_DOWN
  428. // Turn off backlight
  429. # ifdef BACKLIGHT_ENABLE
  430. backlight_set(0);
  431. # endif
  432. # ifdef LED_MATRIX_ENABLE
  433. led_matrix_task();
  434. # endif
  435. # ifdef RGB_MATRIX_ENABLE
  436. rgb_matrix_task();
  437. # endif
  438. // Turn off LED indicators
  439. led_suspend();
  440. // Turn off audio
  441. # ifdef AUDIO_ENABLE
  442. stop_all_notes();
  443. # endif
  444. // Turn off underglow
  445. # if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
  446. rgblight_suspend();
  447. # endif
  448. # if defined(LED_MATRIX_ENABLE)
  449. led_matrix_set_suspend_state(true);
  450. # endif
  451. # if defined(RGB_MATRIX_ENABLE)
  452. rgb_matrix_set_suspend_state(true);
  453. # endif
  454. # ifdef OLED_ENABLE
  455. oled_off();
  456. # endif
  457. # ifdef ST7565_ENABLE
  458. st7565_off();
  459. # endif
  460. # if defined(POINTING_DEVICE_ENABLE)
  461. // run to ensure scanning occurs while suspended
  462. pointing_device_task();
  463. # endif
  464. #endif
  465. }
  466. __attribute__((weak)) void suspend_wakeup_init_quantum(void) {
  467. // Turn on backlight
  468. #ifdef BACKLIGHT_ENABLE
  469. backlight_init();
  470. #endif
  471. // Restore LED indicators
  472. led_wakeup();
  473. // Wake up underglow
  474. #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE)
  475. rgblight_wakeup();
  476. #endif
  477. #if defined(LED_MATRIX_ENABLE)
  478. led_matrix_set_suspend_state(false);
  479. #endif
  480. #if defined(RGB_MATRIX_ENABLE)
  481. rgb_matrix_set_suspend_state(false);
  482. #endif
  483. suspend_wakeup_init_kb();
  484. }
  485. /** \brief converts unsigned integers into char arrays
  486. *
  487. * Takes an unsigned integer and converts that value into an equivalent char array
  488. * A padding character may be specified, ' ' for leading spaces, '0' for leading zeros.
  489. */
  490. const char *get_numeric_str(char *buf, size_t buf_len, uint32_t curr_num, char curr_pad) {
  491. buf[buf_len - 1] = '\0';
  492. for (size_t i = 0; i < buf_len - 1; ++i) {
  493. char c = '0' + curr_num % 10;
  494. buf[buf_len - 2 - i] = (c == '0' && i == 0) ? '0' : (curr_num > 0 ? c : curr_pad);
  495. curr_num /= 10;
  496. }
  497. return buf;
  498. }
  499. /** \brief converts uint8_t into char array
  500. *
  501. * Takes an uint8_t, and uses an internal static buffer to render that value into a char array
  502. * A padding character may be specified, ' ' for leading spaces, '0' for leading zeros.
  503. *
  504. * NOTE: Subsequent invocations will reuse the same static buffer and overwrite the previous
  505. * contents. Use the result immediately, instead of caching it.
  506. */
  507. const char *get_u8_str(uint8_t curr_num, char curr_pad) {
  508. static char buf[4] = {0};
  509. static uint8_t last_num = 0xFF;
  510. static char last_pad = '\0';
  511. if (last_num == curr_num && last_pad == curr_pad) {
  512. return buf;
  513. }
  514. last_num = curr_num;
  515. last_pad = curr_pad;
  516. return get_numeric_str(buf, sizeof(buf), curr_num, curr_pad);
  517. }
  518. /** \brief converts uint16_t into char array
  519. *
  520. * Takes an uint16_t, and uses an internal static buffer to render that value into a char array
  521. * A padding character may be specified, ' ' for leading spaces, '0' for leading zeros.
  522. *
  523. * NOTE: Subsequent invocations will reuse the same static buffer and overwrite the previous
  524. * contents. Use the result immediately, instead of caching it.
  525. */
  526. const char *get_u16_str(uint16_t curr_num, char curr_pad) {
  527. static char buf[6] = {0};
  528. static uint16_t last_num = 0xFF;
  529. static char last_pad = '\0';
  530. if (last_num == curr_num && last_pad == curr_pad) {
  531. return buf;
  532. }
  533. last_num = curr_num;
  534. last_pad = curr_pad;
  535. return get_numeric_str(buf, sizeof(buf), curr_num, curr_pad);
  536. }
  537. #if defined(SECURE_ENABLE)
  538. void secure_hook_quantum(secure_status_t secure_status) {
  539. // If keys are being held when this is triggered, they may not be released properly
  540. // this can result in stuck keys, mods and layers. To prevent that, manually
  541. // clear these, when it is triggered.
  542. if (secure_status == SECURE_PENDING) {
  543. clear_keyboard();
  544. layer_clear();
  545. }
  546. }
  547. #endif