From 98990f50d74d028d530ba5c79ac81be6bd4a1385 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Wed, 4 Jun 2025 01:26:21 -0700 Subject: [PATCH] Additional updates for firmware25 (#411) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add 75_(ansi|iso) Community Layouts to mechlovin/olly/octagon (#22459) * expand mechlovin/olly/octagon * Update info.json * Rename info.json to keyboard.json * correct matrix position for key * remove VIA * [Core] get_keycode_string(): function to format keycodes as strings, for more readable debug logging. (#24787) * keycode_string(): Format keycodes as strings. This adds the `keycode_string()` function described in https://getreuer.info/posts/keyboards/keycode-string/index.html as a core feature. * Fix formatting. * keycode_string review revisions. * Rename keycode_string() -> get_keycode_string() for consistency with existing string utils like get_u8_str(). * Revise custom keycode names with separate _user and _kb tables. * Correct indent in builddefs/generic_features.mk. Co-authored-by: Ryan * Add KC_NUHS, KC_NUBS, and KC_CAPS. * Fix linking error with custom names. * Attempt at simplifying interface. * Formatting fix. * Several fixes and revisions. * Don't use PSTR in KEYCODE_STRING_NAME, since this fails to build on AVR. Store custom names in RAM. * Revise the internal table of common keycode names to use its own storage representation, still in PROGMEM, and now more efficiently stored flat in 8 bytes per entry. * Support Swap Hands keycodes and a few other keycodes. * Revert "Formatting fix." This reverts commit 2a2771068c7ee545ffac4103aa07e847a9ec3816. * Revert "Attempt at simplifying interface." This reverts commit 8eaf67de76e75bc92d106a8b0decc893fbc65fa5. * Simplify custom names API by sigprof's suggestion. * Support more keycodes. * Add QK_LOCK keycode. * Add Secure keycodes. * Add Joystick keycodes. * Add Programmable Button keycodes. * Add macro MC_ keycodes. * For remaining keys in known code ranges, stringify them as "QK_+". For instance, "QK_MIDI+7". * Bug fix and a few improvements. * Fix missing right-hand bit when displaying 5-bit mods numerically. * Support KC_HYPR, KC_MEH, HYPR_T(kc), MEH_T(kc). * Exclude one-shot keycodes when NO_ACTION_ONESHOT is defined. --------- Co-authored-by: Ryan * Align to latest CLI dependencies (#24553) * Align to latest CLI dependencies * Update docs * Add Community Layout support to daskeyboard4 (#23884) add ansi CL * Add the plywrks ply8x hotswap variant. (#23558) * Add hotswap variant * Update RGB matrix * Move files around to target develop * Revert rules.mk for keyboards/jaykeeb/joker/rules.mk * Update keyboards/plywrks/ply8x/hotswap/keyboard.json Co-authored-by: Drashna Jaelre * Apply suggestions from code review Co-authored-by: Duncan Sutherland * Add missing community layouts * Delete keyboards/plywrks/ply8x/rules.mk * Update missing keys in RGB matrix * Add missing key in RGB matrix for hotswap ver * Remove via keymaps * Add keyboard alias for plywrks/ply8x to plywrks/ply8x/solder * Fix typo * Fix another typo --------- Co-authored-by: Drashna Jaelre Co-authored-by: Duncan Sutherland * [Core] use `keycode_string` in unit tests (#25042) * tests: use keycode_string feature With a proper keycode to string implementation in qmk there is no need to use the unit tests only implementation anymore. Signed-off-by: Stefan Kerkmann * tests: remove keycode_util feature This feature is no longer used as we switched the tests to the keycode string implementation. Signed-off-by: Stefan Kerkmann * Non-volatile memory data repository pattern (#24356) * First batch of eeconfig conversions. * Offset and length for datablocks. * `via`, `dynamic_keymap`. * Fix filename. * Commentary. * wilba leds * satisfaction75 * satisfaction75 * more keyboard whack-a-mole * satisfaction75 * omnikeyish * more whack-a-mole * `generic_features.mk` to automatically pick up nvm repositories * thievery * deferred variable resolve * whitespace * convert api to structs/unions * convert api to structs/unions * convert api to structs/unions * fixups * code-side docs * code size fix * rollback * nvm_xxxxx_erase * Updated location of eeconfig magic numbers so non-EEPROM nvm drivers can use them too. * Fixup build. * Fixup compilation error with encoders. * Build fixes. * Add `via_ci` keymap to onekey to exercise VIA bindings (and thus dynamic keymap et.al.), fixup compilation errors based on preprocessor+sizeof. * Build failure rectification. * Migrate remaining `split.soft_serial_pin` to `split.serial.pin` (#25046) * Migrate keyboards/bastardkb * Migrate keyboards/handwired * Migrate keyboards/helix * Fix duplicate serial key * Fix outdated GPIO control function usage (#25060) * [Modules] Provide access to current path in `rules.mk`. (#25061) * Update keymap for keycult 1800 (#25070) Update keymap Co-authored-by: yiancar * Add handwired/erikpeyronson/erkbd (#25030) Co-authored-by: Erik Peyronson Co-authored-by: jack Co-authored-by: Drashna Jaelre * Add support for Starry FRL (#24626) Co-authored-by: jack Co-authored-by: Drashna Jaelre Co-authored-by: Ryan * Add "Large Lad" keyboard (#24727) Co-authored-by: jack * Bump vite from 5.4.12 to 5.4.15 in /builddefs/docsgen (#25065) Bumps [vite](https://github.com/vitejs/vite/tree/HEAD/packages/vite) from 5.4.12 to 5.4.15. - [Release notes](https://github.com/vitejs/vite/releases) - [Changelog](https://github.com/vitejs/vite/blob/v5.4.15/packages/vite/CHANGELOG.md) - [Commits](https://github.com/vitejs/vite/commits/v5.4.15/packages/vite) --- updated-dependencies: - dependency-name: vite dependency-type: direct:development ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Allow AnnePro2 to reboot (#24886) Without this, the QK_REBOOT key did nothing. * Fix path typo related RP2040 (#25069) Fix path typo * Update onekey example for nucleo f446re (#25067) * use accessible pins for nucleo f446re onekey example * remove pin collision with matrix in keyboard.json * use accessible pins for LED * remove pin collision with matrix * Update readme.md to reflect pin changes * Module documentation typo correction (#25073) * Fix lockups on AVR with `qmk/hello_world` module (#25074) Fix lockups on AVR. * At101ish (#25072) * Dell AT101 replacement pcb support * Update keyboards/at101ish/readme.md Co-Authored-By: fauxpark * remove empty src clause in makefile * feature: Update at101ish to qmk v0.28 * feature: Add osdetecting keymap variant. * refactor: Move at101ish keyboard to handwired folder. * fix: Adjust at101ish readme- * fix: review changes. * chore: Remove unneeded feature. --------- Co-authored-by: fauxpark * Add "license" field to Community Module JSON schema. (#25085) Add "license" field to community module schema. * Add kt60HS-T v2 PCB (#25080) * Add kt60HS-Tv2 * Update keyboards/keyten/kt60hs_t/readme.md Co-authored-by: Sergey Vlasov * Update keyboards/keyten/kt60hs_t/v1/readme.md Co-authored-by: Sergey Vlasov * Update keyboards/keyten/kt60hs_t/v2/keyboard.json Co-authored-by: Sergey Vlasov * Update keyboards/keyten/kt60hs_t/v2/readme.md Co-authored-by: Sergey Vlasov * Update keyboards/keyten/kt60hs_t/info.json Co-authored-by: Sergey Vlasov * Change of structure * Moving the keyboard * Update data/mappings/keyboard_aliases.hjson Co-authored-by: Sergey Vlasov * Update keyboards/keyten/kt60hs_t/v1/keyboard.json Co-authored-by: Duncan Sutherland * Update keyboards/keyten/kt60hs_t/v2/keyboard.json Co-authored-by: Duncan Sutherland --------- Co-authored-by: Sergey Vlasov Co-authored-by: Duncan Sutherland * Make sure that unit tests run on all release versions * [ErgoDox EZ] Fix complication issues due to updates * [ErgoDox EZ] Fix compilication errors and warnings We want all green! * Fix 'qmk lint -kb' argument handling (#25093) * Refactor Deemen17 Works DE60 (#25088) * Add Coban Pad 12A (#25039) Co-authored-by: jack * [Keyboard] Add PHDesign PH60/Multi Keyboard PCB (#25086) * Add PH60/Multi Support * Add PCB PIcture for README * Remove MO(_FN2) * README Typo Fix * Layout and README Adjustment * Add README for PHDesign Main Folder * Keymap Improvement * Update README.md * [Keyboard] Add Ortho Slayer (#25099) * Add Ortho Slayer * Update keyboards/keyten/ortho_slayer/keymaps/default/keymap.c Co-authored-by: jack * Update keyboards/keyten/ortho_slayer/readme.md Co-authored-by: jack --------- Co-authored-by: jack * Fix coban pad9a wrong layout in keyboard.json (#25100) * Remove `CTPC`/`CONVERT_TO_PROTON_C` options (#25111) * Remove direct docs.qmk.fm links from docs (#25113) * Add warning when deprecated 'promicro_rp2040' is used (#25112) * Add Vida to QMK (#24225) Co-authored-by: jack Co-authored-by: Duncan Sutherland * More Windows->Unix style path fixes. (#25119) * Include `math.h` where necessary. (#25122) * Cater for use of `__errno_r()` in ChibiOS syscalls.c with newer picolibc revisions (#25121) * chore: Allow disabling underglow on Work Louder devices (#25123) (#25120) * Allow disabling Underglow on Work Louder devices Allows disabling Underglow on Work Louder devices by using `RGBLIGHT_ENABLE = no` on rules.mk * Update keyboards/work_louder/rgb_functions.c Suggested by @zvecr on review. Co-authored-by: Joel Challis --------- Co-authored-by: Joel Challis * Exclude external userspace from lint checking (#24680) * fix: Fix startup sound for Preonic (#25132) (#25133) Add `AUDIO_INIT_DELAY ` to config.h to resolve * New standard layout for Savage65 (65_ansi_blocker_tsangan_split_bs) (#24690) * Added a default firmware and layout for the WindStudio Wind X R1 keyboard. * Wind X R1: cleaned-up the folders to make clear that this firmware is for the release 1 of this keyboard. * Delete keyboards/windstudio/wind_x/R1 directory Removing the uppercase R1 folder * feat(cannonkeys/savage65): Added layout to keyboard.json - Added the layout LAYOUT_65_ansi_blocker_tsangan_split_bs to the community layouts. * kradoindustries_promenade: add LAYOUT_1x2u (#25090) * Update shuguet/shu89 (#24780) * Update keyboard.json Update mod keys location in RGB layout. * Update keyboard.json * Update keyboards/shuguet/shu89/keyboard.json Co-authored-by: Ryan --------- Co-authored-by: Ryan * [Keyboard] Add suika83opti (#24991) * [chore]: move and rename mouse/scroll min/max defines (#25141) * protocol: move {XY/HV}_REPORT_{MIN,MAX} into report.h ..to allow easier re-use in other code implementations. * protocol: rename {XY/HV}_REPORT_{MIN/MAX} to MOUSE_REPORT_{XY/HV}_{MIN/MAX} ..to avoid naming collisions. * [Core] Flow Tap tap-hold option to disable HRMs during fast typing (#25125) aka Global Quick Tap, Require Prior Idle * Add Link keyboard (#25058) Co-authored-by: jack Co-authored-by: Drashna Jaelre * Remove Sofle `rgb_default` keymap & tidy readme's (#25010) * Added Keyboard LumPy27 (#24967) Co-authored-by: jack Co-authored-by: Drashna Jaelre * [Keyboard] Kobold r1 (#25161) * Kobold r1 * Apply suggestions from code review Co-authored-by: jack * `board_init` => `early_hardware_init_post`. --------- Co-authored-by: jack * [Docs] Unify lighting step descriptions (#25167) unify lighting step descriptions and defaults across docs * [Keyboard] Add voidhhkb-hotswap (#25007) * Added files for voidhhkb-hotswap * Updated keyboard name to resolve build errors * Implement suggestions from PR. Use 60_hhkb community layout. * Update keyboards/void/voidhhkb_hotswap/readme.md Co-authored-by: Ryan * Apply suggestions from code review Co-authored-by: jack --------- Co-authored-by: Ryan Co-authored-by: jack * Remove duplication of RGB Matrix defaults (#25146) * Remove duplication of RGB Matrix defaults * Remove more duplication of defaults * fix * Fix missing and extra commas in JSON schema (#25057) * Remove duplication of RGBLight defaults (#25169) * Ignore the Layer Lock key in Repeat Key and Caps Word. (#25171) * Allow for disabling EEPROM subsystem entirely. (#25173) * [keyboard] ymdk/id75/rp2040 (#25157) Co-authored-by: tao heihei <> * Remove `bluefruit_le_read_battery_voltage` function (#25129) * Fix 'Would you like to clone the submodules?' prompt under msys (#24958) * Fixup eeconfig lighting reset. (#25166) * DOCS: `qmk-hid` missing in bootloaders list? (#25177) * Fix for `.clangd`. (#25180) * Update develop branch to Pico SDK 1.5.1 (#25178) * Add lint warning for empty url (#25182) * Implement connection keycode logic (#25176) * Add handwired/footy (#25151) Co-authored-by: jack * Decrease firmware size for `anavi/macropad8`. (#25185) Preparation for bootstrapper. * Align ChibiOS `USB_WAIT_FOR_ENUMERATION` implementation (#25184) * [Bug][Core] Fix for Flow Tap: fix handling of distinct taps and timer updates. (#25175) * Flow Tap bug fix. As reported by @amarz45 and @mwpardue, there is a bug where if two tap-hold keys are pressed in distinct taps back to back, then Flow Tap is not applied on the second tap-hold key, but it should be. In a related bug reported by @NikGovorov, if a tap-hold key is held followed by a tap of a tap-hold key, then Flow Tap updates its timer on the release of the held tap-hold key, but it should be ignored. The problem common to both these bugs is that I incorrectly assumed `tapping_key` is cleared to noevent once it is released, when actually `tapping_key` is still maintained for `TAPPING_TERM` ms after release (for Quick Tap). This commit fixes that. Thanks to @amarz45, @mwpardue, and @NikGovorov for reporting! Details: * Logic for converting the current tap-hold event to a tap is extracted to `flow_tap_key_if_within_term()`, which is now invoked also in the post-release "interfered with other tap key" case. This fixes the distinct taps bug. * The Flow Tap timer is now updated at the beginning of each call to `process_record()`, provided that there is no unsettled tap-hold key at that time and that the record is not for a mod or layer switch key. By moving this update logic to `process_record()`, it is conceptually simpler and more robust. * Unit tests extended to cover the reported scenarios. * Fix formatting. * Revision to fix @NikGovorov's scenario. The issue is that when another key is pressed while a layer-tap hasn't been settled yet, the `prev_keycode` remembers the keycode from before the layer switched. This can then enable Flow Tap for the following key when it shouldn't, or vice versa. Thanks to @NikGovorov for reporting! This commit revises Flow Tap in the following ways: * The previous key and timer are both updated from `process_record()`. This is slightly later in the sequence of processing than before, and by this point, a just-settled layer-tap should have taken effect so that the keycode from the correct layer is remembered. * The Flow Tap previous key and timer are updated now also on key release events, except for releases of modifiers and held layer switches. * The Flow Tap previous key and timer are now updated together, for simplicity. This makes the logic easier to think about. * A few additional unit tests, including @NikGovorov's scenario as "layer_tap_ignored_with_disabled_key_complex." * Remove empty `url` fields (#25181) * Prompt for converter when creating new keymap (#25116) * High resolution scrolling (without feature report parsing) (#24423) * hires scrolling without feature report parsing * fix valid range for exponent * fix incorrect minimum exponent value documentation * Avoid duplication in generated community modules `rules.mk` (#25135) * Bump rlespinasse/github-slug-action from 3 to 5 (#25021) * Remove `"console":false` from keyboards (#25190) * Update 'qmk generate-api' to only publish pure DD keymaps (#24782) * Remove more duplication of defaults (#25189) * Align `new-keyboard` template to current standards (#25191) * Bump vite from 5.4.15 to 5.4.18 in /builddefs/docsgen (#25192) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Fix `boardsource/beiwagon` RGB Matrix coordinates (#25018) * Remove `"command":false` from keyboards (#25193) * Extend lint checks to reject duplication of defaults (#25149) * modelh: add prerequisites for via support (#24932) * First TypeK support (#22876) * Add Lemokey X0 keyboard (#24994) * keyboards/annepro2/ld: Add per-variant linker scripts (#24999) C18 has an MCU with 16K SRAM, up from C15's 8K. Split the linker script into C15 and C18 variants to make use of the larger RAM capacity of C18. * Add new keyboard MirageiX (#25054) Co-authored-by: Drashna Jaelre Co-authored-by: jack <0x6a73@protonmail.com> * [Keymap] Sofle RGB - fixed stuck on numpad layer and layout comments (#24942) * Add handwired 4x14 LuMaWing keyboard (#24885) * Add jcpm2 (JC Pro Macro 2) (#24816) Co-authored-by: jack Co-authored-by: Drashna Jaelre Co-authored-by: Joel Challis * [Keyboard] Add splitkb.com's Halcyon Elora rev2 (#24790) Co-authored-by: Drashna Jaelre * [Keyboard] mzmkb/slimdash/rev1 (#24804) Co-authored-by: Drashna Jaelre Co-authored-by: jack Co-authored-by: Duncan Sutherland Co-authored-by: Ryan * Added new keyboard epssp75 (#24756) Co-authored-by: Drashna Jaelre * Addition of OK-1 (#24646) Co-authored-by: Joel Challis Co-authored-by: Drashna Jaelre * Add Umbra keyboard (#24569) Co-authored-by: Duncan Sutherland Co-authored-by: Ryan Co-authored-by: Drashna Jaelre * Amptrics 0420 keyboard addition (#24744) Co-authored-by: jack Co-authored-by: Drashna Jaelre Co-authored-by: Ryan * [Core] Enhance Flow Tap to work better for rolls over multiple tap-hold keys. (#25200) * Flow Tap revision for rolling press. * Remove debugging cruft. * Formatting fix. * amptrics/0422 - Prevent OOB in `update_leds_for_layer` (#25209) * [Keyboard] Add Gravity-45(#25206) * add gravity-45 * readme.md * fix readme * Update keyboards/green_keys/gravity_45/keyboard.json Co-authored-by: jack <0x6a73@protonmail.com> * run qmk format-json -i keyboards/green_keys/gravity_45/keyboard.json * add url * Update keyboards/green_keys/gravity_45/keyboard.json Co-authored-by: Duncan Sutherland * Update keyboard.json * Update keyboard.json * Update keyboards/green_keys/gravity_45/keyboard.json Co-authored-by: Drashna Jaelre --------- Co-authored-by: jack <0x6a73@protonmail.com> Co-authored-by: Duncan Sutherland Co-authored-by: Drashna Jaelre * Remove redundant keyboard headers (#25208) * Fix Spleeb compile when pointing device is enabled (#25016) * [Bug] Minimise force-included files (#25194) * Add additional hooks for Community modules (#25050) * Workaround for resolving keyboard alias for config file values (#25228) * Generate versions to keycode headers (#25219) * Resolve alias for `qmk new-keymap` keyboard prompts (#25210) * [Keyboard] Add Binepad KN01 (#25224) * Add Binepad NeoKnob KN01 * post @waffle87 recommendations * Add battery changed callbacks (#25207) * Ensure `qmk_userspace_paths` maintains detected order (#25204) * Bind Bluetooth driver to `host_driver_t` (#25199) * Deprecate `qmk generate-compilation-database`. (#25237) * Remove force disable of NKRO when Bluetooth enabled (#25201) * Keycult 60 (#25213) Co-authored-by: Duncan Sutherland Co-authored-by: jack * [Keyboard] Add Binepad KnobX1 (#25222) Co-authored-by: Drashna Jaelre * [Keyboard] Update Tractyl Manuform and add F405 (weact) variant (#24764) * Layout corrections: Zed60 (#25003) * Fixed print statement after enabling 32-bit layers (#25027) * Fix Aurora sweep default keymap configuration (#25148) * Docs update for installing qmk with uv (#24995) * CXT Studio 12E3: Fix encoder resolutions not applying (#25242) * add resolution to encoders so they apply * Tweak default keymap * replace KC_UNDO with C(KC_Z) as well * Add debounce to duplicated defaults check (#25246) * [Docs] Fix typos introduced by PR #25050 (#25250) It isn't a drashna PR if there aren't some typos in it somewhere. * Allow LVGL onekey keymap to be able compile for other board (#25005) * [Keyboard] Add Jason Hazel’s Bad Wings v2 (#25252) Co-authored-by: Florent Allard * Add raw_hid support to host driver (#25255) * Fix Wear Leveling compilation (#25254) * [New Feature/Core] New RGB Matrix Animation "Starlight Smooth" (#25203) * Enable community modules to define LED matrix and RGB matrix effects. (#25187) Co-authored-by: Joel Challis * Fix OS_DETECTION_KEYBOARD_RESET (#25015) Co-authored-by: Nick Brassel * Fixes the numlock indicator for Magic Force MF17 numpad (#25260) * Add Harite v2 keyboard (#24975) * dlip/haritev2 - Post merge fixes (#25264) * Remove more USB only branches from NKRO handling (#25263) * Deprecate `usb.force_nkro`/`FORCE_NKRO` (#25262) * Add BDN9 Rev. 3 (#25261) * Remove duplicate of SPI default config from keyboards (#25266) * Resolve miscellaneous keyboard lint warnings (#25268) * Add Zeropad (#24737) Co-authored-by: Drashna Jaelre Co-authored-by: Joel Challis * Add Waveshare RP2040-Keyboard-3 support (#25269) * Update PR checklist notes on custom matrix (#25240) * Chew folders (#24785) * gcc15 AVR compilation fixes (#25238) * [Core] STM32G0x1 support (#24301) * Use relative paths for schemas, instead of $id. Enables VScode validation. (#25251) * add doio/kb03 (#24815) Co-authored-by: Drashna Jaelre Co-authored-by: Joel Challis * Move rookiebwoy to ivndbt (#25142) * [Chore] use {rgblight,rgb_matrix}_hsv_to_rgb overrides (#25271) * Remove outdated `nix` support due to bit-rot. (#25280) * Add `compiler_support.h` (#25274) * Configure boards to use development_board - 0-9 (#25287) * [Fix] lib8tion: enable fixed scale8 and blend functions (#25272) lib8tion: enable fixed scale8 and blend functions These FastLED derived lib8tion functions have been fixed and enabled by default in FastLED. QMK just never set these defines, there is no reason to keep the buggy implementation. It is assumed that nobody relied on the buggy behavior. * Configure boards to use development_board - UVWXYZ (#25288) * [Docs] Fix tap_hold code blocks (#25298) * salicylic_acid3/getta25 - Fix oled keymap (#25295) * Configure boards to use development_board - S (#25293) * Configure boards to use development_board - T (#25294) * 2025 Q2 changelog (#25297) Co-authored-by: Drashna Jaelre Co-authored-by: Nick Brassel * Update Oryx module for newer code * Soft reset matrix * Use improved i2c reset for voyager and moonlander matrix * Fix formatting * Remove labeler action (unneeded) * Fix module API version for Oryx module * Use i2cStop instead of trying to work around --------- Signed-off-by: Stefan Kerkmann Signed-off-by: dependabot[bot] Co-authored-by: Duncan Sutherland Co-authored-by: QMK Bot Co-authored-by: Pascal Getreuer <50221757+getreuer@users.noreply.github.com> Co-authored-by: Ryan Co-authored-by: Joel Challis Co-authored-by: Ramon Imbao Co-authored-by: Stefan Kerkmann Co-authored-by: Nick Brassel Co-authored-by: jack Co-authored-by: yiancar Co-authored-by: yiancar Co-authored-by: Erik Peyronson Co-authored-by: Erik Peyronson Co-authored-by: Sắn <59417802+MaiTheSan@users.noreply.github.com> Co-authored-by: Hyphen-ated Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Geoffrey Frogeye Co-authored-by: lsh4711 <120231876+lsh4711@users.noreply.github.com> Co-authored-by: Ben Green Co-authored-by: フィルターペーパー <76888457+filterpaper@users.noreply.github.com> Co-authored-by: henrikosorensen Co-authored-by: Ivan Gromov <38141348+key10iq@users.noreply.github.com> Co-authored-by: Sergey Vlasov Co-authored-by: Pham Duc Minh <95753855+Deemen17@users.noreply.github.com> Co-authored-by: Dam Vu Duy Co-authored-by: nonameCCC <79012391+nonameCCC@users.noreply.github.com> Co-authored-by: sudo pacman -Syu Co-authored-by: Andrew Kannan Co-authored-by: Luis Garcia Co-authored-by: Christian C. Berclaz Co-authored-by: Olivier Mehani Co-authored-by: Sylvain Huguet Co-authored-by: suikagiken <115451678+suikagiken@users.noreply.github.com> Co-authored-by: Daniel Reisch Co-authored-by: ClownFish <177758267+clownfish-og@users.noreply.github.com> Co-authored-by: JamesWilson1996 <47866504+JamesWilson1996@users.noreply.github.com> Co-authored-by: Less/Rikki <86894501+lesshonor@users.noreply.github.com> Co-authored-by: Jan Bláha Co-authored-by: Eric Molitor <534583+emolitor@users.noreply.github.com> Co-authored-by: CJ Pais Co-authored-by: eynsai <47629346+eynsai@users.noreply.github.com> Co-authored-by: Joel Beckmeyer Co-authored-by: Álvaro A. Volpato Co-authored-by: Aidan Gauland Co-authored-by: Michał Kopeć Co-authored-by: takashicompany Co-authored-by: jack <0x6a73@protonmail.com> Co-authored-by: Matheus Marques Co-authored-by: LucasMateijsen Co-authored-by: Jeremy Cook Co-authored-by: VeyPatch <126267034+VeyPatch@users.noreply.github.com> Co-authored-by: mizma Co-authored-by: hen-des <141591967+hen-des@users.noreply.github.com> Co-authored-by: Cipulot <40441626+Cipulot@users.noreply.github.com> Co-authored-by: josephawilliamsiv <31166673+josephawilliamsiv@users.noreply.github.com> Co-authored-by: vchowl Co-authored-by: Christopher Hoage Co-authored-by: Silvino R. <366673+silvinor@users.noreply.github.com> Co-authored-by: dabstractor Co-authored-by: Nathan Cain <13713501+nathanscain@users.noreply.github.com> Co-authored-by: muge <221161+muge@users.noreply.github.com> Co-authored-by: HorrorTroll Co-authored-by: cyxae Co-authored-by: Florent Allard Co-authored-by: art-was-here Co-authored-by: Matti Hiljanen <170205+qvr@users.noreply.github.com> Co-authored-by: Wasteland Fluttershy Co-authored-by: Dane Lipscombe Co-authored-by: Danny Co-authored-by: Infos <136488157+diffrentGuesser@users.noreply.github.com> Co-authored-by: Florent Linguenheld Co-authored-by: ivan <81021475+ivndbt@users.noreply.github.com> Co-authored-by: Pablo Martínez <58857054+elpekenin@users.noreply.github.com> --- .clangd | 2 +- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- .github/workflows/labeler.yml | 13 - Makefile | 1 + builddefs/build_full_test.mk | 2 - builddefs/build_keyboard.mk | 58 +- builddefs/build_test.mk | 1 + builddefs/common_features.mk | 188 ++-- builddefs/common_rules.mk | 10 +- builddefs/converters.mk | 7 - builddefs/docsgen/package.json | 2 +- builddefs/docsgen/yarn.lock | 8 +- builddefs/generic_features.mk | 3 + builddefs/support.mk | 11 + .../extras/keycodes_belgian_0.0.1.hjson | 2 +- .../keycodes/extras/keycodes_bepo_0.0.1.hjson | 2 +- .../keycodes_brazilian_abnt2_0.0.1.hjson | 2 +- ...keycodes_canadian_multilingual_0.0.1.hjson | 2 +- .../extras/keycodes_colemak_0.0.1.hjson | 2 +- .../extras/keycodes_croatian_0.0.1.hjson | 2 +- .../extras/keycodes_czech_0.0.1.hjson | 2 +- .../extras/keycodes_danish_0.0.1.hjson | 2 +- .../extras/keycodes_dvorak_0.0.1.hjson | 2 +- .../extras/keycodes_dvorak_fr_0.0.1.hjson | 2 +- .../keycodes_dvorak_programmer_0.0.1.hjson | 2 +- .../extras/keycodes_estonian_0.0.1.hjson | 2 +- .../extras/keycodes_eurkey_0.0.1.hjson | 2 +- .../extras/keycodes_finnish_0.0.1.hjson | 2 +- .../extras/keycodes_french_0.0.1.hjson | 2 +- .../extras/keycodes_french_afnor_0.0.1.hjson | 2 +- .../keycodes_french_mac_iso_0.0.1.hjson | 2 +- .../extras/keycodes_german_0.0.1.hjson | 2 +- .../keycodes_german_mac_iso_0.0.1.hjson | 2 +- .../extras/keycodes_greek_0.0.1.hjson | 2 +- .../extras/keycodes_hebrew_0.0.1.hjson | 2 +- .../extras/keycodes_hungarian_0.0.1.hjson | 2 +- .../extras/keycodes_icelandic_0.0.1.hjson | 2 +- .../extras/keycodes_irish_0.0.1.hjson | 2 +- .../extras/keycodes_italian_0.0.1.hjson | 2 +- .../keycodes_italian_mac_ansi_0.0.1.hjson | 2 +- .../keycodes_italian_mac_iso_0.0.1.hjson | 2 +- .../extras/keycodes_japanese_0.0.1.hjson | 2 +- .../extras/keycodes_korean_0.0.1.hjson | 2 +- .../extras/keycodes_latvian_0.0.1.hjson | 2 +- .../keycodes_lithuanian_azerty_0.0.1.hjson | 2 +- .../keycodes_lithuanian_qwerty_0.0.1.hjson | 2 +- .../keycodes/extras/keycodes_neo2_0.0.1.hjson | 2 +- .../extras/keycodes_nordic_0.0.1.hjson | 2 +- .../extras/keycodes_norman_0.0.1.hjson | 2 +- .../extras/keycodes_norwegian_0.0.1.hjson | 2 +- .../extras/keycodes_plover_0.0.1.hjson | 2 +- .../extras/keycodes_plover_dvorak_0.0.1.hjson | 2 +- .../extras/keycodes_polish_0.0.1.hjson | 2 +- .../extras/keycodes_portuguese_0.0.1.hjson | 2 +- .../keycodes_portuguese_mac_iso_0.0.1.hjson | 2 +- .../extras/keycodes_romanian_0.0.1.hjson | 2 +- .../extras/keycodes_russian_0.0.1.hjson | 2 +- .../extras/keycodes_serbian_0.0.1.hjson | 2 +- .../extras/keycodes_serbian_latin_0.0.1.hjson | 2 +- .../extras/keycodes_slovak_0.0.1.hjson | 2 +- .../extras/keycodes_slovenian_0.0.1.hjson | 2 +- .../extras/keycodes_spanish_0.0.1.hjson | 2 +- .../keycodes_spanish_dvorak_0.0.1.hjson | 2 +- ...keycodes_spanish_latin_america_0.0.1.hjson | 2 +- .../extras/keycodes_swedish_0.0.1.hjson | 2 +- .../keycodes_swedish_mac_ansi_0.0.1.hjson | 2 +- .../keycodes_swedish_mac_iso_0.0.1.hjson | 2 +- .../keycodes_swedish_pro_mac_ansi_0.0.1.hjson | 2 +- .../keycodes_swedish_pro_mac_iso_0.0.1.hjson | 2 +- .../extras/keycodes_swiss_de_0.0.1.hjson | 2 +- .../extras/keycodes_swiss_fr_0.0.1.hjson | 2 +- .../extras/keycodes_turkish_f_0.0.1.hjson | 2 +- .../extras/keycodes_turkish_q_0.0.1.hjson | 2 +- .../keycodes/extras/keycodes_uk_0.0.1.hjson | 2 +- .../extras/keycodes_ukrainian_0.0.1.hjson | 2 +- .../extras/keycodes_us_extended_0.0.1.hjson | 2 +- .../keycodes_us_international_0.0.1.hjson | 2 +- ...eycodes_us_international_linux_0.0.1.hjson | 2 +- .../extras/keycodes_workman_0.0.1.hjson | 2 +- .../extras/keycodes_workman_zxcvm_0.0.1.hjson | 2 +- data/constants/keycodes/keycodes_0.0.1.hjson | 2 +- .../keycodes/keycodes_0.0.1_joystick.hjson | 2 +- .../keycodes/keycodes_0.0.1_magic.hjson | 2 +- .../keycodes_0.0.1_programmable_button.hjson | 2 +- .../keycodes/keycodes_0.0.1_sequencer.hjson | 2 +- .../keycodes/keycodes_0.0.2_basic.hjson | 2 +- .../keycodes/keycodes_0.0.2_magic.hjson | 2 +- .../keycodes/keycodes_0.0.2_sequencer.hjson | 2 +- data/constants/module_hooks/1.1.1.hjson | 3 + data/mappings/info_config.hjson | 6 +- data/mappings/info_defaults.hjson | 74 ++ data/mappings/info_rules.hjson | 4 +- data/schemas/api_keyboard.jsonschema | 6 +- data/schemas/community_module.jsonschema | 11 +- data/schemas/keyboard.jsonschema | 321 +++--- data/schemas/keycodes.jsonschema | 4 +- data/schemas/keymap.jsonschema | 16 +- data/schemas/user_repo_v0.jsonschema | 4 +- data/schemas/user_repo_v1.jsonschema | 6 +- data/schemas/user_repo_v1_1.jsonschema | 8 +- data/templates/keyboard/keyboard.json | 2 - drivers/battery/battery.c | 41 + drivers/battery/battery.h | 46 + drivers/battery/battery_adc.c | 55 ++ drivers/battery/battery_driver.h | 29 + drivers/bluetooth/bluefruit_le.cpp | 21 - drivers/bluetooth/bluefruit_le.h | 4 - drivers/bluetooth/bluetooth.c | 72 +- drivers/bluetooth/bluetooth.h | 39 + drivers/bluetooth/bluetooth_drivers.c | 71 ++ drivers/bluetooth/outputselect.c | 70 -- drivers/bluetooth/outputselect.h | 24 +- drivers/eeprom/eeprom_transient.h | 2 +- drivers/lcd/st7565.c | 3 +- drivers/oled/oled_driver.c | 4 +- drivers/painter/gc9xxx/qp_gc9a01_opcodes.h | 2 +- drivers/painter/ili9xxx/qp_ili9486.c | 16 +- drivers/painter/ld7032/qp_ld7032.h | 2 +- drivers/painter/ld7032/qp_ld7032_opcodes.h | 2 +- drivers/sensors/azoteq_iqs5xx.h | 7 +- drivers/sensors/pimoroni_trackball.c | 12 +- drivers/sensors/pmw33xx_common.h | 5 +- drivers/usbpd.h | 2 +- .../wear_leveling/wear_leveling_flash_spi.c | 1 + keyboards/zsa/moonlander/matrix.c | 34 +- keyboards/zsa/voyager/matrix.c | 36 +- lib/fnv/qmk_fnv_type_validation.c | 9 +- lib/pico-sdk | 2 +- lib/python/qmk/build_targets.py | 24 +- lib/python/qmk/cli/__init__.py | 3 +- lib/python/qmk/cli/doctor/check.py | 26 +- lib/python/qmk/cli/generate/api.py | 5 + .../qmk/cli/generate/community_modules.py | 146 ++- .../qmk/cli/generate/compilation_database.py | 174 +--- lib/python/qmk/cli/generate/keycodes.py | 16 + lib/python/qmk/cli/generate/keycodes_tests.py | 39 - .../qmk/cli/generate/make_dependencies.py | 4 +- lib/python/qmk/cli/generate/rules_mk.py | 34 +- lib/python/qmk/cli/lint.py | 48 +- lib/python/qmk/cli/new/keymap.py | 60 +- lib/python/qmk/commands.py | 3 +- lib/python/qmk/compilation_database.py | 137 +++ lib/python/qmk/constants.py | 3 +- lib/python/qmk/decorators.py | 7 +- lib/python/qmk/info.py | 16 +- lib/python/qmk/json_encoders.py | 8 +- lib/python/qmk/json_schema.py | 5 + lib/python/qmk/keycodes.py | 1 + lib/python/qmk/keymap.py | 11 +- lib/python/qmk/userspace.py | 11 +- .../led_matrix_module.inc | 58 ++ .../flow_led_matrix_effect/qmk_module.json | 8 + .../flow_rgb_matrix_effect/qmk_module.json | 8 + .../rgb_matrix_module.inc | 64 ++ modules/qmk/hello_world/hello_world.c | 2 +- modules/qmk/hello_world/qmk_module.json | 1 + modules/qmk/super_alt_tab/qmk_module.json | 1 + modules/zsa/oryx/introspection.h | 6 + modules/zsa/oryx/oryx.c | 113 +-- modules/zsa/oryx/oryx.h | 2 +- modules/zsa/oryx/post_config.h | 2 + modules/zsa/oryx/qmk_module.json | 2 +- ...gb_matrix_kb.inc => rgb_matrix_module.inc} | 0 modules/zsa/oryx/rules.mk | 1 - platforms/atomic_util.h | 12 +- platforms/avr/drivers/i2c_master.c | 2 +- platforms/avr/drivers/i2c_slave.h | 4 +- platforms/avr/gpio.h | 6 +- platforms/avr/platform.mk | 13 +- .../chibios/boards/BONSAI_C4/configs/board.h | 2 +- .../chibios/boards/BONSAI_C4/configs/config.h | 2 +- .../boards/BONSAI_C4/configs/halconf.h | 2 +- .../GENERIC_STM32_F405XG/board/board.mk | 2 +- .../GENERIC_STM32_F407XE/board/board.mk | 2 +- .../GENERIC_STM32_F407XE/configs/board.h | 2 +- .../GENERIC_STM32_G0B1XB/board/board.mk | 12 + .../boards/GENERIC_STM32_G0B1XB/board/extra.c | 68 ++ .../GENERIC_STM32_G0B1XB/configs/config.h | 7 + .../GENERIC_STM32_G0B1XB/configs/mcuconf.h | 310 ++++++ .../GENERIC_STM32_G474XE/configs/config.h | 2 +- .../GENERIC_WB32_F3G71XX/configs/chconf.h | 2 +- .../GENERIC_WB32_FQ95XX/configs/chconf.h | 2 +- .../SIPEED_LONGAN_NANO/configs/chconf.h | 2 +- .../chibios/boards/common/ld/STM32G0B1xB.ld | 85 ++ platforms/chibios/bootloaders/stm32duino.c | 2 +- platforms/chibios/bootloaders/uf2boot.c | 2 + platforms/chibios/chibios_config.h | 4 +- .../promicro_to_bonsai_c4/_pin_defs.h | 2 +- .../promicro_to_bonsai_c4/post_converter.mk | 2 +- .../pre_converter.mk | 6 + platforms/chibios/drivers/analog.c | 23 +- platforms/chibios/drivers/i2c_master.c | 2 +- platforms/chibios/drivers/usbpd_stm32g4.c | 2 +- .../drivers/wear_leveling/wear_leveling_efl.c | 1 + .../wear_leveling/wear_leveling_legacy.c | 1 + .../wear_leveling_rp2040_flash.c | 7 +- platforms/chibios/errno.h | 13 + platforms/chibios/mcu_selection.mk | 35 + platforms/chibios/platform.c | 2 +- platforms/chibios/vendors/RP/RP2040.mk | 2 +- platforms/eeprom.h | 1 + platforms/test/platform.c | 2 +- quantum/action.c | 20 + quantum/action.h | 6 + quantum/action_tapping.c | 212 +++- quantum/action_tapping.h | 60 ++ quantum/action_util.c | 11 +- quantum/audio/audio.c | 12 +- quantum/audio/audio.h | 6 +- quantum/backlight/backlight.c | 31 +- quantum/backlight/backlight.h | 12 +- quantum/bits.h | 2 +- quantum/command.c | 8 +- quantum/compiler_support.h | 15 + quantum/connection/connection.c | 141 +++ quantum/connection/connection.h | 112 +++ quantum/dynamic_keymap.c | 205 +--- quantum/dynamic_keymap.h | 9 +- quantum/eeconfig.c | 462 ++++----- quantum/eeconfig.h | 162 ++-- quantum/haptic.c | 26 +- quantum/haptic.h | 6 +- quantum/keyboard.c | 23 +- quantum/keycode_config.h | 8 +- quantum/keycode_string.c | 564 +++++++++++ quantum/keycode_string.h | 134 +++ quantum/keycodes.h | 6 + quantum/keymap_extras/keymap_belgian.h | 6 + quantum/keymap_extras/keymap_bepo.h | 6 + .../keymap_extras/keymap_brazilian_abnt2.h | 6 + .../keymap_extras/keymap_canadian_french.h | 6 + .../keymap_canadian_multilingual.h | 6 + quantum/keymap_extras/keymap_colemak.h | 6 + quantum/keymap_extras/keymap_croatian.h | 6 + quantum/keymap_extras/keymap_czech.h | 6 + quantum/keymap_extras/keymap_czech_mac_ansi.h | 6 + quantum/keymap_extras/keymap_czech_mac_iso.h | 6 + quantum/keymap_extras/keymap_danish.h | 6 + quantum/keymap_extras/keymap_dvorak.h | 6 + quantum/keymap_extras/keymap_dvorak_fr.h | 6 + .../keymap_extras/keymap_dvorak_programmer.h | 6 + quantum/keymap_extras/keymap_estonian.h | 6 + quantum/keymap_extras/keymap_eurkey.h | 6 + quantum/keymap_extras/keymap_farsi.h | 6 + quantum/keymap_extras/keymap_finnish.h | 6 + quantum/keymap_extras/keymap_french.h | 6 + quantum/keymap_extras/keymap_french_afnor.h | 6 + quantum/keymap_extras/keymap_french_mac_iso.h | 6 + quantum/keymap_extras/keymap_german.h | 6 + quantum/keymap_extras/keymap_german_mac_iso.h | 6 + quantum/keymap_extras/keymap_greek.h | 6 + quantum/keymap_extras/keymap_hebrew.h | 6 + quantum/keymap_extras/keymap_hungarian.h | 6 + quantum/keymap_extras/keymap_icelandic.h | 6 + quantum/keymap_extras/keymap_irish.h | 6 + quantum/keymap_extras/keymap_italian.h | 6 + .../keymap_extras/keymap_italian_mac_ansi.h | 6 + .../keymap_extras/keymap_italian_mac_iso.h | 6 + quantum/keymap_extras/keymap_japanese.h | 6 + quantum/keymap_extras/keymap_korean.h | 6 + quantum/keymap_extras/keymap_latvian.h | 6 + .../keymap_extras/keymap_lithuanian_azerty.h | 6 + .../keymap_extras/keymap_lithuanian_qwerty.h | 6 + quantum/keymap_extras/keymap_neo2.h | 6 + quantum/keymap_extras/keymap_nordic.h | 6 + quantum/keymap_extras/keymap_norman.h | 6 + quantum/keymap_extras/keymap_norwegian.h | 6 + quantum/keymap_extras/keymap_plover.h | 6 + quantum/keymap_extras/keymap_plover_dvorak.h | 6 + quantum/keymap_extras/keymap_polish.h | 6 + quantum/keymap_extras/keymap_portuguese.h | 6 + .../keymap_extras/keymap_portuguese_mac_iso.h | 6 + quantum/keymap_extras/keymap_romanian.h | 6 + quantum/keymap_extras/keymap_russian.h | 6 + .../keymap_extras/keymap_russian_typewriter.h | 6 + quantum/keymap_extras/keymap_serbian.h | 6 + quantum/keymap_extras/keymap_serbian_latin.h | 6 + quantum/keymap_extras/keymap_slovak.h | 6 + quantum/keymap_extras/keymap_slovenian.h | 6 + quantum/keymap_extras/keymap_spanish.h | 6 + quantum/keymap_extras/keymap_spanish_dvorak.h | 6 + .../keymap_spanish_latin_america.h | 6 + quantum/keymap_extras/keymap_swedish.h | 6 + .../keymap_extras/keymap_swedish_mac_ansi.h | 6 + .../keymap_extras/keymap_swedish_mac_iso.h | 6 + .../keymap_swedish_pro_mac_ansi.h | 6 + .../keymap_swedish_pro_mac_iso.h | 6 + quantum/keymap_extras/keymap_swiss_de.h | 6 + quantum/keymap_extras/keymap_swiss_fr.h | 6 + quantum/keymap_extras/keymap_turkish_f.h | 6 + quantum/keymap_extras/keymap_turkish_q.h | 6 + quantum/keymap_extras/keymap_uk.h | 6 + quantum/keymap_extras/keymap_ukrainian.h | 6 + quantum/keymap_extras/keymap_us.h | 6 + quantum/keymap_extras/keymap_us_extended.h | 6 + .../keymap_extras/keymap_us_international.h | 6 + .../keymap_us_international_linux.h | 6 + quantum/keymap_extras/keymap_workman.h | 6 + quantum/keymap_extras/keymap_workman_zxcvm.h | 6 + quantum/keymap_introspection.c | 13 +- quantum/led_matrix/led_matrix.c | 27 +- quantum/led_matrix/led_matrix.h | 8 +- quantum/led_matrix/led_matrix_types.h | 6 +- quantum/logging/debug.h | 2 +- quantum/nvm/eeprom/nvm_dynamic_keymap.c | 194 ++++ quantum/nvm/eeprom/nvm_eeconfig.c | 305 ++++++ .../nvm/eeprom/nvm_eeprom_eeconfig_internal.h | 63 ++ quantum/nvm/eeprom/nvm_eeprom_via_internal.h | 22 + quantum/nvm/eeprom/nvm_via.c | 77 ++ quantum/nvm/nvm_dynamic_keymap.h | 27 + quantum/nvm/nvm_eeconfig.h | 111 +++ quantum/nvm/nvm_via.h | 17 + quantum/nvm/readme.md | 30 + quantum/nvm/rules.mk | 31 + quantum/os_detection.c | 26 +- quantum/os_detection.h | 3 + quantum/painter/qff.h | 9 +- quantum/painter/qgf.h | 17 +- quantum/painter/qp_draw_core.c | 3 +- quantum/painter/qp_internal.c | 4 +- quantum/painter/qp_internal_formats.h | 3 +- quantum/pointing_device/pointing_device.c | 37 +- quantum/pointing_device/pointing_device.h | 14 +- quantum/process_keycode/process_autocorrect.c | 6 +- quantum/process_keycode/process_caps_word.c | 7 +- quantum/process_keycode/process_clicky.c | 6 +- quantum/process_keycode/process_connection.c | 26 +- quantum/process_keycode/process_leader.c | 6 +- quantum/process_keycode/process_magic.c | 4 +- quantum/process_keycode/process_repeat_key.c | 5 +- quantum/process_keycode/process_steno.c | 7 +- quantum/quantum.c | 4 +- quantum/quantum.h | 1 + quantum/raw_hid.c | 15 + .../rgb_matrix/animations/pixel_flow_anim.h | 4 +- .../animations/rgb_matrix_effects.inc | 3 +- .../animations/starlight_smooth_anim.h | 26 + quantum/rgb_matrix/rgb_matrix.c | 17 +- quantum/rgb_matrix/rgb_matrix.h | 10 +- quantum/rgb_matrix/rgb_matrix_types.h | 6 +- quantum/rgblight/rgblight.c | 53 +- quantum/rgblight/rgblight.h | 9 +- quantum/split_common/split_util.c | 8 +- quantum/split_common/split_util.h | 2 +- quantum/split_common/transaction_id_define.h | 4 +- quantum/split_common/transport.c | 3 +- quantum/unicode/unicode.c | 5 +- quantum/unicode/unicode.h | 6 +- quantum/via.c | 61 +- quantum/via.h | 27 +- quantum/wear_leveling/tests/rules.mk | 2 +- quantum/wear_leveling/wear_leveling.c | 1 + quantum/wear_leveling/wear_leveling_drivers.h | 13 + .../wear_leveling/wear_leveling_internal.h | 14 +- requirements.txt | 2 +- shell.nix | 72 -- tests/basic/test_keycode_util.cpp | 52 - tests/basic/test_one_shot_keys.cpp | 2 +- tests/caps_word/test.mk | 2 + tests/caps_word/test_caps_word.cpp | 52 +- tests/combo/combo_repress/test_combo.cpp | 2 +- tests/combo/test_combo.cpp | 1 - tests/keycode_string/config.h | 19 + tests/keycode_string/test.mk | 22 + tests/keycode_string/test_keycode_string.cpp | 153 +++ tests/no_tapping/no_action_tapping/test.mk | 2 +- tests/no_tapping/no_mod_tap_mods/test.mk | 2 +- .../alt_repeat_key/test_alt_repeat_key.cpp | 2 +- tests/repeat_key/test.mk | 1 + tests/repeat_key/test_repeat_key.cpp | 33 + .../permissive_hold_flow_tap/config.h | 23 + .../permissive_hold_flow_tap/test.mk | 17 + .../permissive_hold_flow_tap/test_keymap.c | 22 + .../test_one_shot_keys.cpp | 174 ++++ .../test_tap_hold.cpp | 911 ++++++++++++++++++ .../tap_hold_configurations/flow_tap/config.h | 23 + .../tap_hold_configurations/flow_tap/test.mk | 18 + .../flow_tap/test_keymap.c | 23 + .../flow_tap/test_tap_hold.cpp | 844 ++++++++++++++++ tests/test_common/build.mk | 1 + tests/test_common/keyboard_report_util.cpp | 8 +- tests/test_common/keycode_table.cpp | 767 --------------- tests/test_common/keycode_util.cpp | 130 --- tests/test_common/keycode_util.hpp | 6 - tests/test_common/test_driver.hpp | 8 +- tests/test_common/test_fixture.cpp | 2 +- tests/test_common/test_keymap_key.hpp | 6 +- tmk_core/protocol.mk | 12 +- tmk_core/protocol/chibios/chibios.c | 29 +- tmk_core/protocol/chibios/usb_main.c | 12 +- tmk_core/protocol/host.c | 110 ++- tmk_core/protocol/host.h | 2 + tmk_core/protocol/host_driver.h | 3 + tmk_core/protocol/lufa/lufa.c | 35 +- tmk_core/protocol/report.c | 12 +- tmk_core/protocol/report.h | 8 + tmk_core/protocol/usb_descriptor.c | 24 + tmk_core/protocol/usb_descriptor_common.h | 20 + tmk_core/protocol/vusb/vusb.c | 53 +- util/nix/poetry.lock | 671 ------------- util/nix/pyproject.toml | 39 - util/nix/sources.json | 38 - util/nix/sources.nix | 198 ---- util/regen.sh | 1 - util/usb_detach/usb_detach.c | 2 +- 405 files changed, 8093 insertions(+), 3902 deletions(-) delete mode 100644 .github/workflows/labeler.yml create mode 100644 builddefs/support.mk create mode 100644 data/constants/module_hooks/1.1.1.hjson create mode 100644 data/mappings/info_defaults.hjson create mode 100644 drivers/battery/battery.c create mode 100644 drivers/battery/battery.h create mode 100644 drivers/battery/battery_adc.c create mode 100644 drivers/battery/battery_driver.h create mode 100644 drivers/bluetooth/bluetooth_drivers.c delete mode 100644 drivers/bluetooth/outputselect.c mode change 100755 => 100644 lib/python/qmk/cli/generate/compilation_database.py delete mode 100644 lib/python/qmk/cli/generate/keycodes_tests.py create mode 100755 lib/python/qmk/compilation_database.py create mode 100644 modules/qmk/flow_led_matrix_effect/led_matrix_module.inc create mode 100644 modules/qmk/flow_led_matrix_effect/qmk_module.json create mode 100644 modules/qmk/flow_rgb_matrix_effect/qmk_module.json create mode 100644 modules/qmk/flow_rgb_matrix_effect/rgb_matrix_module.inc create mode 100644 modules/zsa/oryx/introspection.h rename modules/zsa/oryx/{rgb_matrix_kb.inc => rgb_matrix_module.inc} (100%) create mode 100644 platforms/chibios/boards/GENERIC_STM32_G0B1XB/board/board.mk create mode 100644 platforms/chibios/boards/GENERIC_STM32_G0B1XB/board/extra.c create mode 100644 platforms/chibios/boards/GENERIC_STM32_G0B1XB/configs/config.h create mode 100644 platforms/chibios/boards/GENERIC_STM32_G0B1XB/configs/mcuconf.h create mode 100644 platforms/chibios/boards/common/ld/STM32G0B1xB.ld create mode 100644 platforms/chibios/errno.h create mode 100644 quantum/compiler_support.h create mode 100644 quantum/connection/connection.c create mode 100644 quantum/connection/connection.h create mode 100644 quantum/keycode_string.c create mode 100644 quantum/keycode_string.h create mode 100644 quantum/nvm/eeprom/nvm_dynamic_keymap.c create mode 100644 quantum/nvm/eeprom/nvm_eeconfig.c create mode 100644 quantum/nvm/eeprom/nvm_eeprom_eeconfig_internal.h create mode 100644 quantum/nvm/eeprom/nvm_eeprom_via_internal.h create mode 100644 quantum/nvm/eeprom/nvm_via.c create mode 100644 quantum/nvm/nvm_dynamic_keymap.h create mode 100644 quantum/nvm/nvm_eeconfig.h create mode 100644 quantum/nvm/nvm_via.h create mode 100644 quantum/nvm/readme.md create mode 100644 quantum/nvm/rules.mk create mode 100644 quantum/raw_hid.c create mode 100644 quantum/rgb_matrix/animations/starlight_smooth_anim.h create mode 100644 quantum/wear_leveling/wear_leveling_drivers.h delete mode 100644 shell.nix delete mode 100644 tests/basic/test_keycode_util.cpp create mode 100644 tests/keycode_string/config.h create mode 100644 tests/keycode_string/test.mk create mode 100644 tests/keycode_string/test_keycode_string.cpp create mode 100644 tests/tap_hold_configurations/chordal_hold/permissive_hold_flow_tap/config.h create mode 100644 tests/tap_hold_configurations/chordal_hold/permissive_hold_flow_tap/test.mk create mode 100644 tests/tap_hold_configurations/chordal_hold/permissive_hold_flow_tap/test_keymap.c create mode 100644 tests/tap_hold_configurations/chordal_hold/permissive_hold_flow_tap/test_one_shot_keys.cpp create mode 100644 tests/tap_hold_configurations/chordal_hold/permissive_hold_flow_tap/test_tap_hold.cpp create mode 100644 tests/tap_hold_configurations/flow_tap/config.h create mode 100644 tests/tap_hold_configurations/flow_tap/test.mk create mode 100644 tests/tap_hold_configurations/flow_tap/test_keymap.c create mode 100644 tests/tap_hold_configurations/flow_tap/test_tap_hold.cpp delete mode 100644 tests/test_common/keycode_table.cpp delete mode 100644 tests/test_common/keycode_util.cpp delete mode 100644 tests/test_common/keycode_util.hpp delete mode 100644 util/nix/poetry.lock delete mode 100644 util/nix/pyproject.toml delete mode 100644 util/nix/sources.json delete mode 100644 util/nix/sources.nix diff --git a/.clangd b/.clangd index 6133ae7229..63dadd7e7c 100644 --- a/.clangd +++ b/.clangd @@ -1,4 +1,4 @@ CompileFlags: Add: [-Wno-unknown-attributes, -Wno-maybe-uninitialized, -Wno-unknown-warning-option] - Remove: [-W*, -mmcu=*, -mcpu=*, -mfpu=*, -mfloat-abi=*, -mno-unaligned-access, -mno-thumb-interwork, -mcall-prologues] + Remove: [-W*, -mmcu=*, -mcpu=*, -mfpu=*, -mfloat-abi=*, -mno-unaligned-access, -mno-thumb-interwork, -mcall-prologues, -D__has_include*] Compiler: clang diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index a5d185e1dd..3e32f4d994 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -38,4 +38,4 @@ body: - type: textarea attributes: label: Additional Context - description: Add any other relevant information about the problem here. \ No newline at end of file + description: Add any other relevant information about the problem here. diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml deleted file mode 100644 index 2dc354dda2..0000000000 --- a/.github/workflows/labeler.yml +++ /dev/null @@ -1,13 +0,0 @@ -name: "Pull Request Labeler" - -on: -- pull_request_target - -jobs: - triage: - permissions: - contents: read - pull-requests: write - runs-on: ubuntu-latest - steps: - - uses: actions/labeler@v5 diff --git a/Makefile b/Makefile index c68ee7418a..f1e3bf856f 100644 --- a/Makefile +++ b/Makefile @@ -59,6 +59,7 @@ ifeq ($(ROOT_DIR),) endif include paths.mk +include $(BUILDDEFS_PATH)/support.mk TEST_OUTPUT_DIR := $(BUILD_DIR)/test ERROR_FILE := $(BUILD_DIR)/error_occurred diff --git a/builddefs/build_full_test.mk b/builddefs/build_full_test.mk index 5cae327c6c..82bb9387a6 100644 --- a/builddefs/build_full_test.mk +++ b/builddefs/build_full_test.mk @@ -25,8 +25,6 @@ $(TEST_OUTPUT)_SRC := \ tests/test_common/test_driver.cpp \ tests/test_common/keyboard_report_util.cpp \ tests/test_common/mouse_report_util.cpp \ - tests/test_common/keycode_util.cpp \ - tests/test_common/keycode_table.cpp \ tests/test_common/test_fixture.cpp \ tests/test_common/test_keymap_key.cpp \ tests/test_common/test_logger.cpp \ diff --git a/builddefs/build_keyboard.mk b/builddefs/build_keyboard.mk index c5fc9cd25d..640dedc31e 100644 --- a/builddefs/build_keyboard.mk +++ b/builddefs/build_keyboard.mk @@ -11,6 +11,7 @@ endif .DEFAULT_GOAL := all include paths.mk +include $(BUILDDEFS_PATH)/support.mk include $(BUILDDEFS_PATH)/message.mk # Helper to add defines with a 'QMK_' prefix @@ -97,21 +98,12 @@ endif # Pull in rules.mk files from all our subfolders -ifneq ("$(wildcard $(KEYBOARD_PATH_5)/rules.mk)","") - include $(KEYBOARD_PATH_5)/rules.mk -endif -ifneq ("$(wildcard $(KEYBOARD_PATH_4)/rules.mk)","") - include $(KEYBOARD_PATH_4)/rules.mk -endif -ifneq ("$(wildcard $(KEYBOARD_PATH_3)/rules.mk)","") - include $(KEYBOARD_PATH_3)/rules.mk -endif -ifneq ("$(wildcard $(KEYBOARD_PATH_2)/rules.mk)","") - include $(KEYBOARD_PATH_2)/rules.mk -endif -ifneq ("$(wildcard $(KEYBOARD_PATH_1)/rules.mk)","") - include $(KEYBOARD_PATH_1)/rules.mk -endif +-include $(KEYBOARD_PATH_5)/rules.mk +-include $(KEYBOARD_PATH_4)/rules.mk +-include $(KEYBOARD_PATH_3)/rules.mk +-include $(KEYBOARD_PATH_2)/rules.mk +-include $(KEYBOARD_PATH_1)/rules.mk + # Create dependencies on DD keyboard config - structure validated elsewhere DD_CONFIG_FILES := ifneq ("$(wildcard $(KEYBOARD_PATH_1)/info.json)","") @@ -260,6 +252,9 @@ generated-files: $(INTERMEDIATE_OUTPUT)/src/config.h $(INTERMEDIATE_OUTPUT)/src/ endif # Community modules +COMMUNITY_RULES_MK = $(shell $(QMK_BIN) generate-community-modules-rules-mk -kb $(KEYBOARD) --quiet --escape --output $(INTERMEDIATE_OUTPUT)/src/community_rules.mk $(KEYMAP_JSON)) +include $(COMMUNITY_RULES_MK) + $(INTERMEDIATE_OUTPUT)/src/community_modules.h: $(KEYMAP_JSON) $(DD_CONFIG_FILES) @$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD) $(eval CMD=$(QMK_BIN) generate-community-modules-h -kb $(KEYBOARD) --quiet --output $(INTERMEDIATE_OUTPUT)/src/community_modules.h $(KEYMAP_JSON)) @@ -280,10 +275,19 @@ $(INTERMEDIATE_OUTPUT)/src/community_modules_introspection.h: $(KEYMAP_JSON) $(D $(eval CMD=$(QMK_BIN) generate-community-modules-introspection-h -kb $(KEYBOARD) --quiet --output $(INTERMEDIATE_OUTPUT)/src/community_modules_introspection.h $(KEYMAP_JSON)) @$(BUILD_CMD) +$(INTERMEDIATE_OUTPUT)/src/led_matrix_community_modules.inc: $(KEYMAP_JSON) $(DD_CONFIG_FILES) + @$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD) + $(eval CMD=$(QMK_BIN) generate-led-matrix-community-modules-inc -kb $(KEYBOARD) --quiet --output $(INTERMEDIATE_OUTPUT)/src/led_matrix_community_modules.inc $(KEYMAP_JSON)) + @$(BUILD_CMD) + +$(INTERMEDIATE_OUTPUT)/src/rgb_matrix_community_modules.inc: $(KEYMAP_JSON) $(DD_CONFIG_FILES) + @$(SILENT) || printf "$(MSG_GENERATING) $@" | $(AWK_CMD) + $(eval CMD=$(QMK_BIN) generate-rgb-matrix-community-modules-inc -kb $(KEYBOARD) --quiet --output $(INTERMEDIATE_OUTPUT)/src/rgb_matrix_community_modules.inc $(KEYMAP_JSON)) + @$(BUILD_CMD) + SRC += $(INTERMEDIATE_OUTPUT)/src/community_modules.c -generated-files: $(INTERMEDIATE_OUTPUT)/src/community_modules.h $(INTERMEDIATE_OUTPUT)/src/community_modules.c $(INTERMEDIATE_OUTPUT)/src/community_modules_introspection.c $(INTERMEDIATE_OUTPUT)/src/community_modules_introspection.h - +generated-files: $(INTERMEDIATE_OUTPUT)/src/community_modules.h $(INTERMEDIATE_OUTPUT)/src/community_modules.c $(INTERMEDIATE_OUTPUT)/src/community_modules_introspection.c $(INTERMEDIATE_OUTPUT)/src/community_modules_introspection.h $(INTERMEDIATE_OUTPUT)/src/led_matrix_community_modules.inc $(INTERMEDIATE_OUTPUT)/src/rgb_matrix_community_modules.inc include $(BUILDDEFS_PATH)/converters.mk @@ -487,21 +491,11 @@ ifneq ("$(CONVERTER)","") endif # Pull in post_rules.mk files from all our subfolders -ifneq ("$(wildcard $(KEYBOARD_PATH_1)/post_rules.mk)","") - include $(KEYBOARD_PATH_1)/post_rules.mk -endif -ifneq ("$(wildcard $(KEYBOARD_PATH_2)/post_rules.mk)","") - include $(KEYBOARD_PATH_2)/post_rules.mk -endif -ifneq ("$(wildcard $(KEYBOARD_PATH_3)/post_rules.mk)","") - include $(KEYBOARD_PATH_3)/post_rules.mk -endif -ifneq ("$(wildcard $(KEYBOARD_PATH_4)/post_rules.mk)","") - include $(KEYBOARD_PATH_4)/post_rules.mk -endif -ifneq ("$(wildcard $(KEYBOARD_PATH_5)/post_rules.mk)","") - include $(KEYBOARD_PATH_5)/post_rules.mk -endif +-include $(KEYBOARD_PATH_1)/post_rules.mk +-include $(KEYBOARD_PATH_2)/post_rules.mk +-include $(KEYBOARD_PATH_3)/post_rules.mk +-include $(KEYBOARD_PATH_4)/post_rules.mk +-include $(KEYBOARD_PATH_5)/post_rules.mk define post_rules_mk_community_module_includer ifneq ("$(wildcard $(1)/post_rules.mk)","") diff --git a/builddefs/build_test.mk b/builddefs/build_test.mk index d0de63c6f5..0c5c98e2a3 100644 --- a/builddefs/build_test.mk +++ b/builddefs/build_test.mk @@ -7,6 +7,7 @@ endif OPT = g include paths.mk +include $(BUILDDEFS_PATH)/support.mk include $(BUILDDEFS_PATH)/message.mk TARGET=test/$(TEST_OUTPUT) diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk index 733bdd8d1e..56eed80ae0 100644 --- a/builddefs/common_features.mk +++ b/builddefs/common_features.mk @@ -30,6 +30,8 @@ QUANTUM_SRC += \ $(QUANTUM_DIR)/logging/sendchar.c \ $(QUANTUM_DIR)/process_keycode/process_default_layer.c \ +include $(QUANTUM_DIR)/nvm/rules.mk + VPATH += $(QUANTUM_DIR)/logging # Fall back to lib/printf if there is no platform provided print ifeq ("$(wildcard $(PLATFORM_PATH)/$(PLATFORM_KEY)/printf.mk)","") @@ -169,80 +171,82 @@ endif VALID_EEPROM_DRIVER_TYPES := vendor custom transient i2c spi wear_leveling legacy_stm32_flash EEPROM_DRIVER ?= vendor -ifeq ($(filter $(EEPROM_DRIVER),$(VALID_EEPROM_DRIVER_TYPES)),) +ifneq ($(strip $(EEPROM_DRIVER)),none) + ifeq ($(filter $(EEPROM_DRIVER),$(VALID_EEPROM_DRIVER_TYPES)),) $(call CATASTROPHIC_ERROR,Invalid EEPROM_DRIVER,EEPROM_DRIVER="$(EEPROM_DRIVER)" is not a valid EEPROM driver) -else - OPT_DEFS += -DEEPROM_ENABLE - COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/eeprom - COMMON_VPATH += $(DRIVER_PATH)/eeprom - COMMON_VPATH += $(PLATFORM_COMMON_DIR) - ifeq ($(strip $(EEPROM_DRIVER)), custom) - # Custom EEPROM implementation -- only needs to implement init/erase/read_block/write_block - OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_CUSTOM - SRC += eeprom_driver.c - else ifeq ($(strip $(EEPROM_DRIVER)), wear_leveling) - # Wear-leveling EEPROM implementation - OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_WEAR_LEVELING - SRC += eeprom_driver.c eeprom_wear_leveling.c - else ifeq ($(strip $(EEPROM_DRIVER)), i2c) - # External I2C EEPROM implementation - OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_I2C - I2C_DRIVER_REQUIRED = yes - SRC += eeprom_driver.c eeprom_i2c.c - else ifeq ($(strip $(EEPROM_DRIVER)), spi) - # External SPI EEPROM implementation - OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_SPI - SPI_DRIVER_REQUIRED = yes - SRC += eeprom_driver.c eeprom_spi.c - else ifeq ($(strip $(EEPROM_DRIVER)), legacy_stm32_flash) - # STM32 Emulated EEPROM, backed by MCU flash (soon to be deprecated) - OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_LEGACY_EMULATED_FLASH - COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/flash - COMMON_VPATH += $(DRIVER_PATH)/flash - SRC += eeprom_driver.c eeprom_legacy_emulated_flash.c legacy_flash_ops.c - else ifeq ($(strip $(EEPROM_DRIVER)), transient) - # Transient EEPROM implementation -- no data storage but provides runtime area for it - OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_TRANSIENT - SRC += eeprom_driver.c eeprom_transient.c - else ifeq ($(strip $(EEPROM_DRIVER)), vendor) - # Vendor-implemented EEPROM - OPT_DEFS += -DEEPROM_VENDOR - ifeq ($(PLATFORM),AVR) - # Automatically provided by avr-libc, nothing required - else ifeq ($(PLATFORM),CHIBIOS) - ifneq ($(filter %_STM32F072xB %_STM32F042x6, $(MCU_SERIES)_$(MCU_LDSCRIPT)),) - # STM32 Emulated EEPROM, backed by MCU flash (soon to be deprecated) - OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_LEGACY_EMULATED_FLASH - COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/flash - COMMON_VPATH += $(DRIVER_PATH)/flash - SRC += eeprom_driver.c eeprom_legacy_emulated_flash.c legacy_flash_ops.c - else ifneq ($(filter $(MCU_SERIES),STM32F1xx STM32F3xx STM32F4xx STM32L4xx STM32G4xx WB32F3G71xx WB32FQ95xx AT32F415 GD32VF103),) - # Wear-leveling EEPROM implementation, backed by MCU flash - OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_WEAR_LEVELING - SRC += eeprom_driver.c eeprom_wear_leveling.c - WEAR_LEVELING_DRIVER ?= embedded_flash - else ifneq ($(filter $(MCU_SERIES),STM32L0xx STM32L1xx),) - # True EEPROM on STM32L0xx, L1xx - OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_STM32_L0_L1 - SRC += eeprom_driver.c eeprom_stm32_L0_L1.c - else ifneq ($(filter $(MCU_SERIES),RP2040),) - # Wear-leveling EEPROM implementation, backed by RP2040 flash - OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_WEAR_LEVELING - SRC += eeprom_driver.c eeprom_wear_leveling.c - WEAR_LEVELING_DRIVER ?= rp2040_flash - else ifneq ($(filter $(MCU_SERIES),KL2x K20x),) - # Teensy EEPROM implementations - OPT_DEFS += -DEEPROM_KINETIS_FLEXRAM - SRC += eeprom_kinetis_flexram.c - else - # Fall back to transient, i.e. non-persistent - OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_TRANSIENT - SRC += eeprom_driver.c eeprom_transient.c + else + OPT_DEFS += -DEEPROM_ENABLE + COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/eeprom + COMMON_VPATH += $(DRIVER_PATH)/eeprom + COMMON_VPATH += $(PLATFORM_COMMON_DIR) + ifeq ($(strip $(EEPROM_DRIVER)), custom) + # Custom EEPROM implementation -- only needs to implement init/erase/read_block/write_block + OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_CUSTOM + SRC += eeprom_driver.c + else ifeq ($(strip $(EEPROM_DRIVER)), wear_leveling) + # Wear-leveling EEPROM implementation + OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_WEAR_LEVELING + SRC += eeprom_driver.c eeprom_wear_leveling.c + else ifeq ($(strip $(EEPROM_DRIVER)), i2c) + # External I2C EEPROM implementation + OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_I2C + I2C_DRIVER_REQUIRED = yes + SRC += eeprom_driver.c eeprom_i2c.c + else ifeq ($(strip $(EEPROM_DRIVER)), spi) + # External SPI EEPROM implementation + OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_SPI + SPI_DRIVER_REQUIRED = yes + SRC += eeprom_driver.c eeprom_spi.c + else ifeq ($(strip $(EEPROM_DRIVER)), legacy_stm32_flash) + # STM32 Emulated EEPROM, backed by MCU flash (soon to be deprecated) + OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_LEGACY_EMULATED_FLASH + COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/flash + COMMON_VPATH += $(DRIVER_PATH)/flash + SRC += eeprom_driver.c eeprom_legacy_emulated_flash.c legacy_flash_ops.c + else ifeq ($(strip $(EEPROM_DRIVER)), transient) + # Transient EEPROM implementation -- no data storage but provides runtime area for it + OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_TRANSIENT + SRC += eeprom_driver.c eeprom_transient.c + else ifeq ($(strip $(EEPROM_DRIVER)), vendor) + # Vendor-implemented EEPROM + OPT_DEFS += -DEEPROM_VENDOR + ifeq ($(PLATFORM),AVR) + # Automatically provided by avr-libc, nothing required + else ifeq ($(PLATFORM),CHIBIOS) + ifneq ($(filter %_STM32F072xB %_STM32F042x6, $(MCU_SERIES)_$(MCU_LDSCRIPT)),) + # STM32 Emulated EEPROM, backed by MCU flash (soon to be deprecated) + OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_LEGACY_EMULATED_FLASH + COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/flash + COMMON_VPATH += $(DRIVER_PATH)/flash + SRC += eeprom_driver.c eeprom_legacy_emulated_flash.c legacy_flash_ops.c + else ifneq ($(filter $(MCU_SERIES),STM32F1xx STM32F3xx STM32F4xx STM32L4xx STM32G0xx STM32G4xx WB32F3G71xx WB32FQ95xx AT32F415 GD32VF103),) + # Wear-leveling EEPROM implementation, backed by MCU flash + OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_WEAR_LEVELING + SRC += eeprom_driver.c eeprom_wear_leveling.c + WEAR_LEVELING_DRIVER ?= embedded_flash + else ifneq ($(filter $(MCU_SERIES),STM32L0xx STM32L1xx),) + # True EEPROM on STM32L0xx, L1xx + OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_STM32_L0_L1 + SRC += eeprom_driver.c eeprom_stm32_L0_L1.c + else ifneq ($(filter $(MCU_SERIES),RP2040),) + # Wear-leveling EEPROM implementation, backed by RP2040 flash + OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_WEAR_LEVELING + SRC += eeprom_driver.c eeprom_wear_leveling.c + WEAR_LEVELING_DRIVER ?= rp2040_flash + else ifneq ($(filter $(MCU_SERIES),KL2x K20x),) + # Teensy EEPROM implementations + OPT_DEFS += -DEEPROM_KINETIS_FLEXRAM + SRC += eeprom_kinetis_flexram.c + else + # Fall back to transient, i.e. non-persistent + OPT_DEFS += -DEEPROM_DRIVER -DEEPROM_TRANSIENT + SRC += eeprom_driver.c eeprom_transient.c + endif + else ifeq ($(PLATFORM),TEST) + # Test harness "EEPROM" + OPT_DEFS += -DEEPROM_TEST_HARNESS + SRC += eeprom.c endif - else ifeq ($(PLATFORM),TEST) - # Test harness "EEPROM" - OPT_DEFS += -DEEPROM_TEST_HARNESS - SRC += eeprom.c endif endif endif @@ -263,18 +267,14 @@ ifneq ($(strip $(WEAR_LEVELING_DRIVER)),none) ifeq ($(strip $(WEAR_LEVELING_DRIVER)), embedded_flash) OPT_DEFS += -DHAL_USE_EFL SRC += wear_leveling_efl.c - POST_CONFIG_H += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/wear_leveling/wear_leveling_efl_config.h else ifeq ($(strip $(WEAR_LEVELING_DRIVER)), spi_flash) FLASH_DRIVER := spi SRC += wear_leveling_flash_spi.c - POST_CONFIG_H += $(DRIVER_PATH)/wear_leveling/wear_leveling_flash_spi_config.h else ifeq ($(strip $(WEAR_LEVELING_DRIVER)), rp2040_flash) SRC += wear_leveling_rp2040_flash.c - POST_CONFIG_H += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_PATH)/wear_leveling/wear_leveling_rp2040_flash_config.h else ifeq ($(strip $(WEAR_LEVELING_DRIVER)), legacy) COMMON_VPATH += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/flash SRC += legacy_flash_ops.c wear_leveling_legacy.c - POST_CONFIG_H += $(PLATFORM_PATH)/$(PLATFORM_KEY)/$(DRIVER_DIR)/wear_leveling/wear_leveling_legacy_config.h endif endif endif @@ -635,6 +635,11 @@ ifeq ($(strip $(VIA_ENABLE)), yes) TRI_LAYER_ENABLE := yes endif +ifeq ($(strip $(RAW_ENABLE)), yes) + OPT_DEFS += -DRAW_ENABLE + SRC += raw_hid.c +endif + ifeq ($(strip $(DYNAMIC_KEYMAP_ENABLE)), yes) SEND_STRING_ENABLE := yes endif @@ -717,6 +722,7 @@ ifeq ($(strip $(LIB8TION_ENABLE)), yes) # ATmegaxxU2 does not have hardware MUL instruction - lib8tion must be told to use software multiplication routines OPT_DEFS += -DLIB8_ATTINY endif + OPT_DEFS += -DFASTLED_SCALE8_FIXED=1 -DFASTLED_BLEND_FIXED=1 SRC += $(LIB_PATH)/lib8tion/lib8tion.c endif @@ -888,19 +894,19 @@ ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) OPT_DEFS += -DBLUETOOTH_ENABLE OPT_DEFS += -DBLUETOOTH_$(strip $(shell echo $(BLUETOOTH_DRIVER) | tr '[:lower:]' '[:upper:]')) NO_USB_STARTUP_CHECK := yes + CONNECTION_ENABLE := yes COMMON_VPATH += $(DRIVER_PATH)/bluetooth - SRC += outputselect.c process_connection.c + SRC += $(DRIVER_PATH)/bluetooth/bluetooth.c ifeq ($(strip $(BLUETOOTH_DRIVER)), bluefruit_le) SPI_DRIVER_REQUIRED = yes - ANALOG_DRIVER_REQUIRED = yes - SRC += $(DRIVER_PATH)/bluetooth/bluetooth.c + SRC += $(DRIVER_PATH)/bluetooth/bluetooth_drivers.c SRC += $(DRIVER_PATH)/bluetooth/bluefruit_le.cpp endif ifeq ($(strip $(BLUETOOTH_DRIVER)), rn42) UART_DRIVER_REQUIRED = yes - SRC += $(DRIVER_PATH)/bluetooth/bluetooth.c + SRC += $(DRIVER_PATH)/bluetooth/bluetooth_drivers.c SRC += $(DRIVER_PATH)/bluetooth/rn42.c endif endif @@ -934,6 +940,28 @@ ifeq ($(strip $(DIP_SWITCH_ENABLE)), yes) endif endif +VALID_BATTERY_DRIVER_TYPES := adc custom vendor + +BATTERY_DRIVER ?= adc +ifeq ($(strip $(BATTERY_DRIVER_REQUIRED)), yes) + ifeq ($(filter $(BATTERY_DRIVER),$(VALID_BATTERY_DRIVER_TYPES)),) + $(call CATASTROPHIC_ERROR,Invalid BATTERY_DRIVER,BATTERY_DRIVER="$(BATTERY_DRIVER)" is not a valid battery driver) + endif + + OPT_DEFS += -DBATTERY_DRIVER + OPT_DEFS += -DBATTERY_$(strip $(shell echo $(BATTERY_DRIVER) | tr '[:lower:]' '[:upper:]')) + + COMMON_VPATH += $(DRIVER_PATH)/battery + + SRC += battery.c + SRC += battery_$(strip $(BATTERY_DRIVER)).c + + # add extra deps + ifeq ($(strip $(BATTERY_DRIVER)), adc) + ANALOG_DRIVER_REQUIRED = yes + endif +endif + VALID_WS2812_DRIVER_TYPES := bitbang custom i2c pwm spi vendor WS2812_DRIVER ?= bitbang diff --git a/builddefs/common_rules.mk b/builddefs/common_rules.mk index e45063cfaf..d6f91b10e4 100644 --- a/builddefs/common_rules.mk +++ b/builddefs/common_rules.mk @@ -168,7 +168,7 @@ MOVE_DEP = mv -f $(patsubst %.o,%.td,$@) $(patsubst %.o,%.d,$@) # For a ChibiOS build, ensure that the board files have the hook overrides injected define BOARDSRC_INJECT_HOOKS -$(INTERMEDIATE_OUTPUT)/$(patsubst %.c,%.o,$(patsubst ./%,%,$1)): INIT_HOOK_CFLAGS += -include $(TOP_DIR)/tmk_core/protocol/chibios/init_hooks.h +$(INTERMEDIATE_OUTPUT)/$(patsubst %.c,%.o,$(patsubst ./%,%,$1)): FILE_SPECIFIC_CFLAGS += -include $(TOP_DIR)/tmk_core/protocol/chibios/init_hooks.h endef $(foreach LOBJ, $(BOARDSRC), $(eval $(call BOARDSRC_INJECT_HOOKS,$(LOBJ)))) @@ -289,10 +289,10 @@ $1/%.o : %.c $1/%.d $1/cflags.txt $1/compiler.txt | $(BEGIN) ifneq ($$(VERBOSE_C_INCLUDE),) $$(if $$(filter $$(notdir $$(VERBOSE_C_INCLUDE)),$$(notdir $$<)),$$(eval CC_EXEC += -H)) endif - $$(eval CMD := $$(CC_EXEC) -c $$($1_CFLAGS) $$(INIT_HOOK_CFLAGS) $$(GENDEPFLAGS) $$< -o $$@ && $$(MOVE_DEP)) + $$(eval CMD := $$(CC_EXEC) -c $$($1_CFLAGS) $$(FILE_SPECIFIC_CFLAGS) $$(GENDEPFLAGS) $$< -o $$@ && $$(MOVE_DEP)) @$$(BUILD_CMD) ifneq ($$(DUMP_C_MACROS),) - $$(eval CMD := $$(CC) -E -dM $$($1_CFLAGS) $$(INIT_HOOK_CFLAGS) $$(GENDEPFLAGS) $$<) + $$(eval CMD := $$(CC) -E -dM $$($1_CFLAGS) $$(FILE_SPECIFIC_CFLAGS) $$(GENDEPFLAGS) $$<) @$$(if $$(filter $$(notdir $$(DUMP_C_MACROS)),$$(notdir $$<)),$$(BUILD_CMD)) endif @@ -300,13 +300,13 @@ $1/%.o : %.c $1/%.d $1/cflags.txt $1/compiler.txt | $(BEGIN) $1/%.o : %.cpp $1/%.d $1/cxxflags.txt $1/compiler.txt | $(BEGIN) @mkdir -p $$(@D) @$$(SILENT) || printf "$$(MSG_COMPILING_CXX) $$<" | $$(AWK_CMD) - $$(eval CMD=$$(CC) -c $$($1_CXXFLAGS) $$(INIT_HOOK_CFLAGS) $$(GENDEPFLAGS) $$< -o $$@ && $$(MOVE_DEP)) + $$(eval CMD=$$(CC) -c $$($1_CXXFLAGS) $$(FILE_SPECIFIC_CFLAGS) $$(GENDEPFLAGS) $$< -o $$@ && $$(MOVE_DEP)) @$$(BUILD_CMD) $1/%.o : %.cc $1/%.d $1/cxxflags.txt $1/compiler.txt | $(BEGIN) @mkdir -p $$(@D) @$$(SILENT) || printf "$$(MSG_COMPILING_CXX) $$<" | $$(AWK_CMD) - $$(eval CMD=$$(CC) -c $$($1_CXXFLAGS) $$(INIT_HOOK_CFLAGS) $$(GENDEPFLAGS) $$< -o $$@ && $$(MOVE_DEP)) + $$(eval CMD=$$(CC) -c $$($1_CXXFLAGS) $$(FILE_SPECIFIC_CFLAGS) $$(GENDEPFLAGS) $$< -o $$@ && $$(MOVE_DEP)) @$$(BUILD_CMD) # Assemble: create object files from assembler source files. diff --git a/builddefs/converters.mk b/builddefs/converters.mk index b1e5a1bed2..20ecea5cb9 100644 --- a/builddefs/converters.mk +++ b/builddefs/converters.mk @@ -1,10 +1,3 @@ -# Note for new boards -- CTPC and CONVERT_TO_PROTON_C are deprecated terms -# and should not be replicated for new boards. These will be removed from -# documentation as well as existing keymaps in due course. -ifneq ($(findstring yes, $(CTPC)$(CONVERT_TO_PROTON_C)),) -$(call CATASTROPHIC_ERROR,The `CONVERT_TO_PROTON_C` and `CTPC` options are now deprecated. `CONVERT_TO=proton_c` should be used instead.) -endif - ifneq (,$(filter $(MCU),atmega32u4)) # TODO: opt in rather than assume everything uses a pro micro PIN_COMPATIBLE ?= promicro diff --git a/builddefs/docsgen/package.json b/builddefs/docsgen/package.json index 21f56d7ddf..c2e5412a06 100644 --- a/builddefs/docsgen/package.json +++ b/builddefs/docsgen/package.json @@ -1,7 +1,7 @@ { "license": "GPL-2.0-or-later", "devDependencies": { - "vite": "^5.4.12", + "vite": "^5.4.18", "vitepress": "^1.1.0", "vitepress-plugin-tabs": "^0.5.0", "vue": "^3.4.24" diff --git a/builddefs/docsgen/yarn.lock b/builddefs/docsgen/yarn.lock index 0b36eec07c..a096b8d5c0 100644 --- a/builddefs/docsgen/yarn.lock +++ b/builddefs/docsgen/yarn.lock @@ -766,10 +766,10 @@ tabbable@^6.2.0: resolved "https://registry.yarnpkg.com/tabbable/-/tabbable-6.2.0.tgz#732fb62bc0175cfcec257330be187dcfba1f3b97" integrity sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew== -vite@^5.2.9, vite@^5.4.12: - version "5.4.12" - resolved "https://registry.yarnpkg.com/vite/-/vite-5.4.12.tgz#627d12ff06de3942557dfe8632fd712a12a072c7" - integrity sha512-KwUaKB27TvWwDJr1GjjWthLMATbGEbeWYZIbGZ5qFIsgPP3vWzLu4cVooqhm5/Z2SPDUMjyPVjTztm5tYKwQxA== +vite@^5.2.9, vite@^5.4.18: + version "5.4.18" + resolved "https://registry.yarnpkg.com/vite/-/vite-5.4.18.tgz#b5af357f9d5ebb2e0c085779b7a37a77f09168a4" + integrity sha512-1oDcnEp3lVyHCuQ2YFelM4Alm2o91xNoMncRm1U7S+JdYfYOvbiGZ3/CxGttrOu2M/KcGz7cRC2DoNUA6urmMA== dependencies: esbuild "^0.21.3" postcss "^8.4.43" diff --git a/builddefs/generic_features.mk b/builddefs/generic_features.mk index f14f440877..c826514431 100644 --- a/builddefs/generic_features.mk +++ b/builddefs/generic_features.mk @@ -25,6 +25,7 @@ GENERIC_FEATURES = \ CAPS_WORD \ COMBO \ COMMAND \ + CONNECTION \ CRC \ DEFERRED_EXEC \ DIGITIZER \ @@ -34,6 +35,7 @@ GENERIC_FEATURES = \ DYNAMIC_TAPPING_TERM \ GRAVE_ESC \ HAPTIC \ + KEYCODE_STRING \ KEY_LOCK \ KEY_OVERRIDE \ LAYER_LOCK \ @@ -60,6 +62,7 @@ define HANDLE_GENERIC_FEATURE SRC += $$(wildcard $$(QUANTUM_DIR)/process_keycode/process_$2.c) SRC += $$(wildcard $$(QUANTUM_DIR)/$2/$2.c) SRC += $$(wildcard $$(QUANTUM_DIR)/$2.c) + SRC += $$(wildcard $$(QUANTUM_DIR)/nvm/$$(NVM_DRIVER_LOWER)/nvm_$2.c) VPATH += $$(wildcard $$(QUANTUM_DIR)/$2/) OPT_DEFS += -D$1_ENABLE endef diff --git a/builddefs/support.mk b/builddefs/support.mk new file mode 100644 index 0000000000..7ef7b9b041 --- /dev/null +++ b/builddefs/support.mk @@ -0,0 +1,11 @@ +# Helper to determine if a compiler option is supported +# Args: +# $(1) = option to test, if successful will be output +# $(2) = option to use if $(1) is not supported +# $(3) = additional arguments to pass to the compiler during the test, but aren't contained in the output +cc-option = $(shell \ + if { echo 'int main(){return 0;}' | $(CC) $(1) $(3) -o /dev/null -x c /dev/null >/dev/null 2>&1; }; \ + then echo "$(1)"; else echo "$(2)"; fi) + +# Helper to pass comma character to make functions (use with `$(,)` to pass in `$(call ...)` arguments) +, := , diff --git a/data/constants/keycodes/extras/keycodes_belgian_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_belgian_0.0.1.hjson index d2b8c1d7d9..11b68d16a0 100644 --- a/data/constants/keycodes/extras/keycodes_belgian_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_belgian_0.0.1.hjson @@ -372,4 +372,4 @@ "label": "~", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_bepo_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_bepo_0.0.1.hjson index 713f3f2829..7a9dea9d13 100644 --- a/data/constants/keycodes/extras/keycodes_bepo_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_bepo_0.0.1.hjson @@ -629,4 +629,4 @@ "label": "(narrow non-breaking space)", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_brazilian_abnt2_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_brazilian_abnt2_0.0.1.hjson index 17006a64df..e28970ed33 100644 --- a/data/constants/keycodes/extras/keycodes_brazilian_abnt2_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_brazilian_abnt2_0.0.1.hjson @@ -376,4 +376,4 @@ "label": "₢", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_canadian_multilingual_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_canadian_multilingual_0.0.1.hjson index bfe5d5b54c..a663088e22 100644 --- a/data/constants/keycodes/extras/keycodes_canadian_multilingual_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_canadian_multilingual_0.0.1.hjson @@ -638,4 +638,4 @@ "label": "÷", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_colemak_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_colemak_0.0.1.hjson index 1dc091584b..0bf0f3b221 100644 --- a/data/constants/keycodes/extras/keycodes_colemak_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_colemak_0.0.1.hjson @@ -299,4 +299,4 @@ "label": "?", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_croatian_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_croatian_0.0.1.hjson index 82632aa637..50464921fa 100644 --- a/data/constants/keycodes/extras/keycodes_croatian_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_croatian_0.0.1.hjson @@ -400,4 +400,4 @@ "label": "§", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_czech_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_czech_0.0.1.hjson index 9cfb88c489..8b1572bfcb 100644 --- a/data/constants/keycodes/extras/keycodes_czech_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_czech_0.0.1.hjson @@ -432,4 +432,4 @@ "label": "*", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_danish_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_danish_0.0.1.hjson index fffcd9f9ad..0e8f7a75c6 100644 --- a/data/constants/keycodes/extras/keycodes_danish_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_danish_0.0.1.hjson @@ -356,4 +356,4 @@ "label": "µ", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_dvorak_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_dvorak_0.0.1.hjson index 534f99c8e6..485d86aa21 100644 --- a/data/constants/keycodes/extras/keycodes_dvorak_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_dvorak_0.0.1.hjson @@ -299,4 +299,4 @@ "label": ":", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_dvorak_fr_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_dvorak_fr_0.0.1.hjson index 70c0b3c0aa..69ce14486e 100644 --- a/data/constants/keycodes/extras/keycodes_dvorak_fr_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_dvorak_fr_0.0.1.hjson @@ -314,4 +314,4 @@ "label": "@", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_dvorak_programmer_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_dvorak_programmer_0.0.1.hjson index 8a70dae7ef..6fa9868e4c 100644 --- a/data/constants/keycodes/extras/keycodes_dvorak_programmer_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_dvorak_programmer_0.0.1.hjson @@ -299,4 +299,4 @@ "label": "\"", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_estonian_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_estonian_0.0.1.hjson index bbf7512581..276d3fe664 100644 --- a/data/constants/keycodes/extras/keycodes_estonian_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_estonian_0.0.1.hjson @@ -364,4 +364,4 @@ "label": "ž", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_eurkey_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_eurkey_0.0.1.hjson index 9ff217cff2..9b4fa33053 100644 --- a/data/constants/keycodes/extras/keycodes_eurkey_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_eurkey_0.0.1.hjson @@ -593,4 +593,4 @@ "label": "…", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_finnish_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_finnish_0.0.1.hjson index b284192962..a4d3c99a6f 100644 --- a/data/constants/keycodes/extras/keycodes_finnish_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_finnish_0.0.1.hjson @@ -356,4 +356,4 @@ "label": "µ", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_french_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_french_0.0.1.hjson index 8ba7b35d2e..351dfe89d8 100644 --- a/data/constants/keycodes/extras/keycodes_french_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_french_0.0.1.hjson @@ -364,4 +364,4 @@ "label": "¤", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_french_afnor_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_french_afnor_0.0.1.hjson index 90981d085d..92646c4de8 100644 --- a/data/constants/keycodes/extras/keycodes_french_afnor_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_french_afnor_0.0.1.hjson @@ -620,4 +620,4 @@ "label": "≠", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_french_mac_iso_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_french_mac_iso_0.0.1.hjson index b698018d5b..bb924e9852 100644 --- a/data/constants/keycodes/extras/keycodes_french_mac_iso_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_french_mac_iso_0.0.1.hjson @@ -673,4 +673,4 @@ "label": "±", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_german_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_german_0.0.1.hjson index a1cfd44956..015438abb2 100644 --- a/data/constants/keycodes/extras/keycodes_german_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_german_0.0.1.hjson @@ -356,4 +356,4 @@ "label": "µ", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_german_mac_iso_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_german_mac_iso_0.0.1.hjson index 366ed5b9d1..fa3b8d67b5 100644 --- a/data/constants/keycodes/extras/keycodes_german_mac_iso_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_german_mac_iso_0.0.1.hjson @@ -653,4 +653,4 @@ "label": "—", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_greek_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_greek_0.0.1.hjson index 9c7f8796bf..b61a317b19 100644 --- a/data/constants/keycodes/extras/keycodes_greek_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_greek_0.0.1.hjson @@ -388,4 +388,4 @@ "label": "©", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_hebrew_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_hebrew_0.0.1.hjson index b519229f35..aaf0563623 100644 --- a/data/constants/keycodes/extras/keycodes_hebrew_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_hebrew_0.0.1.hjson @@ -344,4 +344,4 @@ "label": "÷", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_hungarian_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_hungarian_0.0.1.hjson index d4fc908dc0..e7ae0d340c 100644 --- a/data/constants/keycodes/extras/keycodes_hungarian_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_hungarian_0.0.1.hjson @@ -432,4 +432,4 @@ "label": "*", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_icelandic_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_icelandic_0.0.1.hjson index f4d6025a77..59478a1018 100644 --- a/data/constants/keycodes/extras/keycodes_icelandic_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_icelandic_0.0.1.hjson @@ -352,4 +352,4 @@ "label": "µ", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_irish_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_irish_0.0.1.hjson index 94e553469e..99487a5b90 100644 --- a/data/constants/keycodes/extras/keycodes_irish_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_irish_0.0.1.hjson @@ -352,4 +352,4 @@ "label": "´ (dead)", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_italian_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_italian_0.0.1.hjson index 951c564f62..8b859d6de8 100644 --- a/data/constants/keycodes/extras/keycodes_italian_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_italian_0.0.1.hjson @@ -361,4 +361,4 @@ "label": "}", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_italian_mac_ansi_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_italian_mac_ansi_0.0.1.hjson index 328755ca67..551f094974 100644 --- a/data/constants/keycodes/extras/keycodes_italian_mac_ansi_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_italian_mac_ansi_0.0.1.hjson @@ -681,4 +681,4 @@ "label": "—", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_italian_mac_iso_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_italian_mac_iso_0.0.1.hjson index 4beccd804a..aed90f203d 100644 --- a/data/constants/keycodes/extras/keycodes_italian_mac_iso_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_italian_mac_iso_0.0.1.hjson @@ -685,4 +685,4 @@ "label": "—", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_japanese_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_japanese_0.0.1.hjson index d95712abd9..779eef8a84 100644 --- a/data/constants/keycodes/extras/keycodes_japanese_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_japanese_0.0.1.hjson @@ -327,4 +327,4 @@ "label": "_", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_korean_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_korean_0.0.1.hjson index 5ee19c9e4e..8e04d8ed2a 100644 --- a/data/constants/keycodes/extras/keycodes_korean_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_korean_0.0.1.hjson @@ -307,4 +307,4 @@ "label": "?", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_latvian_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_latvian_0.0.1.hjson index ab80f0fdd9..510a2c83a7 100644 --- a/data/constants/keycodes/extras/keycodes_latvian_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_latvian_0.0.1.hjson @@ -437,4 +437,4 @@ "label": "¨ (dead)", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_lithuanian_azerty_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_lithuanian_azerty_0.0.1.hjson index dfb527878e..f6140d7f93 100644 --- a/data/constants/keycodes/extras/keycodes_lithuanian_azerty_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_lithuanian_azerty_0.0.1.hjson @@ -372,4 +372,4 @@ "label": "\\", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_lithuanian_qwerty_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_lithuanian_qwerty_0.0.1.hjson index a4ea30d592..2ab6f83c94 100644 --- a/data/constants/keycodes/extras/keycodes_lithuanian_qwerty_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_lithuanian_qwerty_0.0.1.hjson @@ -365,4 +365,4 @@ "label": "+", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_neo2_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_neo2_0.0.1.hjson index 980bddbf7a..88ede311a6 100644 --- a/data/constants/keycodes/extras/keycodes_neo2_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_neo2_0.0.1.hjson @@ -214,4 +214,4 @@ "label": "(layer 4)", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_nordic_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_nordic_0.0.1.hjson index fb3d1bc84b..8536a004de 100644 --- a/data/constants/keycodes/extras/keycodes_nordic_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_nordic_0.0.1.hjson @@ -113,4 +113,4 @@ "key": "NO_MU" } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_norman_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_norman_0.0.1.hjson index 98ea7e6aab..45cd26ae1c 100644 --- a/data/constants/keycodes/extras/keycodes_norman_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_norman_0.0.1.hjson @@ -299,4 +299,4 @@ "label": "?", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_norwegian_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_norwegian_0.0.1.hjson index 4e8cbb5d0e..0cc79c5631 100644 --- a/data/constants/keycodes/extras/keycodes_norwegian_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_norwegian_0.0.1.hjson @@ -352,4 +352,4 @@ "label": "µ", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_plover_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_plover_0.0.1.hjson index fb00ef0c62..78cfe9dd41 100644 --- a/data/constants/keycodes/extras/keycodes_plover_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_plover_0.0.1.hjson @@ -83,4 +83,4 @@ "key": "PV_U" } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_plover_dvorak_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_plover_dvorak_0.0.1.hjson index 9656dd9821..8e1fe29f8b 100644 --- a/data/constants/keycodes/extras/keycodes_plover_dvorak_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_plover_dvorak_0.0.1.hjson @@ -70,4 +70,4 @@ "key": "PD_U" } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_polish_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_polish_0.0.1.hjson index 609011b1f7..f09f2c9b64 100644 --- a/data/constants/keycodes/extras/keycodes_polish_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_polish_0.0.1.hjson @@ -352,4 +352,4 @@ "label": "Ń", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_portuguese_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_portuguese_0.0.1.hjson index c8e43065d2..ec773ddbb5 100644 --- a/data/constants/keycodes/extras/keycodes_portuguese_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_portuguese_0.0.1.hjson @@ -352,4 +352,4 @@ "label": "€", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_portuguese_mac_iso_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_portuguese_mac_iso_0.0.1.hjson index b1c9aaad98..503a3e92a6 100644 --- a/data/constants/keycodes/extras/keycodes_portuguese_mac_iso_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_portuguese_mac_iso_0.0.1.hjson @@ -617,4 +617,4 @@ "label": "–", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_romanian_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_romanian_0.0.1.hjson index 42b1e89d3b..f388523146 100644 --- a/data/constants/keycodes/extras/keycodes_romanian_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_romanian_0.0.1.hjson @@ -441,4 +441,4 @@ "label": "»", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_russian_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_russian_0.0.1.hjson index d83fc0f61f..41904be634 100644 --- a/data/constants/keycodes/extras/keycodes_russian_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_russian_0.0.1.hjson @@ -288,4 +288,4 @@ "label": "₽", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_serbian_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_serbian_0.0.1.hjson index 98957930a0..3ddd7f15df 100644 --- a/data/constants/keycodes/extras/keycodes_serbian_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_serbian_0.0.1.hjson @@ -304,4 +304,4 @@ "label": "€", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_serbian_latin_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_serbian_latin_0.0.1.hjson index ca4746b646..eec0877aa7 100644 --- a/data/constants/keycodes/extras/keycodes_serbian_latin_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_serbian_latin_0.0.1.hjson @@ -404,4 +404,4 @@ "label": "§", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_slovak_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_slovak_0.0.1.hjson index 14eb4b783a..dbf39b5f49 100644 --- a/data/constants/keycodes/extras/keycodes_slovak_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_slovak_0.0.1.hjson @@ -440,4 +440,4 @@ "label": "}", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_slovenian_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_slovenian_0.0.1.hjson index fd1a4eb4fc..d264d3d392 100644 --- a/data/constants/keycodes/extras/keycodes_slovenian_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_slovenian_0.0.1.hjson @@ -400,4 +400,4 @@ "label": "§", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_spanish_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_spanish_0.0.1.hjson index db3b068e97..9656e35674 100644 --- a/data/constants/keycodes/extras/keycodes_spanish_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_spanish_0.0.1.hjson @@ -356,4 +356,4 @@ "label": "}", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_spanish_dvorak_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_spanish_dvorak_0.0.1.hjson index 39119a6a91..fa0a93ff85 100644 --- a/data/constants/keycodes/extras/keycodes_spanish_dvorak_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_spanish_dvorak_0.0.1.hjson @@ -356,4 +356,4 @@ "label": "}", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_spanish_latin_america_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_spanish_latin_america_0.0.1.hjson index fb1de29e6e..51ad69a55a 100644 --- a/data/constants/keycodes/extras/keycodes_spanish_latin_america_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_spanish_latin_america_0.0.1.hjson @@ -340,4 +340,4 @@ "label": "`", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_swedish_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_swedish_0.0.1.hjson index 6db71ea241..f538a81bd9 100644 --- a/data/constants/keycodes/extras/keycodes_swedish_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_swedish_0.0.1.hjson @@ -356,4 +356,4 @@ "label": "µ", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_swedish_mac_ansi_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_swedish_mac_ansi_0.0.1.hjson index ab7c3ad8d1..59f0173e89 100644 --- a/data/constants/keycodes/extras/keycodes_swedish_mac_ansi_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_swedish_mac_ansi_0.0.1.hjson @@ -639,4 +639,4 @@ "label": "—", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_swedish_mac_iso_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_swedish_mac_iso_0.0.1.hjson index cafd815776..cf2c0d9fdf 100644 --- a/data/constants/keycodes/extras/keycodes_swedish_mac_iso_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_swedish_mac_iso_0.0.1.hjson @@ -637,4 +637,4 @@ "label": "—", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_swedish_pro_mac_ansi_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_swedish_pro_mac_ansi_0.0.1.hjson index c82c79c711..911cbc2be8 100644 --- a/data/constants/keycodes/extras/keycodes_swedish_pro_mac_ansi_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_swedish_pro_mac_ansi_0.0.1.hjson @@ -639,4 +639,4 @@ "label": "—", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_swedish_pro_mac_iso_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_swedish_pro_mac_iso_0.0.1.hjson index 4555739ccd..d8e532f792 100644 --- a/data/constants/keycodes/extras/keycodes_swedish_pro_mac_iso_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_swedish_pro_mac_iso_0.0.1.hjson @@ -637,4 +637,4 @@ "label": "—", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_swiss_de_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_swiss_de_0.0.1.hjson index ae260a5e56..e4a5f91158 100644 --- a/data/constants/keycodes/extras/keycodes_swiss_de_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_swiss_de_0.0.1.hjson @@ -376,4 +376,4 @@ "label": "\\", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_swiss_fr_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_swiss_fr_0.0.1.hjson index 83fb86e49c..e518658314 100644 --- a/data/constants/keycodes/extras/keycodes_swiss_fr_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_swiss_fr_0.0.1.hjson @@ -376,4 +376,4 @@ "label": "\\", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_turkish_f_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_turkish_f_0.0.1.hjson index 2689f10dbe..0f527e04d6 100644 --- a/data/constants/keycodes/extras/keycodes_turkish_f_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_turkish_f_0.0.1.hjson @@ -477,4 +477,4 @@ "label": "º", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_turkish_q_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_turkish_q_0.0.1.hjson index e00cee9ce3..e736bb52a2 100644 --- a/data/constants/keycodes/extras/keycodes_turkish_q_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_turkish_q_0.0.1.hjson @@ -372,4 +372,4 @@ "label": "` (dead)", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_uk_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_uk_0.0.1.hjson index 006bf5c59e..aa97e11fa9 100644 --- a/data/constants/keycodes/extras/keycodes_uk_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_uk_0.0.1.hjson @@ -350,4 +350,4 @@ "label": "Á" } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_ukrainian_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_ukrainian_0.0.1.hjson index 2e8629f58b..3596dc14e0 100644 --- a/data/constants/keycodes/extras/keycodes_ukrainian_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_ukrainian_0.0.1.hjson @@ -292,4 +292,4 @@ "label": "ґ", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_us_extended_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_us_extended_0.0.1.hjson index ecac6ca161..15b21dd526 100644 --- a/data/constants/keycodes/extras/keycodes_us_extended_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_us_extended_0.0.1.hjson @@ -585,4 +585,4 @@ "label": "̉ (dead)", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_us_international_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_us_international_0.0.1.hjson index 36a574a4ad..34328be8b8 100644 --- a/data/constants/keycodes/extras/keycodes_us_international_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_us_international_0.0.1.hjson @@ -505,4 +505,4 @@ "label": "¢", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_us_international_linux_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_us_international_linux_0.0.1.hjson index d6bdf2e02d..fcf848dd87 100644 --- a/data/constants/keycodes/extras/keycodes_us_international_linux_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_us_international_linux_0.0.1.hjson @@ -573,4 +573,4 @@ "label": "̉ (dead)", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_workman_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_workman_0.0.1.hjson index 27471a15e4..14220e560e 100644 --- a/data/constants/keycodes/extras/keycodes_workman_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_workman_0.0.1.hjson @@ -299,4 +299,4 @@ "label": "?", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/extras/keycodes_workman_zxcvm_0.0.1.hjson b/data/constants/keycodes/extras/keycodes_workman_zxcvm_0.0.1.hjson index 86f6a5bffb..f05ec1a3ea 100644 --- a/data/constants/keycodes/extras/keycodes_workman_zxcvm_0.0.1.hjson +++ b/data/constants/keycodes/extras/keycodes_workman_zxcvm_0.0.1.hjson @@ -299,4 +299,4 @@ "label": "?", } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/keycodes_0.0.1.hjson b/data/constants/keycodes/keycodes_0.0.1.hjson index 7ba1ecf201..c40baf13dc 100644 --- a/data/constants/keycodes/keycodes_0.0.1.hjson +++ b/data/constants/keycodes/keycodes_0.0.1.hjson @@ -93,4 +93,4 @@ "key": "SAFE_RANGE" } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/keycodes_0.0.1_joystick.hjson b/data/constants/keycodes/keycodes_0.0.1_joystick.hjson index 0bda7c29f3..b851d72eef 100644 --- a/data/constants/keycodes/keycodes_0.0.1_joystick.hjson +++ b/data/constants/keycodes/keycodes_0.0.1_joystick.hjson @@ -225,4 +225,4 @@ ] } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/keycodes_0.0.1_magic.hjson b/data/constants/keycodes/keycodes_0.0.1_magic.hjson index 7ee1f2bce9..0e3e8dc55f 100644 --- a/data/constants/keycodes/keycodes_0.0.1_magic.hjson +++ b/data/constants/keycodes/keycodes_0.0.1_magic.hjson @@ -246,4 +246,4 @@ ] } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/keycodes_0.0.1_programmable_button.hjson b/data/constants/keycodes/keycodes_0.0.1_programmable_button.hjson index 645bcd6a39..7d031728a6 100644 --- a/data/constants/keycodes/keycodes_0.0.1_programmable_button.hjson +++ b/data/constants/keycodes/keycodes_0.0.1_programmable_button.hjson @@ -225,4 +225,4 @@ ] } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/keycodes_0.0.1_sequencer.hjson b/data/constants/keycodes/keycodes_0.0.1_sequencer.hjson index 039d09b2fa..85844ae99c 100644 --- a/data/constants/keycodes/keycodes_0.0.1_sequencer.hjson +++ b/data/constants/keycodes/keycodes_0.0.1_sequencer.hjson @@ -37,4 +37,4 @@ "key": "SQ_SCLR" } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/keycodes_0.0.2_basic.hjson b/data/constants/keycodes/keycodes_0.0.2_basic.hjson index 2b5df85d99..d9cefe7e93 100644 --- a/data/constants/keycodes/keycodes_0.0.2_basic.hjson +++ b/data/constants/keycodes/keycodes_0.0.2_basic.hjson @@ -17,4 +17,4 @@ ] } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/keycodes_0.0.2_magic.hjson b/data/constants/keycodes/keycodes_0.0.2_magic.hjson index 81758975e3..2fc8ba038d 100644 --- a/data/constants/keycodes/keycodes_0.0.2_magic.hjson +++ b/data/constants/keycodes/keycodes_0.0.2_magic.hjson @@ -248,4 +248,4 @@ ] } } -} \ No newline at end of file +} diff --git a/data/constants/keycodes/keycodes_0.0.2_sequencer.hjson b/data/constants/keycodes/keycodes_0.0.2_sequencer.hjson index eedaed166c..445a2c9328 100644 --- a/data/constants/keycodes/keycodes_0.0.2_sequencer.hjson +++ b/data/constants/keycodes/keycodes_0.0.2_sequencer.hjson @@ -66,4 +66,4 @@ ] } } -} \ No newline at end of file +} diff --git a/data/constants/module_hooks/1.1.1.hjson b/data/constants/module_hooks/1.1.1.hjson new file mode 100644 index 0000000000..49f5d0d5d0 --- /dev/null +++ b/data/constants/module_hooks/1.1.1.hjson @@ -0,0 +1,3 @@ +{ + // This version exists to signify addition of LED/RGB effect support. +} diff --git a/data/mappings/info_config.hjson b/data/mappings/info_config.hjson index b643553b52..e4def1a4d7 100644 --- a/data/mappings/info_config.hjson +++ b/data/mappings/info_config.hjson @@ -64,6 +64,9 @@ "WEAR_LEVELING_BACKING_SIZE": {"info_key": "eeprom.wear_leveling.backing_size", "value_type": "int", "to_json": false}, "WEAR_LEVELING_LOGICAL_SIZE": {"info_key": "eeprom.wear_leveling.logical_size", "value_type": "int", "to_json": false}, + // host + "NKRO_DEFAULT_ON": {"info_key": "host.default.nkro", "value_type": "bool"}, + // Layer locking "LAYER_LOCK_IDLE_TIMEOUT": {"info_key": "layer_lock.timeout", "value_type": "int"}, @@ -201,6 +204,7 @@ // Tapping "CHORDAL_HOLD": {"info_key": "tapping.chordal_hold", "value_type": "flag"}, + "FLOW_TAP_TERM": {"info_key": "tapping.flow_tap_term", "value_type": "int"}, "HOLD_ON_OTHER_KEY_PRESS": {"info_key": "tapping.hold_on_other_key_press", "value_type": "flag"}, "HOLD_ON_OTHER_KEY_PRESS_PER_KEY": {"info_key": "tapping.hold_on_other_key_press_per_key", "value_type": "flag"}, "PERMISSIVE_HOLD": {"info_key": "tapping.permissive_hold", "value_type": "flag"}, @@ -214,7 +218,6 @@ "TAPPING_TOGGLE": {"info_key": "tapping.toggle", "value_type": "int"}, // USB - "FORCE_NKRO": {"info_key": "usb.force_nkro", "value_type": "flag"}, "USB_MAX_POWER_CONSUMPTION": {"info_key": "usb.max_power", "value_type": "int"}, "USB_POLLING_INTERVAL_MS": {"info_key": "usb.polling_interval", "value_type": "int"}, "USB_SUSPEND_WAKEUP_DELAY": {"info_key": "usb.suspend_wakeup_delay", "value_type": "int"}, @@ -252,6 +255,7 @@ "PRODUCT": {"info_key": "keyboard_name", "warn_duplicate": false, "value_type": "str", "deprecated": true, "replace_with": "`keyboard_name` in info.json"}, "PRODUCT_ID": {"info_key": "usb.pid", "value_type": "hex", "deprecated": true, "replace_with": "`usb.pid` in info.json"}, "VENDOR_ID": {"info_key": "usb.vid", "value_type": "hex", "deprecated": true, "replace_with": "`usb.vid` in info.json"}, + "FORCE_NKRO": {"info_key": "usb.force_nkro", "value_type": "flag", "deprecated": true, "replace_with": "`host.default.nkro` in info.json"}, // Items we want flagged in lint "VIAL_KEYBOARD_UID": {"info_key": "_invalid.vial_uid", "invalid": true}, diff --git a/data/mappings/info_defaults.hjson b/data/mappings/info_defaults.hjson new file mode 100644 index 0000000000..b33cb4fa1f --- /dev/null +++ b/data/mappings/info_defaults.hjson @@ -0,0 +1,74 @@ +{ + "bootmagic": { + "matrix": [0, 0] + }, + "backlight": { + "default": { + "on": true + }, + "breathing_period": 6, + "levels": 3, + "on_state": 1 + }, + "debounce": 5, + "features": { + "command": false, + "console": false + }, + "indicators": { + "on_state": 1 + }, + "led_matrix": { + "default": { + "animation": "solid", + "on": true, + "val": 255, + "speed": 128 + }, + "led_flush_limit": 16, + "max_brightness": 255, + "sleep": false, + "speed_steps": 16, + "val_steps": 16 + }, + "rgblight": { + "default": { + "animation": "static_light", + "on": true, + "hue": 0, + "sat": 255, + "val": 255, + "speed": 0 + }, + "brightness_steps": 17, + "hue_steps": 8, + "max_brightness": 255, + "saturation_steps": 17, + "sleep": false + }, + "rgb_matrix": { + "default": { + "animation": "cycle_left_right", + "on": true, + "hue": 0, + "sat": 255, + "val": 255, + "speed": 128 + }, + "hue_steps": 8, + "led_flush_limit": 16, + "max_brightness": 255, + "sat_steps": 16, + "sleep": false, + "speed_steps": 16, + "val_steps": 16 + }, + "split": { + "serial": { + "driver": "bitbang" + } + }, + "ws2812": { + "driver": "bitbang" + } +} diff --git a/data/mappings/info_rules.hjson b/data/mappings/info_rules.hjson index 00685b5b5f..238957f170 100644 --- a/data/mappings/info_rules.hjson +++ b/data/mappings/info_rules.hjson @@ -53,8 +53,8 @@ "WS2812_DRIVER": {"info_key": "ws2812.driver"}, // Items we want flagged in lint - "CTPC": {"info_key": "_deprecated.ctpc", "deprecated": true, "replace_with": "CONVERT_TO=proton_c"}, - "CONVERT_TO_PROTON_C": {"info_key": "_deprecated.ctpc", "deprecated": true, "replace_with": "CONVERT_TO=proton_c"}, "DEFAULT_FOLDER": {"info_key": "_deprecated.default_folder", "deprecated": true}, + "CTPC": {"info_key": "_invalid.ctpc", "invalid": true, "replace_with": "CONVERT_TO=proton_c"}, + "CONVERT_TO_PROTON_C": {"info_key": "_invalid.ctpc", "invalid": true, "replace_with": "CONVERT_TO=proton_c"}, "VIAL_ENABLE": {"info_key": "_invalid.vial", "invalid": true} } diff --git a/data/schemas/api_keyboard.jsonschema b/data/schemas/api_keyboard.jsonschema index 6a30b5d990..a3b7872ee0 100644 --- a/data/schemas/api_keyboard.jsonschema +++ b/data/schemas/api_keyboard.jsonschema @@ -1,7 +1,7 @@ { "$id": "qmk.api.keyboard.v1", "allOf": [ - {"$ref": "qmk.keyboard.v1"}, + {"$ref": "./keyboard.jsonschema#"}, { "properties": { "keymaps": { @@ -10,8 +10,8 @@ "url": {"type": "string"} } }, - "parse_errors": {"$ref": "qmk.definitions.v1#/string_array"}, - "parse_warnings": {"$ref": "qmk.definitions.v1#/string_array"}, + "parse_errors": {"$ref": "./definitions.jsonschema#/string_array"}, + "parse_warnings": {"$ref": "./definitions.jsonschema#/string_array"}, "processor_type": {"type": "string"}, "protocol": {"type": "string"}, "keyboard_folder": {"type": "string"}, diff --git a/data/schemas/community_module.jsonschema b/data/schemas/community_module.jsonschema index a3474476df..92981ceb5c 100644 --- a/data/schemas/community_module.jsonschema +++ b/data/schemas/community_module.jsonschema @@ -3,15 +3,16 @@ "$id": "qmk.community_module.v1", "title": "Community Module Information", "type": "object", - "required": ["module_name", "maintainer"] + "required": ["module_name", "maintainer"], "properties": { - "module_name": {"$ref": "qmk.definitions.v1#/text_identifier"}, - "maintainer": {"$ref": "qmk.definitions.v1#/text_identifier"}, + "module_name": {"$ref": "./definitions.jsonschema#/text_identifier"}, + "maintainer": {"$ref": "./definitions.jsonschema#/text_identifier"}, + "license": {"type": "string"}, "url": { "type": "string", "format": "uri" }, - "keycodes": {"$ref": "qmk.definitions.v1#/keycode_decl_array"}, - "features": {"$ref": "qmk.keyboard.v1#/definitions/features_config"}, + "keycodes": {"$ref": "./definitions.jsonschema#/keycode_decl_array"}, + "features": {"$ref": "./keyboard.jsonschema#/definitions/features_config"} } } diff --git a/data/schemas/keyboard.jsonschema b/data/schemas/keyboard.jsonschema index 9b63f62d45..3aa259605e 100644 --- a/data/schemas/keyboard.jsonschema +++ b/data/schemas/keyboard.jsonschema @@ -17,9 +17,9 @@ "additionalProperties": false, "required": ["pin_a", "pin_b"], "properties": { - "pin_a": {"$ref": "qmk.definitions.v1#/mcu_pin"}, - "pin_b": {"$ref": "qmk.definitions.v1#/mcu_pin"}, - "resolution": {"$ref": "qmk.definitions.v1#/unsigned_int"} + "pin_a": {"$ref": "./definitions.jsonschema#/mcu_pin"}, + "pin_b": {"$ref": "./definitions.jsonschema#/mcu_pin"}, + "resolution": {"$ref": "./definitions.jsonschema#/unsigned_int"} } } } @@ -28,22 +28,22 @@ "dip_switch_config": { "type": "object", "properties": { - "pins": {"$ref": "qmk.definitions.v1#/mcu_pin_array"} + "pins": {"$ref": "./definitions.jsonschema#/mcu_pin_array"} } - } - "features_config": { - "$ref": "qmk.definitions.v1#/boolean_array", - "propertyNames": {"$ref": "qmk.definitions.v1#/snake_case"}, - "not": {"required": ["lto"]} }, + "features_config": { + "$ref": "./definitions.jsonschema#/boolean_array", + "propertyNames": {"$ref": "./definitions.jsonschema#/snake_case"}, + "not": {"required": ["lto"]} + } }, "type": "object", "not": {"required": ["vendorId", "productId"]}, // reject via keys... "properties": { - "keyboard_name": {"$ref": "qmk.definitions.v1#/text_identifier"}, - "keyboard_folder": {"$ref": "qmk.definitions.v1#/keyboard"}, - "maintainer": {"$ref": "qmk.definitions.v1#/text_identifier"}, - "manufacturer": {"$ref": "qmk.definitions.v1#/text_identifier"}, + "keyboard_name": {"$ref": "./definitions.jsonschema#/text_identifier"}, + "keyboard_folder": {"$ref": "./definitions.jsonschema#/keyboard"}, + "maintainer": {"$ref": "./definitions.jsonschema#/text_identifier"}, + "manufacturer": {"$ref": "./definitions.jsonschema#/text_identifier"}, "url": { "type": "string", "format": "uri" @@ -84,6 +84,7 @@ "STM32F407", "STM32F411", "STM32F446", + "STM32G0B1", "STM32G431", "STM32G474", "STM32H723", @@ -118,8 +119,8 @@ "type": "object", "additionalProperties": false, "properties": { - "data_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"}, - "clock_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"}, + "data_pin": {"$ref": "./definitions.jsonschema#/mcu_pin"}, + "clock_pin": {"$ref": "./definitions.jsonschema#/mcu_pin"}, "default_brightness": { "type": "integer", "minimum": 0, @@ -144,13 +145,13 @@ "enum": ["dac_additive", "dac_basic", "pwm_software", "pwm_hardware"] }, "macro_beep": {"type": "boolean"}, - "pins": {"$ref": "qmk.definitions.v1#/mcu_pin_array"}, + "pins": {"$ref": "./definitions.jsonschema#/mcu_pin_array"}, "power_control": { "type": "object", "additionalProperties": false, "properties": { - "on_state": {"$ref": "qmk.definitions.v1#/bit"}, - "pin": {"$ref": "qmk.definitions.v1#/mcu_pin"} + "on_state": {"$ref": "./definitions.jsonschema#/bit"}, + "pin": {"$ref": "./definitions.jsonschema#/mcu_pin"} } }, "voices": {"type": "boolean"} @@ -170,20 +171,20 @@ "properties": { "on": {"type": "boolean"}, "breathing": {"type": "boolean"}, - "brightness": {"$ref": "qmk.definitions.v1#/unsigned_int_8"} + "brightness": {"$ref": "./definitions.jsonschema#/unsigned_int_8"} } }, "breathing": {"type": "boolean"}, - "breathing_period": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, + "breathing_period": {"$ref": "./definitions.jsonschema#/unsigned_int_8"}, "levels": { "type": "integer", "minimum": 1, "maximum": 31 }, - "max_brightness": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, - "pin": {"$ref": "qmk.definitions.v1#/mcu_pin"}, - "pins": {"$ref": "qmk.definitions.v1#/mcu_pin_array"}, - "on_state": {"$ref": "qmk.definitions.v1#/bit"}, + "max_brightness": {"$ref": "./definitions.jsonschema#/unsigned_int_8"}, + "pin": {"$ref": "./definitions.jsonschema#/mcu_pin"}, + "pins": {"$ref": "./definitions.jsonschema#/mcu_pin_array"}, + "on_state": {"$ref": "./definitions.jsonschema#/bit"}, "as_caps_lock": {"type": "boolean"} } }, @@ -268,7 +269,7 @@ "type": "string", "enum": ["COL2ROW", "ROW2COL"] }, - "debounce": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "debounce": {"$ref": "./definitions.jsonschema#/unsigned_int"}, "caps_word": { "type": "object", "additionalProperties": false, @@ -276,20 +277,20 @@ "enabled": {"type": "boolean"}, "both_shifts_turns_on": {"type": "boolean"}, "double_tap_shift_turns_on": {"type": "boolean"}, - "idle_timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "idle_timeout": {"$ref": "./definitions.jsonschema#/unsigned_int"}, "invert_on_shift": {"type": "boolean"} } }, "combo": { "type": "object", "properties": { - "count": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "term": {"$ref": "qmk.definitions.v1#/unsigned_int"} + "count": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "term": {"$ref": "./definitions.jsonschema#/unsigned_int"} } }, "community_layouts": { "type": "array", - "items": {"$ref": "qmk.definitions.v1#/filename"} + "items": {"$ref": "./definitions.jsonschema#/filename"} }, "dip_switch": { "$ref": "#/definitions/dip_switch_config", @@ -319,10 +320,10 @@ "properties": { "driver": { "type": "string", - "enum": ["custom", "embedded_flash", "legacy", "rp2040_flash", "spi_flash"] + "enum": ["none", "custom", "embedded_flash", "legacy", "rp2040_flash", "spi_flash"] }, - "backing_size": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "logical_size": {"$ref": "qmk.definitions.v1#/unsigned_int"} + "backing_size": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "logical_size": {"$ref": "./definitions.jsonschema#/unsigned_int"} } } } @@ -337,12 +338,12 @@ "indicators": { "type": "object", "properties": { - "caps_lock": {"$ref": "qmk.definitions.v1#/mcu_pin"}, - "num_lock": {"$ref": "qmk.definitions.v1#/mcu_pin"}, - "scroll_lock": {"$ref": "qmk.definitions.v1#/mcu_pin"}, - "compose": {"$ref": "qmk.definitions.v1#/mcu_pin"}, - "kana": {"$ref": "qmk.definitions.v1#/mcu_pin"}, - "on_state": {"$ref": "qmk.definitions.v1#/bit"} + "caps_lock": {"$ref": "./definitions.jsonschema#/mcu_pin"}, + "num_lock": {"$ref": "./definitions.jsonschema#/mcu_pin"}, + "scroll_lock": {"$ref": "./definitions.jsonschema#/mcu_pin"}, + "compose": {"$ref": "./definitions.jsonschema#/mcu_pin"}, + "kana": {"$ref": "./definitions.jsonschema#/mcu_pin"}, + "on_state": {"$ref": "./definitions.jsonschema#/bit"} } }, "joystick": { @@ -350,20 +351,20 @@ "properties": { "enabled": {"type": "boolean"}, "driver": {"type": "string"}, - "button_count": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "axis_resolution": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "button_count": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "axis_resolution": {"$ref": "./definitions.jsonschema#/unsigned_int"}, "axes": { "type": "object", - "propertyNames": {"enum": ["x", "y", "z", "rx", "ry", "rz"]} + "propertyNames": {"enum": ["x", "y", "z", "rx", "ry", "rz"]}, "additionalProperties": { "oneOf": [ { "type": "object", "properties": { - "input_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"}, - "low": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "rest": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "high": {"$ref": "qmk.definitions.v1#/unsigned_int"} + "input_pin": {"$ref": "./definitions.jsonschema#/mcu_pin"}, + "low": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "rest": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "high": {"$ref": "./definitions.jsonschema#/unsigned_int"} } }, { @@ -375,20 +376,20 @@ } } }, - "keycodes": {"$ref": "qmk.definitions.v1#/keycode_decl_array"}, + "keycodes": {"$ref": "./definitions.jsonschema#/keycode_decl_array"}, "layer_lock": { "type": "object", "properties": { - "timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"} + "timeout": {"$ref": "./definitions.jsonschema#/unsigned_int"} } }, "layout_aliases": { "type": "object", - "additionalProperties": {"$ref": "qmk.definitions.v1#/layout_macro"} + "additionalProperties": {"$ref": "./definitions.jsonschema#/layout_macro"} }, "layouts": { "type": "object", - "propertyNames": {"$ref": "qmk.definitions.v1#/layout_macro"}, + "propertyNames": {"$ref": "./definitions.jsonschema#/layout_macro"}, "additionalProperties": { "type": "object", "additionalProperties": false, @@ -403,7 +404,7 @@ "additionalProperties": false, "required": ["x", "y"], "properties": { - "encoder": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "encoder": {"$ref": "./definitions.jsonschema#/unsigned_int"}, "label": { "type": "string", "pattern": "^[^\\n]*$" @@ -417,13 +418,13 @@ "minimum": 0 } }, - "r": {"$ref": "qmk.definitions.v1#/signed_decimal"}, - "rx": {"$ref": "qmk.definitions.v1#/unsigned_decimal"}, - "ry": {"$ref": "qmk.definitions.v1#/unsigned_decimal"}, - "h": {"$ref": "qmk.definitions.v1#/key_unit"}, - "w": {"$ref": "qmk.definitions.v1#/key_unit"}, - "x": {"$ref": "qmk.definitions.v1#/key_unit"}, - "y": {"$ref": "qmk.definitions.v1#/key_unit"}, + "r": {"$ref": "./definitions.jsonschema#/signed_decimal"}, + "rx": {"$ref": "./definitions.jsonschema#/unsigned_decimal"}, + "ry": {"$ref": "./definitions.jsonschema#/unsigned_decimal"}, + "h": {"$ref": "./definitions.jsonschema#/key_unit"}, + "w": {"$ref": "./definitions.jsonschema#/key_unit"}, + "x": {"$ref": "./definitions.jsonschema#/key_unit"}, + "y": {"$ref": "./definitions.jsonschema#/key_unit"}, "hand": { "type": "string", "enum": ["L", "R", "*"] @@ -443,12 +444,24 @@ } } }, + "host": { + "type": "object", + "properties": { + "default": { + "type": "object", + "additionalProperties": false, + "properties": { + "nkro": {"type": "boolean"} + } + } + } + }, "leader_key": { "type": "object", "properties": { "timing": {"type": "boolean"}, "strict_processing": {"type": "boolean"}, - "timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"} + "timeout": {"$ref": "./definitions.jsonschema#/unsigned_int"} } }, "matrix_pins": { @@ -458,14 +471,14 @@ "custom": {"type": "boolean"}, "custom_lite": {"type": "boolean"}, "ghost": {"type": "boolean"}, - "input_pressed_state": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "io_delay": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "input_pressed_state": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "io_delay": {"$ref": "./definitions.jsonschema#/unsigned_int"}, "direct": { "type": "array", - "items": {"$ref": "qmk.definitions.v1#/mcu_pin_array"} + "items": {"$ref": "./definitions.jsonschema#/mcu_pin_array"} }, - "cols": {"$ref": "qmk.definitions.v1#/mcu_pin_array"}, - "rows": {"$ref": "qmk.definitions.v1#/mcu_pin_array"} + "cols": {"$ref": "./definitions.jsonschema#/mcu_pin_array"}, + "rows": {"$ref": "./definitions.jsonschema#/mcu_pin_array"} } }, "modules": { @@ -478,18 +491,18 @@ "type": "object", "properties": { "enabled": {"type": "boolean"}, - "delay": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, - "interval": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, - "max_speed": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, - "time_to_max": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, - "wheel_delay": {"$ref": "qmk.definitions.v1#/unsigned_int_8"} + "delay": {"$ref": "./definitions.jsonschema#/unsigned_int_8"}, + "interval": {"$ref": "./definitions.jsonschema#/unsigned_int_8"}, + "max_speed": {"$ref": "./definitions.jsonschema#/unsigned_int_8"}, + "time_to_max": {"$ref": "./definitions.jsonschema#/unsigned_int_8"}, + "wheel_delay": {"$ref": "./definitions.jsonschema#/unsigned_int_8"} } }, "oneshot": { "type": "object", "properties": { - "tap_toggle": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"} + "tap_toggle": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "timeout": {"$ref": "./definitions.jsonschema#/unsigned_int"} } }, "led_matrix": { @@ -497,7 +510,7 @@ "properties": { "animations": { "type": "object", - "propertyNames": {"$ref": "qmk.definitions.v1#/snake_case"}, + "propertyNames": {"$ref": "./definitions.jsonschema#/snake_case"}, "additionalProperties": {"type": "boolean"} }, "default": { @@ -506,8 +519,8 @@ "properties": { "on": {"type": "boolean"}, "animation": {"type": "string"}, - "val": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, - "speed": {"$ref": "qmk.definitions.v1#/unsigned_int_8"} + "val": {"$ref": "./definitions.jsonschema#/unsigned_int_8"}, + "speed": {"$ref": "./definitions.jsonschema#/unsigned_int_8"} } }, "driver": { @@ -533,27 +546,28 @@ "type": "array", "minItems": 2, "maxItems": 2, - "items": {"$ref": "qmk.definitions.v1#/unsigned_int_8"} + "items": {"$ref": "./definitions.jsonschema#/unsigned_int_8"} }, - "max_brightness": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, - "timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "val_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "speed_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "led_flush_limit": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "led_process_limit": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "max_brightness": {"$ref": "./definitions.jsonschema#/unsigned_int_8"}, + "timeout": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "val_steps": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "speed_steps": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "led_flush_limit": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "led_process_limit": {"$ref": "./definitions.jsonschema#/unsigned_int"}, "react_on_keyup": {"type": "boolean"}, "sleep": {"type": "boolean"}, "split_count": { "type": "array", "minItems": 2, "maxItems": 2, - "items": {"$ref": "qmk.definitions.v1#/unsigned_int"} + "items": {"$ref": "./definitions.jsonschema#/unsigned_int"} }, "layout": { "type": "array", "items": { "type": "object", "additionalProperties": false, + "required": ["x", "y"], "properties": { "matrix": { "type": "array", @@ -564,9 +578,9 @@ "minimum": 0 } }, - "x": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "y": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "flags": {"$ref": "qmk.definitions.v1#/unsigned_int_8"} + "x": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "y": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "flags": {"$ref": "./definitions.jsonschema#/unsigned_int_8"} } } } @@ -577,7 +591,7 @@ "properties": { "animations": { "type": "object", - "propertyNames": {"$ref": "qmk.definitions.v1#/snake_case"}, + "propertyNames": {"$ref": "./definitions.jsonschema#/snake_case"}, "additionalProperties": {"type": "boolean"} }, "default": { @@ -586,10 +600,10 @@ "properties": { "on": {"type": "boolean"}, "animation": {"type": "string"}, - "hue": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, - "sat": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, - "val": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, - "speed": {"$ref": "qmk.definitions.v1#/unsigned_int_8"} + "hue": {"$ref": "./definitions.jsonschema#/unsigned_int_8"}, + "sat": {"$ref": "./definitions.jsonschema#/unsigned_int_8"}, + "val": {"$ref": "./definitions.jsonschema#/unsigned_int_8"}, + "speed": {"$ref": "./definitions.jsonschema#/unsigned_int_8"} } }, "driver": { @@ -617,29 +631,30 @@ "type": "array", "minItems": 2, "maxItems": 2, - "items": {"$ref": "qmk.definitions.v1#/unsigned_int_8"} + "items": {"$ref": "./definitions.jsonschema#/unsigned_int_8"} }, - "max_brightness": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, - "timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "hue_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "sat_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "val_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "speed_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "led_flush_limit": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "led_process_limit": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "max_brightness": {"$ref": "./definitions.jsonschema#/unsigned_int_8"}, + "timeout": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "hue_steps": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "sat_steps": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "val_steps": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "speed_steps": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "led_flush_limit": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "led_process_limit": {"$ref": "./definitions.jsonschema#/unsigned_int"}, "react_on_keyup": {"type": "boolean"}, "sleep": {"type": "boolean"}, "split_count": { "type": "array", "minItems": 2, "maxItems": 2, - "items": {"$ref": "qmk.definitions.v1#/unsigned_int"} + "items": {"$ref": "./definitions.jsonschema#/unsigned_int"} }, "layout": { "type": "array", "items": { "type": "object", "additionalProperties": false, + "required": ["x", "y"], "properties": { "matrix": { "type": "array", @@ -650,9 +665,9 @@ "minimum": 0 } }, - "x": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "y": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "flags": {"$ref": "qmk.definitions.v1#/unsigned_int_8"} + "x": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "y": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "flags": {"$ref": "./definitions.jsonschema#/unsigned_int_8"} } } } @@ -664,27 +679,27 @@ "properties": { "animations": { "type": "object", - "propertyNames": {"$ref": "qmk.definitions.v1#/snake_case"}, + "propertyNames": {"$ref": "./definitions.jsonschema#/snake_case"}, "additionalProperties": {"type": "boolean"} }, - "brightness_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "brightness_steps": {"$ref": "./definitions.jsonschema#/unsigned_int"}, "default": { "type": "object", "additionalProperties": false, "properties": { "on": {"type": "boolean"}, "animation": {"type": "string"}, - "hue": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, - "sat": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, - "val": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, - "speed": {"$ref": "qmk.definitions.v1#/unsigned_int_8"} + "hue": {"$ref": "./definitions.jsonschema#/unsigned_int_8"}, + "sat": {"$ref": "./definitions.jsonschema#/unsigned_int_8"}, + "val": {"$ref": "./definitions.jsonschema#/unsigned_int_8"}, + "speed": {"$ref": "./definitions.jsonschema#/unsigned_int_8"} } }, "driver": { "type": "string", "enum": ["apa102", "custom", "ws2812"] }, - "hue_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "hue_steps": {"$ref": "./definitions.jsonschema#/unsigned_int"}, "layers": { "type": "object", "additionalProperties": false, @@ -699,29 +714,29 @@ "override_rgb": {"type": "boolean"} } }, - "led_count": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "led_count": {"$ref": "./definitions.jsonschema#/unsigned_int"}, "led_map": { "type": "array", "minItems": 2, - "items": {"$ref": "qmk.definitions.v1#/unsigned_int"} + "items": {"$ref": "./definitions.jsonschema#/unsigned_int"} }, - "max_brightness": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, + "max_brightness": {"$ref": "./definitions.jsonschema#/unsigned_int_8"}, "pin": { - "$ref": "qmk.definitions.v1#/mcu_pin", + "$ref": "./definitions.jsonschema#/mcu_pin", "$comment": "Deprecated: use ws2812.pin instead" }, "rgbw": { "type": "boolean", "$comment": "Deprecated: use ws2812.rgbw instead" }, - "saturation_steps": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "saturation_steps": {"$ref": "./definitions.jsonschema#/unsigned_int"}, "sleep": {"type": "boolean"}, "split": {"type": "boolean"}, "split_count": { "type": "array", "minItems": 2, "maxItems": 2, - "items": {"$ref": "qmk.definitions.v1#/unsigned_int"} + "items": {"$ref": "./definitions.jsonschema#/unsigned_int"} } } }, @@ -730,8 +745,8 @@ "additionalProperties": false, "properties": { "enabled": {"type": "boolean"}, - "unlock_timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "idle_timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "unlock_timeout": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "idle_timeout": {"$ref": "./definitions.jsonschema#/unsigned_int"}, "unlock_sequence": { "type": "array", "minItems": 1, @@ -765,8 +780,8 @@ "properties": { "enabled": {"type": "boolean"}, "mouse_enabled": {"type": "boolean"}, - "clock_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"}, - "data_pin": {"$ref": "qmk.definitions.v1#/mcu_pin"}, + "clock_pin": {"$ref": "./definitions.jsonschema#/mcu_pin"}, + "data_pin": {"$ref": "./definitions.jsonschema#/mcu_pin"}, "driver": { "type": "string", "enum": ["busywait", "interrupt", "usart", "vendor"] @@ -803,11 +818,11 @@ "properties": { "direct": { "type": "array", - "items": {"$ref": "qmk.definitions.v1#/mcu_pin_array"} + "items": {"$ref": "./definitions.jsonschema#/mcu_pin_array"} }, - "cols": {"$ref": "qmk.definitions.v1#/mcu_pin_array"}, - "rows": {"$ref": "qmk.definitions.v1#/mcu_pin_array"}, - "unused": {"$ref": "qmk.definitions.v1#/mcu_pin_array"} + "cols": {"$ref": "./definitions.jsonschema#/mcu_pin_array"}, + "rows": {"$ref": "./definitions.jsonschema#/mcu_pin_array"}, + "unused": {"$ref": "./definitions.jsonschema#/mcu_pin_array"} } } } @@ -834,16 +849,16 @@ "type": "object", "additionalProperties": false, "properties": { - "pin": {"$ref": "qmk.definitions.v1#/mcu_pin"}, + "pin": {"$ref": "./definitions.jsonschema#/mcu_pin"}, "matrix_grid": { - "$ref": "qmk.definitions.v1#/mcu_pin_array", + "$ref": "./definitions.jsonschema#/mcu_pin_array", "minItems": 2, "maxItems": 2 } } }, "soft_serial_pin": { - "$ref": "qmk.definitions.v1#/mcu_pin", + "$ref": "./definitions.jsonschema#/mcu_pin", "$comment": "Deprecated: use split.serial.pin instead" }, "soft_serial_speed": { @@ -859,7 +874,7 @@ "type": "string", "enum": ["bitbang", "usart", "vendor"] }, - "pin": {"$ref": "qmk.definitions.v1#/mcu_pin"} + "pin": {"$ref": "./definitions.jsonschema#/mcu_pin"} } }, "transport": { @@ -887,7 +902,7 @@ } }, "watchdog": {"type": "boolean"}, - "watchdog_timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "watchdog_timeout": {"$ref": "./definitions.jsonschema#/unsigned_int"}, "sync_matrix_state": { "type": "boolean", "$comment": "Deprecated: use sync.matrix_state instead" @@ -903,8 +918,8 @@ "additionalProperties": false, "properties": { "enabled": {"type": "boolean"}, - "polling_interval": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"} + "polling_interval": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "timeout": {"$ref": "./definitions.jsonschema#/unsigned_int"} } }, "main": { @@ -914,7 +929,7 @@ }, "matrix_grid": { "type": "array", - "items": {"$ref": "qmk.definitions.v1#/mcu_pin"}, + "items": {"$ref": "./definitions.jsonschema#/mcu_pin"}, "$comment": "Deprecated: use split.handedness.matrix_grid instead" } } @@ -936,9 +951,9 @@ "permissive_hold_per_key": {"type": "boolean"}, "retro": {"type": "boolean"}, "retro_per_key": {"type": "boolean"}, - "term": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "term": {"$ref": "./definitions.jsonschema#/unsigned_int"}, "term_per_key": {"type": "boolean"}, - "toggle": {"$ref": "qmk.definitions.v1#/unsigned_int"} + "toggle": {"$ref": "./definitions.jsonschema#/unsigned_int"} } }, "usb": { @@ -946,16 +961,20 @@ "additionalProperties": false, "properties": { "device_ver": { - "$ref": "qmk.definitions.v1#/hex_number_4d", + "$ref": "./definitions.jsonschema#/hex_number_4d", "$comment": "Deprecated: use device_version instead" }, - "device_version": {"$ref": "qmk.definitions.v1#/bcd_version"}, - "force_nkro": {"type": "boolean"}, - "pid": {"$ref": "qmk.definitions.v1#/hex_number_4d"}, - "vid": {"$ref": "qmk.definitions.v1#/hex_number_4d"}, - "max_power": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "device_version": {"$ref": "./definitions.jsonschema#/bcd_version"}, + "force_nkro": { + "type": "boolean", + "$comment": "Deprecated: use host.default.nkro instead" + + }, + "pid": {"$ref": "./definitions.jsonschema#/hex_number_4d"}, + "vid": {"$ref": "./definitions.jsonschema#/hex_number_4d"}, + "max_power": {"$ref": "./definitions.jsonschema#/unsigned_int"}, "no_startup_check": {"type": "boolean"}, - "polling_interval": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, + "polling_interval": {"$ref": "./definitions.jsonschema#/unsigned_int_8"}, "shared_endpoint": { "type": "object", "additionalProperties": false, @@ -964,7 +983,7 @@ "mouse": {"type": "boolean"} } }, - "suspend_wakeup_delay": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "suspend_wakeup_delay": {"$ref": "./definitions.jsonschema#/unsigned_int"}, "wait_for_enumeration": {"type": "boolean"} } }, @@ -972,9 +991,9 @@ "type": "object", "additionalProperties": false, "properties": { - "keys_per_scan": {"$ref": "qmk.definitions.v1#/unsigned_int_8"}, - "tap_keycode_delay": {"$ref": "qmk.definitions.v1#/unsigned_int"}, - "tap_capslock_delay": {"$ref": "qmk.definitions.v1#/unsigned_int"}, + "keys_per_scan": {"$ref": "./definitions.jsonschema#/unsigned_int_8"}, + "tap_keycode_delay": {"$ref": "./definitions.jsonschema#/unsigned_int"}, + "tap_capslock_delay": {"$ref": "./definitions.jsonschema#/unsigned_int"}, "locking": { "type": "object", "additionalProperties": false, @@ -989,10 +1008,10 @@ "type": "object", "additionalProperties": false, "properties": { - "esc_output": {"$ref": "qmk.definitions.v1#/mcu_pin"}, - "esc_input": {"$ref": "qmk.definitions.v1#/mcu_pin"}, - "led": {"$ref": "qmk.definitions.v1#/mcu_pin"}, - "speaker": {"$ref": "qmk.definitions.v1#/mcu_pin"} + "esc_output": {"$ref": "./definitions.jsonschema#/mcu_pin"}, + "esc_input": {"$ref": "./definitions.jsonschema#/mcu_pin"}, + "led": {"$ref": "./definitions.jsonschema#/mcu_pin"}, + "speaker": {"$ref": "./definitions.jsonschema#/mcu_pin"} } }, "ws2812": { @@ -1003,10 +1022,10 @@ "type": "string", "enum": ["bitbang", "custom", "i2c", "pwm", "spi", "vendor"] }, - "pin": {"$ref": "qmk.definitions.v1#/mcu_pin"}, + "pin": {"$ref": "./definitions.jsonschema#/mcu_pin"}, "rgbw": {"type": "boolean"}, - "i2c_address": {"$ref": "qmk.definitions.v1#/hex_number_2d"}, - "i2c_timeout": {"$ref": "qmk.definitions.v1#/unsigned_int"} + "i2c_address": {"$ref": "./definitions.jsonschema#/hex_number_2d"}, + "i2c_timeout": {"$ref": "./definitions.jsonschema#/unsigned_int"} } } } diff --git a/data/schemas/keycodes.jsonschema b/data/schemas/keycodes.jsonschema index df6ce95a83..0f9dfc763e 100644 --- a/data/schemas/keycodes.jsonschema +++ b/data/schemas/keycodes.jsonschema @@ -30,10 +30,10 @@ "keycodes": { "type": "object", "propertyNames": { - "$ref": "qmk.definitions.v1#/hex_number_4d" + "$ref": "./definitions.jsonschema#/hex_number_4d" }, "additionalProperties": { - "type": "object", // use 'qmk.definitions.v1#/keycode_decl' when problem keycodes are removed + "type": "object", // use './definitions.jsonschema#/keycode_decl' when problem keycodes are removed "required": [ "key" ], diff --git a/data/schemas/keymap.jsonschema b/data/schemas/keymap.jsonschema index b92a536c2c..99aeaa6b6c 100644 --- a/data/schemas/keymap.jsonschema +++ b/data/schemas/keymap.jsonschema @@ -10,10 +10,10 @@ "minLength": 1, "pattern": "^[a-z][0-9a-z_]*$" }, - "host_language": {"$ref": "qmk.definitions.v1#/text_identifier"}, - "keyboard": {"$ref": "qmk.definitions.v1#/text_identifier"}, - "keymap": {"$ref": "qmk.definitions.v1#/text_identifier"}, - "layout": {"$ref": "qmk.definitions.v1#/layout_macro"}, + "host_language": {"$ref": "./definitions.jsonschema#/text_identifier"}, + "keyboard": {"$ref": "./definitions.jsonschema#/text_identifier"}, + "keymap": {"$ref": "./definitions.jsonschema#/text_identifier"}, + "layout": {"$ref": "./definitions.jsonschema#/layout_macro"}, "layers": { "type": "array", "items": { @@ -55,11 +55,11 @@ "keycodes": { "type": "array", "items": { - "$ref": "qmk.definitions.v1#/text_identifier" + "$ref": "./definitions.jsonschema#/text_identifier" } }, "duration": { - "$ref": "qmk.definitions.v1#/unsigned_int" + "$ref": "./definitions.jsonschema#/unsigned_int" } } } @@ -67,8 +67,8 @@ } } }, - "keycodes": {"$ref": "qmk.definitions.v1#/keycode_decl_array"}, - "config": {"$ref": "qmk.keyboard.v1"}, + "keycodes": {"$ref": "./definitions.jsonschema#/keycode_decl_array"}, + "config": {"$ref": "./keyboard.jsonschema#"}, "notes": { "type": "string" }, diff --git a/data/schemas/user_repo_v0.jsonschema b/data/schemas/user_repo_v0.jsonschema index b18ac50428..58d955abe2 100644 --- a/data/schemas/user_repo_v0.jsonschema +++ b/data/schemas/user_repo_v0.jsonschema @@ -8,7 +8,7 @@ ], "properties": { "userspace_version": { - "type": "string", - }, + "type": "string" + } } } diff --git a/data/schemas/user_repo_v1.jsonschema b/data/schemas/user_repo_v1.jsonschema index 69a59bce00..07c61d0fea 100644 --- a/data/schemas/user_repo_v1.jsonschema +++ b/data/schemas/user_repo_v1.jsonschema @@ -6,10 +6,10 @@ "definitions": { "build_target": { "oneOf": [ - {"$ref": "qmk.definitions.v1#/keyboard_keymap_tuple"}, - {"$ref": "qmk.definitions.v1#/json_file_path"} + {"$ref": "./definitions.jsonschema#/keyboard_keymap_tuple"}, + {"$ref": "./definitions.jsonschema#/json_file_path"} ] - }, + } }, "required": [ "userspace_version", diff --git a/data/schemas/user_repo_v1_1.jsonschema b/data/schemas/user_repo_v1_1.jsonschema index 5a7ccce063..cd6d89ad81 100644 --- a/data/schemas/user_repo_v1_1.jsonschema +++ b/data/schemas/user_repo_v1_1.jsonschema @@ -6,11 +6,11 @@ "definitions": { "build_target": { "oneOf": [ - {"$ref": "qmk.definitions.v1#/keyboard_keymap_tuple"}, - {"$ref": "qmk.definitions.v1#/keyboard_keymap_env"}, - {"$ref": "qmk.definitions.v1#/json_file_path"} + {"$ref": "./definitions.jsonschema#/keyboard_keymap_tuple"}, + {"$ref": "./definitions.jsonschema#/keyboard_keymap_env"}, + {"$ref": "./definitions.jsonschema#/json_file_path"} ] - }, + } }, "required": [ "userspace_version", diff --git a/data/templates/keyboard/keyboard.json b/data/templates/keyboard/keyboard.json index 94085d7f5a..87aa853cbb 100644 --- a/data/templates/keyboard/keyboard.json +++ b/data/templates/keyboard/keyboard.json @@ -14,8 +14,6 @@ }, "features": { "bootmagic": true, - "command": false, - "console": false, "extrakey": true, "mousekey": true, "nkro": true diff --git a/drivers/battery/battery.c b/drivers/battery/battery.c new file mode 100644 index 0000000000..faf3c5a214 --- /dev/null +++ b/drivers/battery/battery.c @@ -0,0 +1,41 @@ +// Copyright 2025 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "battery_driver.h" +#include "battery.h" +#include "timer.h" + +#ifndef BATTERY_SAMPLE_INTERVAL +# define BATTERY_SAMPLE_INTERVAL 30000 +#endif + +static uint8_t last_bat_level = 100; + +void battery_init(void) { + battery_driver_init(); + + last_bat_level = battery_driver_sample_percent(); +} + +__attribute__((weak)) void battery_percent_changed_user(uint8_t level) {} +__attribute__((weak)) void battery_percent_changed_kb(uint8_t level) {} + +static void handle_percent_changed(void) { + battery_percent_changed_user(last_bat_level); + battery_percent_changed_kb(last_bat_level); +} + +void battery_task(void) { + static uint32_t bat_timer = 0; + if (timer_elapsed32(bat_timer) > BATTERY_SAMPLE_INTERVAL) { + last_bat_level = battery_driver_sample_percent(); + + handle_percent_changed(); + + bat_timer = timer_read32(); + } +} + +uint8_t battery_get_percent(void) { + return last_bat_level; +} diff --git a/drivers/battery/battery.h b/drivers/battery/battery.h new file mode 100644 index 0000000000..0985723eaa --- /dev/null +++ b/drivers/battery/battery.h @@ -0,0 +1,46 @@ +// Copyright 2025 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include + +/** + * \file + * + * \defgroup battery Battery API + * + * \brief API to query battery status. + * \{ + */ + +/** + * \brief Initialize the battery driver. + */ +void battery_init(void); + +/** + * \brief Perform housekeeping tasks. + */ +void battery_task(void); + +/** + * \brief Sample battery level. + * + * \return The battery percentage, in the range 0-100. + */ +uint8_t battery_get_percent(void); + +/** + * \brief user hook called when battery level changed. + * + */ +void battery_percent_changed_user(uint8_t level); + +/** + * \brief keyboard hook called when battery level changed. + * + */ +void battery_percent_changed_kb(uint8_t level); + +/** \} */ diff --git a/drivers/battery/battery_adc.c b/drivers/battery/battery_adc.c new file mode 100644 index 0000000000..cf0e69cb48 --- /dev/null +++ b/drivers/battery/battery_adc.c @@ -0,0 +1,55 @@ +// Copyright 2025 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "analog.h" +#include "gpio.h" + +#ifndef BATTERY_PIN +# error("BATTERY_PIN not configured!") +#endif + +#ifndef BATTERY_REF_VOLTAGE_MV +# define BATTERY_REF_VOLTAGE_MV 3300 +#endif + +#ifndef BATTERY_VOLTAGE_DIVIDER_R1 +# define BATTERY_VOLTAGE_DIVIDER_R1 100 +#endif + +#ifndef BATTERY_VOLTAGE_DIVIDER_R2 +# define BATTERY_VOLTAGE_DIVIDER_R2 100 +#endif + +// TODO: infer from adc config? +#ifndef BATTERY_ADC_RESOLUTION +# define BATTERY_ADC_RESOLUTION 10 +#endif + +void battery_driver_init(void) { + gpio_set_pin_input(BATTERY_PIN); +} + +uint16_t battery_driver_get_mv(void) { + uint32_t raw = analogReadPin(BATTERY_PIN); + + uint32_t bat_mv = raw * BATTERY_REF_VOLTAGE_MV / (1 << BATTERY_ADC_RESOLUTION); + +#if BATTERY_VOLTAGE_DIVIDER_R1 > 0 && BATTERY_VOLTAGE_DIVIDER_R2 > 0 + bat_mv = bat_mv * (BATTERY_VOLTAGE_DIVIDER_R1 + BATTERY_VOLTAGE_DIVIDER_R2) / BATTERY_VOLTAGE_DIVIDER_R2; +#endif + + return bat_mv; +} + +uint8_t battery_driver_sample_percent(void) { + uint16_t bat_mv = battery_driver_get_mv(); + + // https://github.com/zmkfirmware/zmk/blob/3f7c9d7cc4f46617faad288421025ea2a6b0bd28/app/module/drivers/sensor/battery/battery_common.c#L33 + if (bat_mv >= 4200) { + return 100; + } else if (bat_mv <= 3450) { + return 0; + } + + return bat_mv * 2 / 15 - 459; +} diff --git a/drivers/battery/battery_driver.h b/drivers/battery/battery_driver.h new file mode 100644 index 0000000000..c2ee75e966 --- /dev/null +++ b/drivers/battery/battery_driver.h @@ -0,0 +1,29 @@ +// Copyright 2025 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include + +/** + * \file + * + * \defgroup battery Battery Driver API + * + * \brief API to query battery status. + * \{ + */ + +/** + * \brief Initialize the battery driver. This function must be called only once, before any of the below functions can be called. + */ +void battery_driver_init(void); + +/** + * \brief Sample battery level. + * + * \return The battery percentage, in the range 0-100. + */ +uint8_t battery_driver_sample_percent(void); + +/** \} */ diff --git a/drivers/bluetooth/bluefruit_le.cpp b/drivers/bluetooth/bluefruit_le.cpp index 218eca2195..5fdd104dcf 100644 --- a/drivers/bluetooth/bluefruit_le.cpp +++ b/drivers/bluetooth/bluefruit_le.cpp @@ -32,13 +32,8 @@ # define BLUEFRUIT_LE_SCK_DIVISOR 2 // 4MHz SCK/8MHz CPU, calculated for Feather 32U4 BLE #endif -#define SAMPLE_BATTERY #define ConnectionUpdateInterval 1000 /* milliseconds */ -#ifndef BATTERY_LEVEL_PIN -# define BATTERY_LEVEL_PIN B5 -#endif - static struct { bool is_connected; bool initialized; @@ -48,10 +43,6 @@ static struct { #define UsingEvents 2 bool event_flags; -#ifdef SAMPLE_BATTERY - uint16_t last_battery_update; - uint32_t vbat; -#endif uint16_t last_connection_update; } state; @@ -549,14 +540,6 @@ void bluefruit_le_task(void) { set_connected(atoi(resbuf)); } } - -#ifdef SAMPLE_BATTERY - if (timer_elapsed(state.last_battery_update) > BatteryUpdateInterval && resp_buf.empty()) { - state.last_battery_update = timer_read(); - - state.vbat = analogReadPin(BATTERY_LEVEL_PIN); - } -#endif } static bool process_queue_item(struct queue_item *item, uint16_t timeout) { @@ -655,10 +638,6 @@ void bluefruit_le_send_mouse(report_mouse_t *report) { } } -uint32_t bluefruit_le_read_battery_voltage(void) { - return state.vbat; -} - bool bluefruit_le_set_mode_leds(bool on) { if (!state.configured) { return false; diff --git a/drivers/bluetooth/bluefruit_le.h b/drivers/bluetooth/bluefruit_le.h index a3de03c35c..5efe92b6e0 100644 --- a/drivers/bluetooth/bluefruit_le.h +++ b/drivers/bluetooth/bluefruit_le.h @@ -45,10 +45,6 @@ extern void bluefruit_le_send_consumer(uint16_t usage); * change. */ extern void bluefruit_le_send_mouse(report_mouse_t *report); -/* Compute battery voltage by reading an analog pin. - * Returns the integer number of millivolts */ -extern uint32_t bluefruit_le_read_battery_voltage(void); - extern bool bluefruit_le_set_mode_leds(bool on); extern bool bluefruit_le_set_power_level(int8_t level); diff --git a/drivers/bluetooth/bluetooth.c b/drivers/bluetooth/bluetooth.c index d5382401e7..e61e24e1f2 100644 --- a/drivers/bluetooth/bluetooth.c +++ b/drivers/bluetooth/bluetooth.c @@ -1,62 +1,32 @@ -/* - * Copyright 2022 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ +// Copyright 2025 QMK +// SPDX-License-Identifier: GPL-2.0-or-later #include "bluetooth.h" -#if defined(BLUETOOTH_BLUEFRUIT_LE) -# include "bluefruit_le.h" -#elif defined(BLUETOOTH_RN42) -# include "rn42.h" -#endif +__attribute__((weak)) void bluetooth_init(void) {} -void bluetooth_init(void) { -#if defined(BLUETOOTH_BLUEFRUIT_LE) - bluefruit_le_init(); -#elif defined(BLUETOOTH_RN42) - rn42_init(); -#endif +__attribute__((weak)) void bluetooth_task(void) {} + +__attribute__((weak)) bool bluetooth_is_connected(void) { + return true; } -void bluetooth_task(void) { -#if defined(BLUETOOTH_BLUEFRUIT_LE) - bluefruit_le_task(); -#endif +__attribute__((weak)) bool bluetooth_can_send_nkro(void) { + return false; } -void bluetooth_send_keyboard(report_keyboard_t *report) { -#if defined(BLUETOOTH_BLUEFRUIT_LE) - bluefruit_le_send_keyboard(report); -#elif defined(BLUETOOTH_RN42) - rn42_send_keyboard(report); -#endif +__attribute__((weak)) uint8_t bluetooth_keyboard_leds(void) { + return 0; } -void bluetooth_send_mouse(report_mouse_t *report) { -#if defined(BLUETOOTH_BLUEFRUIT_LE) - bluefruit_le_send_mouse(report); -#elif defined(BLUETOOTH_RN42) - rn42_send_mouse(report); -#endif -} +__attribute__((weak)) void bluetooth_send_keyboard(report_keyboard_t *report) {} -void bluetooth_send_consumer(uint16_t usage) { -#if defined(BLUETOOTH_BLUEFRUIT_LE) - bluefruit_le_send_consumer(usage); -#elif defined(BLUETOOTH_RN42) - rn42_send_consumer(usage); -#endif -} +__attribute__((weak)) void bluetooth_send_nkro(report_nkro_t *report) {} + +__attribute__((weak)) void bluetooth_send_mouse(report_mouse_t *report) {} + +__attribute__((weak)) void bluetooth_send_consumer(uint16_t usage) {} + +__attribute__((weak)) void bluetooth_send_system(uint16_t usage) {} + +__attribute__((weak)) void bluetooth_send_raw_hid(uint8_t *data, uint8_t length) {} diff --git a/drivers/bluetooth/bluetooth.h b/drivers/bluetooth/bluetooth.h index 2e4d0df538..bbd41a9194 100644 --- a/drivers/bluetooth/bluetooth.h +++ b/drivers/bluetooth/bluetooth.h @@ -30,6 +30,23 @@ void bluetooth_init(void); */ void bluetooth_task(void); +/** + * \brief Detects if Bluetooth is connected. + * + * \return `true` if connected, `false` otherwise. + */ +bool bluetooth_is_connected(void); + +/** + * \brief Detects if `bluetooth_send_nkro` should be used over `bluetooth_send_keyboard`. + */ +bool bluetooth_can_send_nkro(void); + +/** + * \brief Get current LED state. + */ +uint8_t bluetooth_keyboard_leds(void); + /** * \brief Send a keyboard report. * @@ -37,6 +54,13 @@ void bluetooth_task(void); */ void bluetooth_send_keyboard(report_keyboard_t *report); +/** + * \brief Send a nkro report. + * + * \param report The nkro report to send. + */ +void bluetooth_send_nkro(report_nkro_t *report); + /** * \brief Send a mouse report. * @@ -50,3 +74,18 @@ void bluetooth_send_mouse(report_mouse_t *report); * \param usage The consumer usage to send. */ void bluetooth_send_consumer(uint16_t usage); + +/** + * \brief Send a system usage. + * + * \param usage The system usage to send. + */ +void bluetooth_send_system(uint16_t usage); + +/** + * \brief Send a raw_hid packet. + * + * \param data A pointer to the buffer to be sent. Always 32 bytes in length. + * \param length The length of the buffer. Always 32. + */ +void bluetooth_send_raw_hid(uint8_t *data, uint8_t length); diff --git a/drivers/bluetooth/bluetooth_drivers.c b/drivers/bluetooth/bluetooth_drivers.c new file mode 100644 index 0000000000..b91d4501e6 --- /dev/null +++ b/drivers/bluetooth/bluetooth_drivers.c @@ -0,0 +1,71 @@ +/* + * Copyright 2022 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "bluetooth.h" + +#if defined(BLUETOOTH_BLUEFRUIT_LE) +# include "bluefruit_le.h" +#elif defined(BLUETOOTH_RN42) +# include "rn42.h" +#endif + +void bluetooth_init(void) { +#if defined(BLUETOOTH_BLUEFRUIT_LE) + bluefruit_le_init(); +#elif defined(BLUETOOTH_RN42) + rn42_init(); +#endif +} + +void bluetooth_task(void) { +#if defined(BLUETOOTH_BLUEFRUIT_LE) + bluefruit_le_task(); +#endif +} + +bool bluetooth_is_connected(void) { +#if defined(BLUETOOTH_BLUEFRUIT_LE) + return bluefruit_le_is_connected(); +#else + // TODO: drivers should check if BT is connected here + return true; +#endif +} + +void bluetooth_send_keyboard(report_keyboard_t *report) { +#if defined(BLUETOOTH_BLUEFRUIT_LE) + bluefruit_le_send_keyboard(report); +#elif defined(BLUETOOTH_RN42) + rn42_send_keyboard(report); +#endif +} + +void bluetooth_send_mouse(report_mouse_t *report) { +#if defined(BLUETOOTH_BLUEFRUIT_LE) + bluefruit_le_send_mouse(report); +#elif defined(BLUETOOTH_RN42) + rn42_send_mouse(report); +#endif +} + +void bluetooth_send_consumer(uint16_t usage) { +#if defined(BLUETOOTH_BLUEFRUIT_LE) + bluefruit_le_send_consumer(usage); +#elif defined(BLUETOOTH_RN42) + rn42_send_consumer(usage); +#endif +} diff --git a/drivers/bluetooth/outputselect.c b/drivers/bluetooth/outputselect.c deleted file mode 100644 index b986ba274e..0000000000 --- a/drivers/bluetooth/outputselect.c +++ /dev/null @@ -1,70 +0,0 @@ -/* -Copyright 2017 Priyadi Iman Nurcahyo -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 2 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ - -#include "outputselect.h" -#include "usb_util.h" - -#ifdef BLUETOOTH_BLUEFRUIT_LE -# include "bluefruit_le.h" -#endif - -uint8_t desired_output = OUTPUT_DEFAULT; - -/** \brief Set Output - * - * FIXME: Needs doc - */ -void set_output(uint8_t output) { - set_output_user(output); - desired_output = output; -} - -/** \brief Set Output User - * - * FIXME: Needs doc - */ -__attribute__((weak)) void set_output_user(uint8_t output) {} - -/** \brief Auto Detect Output - * - * FIXME: Needs doc - */ -uint8_t auto_detect_output(void) { - if (usb_connected_state()) { - return OUTPUT_USB; - } - -#ifdef BLUETOOTH_BLUEFRUIT_LE - if (bluefruit_le_is_connected()) { - return OUTPUT_BLUETOOTH; - } -#endif - -#ifdef BLUETOOTH_ENABLE - return OUTPUT_BLUETOOTH; // should check if BT is connected here -#endif - - return OUTPUT_NONE; -} - -/** \brief Where To Send - * - * FIXME: Needs doc - */ -uint8_t where_to_send(void) { - if (desired_output == OUTPUT_AUTO) { - return auto_detect_output(); - } - return desired_output; -} diff --git a/drivers/bluetooth/outputselect.h b/drivers/bluetooth/outputselect.h index c4548e1122..25f063bbff 100644 --- a/drivers/bluetooth/outputselect.h +++ b/drivers/bluetooth/outputselect.h @@ -14,21 +14,17 @@ along with this program. If not, see . #pragma once -#include +#include "connection.h" -enum outputs { - OUTPUT_AUTO, +// DEPRECATED - DO NOT USE - OUTPUT_NONE, - OUTPUT_USB, - OUTPUT_BLUETOOTH -}; +#define OUTPUT_AUTO CONNECTION_HOST_AUTO +#define OUTPUT_NONE CONNECTION_HOST_NONE +#define OUTPUT_USB CONNECTION_HOST_USB +#define OUTPUT_BLUETOOTH CONNECTION_HOST_BLUETOOTH -#ifndef OUTPUT_DEFAULT -# define OUTPUT_DEFAULT OUTPUT_AUTO -#endif +#define set_output connection_set_host_noeeprom +#define where_to_send connection_get_host +#define auto_detect_output connection_auto_detect_host -void set_output(uint8_t output); -void set_output_user(uint8_t output); -uint8_t auto_detect_output(void); -uint8_t where_to_send(void); +void set_output_user(uint8_t output); diff --git a/drivers/eeprom/eeprom_transient.h b/drivers/eeprom/eeprom_transient.h index 687b8619fe..0483fd58b9 100644 --- a/drivers/eeprom/eeprom_transient.h +++ b/drivers/eeprom/eeprom_transient.h @@ -20,6 +20,6 @@ The size of the transient EEPROM buffer size. */ #ifndef TRANSIENT_EEPROM_SIZE -# include "eeconfig.h" +# include "nvm_eeprom_eeconfig_internal.h" # define TRANSIENT_EEPROM_SIZE (((EECONFIG_SIZE + 3) / 4) * 4) // based off eeconfig's current usage, aligned to 4-byte sizes, to deal with LTO #endif diff --git a/drivers/lcd/st7565.c b/drivers/lcd/st7565.c index cf71c5e5a3..f24bb78048 100644 --- a/drivers/lcd/st7565.c +++ b/drivers/lcd/st7565.c @@ -19,6 +19,7 @@ along with this program. If not, see . #include +#include "compiler_support.h" #include "keyboard.h" #include "progmem.h" #include "timer.h" @@ -265,7 +266,7 @@ void st7565_write_char(const char data, bool invert) { static uint8_t st7565_temp_buffer[ST7565_FONT_WIDTH]; memcpy(&st7565_temp_buffer, st7565_cursor, ST7565_FONT_WIDTH); - _Static_assert(sizeof(font) >= ((ST7565_FONT_END + 1 - ST7565_FONT_START) * ST7565_FONT_WIDTH), "ST7565_FONT_END references outside array"); + STATIC_ASSERT(sizeof(font) >= ((ST7565_FONT_END + 1 - ST7565_FONT_START) * ST7565_FONT_WIDTH), "ST7565_FONT_END references outside array"); // set the reder buffer data uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c index 1d1c2a90c4..7e46bcb3f7 100644 --- a/drivers/oled/oled_driver.c +++ b/drivers/oled/oled_driver.c @@ -23,6 +23,8 @@ along with this program. If not, see . # include "keyboard.h" # endif #endif + +#include "compiler_support.h" #include "oled_driver.h" #include OLED_FONT_H #include "timer.h" @@ -601,7 +603,7 @@ void oled_write_char(const char data, bool invert) { static uint8_t oled_temp_buffer[OLED_FONT_WIDTH]; memcpy(&oled_temp_buffer, oled_cursor, OLED_FONT_WIDTH); - _Static_assert(sizeof(font) >= ((OLED_FONT_END + 1 - OLED_FONT_START) * OLED_FONT_WIDTH), "OLED_FONT_END references outside array"); + STATIC_ASSERT(sizeof(font) >= ((OLED_FONT_END + 1 - OLED_FONT_START) * OLED_FONT_WIDTH), "OLED_FONT_END references outside array"); // set the reder buffer data uint8_t cast_data = (uint8_t)data; // font based on unsigned type for index diff --git a/drivers/painter/gc9xxx/qp_gc9a01_opcodes.h b/drivers/painter/gc9xxx/qp_gc9a01_opcodes.h index 5853902e68..31de5ee9e3 100644 --- a/drivers/painter/gc9xxx/qp_gc9a01_opcodes.h +++ b/drivers/painter/gc9xxx/qp_gc9a01_opcodes.h @@ -101,4 +101,4 @@ #define GC9A01_GRAM_INTERFACE_RGB 0b00000010 #define GC9A01_RGB_INTERFACE_MODE_1_TRANSFER 0b00000000 -#define GC9A01_RGB_INTERFACE_MODE_3_TRANSFER 0b00000001 \ No newline at end of file +#define GC9A01_RGB_INTERFACE_MODE_3_TRANSFER 0b00000001 diff --git a/drivers/painter/ili9xxx/qp_ili9486.c b/drivers/painter/ili9xxx/qp_ili9486.c index c4f3c15cec..48db779c04 100644 --- a/drivers/painter/ili9xxx/qp_ili9486.c +++ b/drivers/painter/ili9xxx/qp_ili9486.c @@ -75,9 +75,9 @@ static void qp_comms_spi_dc_reset_send_command_odd_cs_pulse(painter_device_t dev painter_driver_t * driver = (painter_driver_t *)device; qp_comms_spi_dc_reset_config_t *comms_config = (qp_comms_spi_dc_reset_config_t *)driver->comms_config; - writePinLow(comms_config->spi_config.chip_select_pin); + gpio_write_pin_low(comms_config->spi_config.chip_select_pin); qp_comms_spi_dc_reset_send_command(device, cmd); - writePinHigh(comms_config->spi_config.chip_select_pin); + gpio_write_pin_high(comms_config->spi_config.chip_select_pin); } static uint32_t qp_comms_spi_send_data_odd_cs_pulse(painter_device_t device, const void *data, uint32_t byte_count) { @@ -88,20 +88,20 @@ static uint32_t qp_comms_spi_send_data_odd_cs_pulse(painter_device_t device, con const uint8_t *p = (const uint8_t *)data; uint32_t max_msg_length = 1024; - writePinHigh(comms_config->dc_pin); + gpio_write_pin_high(comms_config->dc_pin); while (bytes_remaining > 0) { uint32_t bytes_this_loop = QP_MIN(bytes_remaining, max_msg_length); bool odd_bytes = bytes_this_loop & 1; // send data - writePinLow(comms_config->spi_config.chip_select_pin); + gpio_write_pin_low(comms_config->spi_config.chip_select_pin); spi_transmit(p, bytes_this_loop); p += bytes_this_loop; // extra CS toggle, for alignment if (odd_bytes) { - writePinHigh(comms_config->spi_config.chip_select_pin); - writePinLow(comms_config->spi_config.chip_select_pin); + gpio_write_pin_high(comms_config->spi_config.chip_select_pin); + gpio_write_pin_low(comms_config->spi_config.chip_select_pin); } bytes_remaining -= bytes_this_loop; @@ -116,9 +116,9 @@ static uint32_t qp_ili9486_send_data_toggling(painter_device_t device, const uin uint32_t ret; for (uint8_t j = 0; j < byte_count; ++j) { - writePinLow(comms_config->spi_config.chip_select_pin); + gpio_write_pin_low(comms_config->spi_config.chip_select_pin); ret = qp_comms_spi_dc_reset_send_data(device, &data[j], 1); - writePinHigh(comms_config->spi_config.chip_select_pin); + gpio_write_pin_high(comms_config->spi_config.chip_select_pin); } return ret; diff --git a/drivers/painter/ld7032/qp_ld7032.h b/drivers/painter/ld7032/qp_ld7032.h index 967eb7999c..9af80dd468 100644 --- a/drivers/painter/ld7032/qp_ld7032.h +++ b/drivers/painter/ld7032/qp_ld7032.h @@ -63,4 +63,4 @@ painter_device_t qp_ld7032_make_spi_device(uint16_t panel_width, uint16_t panel_ */ painter_device_t qp_ld7032_make_i2c_device(uint16_t panel_width, uint16_t panel_height, uint8_t i2c_address); -#endif // QUANTUM_PAINTER_LD7032_I2C_ENABLE \ No newline at end of file +#endif // QUANTUM_PAINTER_LD7032_I2C_ENABLE diff --git a/drivers/painter/ld7032/qp_ld7032_opcodes.h b/drivers/painter/ld7032/qp_ld7032_opcodes.h index 08ab77d6f8..ed8b397c67 100644 --- a/drivers/painter/ld7032/qp_ld7032_opcodes.h +++ b/drivers/painter/ld7032/qp_ld7032_opcodes.h @@ -42,4 +42,4 @@ typedef enum { LD7032_S_START_STOP = 0xCD, LD7032_S_SELECT = 0xCE, LD7032_TESTCNT1 = 0xF0, //-0xFF -} ld7032_opcodes; \ No newline at end of file +} ld7032_opcodes; diff --git a/drivers/sensors/azoteq_iqs5xx.h b/drivers/sensors/azoteq_iqs5xx.h index e1e8b67b31..eb01903e33 100644 --- a/drivers/sensors/azoteq_iqs5xx.h +++ b/drivers/sensors/azoteq_iqs5xx.h @@ -4,6 +4,7 @@ #pragma once +#include "compiler_support.h" #include "i2c_master.h" #include "pointing_device.h" #include "util.h" @@ -79,7 +80,7 @@ typedef struct { azoteq_iqs5xx_relative_xy_t y; } azoteq_iqs5xx_base_data_t; -_Static_assert(sizeof(azoteq_iqs5xx_base_data_t) == 10, "azoteq_iqs5xx_basic_report_t should be 10 bytes"); +STATIC_ASSERT(sizeof(azoteq_iqs5xx_base_data_t) == 10, "azoteq_iqs5xx_basic_report_t should be 10 bytes"); typedef struct { uint8_t number_of_fingers; @@ -87,7 +88,7 @@ typedef struct { azoteq_iqs5xx_relative_xy_t y; } azoteq_iqs5xx_report_data_t; -_Static_assert(sizeof(azoteq_iqs5xx_report_data_t) == 5, "azoteq_iqs5xx_report_data_t should be 5 bytes"); +STATIC_ASSERT(sizeof(azoteq_iqs5xx_report_data_t) == 5, "azoteq_iqs5xx_report_data_t should be 5 bytes"); typedef struct PACKED { bool sw_input : 1; @@ -159,7 +160,7 @@ typedef struct PACKED { uint16_t zoom_consecutive_distance; } azoteq_iqs5xx_gesture_config_t; -_Static_assert(sizeof(azoteq_iqs5xx_gesture_config_t) == 24, "azoteq_iqs5xx_gesture_config_t should be 24 bytes"); +STATIC_ASSERT(sizeof(azoteq_iqs5xx_gesture_config_t) == 24, "azoteq_iqs5xx_gesture_config_t should be 24 bytes"); typedef struct { uint16_t x_resolution; diff --git a/drivers/sensors/pimoroni_trackball.c b/drivers/sensors/pimoroni_trackball.c index afbe3d5b77..06e5042953 100644 --- a/drivers/sensors/pimoroni_trackball.c +++ b/drivers/sensors/pimoroni_trackball.c @@ -101,12 +101,12 @@ int16_t pimoroni_trackball_get_offsets(uint8_t negative_dir, uint8_t positive_di } mouse_xy_report_t pimoroni_trackball_adapt_values(xy_clamp_range_t *offset) { - if (*offset > XY_REPORT_MAX) { - *offset -= XY_REPORT_MAX; - return (mouse_xy_report_t)XY_REPORT_MAX; - } else if (*offset < XY_REPORT_MIN) { - *offset += XY_REPORT_MAX; - return (mouse_xy_report_t)XY_REPORT_MIN; + if (*offset > MOUSE_REPORT_XY_MAX) { + *offset -= MOUSE_REPORT_XY_MAX; + return (mouse_xy_report_t)MOUSE_REPORT_XY_MAX; + } else if (*offset < MOUSE_REPORT_XY_MIN) { + *offset += MOUSE_REPORT_XY_MAX; + return (mouse_xy_report_t)MOUSE_REPORT_XY_MIN; } else { mouse_xy_report_t temp_return = *offset; *offset = 0; diff --git a/drivers/sensors/pmw33xx_common.h b/drivers/sensors/pmw33xx_common.h index 22e35c3327..82303ba6d9 100644 --- a/drivers/sensors/pmw33xx_common.h +++ b/drivers/sensors/pmw33xx_common.h @@ -10,6 +10,7 @@ #pragma once +#include "compiler_support.h" #include "keyboard.h" #include #include "spi_master.h" @@ -39,8 +40,8 @@ typedef struct __attribute__((packed)) { int16_t delta_y; // displacement on y directions. } pmw33xx_report_t; -_Static_assert(sizeof(pmw33xx_report_t) == 6, "pmw33xx_report_t must be 6 bytes in size"); -_Static_assert(sizeof((pmw33xx_report_t){0}.motion) == 1, "pmw33xx_report_t.motion must be 1 byte in size"); +STATIC_ASSERT(sizeof(pmw33xx_report_t) == 6, "pmw33xx_report_t must be 6 bytes in size"); +STATIC_ASSERT(sizeof((pmw33xx_report_t){0}.motion) == 1, "pmw33xx_report_t.motion must be 1 byte in size"); #if !defined(PMW33XX_CLOCK_SPEED) # define PMW33XX_CLOCK_SPEED 2000000 diff --git a/drivers/usbpd.h b/drivers/usbpd.h index df4f29bb9d..e9dca67f66 100644 --- a/drivers/usbpd.h +++ b/drivers/usbpd.h @@ -26,4 +26,4 @@ typedef enum { void usbpd_init(void); // Gets the current state of the USBPD allowance -usbpd_allowance_t usbpd_get_allowance(void); \ No newline at end of file +usbpd_allowance_t usbpd_get_allowance(void); diff --git a/drivers/wear_leveling/wear_leveling_flash_spi.c b/drivers/wear_leveling/wear_leveling_flash_spi.c index 304aed1641..ca2c174580 100644 --- a/drivers/wear_leveling/wear_leveling_flash_spi.c +++ b/drivers/wear_leveling/wear_leveling_flash_spi.c @@ -5,6 +5,7 @@ #include "util.h" #include "timer.h" #include "wear_leveling.h" +#include "wear_leveling_flash_spi_config.h" #include "wear_leveling_internal.h" #ifndef WEAR_LEVELING_EXTERNAL_FLASH_BULK_COUNT diff --git a/keyboards/zsa/moonlander/matrix.c b/keyboards/zsa/moonlander/matrix.c index 1bc4750e62..26bb34ae65 100644 --- a/keyboards/zsa/moonlander/matrix.c +++ b/keyboards/zsa/moonlander/matrix.c @@ -18,6 +18,7 @@ #include "moonlander.h" #include "mcp23018.h" +#include "i2c_master.h" #pragma GCC push_options #pragma GCC optimize("-O3") @@ -34,6 +35,9 @@ extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values static matrix_row_t raw_matrix_right[MATRIX_ROWS]; #define MCP_ROWS_PER_HAND (MATRIX_ROWS / 2) +#ifndef I2C_DRIVER +# define I2C_DRIVER I2CD1 +#endif extern bool mcp23018_leds[3]; extern bool is_launching; @@ -46,6 +50,25 @@ bool io_expander_ready(void) { return mcp23018_read_pins(MCP23018_DEFAULT_ADDRESS, mcp23018_PORTA, &tx); } +uint8_t mcp23018_init_local(bool first_run) { + if (!first_run) { + i2cStop(&I2C_DRIVER); + } + wait_ms(10); + // Try releasing special pins for a short time + palSetLineMode(B6, PAL_MODE_INPUT); + palSetLineMode(B7, PAL_MODE_INPUT); + wait_ms(10); + palSetLineMode(B6, PAL_MODE_ALTERNATE(4) | PAL_OUTPUT_TYPE_OPENDRAIN); + palSetLineMode(B7, PAL_MODE_ALTERNATE(4) | PAL_OUTPUT_TYPE_OPENDRAIN); + + uint8_t errors = 0; + errors += !mcp23018_set_config(MCP23018_DEFAULT_ADDRESS, mcp23018_PORTA, 0b00000000); + errors += !mcp23018_set_config(MCP23018_DEFAULT_ADDRESS, mcp23018_PORTB, 0b00111111); + + return errors; +} + void matrix_init_custom(void) { // outputs gpio_set_pin_output(B10); @@ -64,9 +87,7 @@ void matrix_init_custom(void) { gpio_set_pin_input_low(A7); gpio_set_pin_input_low(B0); - mcp23018_init(MCP23018_DEFAULT_ADDRESS); - mcp23018_errors += !mcp23018_set_config(MCP23018_DEFAULT_ADDRESS, mcp23018_PORTA, 0b00000000); - mcp23018_errors += !mcp23018_set_config(MCP23018_DEFAULT_ADDRESS, mcp23018_PORTB, 0b00111111); + mcp23018_errors = mcp23018_init_local(true); if (!mcp23018_errors) { is_launching = true; @@ -80,8 +101,11 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) { if (++mcp23018_reset_loop > 0x1FFF) { if (io_expander_ready()) { // If we managed to initialize the mcp23018 - we need to reinitialize the matrix / layer state. During an electric discharge the i2c peripherals might be in a weird state. Giving a delay and resetting the MCU allows to recover from this. - wait_ms(200); - mcu_reset(); + mcp23018_reset_loop = 0; + mcp23018_errors = mcp23018_init_local(false); +#ifdef RGB_MATRIX_ENABLE + rgb_matrix_init(); +#endif } } } diff --git a/keyboards/zsa/voyager/matrix.c b/keyboards/zsa/voyager/matrix.c index 931af40bc8..b05313a033 100644 --- a/keyboards/zsa/voyager/matrix.c +++ b/keyboards/zsa/voyager/matrix.c @@ -2,9 +2,10 @@ // Copyright 2023 Christopher Courtney, aka Drashna Jael're (@drashna) // SPDX-License-Identifier: GPL-2.0-or-later -#include #include "voyager.h" #include "mcp23018.h" +#include "i2c_master.h" +#include #pragma GCC push_options #pragma GCC optimize("-O3") @@ -14,6 +15,9 @@ extern matrix_row_t raw_matrix[MATRIX_ROWS]; // raw values static matrix_row_t raw_matrix_right[MATRIX_COLS]; #define MCP_ROWS_PER_HAND (MATRIX_ROWS / 2) +#ifndef I2C_DRIVER +# define I2C_DRIVER I2CD1 +#endif #ifndef VOYAGER_I2C_TIMEOUT # define VOYAGER_I2C_TIMEOUT 100 #endif @@ -33,6 +37,25 @@ bool io_expander_ready(void) { return mcp23018_readPins(MCP23018_DEFAULT_ADDRESS, mcp23018_PORTA, &tx); } +uint8_t mcp23018_init_local(bool first_run) { + if (!first_run) { + i2cStop(&I2C_DRIVER); + } + wait_ms(10); + // Try releasing special pins for a short time + palSetLineMode(B6, PAL_MODE_INPUT); + palSetLineMode(B7, PAL_MODE_INPUT); + wait_ms(10); + palSetLineMode(B6, PAL_MODE_ALTERNATE(4) | PAL_OUTPUT_TYPE_OPENDRAIN); + palSetLineMode(B7, PAL_MODE_ALTERNATE(4) | PAL_OUTPUT_TYPE_OPENDRAIN); + + uint8_t errors = 0; + errors += !mcp23018_set_config(MCP23018_DEFAULT_ADDRESS, mcp23018_PORTA, 0b00000000); + errors += !mcp23018_set_config(MCP23018_DEFAULT_ADDRESS, mcp23018_PORTB, 0b00111111); + + return errors; +} + void matrix_init_custom(void) { // outputs gpio_set_pin_output(B10); @@ -51,9 +74,7 @@ void matrix_init_custom(void) { gpio_set_pin_input_low(A7); gpio_set_pin_input_low(B0); - mcp23018_init(MCP23018_DEFAULT_ADDRESS); - mcp23018_errors += !mcp23018_set_config(MCP23018_DEFAULT_ADDRESS, mcp23018_PORTA, 0b00000000); - mcp23018_errors += !mcp23018_set_config(MCP23018_DEFAULT_ADDRESS, mcp23018_PORTB, 0b00111111); + mcp23018_errors = mcp23018_init_local(true); if (!mcp23018_errors) { is_launching = true; @@ -67,8 +88,11 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) { if (++mcp23018_reset_loop > 0x1FFF) { if (io_expander_ready()) { // If we managed to initialize the mcp23018 - we need to reinitialize the matrix / layer state. During an electric discharge the i2c peripherals might be in a weird state. Giving a delay and resetting the MCU allows to recover from this. - wait_ms(200); - mcu_reset(); + mcp23018_reset_loop = 0; + mcp23018_errors = mcp23018_init_local(false); +#ifdef RGB_MATRIX_ENABLE + rgb_matrix_init(); +#endif } } } diff --git a/lib/fnv/qmk_fnv_type_validation.c b/lib/fnv/qmk_fnv_type_validation.c index e8576617ba..5e8ef5c54c 100644 --- a/lib/fnv/qmk_fnv_type_validation.c +++ b/lib/fnv/qmk_fnv_type_validation.c @@ -1,14 +1,15 @@ // Copyright 2022 Nick Brassel (@tzarc) // SPDX-License-Identifier: GPL-2.0-or-later #include "fnv.h" +#include "compiler_support.h" // This library was originally sourced from: // http://www.isthe.com/chongo/tech/comp/fnv/index.html // // Version at the time of retrieval on 2022-06-26: v5.0.3 -_Static_assert(sizeof(long long) == 8, "long long should be 64 bits"); -_Static_assert(sizeof(unsigned long long) == 8, "unsigned long long should be 64 bits"); +STATIC_ASSERT(sizeof(long long) == 8, "long long should be 64 bits"); +STATIC_ASSERT(sizeof(unsigned long long) == 8, "unsigned long long should be 64 bits"); -_Static_assert(sizeof(Fnv32_t) == 4, "Fnv32_t should be 32 bits"); -_Static_assert(sizeof(Fnv64_t) == 8, "Fnv64_t should be 64 bits"); +STATIC_ASSERT(sizeof(Fnv32_t) == 4, "Fnv32_t should be 32 bits"); +STATIC_ASSERT(sizeof(Fnv64_t) == 8, "Fnv64_t should be 64 bits"); diff --git a/lib/pico-sdk b/lib/pico-sdk index a3398d8d3a..d0c5cac430 160000 --- a/lib/pico-sdk +++ b/lib/pico-sdk @@ -1 +1 @@ -Subproject commit a3398d8d3a772f37fef44a74743a1de69770e9c2 +Subproject commit d0c5cac430cc955b65efa0e899748853d9a80928 diff --git a/lib/python/qmk/build_targets.py b/lib/python/qmk/build_targets.py index e2df029490..35a5f89f91 100644 --- a/lib/python/qmk/build_targets.py +++ b/lib/python/qmk/build_targets.py @@ -11,7 +11,8 @@ from qmk.commands import find_make, get_make_parallel_args, parse_configurator_j from qmk.keyboard import keyboard_folder from qmk.info import keymap_json from qmk.keymap import locate_keymap -from qmk.path import is_under_qmk_firmware, is_under_qmk_userspace +from qmk.path import is_under_qmk_firmware, is_under_qmk_userspace, unix_style_path +from qmk.compilation_database import write_compilation_database # These must be kept in the order in which they're applied to $(TARGET) in the makefiles in order to ensure consistency. TARGET_FILENAME_MODIFIERS = ['FORCE_LAYOUT', 'CONVERT_TO'] @@ -150,7 +151,6 @@ class BuildTarget: def generate_compilation_database(self, build_target: str = None, skip_clean: bool = False, **env_vars) -> None: self.prepare_build(build_target=build_target, **env_vars) command = self.compile_command(build_target=build_target, dry_run=True, **env_vars) - from qmk.cli.generate.compilation_database import write_compilation_database # Lazy load due to circular references output_path = QMK_FIRMWARE / 'compile_commands.json' ret = write_compilation_database(command=command, output_path=output_path, skip_clean=skip_clean, **env_vars) if ret and output_path.exists() and HAS_QMK_USERSPACE: @@ -204,11 +204,11 @@ class KeyboardKeymapBuildTarget(BuildTarget): if is_under_qmk_userspace(keymap_location) and not is_under_qmk_firmware(keymap_location): keymap_directory = keymap_location.parent compile_args.extend([ - f'MAIN_KEYMAP_PATH_1={keymap_directory}', - f'MAIN_KEYMAP_PATH_2={keymap_directory}', - f'MAIN_KEYMAP_PATH_3={keymap_directory}', - f'MAIN_KEYMAP_PATH_4={keymap_directory}', - f'MAIN_KEYMAP_PATH_5={keymap_directory}', + f'MAIN_KEYMAP_PATH_1={unix_style_path(keymap_directory)}', + f'MAIN_KEYMAP_PATH_2={unix_style_path(keymap_directory)}', + f'MAIN_KEYMAP_PATH_3={unix_style_path(keymap_directory)}', + f'MAIN_KEYMAP_PATH_4={unix_style_path(keymap_directory)}', + f'MAIN_KEYMAP_PATH_5={unix_style_path(keymap_directory)}', ]) return compile_args @@ -267,11 +267,11 @@ class JsonKeymapBuildTarget(BuildTarget): generated_files_path = intermediate_output / 'src' keymap_json = generated_files_path / 'keymap.json' compile_args.extend([ - f'MAIN_KEYMAP_PATH_1={intermediate_output}', - f'MAIN_KEYMAP_PATH_2={intermediate_output}', - f'MAIN_KEYMAP_PATH_3={intermediate_output}', - f'MAIN_KEYMAP_PATH_4={intermediate_output}', - f'MAIN_KEYMAP_PATH_5={intermediate_output}', + f'MAIN_KEYMAP_PATH_1={unix_style_path(intermediate_output)}', + f'MAIN_KEYMAP_PATH_2={unix_style_path(intermediate_output)}', + f'MAIN_KEYMAP_PATH_3={unix_style_path(intermediate_output)}', + f'MAIN_KEYMAP_PATH_4={unix_style_path(intermediate_output)}', + f'MAIN_KEYMAP_PATH_5={unix_style_path(intermediate_output)}', f'KEYMAP_JSON={keymap_json}', f'KEYMAP_PATH={generated_files_path}', ]) diff --git a/lib/python/qmk/cli/__init__.py b/lib/python/qmk/cli/__init__.py index 3f2ba9ce3c..26905ec134 100644 --- a/lib/python/qmk/cli/__init__.py +++ b/lib/python/qmk/cli/__init__.py @@ -58,7 +58,6 @@ subcommands = [ 'qmk.cli.generate.keyboard_c', 'qmk.cli.generate.keyboard_h', 'qmk.cli.generate.keycodes', - 'qmk.cli.generate.keycodes_tests', 'qmk.cli.generate.keymap_h', 'qmk.cli.generate.make_dependencies', 'qmk.cli.generate.rgb_breathe_table', @@ -215,7 +214,7 @@ if sys.version_info[0] != 3 or sys.version_info[1] < 9: milc_version = __VERSION__.split('.') -if int(milc_version[0]) < 2 and int(milc_version[1]) < 4: +if int(milc_version[0]) < 2 and int(milc_version[1]) < 9: requirements = Path('requirements.txt').resolve() _eprint(f'Your MILC library is too old! Please upgrade: python3 -m pip install -U -r {str(requirements)}') diff --git a/lib/python/qmk/cli/doctor/check.py b/lib/python/qmk/cli/doctor/check.py index 2804a1d7df..51b0f0c80a 100644 --- a/lib/python/qmk/cli/doctor/check.py +++ b/lib/python/qmk/cli/doctor/check.py @@ -54,10 +54,13 @@ def _check_arm_gcc_installation(): """Returns OK if the arm-none-eabi-gcc is fully installed and can produce binaries. """ with TemporaryDirectory() as temp_dir: - temp_file = Path(temp_dir) / 'test.elf' + temp_in = Path(temp_dir) / 'test.c' + temp_out = Path(temp_dir) / 'test.elf' - args = ['arm-none-eabi-gcc', '-mcpu=cortex-m0', '-mthumb', '-mno-thumb-interwork', '--specs=nosys.specs', '--specs=nano.specs', '-x', 'c', '-o', str(temp_file), '-'] - result = cli.run(args, stdin=None, stdout=None, stderr=None, input='#include \nint main() { return __NEWLIB__ * __NEWLIB_MINOR__ * __NEWLIB_PATCHLEVEL__; }') + temp_in.write_text('#include \nint main() { return __NEWLIB__ * __NEWLIB_MINOR__ * __NEWLIB_PATCHLEVEL__; }', encoding='utf-8') + + args = ['arm-none-eabi-gcc', '-mcpu=cortex-m0', '-mthumb', '-mno-thumb-interwork', '--specs=nosys.specs', '--specs=nano.specs', '-x', 'c', '-o', str(temp_out), str(temp_in)] + result = cli.run(args, stdout=None, stderr=None) if result.returncode == 0: cli.log.info('Successfully compiled using arm-none-eabi-gcc') else: @@ -65,8 +68,8 @@ def _check_arm_gcc_installation(): cli.log.error(f'Command: {" ".join(args)}') return CheckStatus.ERROR - args = ['arm-none-eabi-size', str(temp_file)] - result = cli.run(args, stdin=None, stdout=None, stderr=None) + args = ['arm-none-eabi-size', str(temp_out)] + result = cli.run(args, stdout=None, stderr=None) if result.returncode == 0: cli.log.info('Successfully tested arm-none-eabi-binutils using arm-none-eabi-size') else: @@ -91,10 +94,13 @@ def _check_avr_gcc_installation(): """Returns OK if the avr-gcc is fully installed and can produce binaries. """ with TemporaryDirectory() as temp_dir: - temp_file = Path(temp_dir) / 'test.elf' + temp_in = Path(temp_dir) / 'test.c' + temp_out = Path(temp_dir) / 'test.elf' - args = ['avr-gcc', '-mmcu=atmega32u4', '-x', 'c', '-o', str(temp_file), '-'] - result = cli.run(args, stdin=None, stdout=None, stderr=None, input='int main() { return 0; }') + temp_in.write_text('int main() { return 0; }', encoding='utf-8') + + args = ['avr-gcc', '-mmcu=atmega32u4', '-x', 'c', '-o', str(temp_out), str(temp_in)] + result = cli.run(args, stdout=None, stderr=None) if result.returncode == 0: cli.log.info('Successfully compiled using avr-gcc') else: @@ -102,8 +108,8 @@ def _check_avr_gcc_installation(): cli.log.error(f'Command: {" ".join(args)}') return CheckStatus.ERROR - args = ['avr-size', str(temp_file)] - result = cli.run(args, stdin=None, stdout=None, stderr=None) + args = ['avr-size', str(temp_out)] + result = cli.run(args, stdout=None, stderr=None) if result.returncode == 0: cli.log.info('Successfully tested avr-binutils using avr-size') else: diff --git a/lib/python/qmk/cli/generate/api.py b/lib/python/qmk/cli/generate/api.py index 8311818476..7f7c05f6e2 100755 --- a/lib/python/qmk/cli/generate/api.py +++ b/lib/python/qmk/cli/generate/api.py @@ -131,6 +131,11 @@ def generate_api(cli): if keymap_rel is None: cli.log.debug('Skipping keymap %s (not in qmk_firmware)', keymap) continue + + if (keymap_rel / 'keymap.c').exists(): + cli.log.debug('Skipping keymap %s (not pure dd keymap)', keymap) + continue + kb_json['keymaps'][keymap.name] = { # TODO: deprecate 'url' as consumer needs to know its potentially hjson 'url': f'https://raw.githubusercontent.com/qmk/qmk_firmware/master/{keymap_rel}/keymap.json', diff --git a/lib/python/qmk/cli/generate/community_modules.py b/lib/python/qmk/cli/generate/community_modules.py index 734c218953..a5ab61f9bd 100644 --- a/lib/python/qmk/cli/generate/community_modules.py +++ b/lib/python/qmk/cli/generate/community_modules.py @@ -8,7 +8,7 @@ import qmk.path from qmk.info import get_modules from qmk.keyboard import keyboard_completer, keyboard_folder from qmk.commands import dump_lines -from qmk.constants import GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE +from qmk.constants import GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE, GPL2_HEADER_SH_LIKE, GENERATED_HEADER_SH_LIKE from qmk.community_modules import module_api_list, load_module_jsons, find_module_path @@ -52,7 +52,7 @@ def _render_keycodes(module_jsons): lines.append('') lines.append(' LAST_COMMUNITY_MODULE_KEY') lines.append('};') - lines.append('_Static_assert((int)LAST_COMMUNITY_MODULE_KEY <= (int)(QK_COMMUNITY_MODULE_MAX+1), "Too many community module keycodes");') + lines.append('STATIC_ASSERT((int)LAST_COMMUNITY_MODULE_KEY <= (int)(QK_COMMUNITY_MODULE_MAX+1), "Too many community module keycodes");') return lines @@ -131,6 +131,69 @@ def _render_core_implementation(api, modules): return lines +def _generate_features_rules(features_dict): + lines = [] + for feature, enabled in features_dict.items(): + feature = feature.upper() + enabled = 'yes' if enabled else 'no' + lines.append(f'{feature}_ENABLE={enabled}') + return lines + + +def _generate_modules_rules(keyboard, filename): + lines = [] + modules = get_modules(keyboard, filename) + if len(modules) > 0: + lines.append('') + lines.append('OPT_DEFS += -DCOMMUNITY_MODULES_ENABLE=TRUE') + for module in modules: + module_path = qmk.path.unix_style_path(find_module_path(module)) + if not module_path: + raise FileNotFoundError(f"Module '{module}' not found.") + lines.append('') + lines.append(f'COMMUNITY_MODULES += {module_path.name}') # use module_path here instead of module as it may be a subdirectory + lines.append(f'OPT_DEFS += -DCOMMUNITY_MODULE_{module_path.name.upper()}_ENABLE=TRUE') + lines.append(f'COMMUNITY_MODULE_PATHS += {module_path}') + lines.append(f'VPATH += {module_path}') + lines.append(f'SRC += $(wildcard {module_path}/{module_path.name}.c)') + lines.append(f'MODULE_NAME_{module_path.name.upper()} := {module_path.name}') + lines.append(f'MODULE_PATH_{module_path.name.upper()} := {module_path}') + lines.append(f'-include {module_path}/rules.mk') + + module_jsons = load_module_jsons(modules) + for module_json in module_jsons: + if 'features' in module_json: + lines.append('') + lines.append(f'# Module: {module_json["module_name"]}') + lines.extend(_generate_features_rules(module_json['features'])) + return lines + + +@cli.argument('-o', '--output', arg_only=True, type=qmk.path.normpath, help='File to write to') +@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages") +@cli.argument('-e', '--escape', arg_only=True, action='store_true', help="Escape spaces in quiet mode") +@cli.argument('-kb', '--keyboard', arg_only=True, type=keyboard_folder, completer=keyboard_completer, help='Keyboard to generate rules.mk for.') +@cli.argument('filename', nargs='?', arg_only=True, type=qmk.path.FileType('r'), completer=FilesCompleter('.json'), help='A configurator export JSON to be compiled and flashed or a pre-compiled binary firmware file (bin/hex) to be flashed.') +@cli.subcommand('Creates a community_modules_rules_mk from a keymap.json file.') +def generate_community_modules_rules_mk(cli): + + rules_mk_lines = [GPL2_HEADER_SH_LIKE, GENERATED_HEADER_SH_LIKE] + + rules_mk_lines.extend(_generate_modules_rules(cli.args.keyboard, cli.args.filename)) + + # Show the results + dump_lines(cli.args.output, rules_mk_lines) + + if cli.args.output: + if cli.args.quiet: + if cli.args.escape: + print(cli.args.output.as_posix().replace(' ', '\\ ')) + else: + print(cli.args.output) + else: + cli.log.info('Wrote rules.mk to %s.', cli.args.output) + + @cli.argument('-o', '--output', arg_only=True, type=qmk.path.normpath, help='File to write to') @cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages") @cli.argument('-kb', '--keyboard', arg_only=True, type=keyboard_folder, completer=keyboard_completer, help='Keyboard to generate community_modules.h for.') @@ -152,9 +215,11 @@ def generate_community_modules_h(cli): '#include ', '#include ', '', + '#include "compiler_support.h"', + '', '#define COMMUNITY_MODULES_API_VERSION_BUILDER(ver_major,ver_minor,ver_patch) (((((uint32_t)(ver_major))&0xFF) << 24) | ((((uint32_t)(ver_minor))&0xFF) << 16) | (((uint32_t)(ver_patch))&0xFF))', f'#define COMMUNITY_MODULES_API_VERSION COMMUNITY_MODULES_API_VERSION_BUILDER({ver_major},{ver_minor},{ver_patch})', - f'#define ASSERT_COMMUNITY_MODULES_MIN_API_VERSION(ver_major,ver_minor,ver_patch) _Static_assert(COMMUNITY_MODULES_API_VERSION_BUILDER(ver_major,ver_minor,ver_patch) <= COMMUNITY_MODULES_API_VERSION, "Community module requires a newer version of QMK modules API -- needs: " #ver_major "." #ver_minor "." #ver_patch ", current: {api_version}.")', + f'#define ASSERT_COMMUNITY_MODULES_MIN_API_VERSION(ver_major,ver_minor,ver_patch) STATIC_ASSERT(COMMUNITY_MODULES_API_VERSION_BUILDER(ver_major,ver_minor,ver_patch) <= COMMUNITY_MODULES_API_VERSION, "Community module requires a newer version of QMK modules API -- needs: " #ver_major "." #ver_minor "." #ver_patch ", current: {api_version}.")', '', 'typedef struct keyrecord_t keyrecord_t; // forward declaration so we don\'t need to include quantum.h', '', @@ -215,33 +280,32 @@ def generate_community_modules_c(cli): dump_lines(cli.args.output, lines, cli.args.quiet, remove_repeated_newlines=True) +def _generate_include_per_module(cli, include_file_name): + """Generates C code to include "/include_file_name" for each module.""" + if cli.args.output and cli.args.output.name == '-': + cli.args.output = None + + lines = [GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE] + + for module in get_modules(cli.args.keyboard, cli.args.filename): + full_path = f'{find_module_path(module)}/{include_file_name}' + lines.append('') + lines.append(f'#if __has_include("{full_path}")') + lines.append(f'#include "{full_path}"') + lines.append(f'#endif // __has_include("{full_path}")') + + dump_lines(cli.args.output, lines, cli.args.quiet, remove_repeated_newlines=True) + + @cli.argument('-o', '--output', arg_only=True, type=qmk.path.normpath, help='File to write to') @cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages") -@cli.argument('-kb', '--keyboard', arg_only=True, type=keyboard_folder, completer=keyboard_completer, help='Keyboard to generate community_modules.c for.') +@cli.argument('-kb', '--keyboard', arg_only=True, type=keyboard_folder, completer=keyboard_completer, help='Keyboard to generate community_modules_introspection.h for.') @cli.argument('filename', nargs='?', type=qmk.path.FileType('r'), arg_only=True, completer=FilesCompleter('.json'), help='Configurator JSON file') @cli.subcommand('Creates a community_modules_introspection.h from a keymap.json file.') def generate_community_modules_introspection_h(cli): """Creates a community_modules_introspection.h from a keymap.json file """ - if cli.args.output and cli.args.output.name == '-': - cli.args.output = None - - lines = [ - GPL2_HEADER_C_LIKE, - GENERATED_HEADER_C_LIKE, - '', - ] - - modules = get_modules(cli.args.keyboard, cli.args.filename) - if len(modules) > 0: - for module in modules: - module_path = find_module_path(module) - lines.append(f'#if __has_include("{module_path}/introspection.h")') - lines.append(f'#include "{module_path}/introspection.h"') - lines.append(f'#endif // __has_include("{module_path}/introspection.h")') - lines.append('') - - dump_lines(cli.args.output, lines, cli.args.quiet, remove_repeated_newlines=True) + _generate_include_per_module(cli, 'introspection.h') @cli.argument('-o', '--output', arg_only=True, type=qmk.path.normpath, help='File to write to') @@ -252,22 +316,26 @@ def generate_community_modules_introspection_h(cli): def generate_community_modules_introspection_c(cli): """Creates a community_modules_introspection.c from a keymap.json file """ - if cli.args.output and cli.args.output.name == '-': - cli.args.output = None + _generate_include_per_module(cli, 'introspection.c') - lines = [ - GPL2_HEADER_C_LIKE, - GENERATED_HEADER_C_LIKE, - '', - ] - modules = get_modules(cli.args.keyboard, cli.args.filename) - if len(modules) > 0: - for module in modules: - module_path = find_module_path(module) - lines.append(f'#if __has_include("{module_path}/introspection.c")') - lines.append(f'#include "{module_path}/introspection.c"') - lines.append(f'#endif // __has_include("{module_path}/introspection.c")') - lines.append('') +@cli.argument('-o', '--output', arg_only=True, type=qmk.path.normpath, help='File to write to') +@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages") +@cli.argument('-kb', '--keyboard', arg_only=True, type=keyboard_folder, completer=keyboard_completer, help='Keyboard to generate led_matrix_community_modules.inc for.') +@cli.argument('filename', nargs='?', type=qmk.path.FileType('r'), arg_only=True, completer=FilesCompleter('.json'), help='Configurator JSON file') +@cli.subcommand('Creates an led_matrix_community_modules.inc from a keymap.json file.') +def generate_led_matrix_community_modules_inc(cli): + """Creates an led_matrix_community_modules.inc from a keymap.json file + """ + _generate_include_per_module(cli, 'led_matrix_module.inc') - dump_lines(cli.args.output, lines, cli.args.quiet, remove_repeated_newlines=True) + +@cli.argument('-o', '--output', arg_only=True, type=qmk.path.normpath, help='File to write to') +@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages") +@cli.argument('-kb', '--keyboard', arg_only=True, type=keyboard_folder, completer=keyboard_completer, help='Keyboard to generate rgb_matrix_community_modules.inc for.') +@cli.argument('filename', nargs='?', type=qmk.path.FileType('r'), arg_only=True, completer=FilesCompleter('.json'), help='Configurator JSON file') +@cli.subcommand('Creates an rgb_matrix_community_modules.inc from a keymap.json file.') +def generate_rgb_matrix_community_modules_inc(cli): + """Creates an rgb_matrix_community_modules.inc from a keymap.json file + """ + _generate_include_per_module(cli, 'rgb_matrix_module.inc') diff --git a/lib/python/qmk/cli/generate/compilation_database.py b/lib/python/qmk/cli/generate/compilation_database.py old mode 100755 new mode 100644 index b9c716bf0c..339b53c2c2 --- a/lib/python/qmk/cli/generate/compilation_database.py +++ b/lib/python/qmk/cli/generate/compilation_database.py @@ -1,169 +1,9 @@ -"""Creates a compilation database for the given keyboard build. -""" - -import json -import os -import re -import shlex -import shutil -from functools import lru_cache -from pathlib import Path -from typing import Dict, Iterator, List, Union - -from milc import cli, MILC - -from qmk.commands import find_make -from qmk.constants import QMK_FIRMWARE -from qmk.decorators import automagic_keyboard, automagic_keymap -from qmk.keyboard import keyboard_completer, keyboard_folder -from qmk.keymap import keymap_completer -from qmk.build_targets import KeyboardKeymapBuildTarget +from milc import cli -@lru_cache(maxsize=10) -def system_libs(binary: str) -> List[Path]: - """Find the system include directory that the given build tool uses. - """ - cli.log.debug("searching for system library directory for binary: %s", binary) - - # Actually query xxxxxx-gcc to find its include paths. - if binary.endswith("gcc") or binary.endswith("g++"): - # (TODO): Remove 'stdin' once 'input' no longer causes issues under MSYS - result = cli.run([binary, '-E', '-Wp,-v', '-'], capture_output=True, check=True, stdin=None, input='\n') - paths = [] - for line in result.stderr.splitlines(): - if line.startswith(" "): - paths.append(Path(line.strip()).resolve()) - return paths - - return list(Path(binary).resolve().parent.parent.glob("*/include")) if binary else [] - - -@lru_cache(maxsize=10) -def cpu_defines(binary: str, compiler_args: str) -> List[str]: - cli.log.debug("gathering definitions for compilation: %s %s", binary, compiler_args) - if binary.endswith("gcc") or binary.endswith("g++"): - invocation = [binary, '-dM', '-E'] - if binary.endswith("gcc"): - invocation.extend(['-x', 'c']) - elif binary.endswith("g++"): - invocation.extend(['-x', 'c++']) - compiler_args = shlex.split(compiler_args) - invocation.extend(compiler_args) - invocation.append('-') - result = cli.run(invocation, capture_output=True, check=True, stdin=None, input='\n') - define_args = [] - for line in result.stdout.splitlines(): - line_args = line.split(' ', 2) - if len(line_args) == 3 and line_args[0] == '#define': - define_args.append(f'-D{line_args[1]}={line_args[2]}') - elif len(line_args) == 2 and line_args[0] == '#define': - define_args.append(f'-D{line_args[1]}') - return list(sorted(set(define_args))) - return [] - - -file_re = re.compile(r'printf "Compiling: ([^"]+)') -cmd_re = re.compile(r'LOG=\$\((.+?)&&') - - -def parse_make_n(f: Iterator[str]) -> List[Dict[str, str]]: - """parse the output of `make -n ` - - This function makes many assumptions about the format of your build log. - This happens to work right now for qmk. - """ - - state = 'start' - this_file = None - records = [] - for line in f: - if state == 'start': - m = file_re.search(line) - if m: - this_file = m.group(1) - state = 'cmd' - - if state == 'cmd': - assert this_file - m = cmd_re.search(line) - if m: - # we have a hit! - this_cmd = m.group(1) - args = shlex.split(this_cmd) - binary = shutil.which(args[0]) - compiler_args = set(filter(lambda x: x.startswith('-m') or x.startswith('-f'), args)) - for s in system_libs(binary): - args += ['-isystem', '%s' % s] - args.extend(cpu_defines(binary, ' '.join(shlex.quote(s) for s in compiler_args))) - new_cmd = ' '.join(shlex.quote(s) for s in args) - records.append({"directory": str(QMK_FIRMWARE.resolve()), "command": new_cmd, "file": this_file}) - state = 'start' - - return records - - -def write_compilation_database(keyboard: str = None, keymap: str = None, output_path: Path = QMK_FIRMWARE / 'compile_commands.json', skip_clean: bool = False, command: List[str] = None, **env_vars) -> bool: - # Generate the make command for a specific keyboard/keymap. - if not command: - from qmk.build_targets import KeyboardKeymapBuildTarget # Lazy load due to circular references - target = KeyboardKeymapBuildTarget(keyboard, keymap) - command = target.compile_command(dry_run=True, **env_vars) - - if not command: - cli.log.error('You must supply both `--keyboard` and `--keymap`, or be in a directory for a keyboard or keymap.') - cli.echo('usage: qmk generate-compilation-database [-kb KEYBOARD] [-km KEYMAP]') - return False - - # remove any environment variable overrides which could trip us up - env = os.environ.copy() - env.pop("MAKEFLAGS", None) - - # re-use same executable as the main make invocation (might be gmake) - if not skip_clean: - clean_command = [find_make(), "clean"] - cli.log.info('Making clean with {fg_cyan}%s', ' '.join(clean_command)) - cli.run(clean_command, capture_output=False, check=True, env=env) - - cli.log.info('Gathering build instructions from {fg_cyan}%s', ' '.join(command)) - - result = cli.run(command, capture_output=True, check=True, env=env) - db = parse_make_n(result.stdout.splitlines()) - if not db: - cli.log.error("Failed to parse output from make output:\n%s", result.stdout) - return False - - cli.log.info("Found %s compile commands", len(db)) - - cli.log.info(f"Writing build database to {output_path}") - output_path.write_text(json.dumps(db, indent=4)) - - return True - - -@cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, help='The keyboard\'s name') -@cli.argument('-km', '--keymap', completer=keymap_completer, help='The keymap\'s name') -@cli.subcommand('Create a compilation database.') -@automagic_keyboard -@automagic_keymap -def generate_compilation_database(cli: MILC) -> Union[bool, int]: - """Creates a compilation database for the given keyboard build. - - Does a make clean, then a make -n for this target and uses the dry-run output to create - a compilation database (compile_commands.json). This file can help some IDEs and - IDE-like editors work better. For more information about this: - - https://clang.llvm.org/docs/JSONCompilationDatabase.html - """ - # check both config domains: the magic decorator fills in `generate_compilation_database` but the user is - # more likely to have set `compile` in their config file. - current_keyboard = cli.config.generate_compilation_database.keyboard or cli.config.user.keyboard - current_keymap = cli.config.generate_compilation_database.keymap or cli.config.user.keymap - - if not current_keyboard: - cli.log.error('Could not determine keyboard!') - elif not current_keymap: - cli.log.error('Could not determine keymap!') - - target = KeyboardKeymapBuildTarget(current_keyboard, current_keymap) - return target.generate_compilation_database() +@cli.argument('-kb', '--keyboard', help='[unused] The keyboard\'s name') +@cli.argument('-km', '--keymap', help='[unused] The keymap\'s name') +@cli.subcommand('[deprecated] Create a compilation database.') +def generate_compilation_database(cli): + cli.log.error('This command is deprecated and has effectively been removed. Please use the `--compiledb` flag with `qmk compile` instead.') + return False diff --git a/lib/python/qmk/cli/generate/keycodes.py b/lib/python/qmk/cli/generate/keycodes.py index 719fced5d5..d686935fa8 100644 --- a/lib/python/qmk/cli/generate/keycodes.py +++ b/lib/python/qmk/cli/generate/keycodes.py @@ -125,6 +125,20 @@ def _generate_aliases(lines, keycodes): lines.append(f'#define {alias} {value.get("key")}') +def _generate_version(lines, keycodes, prefix=''): + version = keycodes['version'] + major, minor, patch = map(int, version.split('.')) + + bcd = f'0x{major:02d}{minor:02d}{patch:04d}' + + lines.append('') + lines.append(f'#define QMK_{prefix}KEYCODES_VERSION "{version}"') + lines.append(f'#define QMK_{prefix}KEYCODES_VERSION_BCD {bcd}') + lines.append(f'#define QMK_{prefix}KEYCODES_VERSION_MAJOR {major}') + lines.append(f'#define QMK_{prefix}KEYCODES_VERSION_MINOR {minor}') + lines.append(f'#define QMK_{prefix}KEYCODES_VERSION_PATCH {patch}') + + @cli.argument('-v', '--version', arg_only=True, required=True, help='Version of keycodes to generate.') @cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to') @cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages") @@ -138,6 +152,7 @@ def generate_keycodes(cli): keycodes = load_spec(cli.args.version) + _generate_version(keycodes_h_lines, keycodes) _generate_ranges(keycodes_h_lines, keycodes) _generate_defines(keycodes_h_lines, keycodes) _generate_helpers(keycodes_h_lines, keycodes) @@ -160,6 +175,7 @@ def generate_keycode_extras(cli): keycodes = load_spec(cli.args.version, cli.args.lang) + _generate_version(keycodes_h_lines, keycodes, f'{cli.args.lang.upper()}_') _generate_aliases(keycodes_h_lines, keycodes) # Show the results diff --git a/lib/python/qmk/cli/generate/keycodes_tests.py b/lib/python/qmk/cli/generate/keycodes_tests.py deleted file mode 100644 index 453b4693a7..0000000000 --- a/lib/python/qmk/cli/generate/keycodes_tests.py +++ /dev/null @@ -1,39 +0,0 @@ -"""Used by the make system to generate a keycode lookup table from keycodes_{version}.json -""" -from milc import cli - -from qmk.constants import GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE -from qmk.commands import dump_lines -from qmk.path import normpath -from qmk.keycodes import load_spec - - -def _generate_defines(lines, keycodes): - lines.append('') - lines.append('std::map KEYCODE_ID_TABLE = {') - for key, value in keycodes["keycodes"].items(): - lines.append(f' {{{value.get("key")}, "{value.get("key")}"}},') - lines.append('};') - - -@cli.argument('-v', '--version', arg_only=True, required=True, help='Version of keycodes to generate.') -@cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to') -@cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages") -@cli.subcommand('Used by the make system to generate a keycode lookup table from keycodes_{version}.json', hidden=True) -def generate_keycodes_tests(cli): - """Generates a keycode to identifier lookup table for unit test output. - """ - - # Build the keycodes.h file. - keycodes_h_lines = [GPL2_HEADER_C_LIKE, GENERATED_HEADER_C_LIKE, '// clang-format off'] - keycodes_h_lines.append('extern "C" {\n#include \n}') - keycodes_h_lines.append('#include ') - keycodes_h_lines.append('#include ') - keycodes_h_lines.append('#include ') - - keycodes = load_spec(cli.args.version) - - _generate_defines(keycodes_h_lines, keycodes) - - # Show the results - dump_lines(cli.args.output, keycodes_h_lines, cli.args.quiet) diff --git a/lib/python/qmk/cli/generate/make_dependencies.py b/lib/python/qmk/cli/generate/make_dependencies.py index 331132a20f..9548187888 100755 --- a/lib/python/qmk/cli/generate/make_dependencies.py +++ b/lib/python/qmk/cli/generate/make_dependencies.py @@ -8,7 +8,7 @@ from argcomplete.completers import FilesCompleter from qmk.commands import dump_lines from qmk.keyboard import keyboard_completer, keyboard_folder from qmk.keymap import keymap_completer, locate_keymap -from qmk.path import normpath, FileType +from qmk.path import normpath, FileType, unix_style_path @cli.argument('filename', nargs='?', arg_only=True, type=FileType('r'), completer=FilesCompleter('.json'), help='A configurator export JSON.') @@ -53,4 +53,4 @@ def generate_make_dependencies(cli): for file in interesting_files: check_files.append(Path('users') / cli.args.keymap / file) - dump_lines(cli.args.output, [f'generated-files: $(wildcard {found})\n' for found in check_files]) + dump_lines(cli.args.output, [f'generated-files: $(wildcard {unix_style_path(found)})\n' for found in check_files]) diff --git a/lib/python/qmk/cli/generate/rules_mk.py b/lib/python/qmk/cli/generate/rules_mk.py index ef4101d77f..358a22fd1d 100755 --- a/lib/python/qmk/cli/generate/rules_mk.py +++ b/lib/python/qmk/cli/generate/rules_mk.py @@ -6,13 +6,12 @@ from dotty_dict import dotty from argcomplete.completers import FilesCompleter from milc import cli -from qmk.info import info_json, get_modules +from qmk.info import info_json from qmk.json_schema import json_load from qmk.keyboard import keyboard_completer, keyboard_folder from qmk.commands import dump_lines, parse_configurator_json -from qmk.path import normpath, unix_style_path, FileType +from qmk.path import normpath, FileType from qmk.constants import GPL2_HEADER_SH_LIKE, GENERATED_HEADER_SH_LIKE -from qmk.community_modules import find_module_path, load_module_jsons def generate_rule(rules_key, rules_value): @@ -56,33 +55,6 @@ def generate_features_rules(features_dict): return lines -def generate_modules_rules(keyboard, filename): - lines = [] - modules = get_modules(keyboard, filename) - if len(modules) > 0: - lines.append('') - lines.append('OPT_DEFS += -DCOMMUNITY_MODULES_ENABLE=TRUE') - for module in modules: - module_path = unix_style_path(find_module_path(module)) - if not module_path: - raise FileNotFoundError(f"Module '{module}' not found.") - lines.append('') - lines.append(f'COMMUNITY_MODULES += {module_path.name}') # use module_path here instead of module as it may be a subdirectory - lines.append(f'OPT_DEFS += -DCOMMUNITY_MODULE_{module_path.name.upper()}_ENABLE=TRUE') - lines.append(f'COMMUNITY_MODULE_PATHS += {module_path}') - lines.append(f'VPATH += {module_path}') - lines.append(f'SRC += $(wildcard {module_path}/{module_path.name}.c)') - lines.append(f'-include {module_path}/rules.mk') - - module_jsons = load_module_jsons(modules) - for module_json in module_jsons: - if 'features' in module_json: - lines.append('') - lines.append(f'# Module: {module_json["module_name"]}') - lines.extend(generate_features_rules(module_json['features'])) - return lines - - @cli.argument('filename', nargs='?', arg_only=True, type=FileType('r'), completer=FilesCompleter('.json'), help='A configurator export JSON to be compiled and flashed or a pre-compiled binary firmware file (bin/hex) to be flashed.') @cli.argument('-o', '--output', arg_only=True, type=normpath, help='File to write to') @cli.argument('-q', '--quiet', arg_only=True, action='store_true', help="Quiet mode, only output error messages") @@ -133,8 +105,6 @@ def generate_rules_mk(cli): if converter: rules_mk_lines.append(generate_rule('CONVERT_TO', converter)) - rules_mk_lines.extend(generate_modules_rules(cli.args.keyboard, cli.args.filename)) - # Show the results dump_lines(cli.args.output, rules_mk_lines) diff --git a/lib/python/qmk/cli/lint.py b/lib/python/qmk/cli/lint.py index c09e377ad6..484ddb5bd9 100644 --- a/lib/python/qmk/cli/lint.py +++ b/lib/python/qmk/cli/lint.py @@ -1,5 +1,6 @@ """Command to look over a keyboard/keymap and check for common mistakes. """ +from dotty_dict import dotty from pathlib import Path from milc import cli @@ -11,6 +12,7 @@ from qmk.keymap import locate_keymap, list_keymaps from qmk.path import keyboard from qmk.git import git_get_ignored_files from qmk.c_parse import c_source_files, preprocess_c_file +from qmk.json_schema import json_load CHIBIOS_CONF_CHECKS = ['chconf.h', 'halconf.h', 'mcuconf.h', 'board.h'] INVALID_KB_FEATURES = set(['encoder_map', 'dip_switch_map', 'combo', 'tap_dance', 'via']) @@ -26,7 +28,7 @@ def _list_defaultish_keymaps(kb): defaultish.extend(INVALID_KM_NAMES) keymaps = set() - for x in list_keymaps(kb): + for x in list_keymaps(kb, include_userspace=False): if x in defaultish or x.startswith('default'): keymaps.add(x) @@ -171,6 +173,14 @@ def _handle_invalid_features(kb, info): return ok +def _handle_invalid_config(kb, info): + """Check for invalid keyboard level config + """ + if info.get('url') == "": + cli.log.warning(f'{kb}: Invalid keyboard level config detected - Optional field "url" should not be empty.') + return True + + def _chibios_conf_includenext_check(target): """Check the ChibiOS conf.h for the correct inclusion of the next conf.h """ @@ -206,6 +216,32 @@ def _rules_mk_assignment_only(rules_mk): return errors +def _handle_duplicating_code_defaults(kb, info): + def _collect_dotted_output(kb_info_json, prefix=''): + """Print the info.json in a plain text format with dot-joined keys. + """ + for key in sorted(kb_info_json): + new_prefix = f'{prefix}.{key}' if prefix else key + + if isinstance(kb_info_json[key], dict): + yield from _collect_dotted_output(kb_info_json[key], new_prefix) + elif isinstance(kb_info_json[key], list): + # TODO: handle non primitives? + yield (new_prefix, kb_info_json[key]) + else: + yield (new_prefix, kb_info_json[key]) + + defaults_map = json_load(Path('data/mappings/info_defaults.hjson')) + dotty_info = dotty(info) + + for key, v_default in _collect_dotted_output(defaults_map): + v_info = dotty_info.get(key) + if v_default == v_info: + cli.log.warning(f'{kb}: Option "{key}" duplicates default value of "{v_default}"') + + return True + + def keymap_check(kb, km): """Perform the keymap level checks. """ @@ -255,6 +291,12 @@ def keyboard_check(kb): # noqa C901 if not _handle_invalid_features(kb, kb_info): ok = False + if not _handle_invalid_config(kb, kb_info): + ok = False + + if not _handle_duplicating_code_defaults(kb, kb_info): + ok = False + invalid_files = git_get_ignored_files(f'keyboards/{kb}/') for file in invalid_files: if 'keymap' in file: @@ -317,10 +359,10 @@ def lint(cli): if isinstance(cli.config.lint.keyboard, str): # if provided via config - string not array keyboard_list = [cli.config.lint.keyboard] - elif is_all_keyboards(cli.args.keyboard[0]): + elif any(is_all_keyboards(kb) for kb in cli.args.keyboard): keyboard_list = list_keyboards() else: - keyboard_list = cli.config.lint.keyboard + keyboard_list = list(set(cli.config.lint.keyboard)) failed = [] diff --git a/lib/python/qmk/cli/new/keymap.py b/lib/python/qmk/cli/new/keymap.py index 8b7160f5f2..20a0c0198c 100755 --- a/lib/python/qmk/cli/new/keymap.py +++ b/lib/python/qmk/cli/new/keymap.py @@ -1,10 +1,12 @@ """This script automates the copying of the default keymap into your own keymap. """ import re +import json import shutil +from pathlib import Path from milc import cli -from milc.questions import question +from milc.questions import question, choice from qmk.constants import HAS_QMK_USERSPACE, QMK_USERSPACE from qmk.path import is_keyboard, keymaps, keymap @@ -12,6 +14,34 @@ from qmk.git import git_get_username from qmk.decorators import automagic_keyboard, automagic_keymap from qmk.keyboard import keyboard_completer, keyboard_folder from qmk.userspace import UserspaceDefs +from qmk.json_schema import json_load +from qmk.json_encoders import KeymapJSONEncoder +from qmk.info import info_json + + +def _list_available_converters(kb_name): + """Search for converters that can be applied to a given keyboard + """ + if not is_keyboard(kb_name): + return None + + info = info_json(kb_name) + pin_compatible = info.get('pin_compatible') + if not pin_compatible: + return None + + return sorted(folder.name.split('_to_')[-1] for folder in Path('platforms').glob(f'*/converters/{pin_compatible}_to_*')) + + +def _set_converter(file, converter): + """add/overwrite any existing converter specified in keymap.json + """ + json_data = json_load(file) if file.exists() else {} + + json_data['converter'] = converter + + output = json.dumps(json_data, cls=KeymapJSONEncoder, sort_keys=True) + file.write_text(output + '\n', encoding='utf-8') def validate_keymap_name(name): @@ -37,8 +67,28 @@ Keymap name? """ return question(prompt, default=git_get_username()) +def prompt_converter(kb_name): + prompt = """ +{fg_yellow}Configure Development Board{style_reset_all} +For more information, see: +https://docs.qmk.fm/feature_converters + +Use converter? """ + + converters = _list_available_converters(kb_name) + if not converters: + return None + + choices = ['No (default)', *converters] + + answer = choice(prompt, options=choices, default=0) + return None if choices.index(answer) == 0 else answer + + @cli.argument('-kb', '--keyboard', type=keyboard_folder, completer=keyboard_completer, help='Specify keyboard name. Example: 1upkeyboards/1up60hse') @cli.argument('-km', '--keymap', help='Specify the name for the new keymap directory') +@cli.argument('--converter', help='Specify the name of a converter to configure') +@cli.argument('--skip-converter', arg_only=True, action='store_true', help='Skip converter') @cli.subcommand('Creates a new keymap for the keyboard of your choosing') @automagic_keyboard @automagic_keymap @@ -51,9 +101,12 @@ def new_keymap(cli): # ask for user input if keyboard or keymap was not provided in the command line kb_name = cli.config.new_keymap.keyboard if cli.config.new_keymap.keyboard else prompt_keyboard() user_name = cli.config.new_keymap.keymap if cli.config.new_keymap.keymap else prompt_user() + converter = cli.config.new_keymap.converter if cli.args.skip_converter or cli.config.new_keymap.converter else prompt_converter(kb_name) # check directories - if not is_keyboard(kb_name): + try: + kb_name = keyboard_folder(kb_name) + except ValueError: cli.log.error(f'Keyboard {{fg_cyan}}{kb_name}{{fg_reset}} does not exist! Please choose a valid name.') return False @@ -77,6 +130,9 @@ def new_keymap(cli): # create user directory with default keymap files shutil.copytree(keymap_path_default, keymap_path_new, symlinks=True) + if converter: + _set_converter(keymap_path_new / 'keymap.json', converter) + # end message to user cli.log.info(f'{{fg_green}}Created a new keymap called {{fg_cyan}}{user_name}{{fg_green}} in: {{fg_cyan}}{keymap_path_new}.{{fg_reset}}') cli.log.info(f"Compile a firmware with your new keymap by typing: {{fg_yellow}}qmk compile -kb {kb_name} -km {user_name}{{fg_reset}}.") diff --git a/lib/python/qmk/commands.py b/lib/python/qmk/commands.py index 0e1876ca7a..ac1455967d 100644 --- a/lib/python/qmk/commands.py +++ b/lib/python/qmk/commands.py @@ -12,6 +12,7 @@ from qmk.constants import QMK_USERSPACE, HAS_QMK_USERSPACE from qmk.json_schema import json_load, validate from qmk.keyboard import keyboard_alias_definitions from qmk.util import maybe_exit +from qmk.path import unix_style_path def find_make(): @@ -85,7 +86,7 @@ def build_environment(args): envs = parse_env_vars(args) if HAS_QMK_USERSPACE: - envs['QMK_USERSPACE'] = Path(QMK_USERSPACE).resolve() + envs['QMK_USERSPACE'] = unix_style_path(Path(QMK_USERSPACE).resolve()) return envs diff --git a/lib/python/qmk/compilation_database.py b/lib/python/qmk/compilation_database.py new file mode 100755 index 0000000000..4c88dadbdd --- /dev/null +++ b/lib/python/qmk/compilation_database.py @@ -0,0 +1,137 @@ +"""Creates a compilation database for the given keyboard build. +""" + +import json +import os +import re +import shlex +import shutil +from functools import lru_cache +from pathlib import Path +from typing import Dict, Iterator, List + +from milc import cli + +from qmk.commands import find_make +from qmk.constants import QMK_FIRMWARE + + +@lru_cache(maxsize=10) +def system_libs(binary: str) -> List[Path]: + """Find the system include directory that the given build tool uses. + """ + cli.log.debug("searching for system library directory for binary: %s", binary) + + # Actually query xxxxxx-gcc to find its include paths. + if binary.endswith("gcc") or binary.endswith("g++"): + # (TODO): Remove 'stdin' once 'input' no longer causes issues under MSYS + result = cli.run([binary, '-E', '-Wp,-v', '-'], capture_output=True, check=True, stdin=None, input='\n') + paths = [] + for line in result.stderr.splitlines(): + if line.startswith(" "): + paths.append(Path(line.strip()).resolve()) + return paths + + return list(Path(binary).resolve().parent.parent.glob("*/include")) if binary else [] + + +@lru_cache(maxsize=10) +def cpu_defines(binary: str, compiler_args: str) -> List[str]: + cli.log.debug("gathering definitions for compilation: %s %s", binary, compiler_args) + if binary.endswith("gcc") or binary.endswith("g++"): + invocation = [binary, '-dM', '-E'] + if binary.endswith("gcc"): + invocation.extend(['-x', 'c']) + elif binary.endswith("g++"): + invocation.extend(['-x', 'c++']) + compiler_args = shlex.split(compiler_args) + invocation.extend(compiler_args) + invocation.append('-') + result = cli.run(invocation, capture_output=True, check=True, stdin=None, input='\n') + define_args = [] + for line in result.stdout.splitlines(): + line_args = line.split(' ', 2) + if len(line_args) == 3 and line_args[0] == '#define': + define_args.append(f'-D{line_args[1]}={line_args[2]}') + elif len(line_args) == 2 and line_args[0] == '#define': + define_args.append(f'-D{line_args[1]}') + return list(sorted(set(define_args))) + return [] + + +file_re = re.compile(r'printf "Compiling: ([^"]+)') +cmd_re = re.compile(r'LOG=\$\((.+?)&&') + + +def parse_make_n(f: Iterator[str]) -> List[Dict[str, str]]: + """parse the output of `make -n ` + + This function makes many assumptions about the format of your build log. + This happens to work right now for qmk. + """ + + state = 'start' + this_file = None + records = [] + for line in f: + if state == 'start': + m = file_re.search(line) + if m: + this_file = m.group(1) + state = 'cmd' + + if state == 'cmd': + assert this_file + m = cmd_re.search(line) + if m: + # we have a hit! + this_cmd = m.group(1) + args = shlex.split(this_cmd) + binary = shutil.which(args[0]) + compiler_args = set(filter(lambda x: x.startswith('-m') or x.startswith('-f'), args)) + for s in system_libs(binary): + args += ['-isystem', '%s' % s] + args.extend(cpu_defines(binary, ' '.join(shlex.quote(s) for s in compiler_args))) + new_cmd = ' '.join(shlex.quote(s) for s in args) + records.append({"directory": str(QMK_FIRMWARE.resolve()), "command": new_cmd, "file": this_file}) + state = 'start' + + return records + + +def write_compilation_database(keyboard: str = None, keymap: str = None, output_path: Path = QMK_FIRMWARE / 'compile_commands.json', skip_clean: bool = False, command: List[str] = None, **env_vars) -> bool: + # Generate the make command for a specific keyboard/keymap. + if not command: + from qmk.build_targets import KeyboardKeymapBuildTarget # Lazy load due to circular references + target = KeyboardKeymapBuildTarget(keyboard, keymap) + command = target.compile_command(dry_run=True, **env_vars) + + if not command: + cli.log.error('You must supply both `--keyboard` and `--keymap`, or be in a directory for a keyboard or keymap.') + cli.echo('usage: qmk generate-compilation-database [-kb KEYBOARD] [-km KEYMAP]') + return False + + # remove any environment variable overrides which could trip us up + env = os.environ.copy() + env.pop("MAKEFLAGS", None) + + # re-use same executable as the main make invocation (might be gmake) + if not skip_clean: + clean_command = [find_make(), "clean"] + cli.log.info('Making clean with {fg_cyan}%s', ' '.join(clean_command)) + cli.run(clean_command, capture_output=False, check=True, env=env) + + cli.log.info('Gathering build instructions from {fg_cyan}%s', ' '.join(command)) + + result = cli.run(command, capture_output=True, check=True, env=env) + db = parse_make_n(result.stdout.splitlines()) + if not db: + cli.log.error("Failed to parse output from make output:\n%s", result.stdout) + return False + + cli.log.info("Found %s compile commands", len(db)) + + cli.log.info(f"Writing build database to {output_path}") + output_path.write_text(json.dumps(db, indent=4)) + + return True diff --git a/lib/python/qmk/constants.py b/lib/python/qmk/constants.py index e055d3fbc9..e3e47c2bd2 100644 --- a/lib/python/qmk/constants.py +++ b/lib/python/qmk/constants.py @@ -22,7 +22,7 @@ QMK_FIRMWARE_UPSTREAM = 'qmk/qmk_firmware' MAX_KEYBOARD_SUBFOLDERS = 5 # Supported processor types -CHIBIOS_PROCESSORS = 'cortex-m0', 'cortex-m0plus', 'cortex-m3', 'cortex-m4', 'MKL26Z64', 'MK20DX128', 'MK20DX256', 'MK64FX512', 'MK66FX1M0', 'RP2040', 'STM32F042', 'STM32F072', 'STM32F103', 'STM32F303', 'STM32F401', 'STM32F405', 'STM32F407', 'STM32F411', 'STM32F446', 'STM32G431', 'STM32G474', 'STM32H723', 'STM32H733', 'STM32L412', 'STM32L422', 'STM32L432', 'STM32L433', 'STM32L442', 'STM32L443', 'GD32VF103', 'WB32F3G71', 'WB32FQ95', 'AT32F415' +CHIBIOS_PROCESSORS = 'cortex-m0', 'cortex-m0plus', 'cortex-m3', 'cortex-m4', 'MKL26Z64', 'MK20DX128', 'MK20DX256', 'MK64FX512', 'MK66FX1M0', 'RP2040', 'STM32F042', 'STM32F072', 'STM32F103', 'STM32F303', 'STM32F401', 'STM32F405', 'STM32F407', 'STM32F411', 'STM32F446', 'STM32G0B1', 'STM32G431', 'STM32G474', 'STM32H723', 'STM32H733', 'STM32L412', 'STM32L422', 'STM32L432', 'STM32L433', 'STM32L442', 'STM32L443', 'GD32VF103', 'WB32F3G71', 'WB32FQ95', 'AT32F415' LUFA_PROCESSORS = 'at90usb162', 'atmega16u2', 'atmega32u2', 'atmega16u4', 'atmega32u4', 'at90usb646', 'at90usb647', 'at90usb1286', 'at90usb1287', None VUSB_PROCESSORS = 'atmega32a', 'atmega328p', 'atmega328', 'attiny85' @@ -42,6 +42,7 @@ MCU2BOOTLOADER = { "STM32F407": "stm32-dfu", "STM32F411": "stm32-dfu", "STM32F446": "stm32-dfu", + "STM32G0B1": "stm32-dfu", "STM32G431": "stm32-dfu", "STM32G474": "stm32-dfu", "STM32H723": "stm32-dfu", diff --git a/lib/python/qmk/decorators.py b/lib/python/qmk/decorators.py index 16b44d6d59..0cad55a483 100644 --- a/lib/python/qmk/decorators.py +++ b/lib/python/qmk/decorators.py @@ -5,7 +5,7 @@ from time import monotonic from milc import cli -from qmk.keyboard import find_keyboard_from_dir +from qmk.keyboard import find_keyboard_from_dir, keyboard_folder from qmk.keymap import find_keymap_from_dir @@ -27,6 +27,11 @@ def automagic_keyboard(func): def wrapper(*args, **kwargs): cmd = _get_subcommand_name() + # TODO: Workaround for if config file contains "old" keyboard name + # Potential long-term fix needs to be within global cli or milc + if cli.config_source[cmd]['keyboard'] == 'config_file': + cli.config[cmd]['keyboard'] = keyboard_folder(cli.config[cmd]['keyboard']) + # Ensure that `--keyboard` was not passed and CWD is under `qmk_firmware/keyboards` if cli.config_source[cmd]['keyboard'] != 'argument': keyboard = find_keyboard_from_dir() diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index 93eba7376a..d95fd3d799 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -1066,23 +1066,13 @@ def get_modules(keyboard, keymap_filename): """ modules = [] + kb_info_json = info_json(keyboard) + modules.extend(kb_info_json.get('modules', [])) + if keymap_filename: keymap_json = parse_configurator_json(keymap_filename) if keymap_json: - kb = keymap_json.get('keyboard', None) - if not kb: - kb = keyboard - - if kb: - kb_info_json = info_json(kb) - if kb_info_json: - modules.extend(kb_info_json.get('modules', [])) - modules.extend(keymap_json.get('modules', [])) - elif keyboard: - kb_info_json = info_json(keyboard) - modules.extend(kb_info_json.get('modules', [])) - return list(dict.fromkeys(modules)) # remove dupes diff --git a/lib/python/qmk/json_encoders.py b/lib/python/qmk/json_encoders.py index e83a381d52..e8bcf48996 100755 --- a/lib/python/qmk/json_encoders.py +++ b/lib/python/qmk/json_encoders.py @@ -250,12 +250,14 @@ class CommunityModuleJSONEncoder(QMKJSONEncoder): return '00module_name' if key == 'maintainer': return '01maintainer' + if key == 'license': + return '02license' if key == 'url': - return '02url' + return '03url' if key == 'features': - return '03features' + return '04features' if key == 'keycodes': - return '04keycodes' + return '05keycodes' elif self.indentation_level == 3: # keycodes if key == 'key': return '00key' diff --git a/lib/python/qmk/json_schema.py b/lib/python/qmk/json_schema.py index b11a0ed7ea..e871598565 100644 --- a/lib/python/qmk/json_schema.py +++ b/lib/python/qmk/json_schema.py @@ -76,8 +76,13 @@ def compile_schema_store(): if not isinstance(schema_data, dict): cli.log.debug('Skipping schema file %s', schema_file) continue + + # `$id`-based references schema_store[schema_data['$id']] = schema_data + # Path-based references + schema_store[Path(schema_file).name] = schema_data + return schema_store diff --git a/lib/python/qmk/keycodes.py b/lib/python/qmk/keycodes.py index 966930547c..9e4664e5f1 100644 --- a/lib/python/qmk/keycodes.py +++ b/lib/python/qmk/keycodes.py @@ -89,6 +89,7 @@ def load_spec(version, lang=None): spec = _process_files(_locate_files(path, prefix, versions)) # Sort? + spec['version'] = version spec['keycodes'] = dict(sorted(spec.get('keycodes', {}).items())) spec['ranges'] = dict(sorted(spec.get('ranges', {}).items())) diff --git a/lib/python/qmk/keymap.py b/lib/python/qmk/keymap.py index 8e36461722..b7138aa4a1 100644 --- a/lib/python/qmk/keymap.py +++ b/lib/python/qmk/keymap.py @@ -399,7 +399,7 @@ def is_keymap_target(keyboard, keymap): return False -def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=False): +def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=False, include_userspace=True): """List the available keymaps for a keyboard. Args: @@ -418,14 +418,19 @@ def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=Fa fullpath When set to True the full path of the keymap relative to the `qmk_firmware` root will be provided. + include_userspace + When set to True, also search userspace for available keymaps + Returns: a sorted list of valid keymap names. """ names = set() + has_userspace = HAS_QMK_USERSPACE and include_userspace + # walk up the directory tree until keyboards_dir # and collect all directories' name with keymap.c file in it - for search_dir in [QMK_FIRMWARE, QMK_USERSPACE] if HAS_QMK_USERSPACE else [QMK_FIRMWARE]: + for search_dir in [QMK_FIRMWARE, QMK_USERSPACE] if has_userspace else [QMK_FIRMWARE]: keyboards_dir = search_dir / Path('keyboards') kb_path = keyboards_dir / keyboard @@ -443,7 +448,7 @@ def list_keymaps(keyboard, c=True, json=True, additional_files=None, fullpath=Fa info = info_json(keyboard) community_parents = list(Path('layouts').glob('*/')) - if HAS_QMK_USERSPACE and (Path(QMK_USERSPACE) / "layouts").exists(): + if has_userspace and (Path(QMK_USERSPACE) / "layouts").exists(): community_parents.append(Path(QMK_USERSPACE) / "layouts") for community_parent in community_parents: diff --git a/lib/python/qmk/userspace.py b/lib/python/qmk/userspace.py index 1c2a97f9c1..881490f796 100644 --- a/lib/python/qmk/userspace.py +++ b/lib/python/qmk/userspace.py @@ -12,29 +12,30 @@ from qmk.json_encoders import UserspaceJSONEncoder def qmk_userspace_paths(): - test_dirs = set() + test_dirs = [] # If we're already in a directory with a qmk.json and a keyboards or layouts directory, interpret it as userspace if environ.get('ORIG_CWD') is not None: current_dir = Path(environ['ORIG_CWD']) while len(current_dir.parts) > 1: if (current_dir / 'qmk.json').is_file(): - test_dirs.add(current_dir) + test_dirs.append(current_dir) current_dir = current_dir.parent # If we have a QMK_USERSPACE environment variable, use that if environ.get('QMK_USERSPACE') is not None: current_dir = Path(environ['QMK_USERSPACE']).expanduser() if current_dir.is_dir(): - test_dirs.add(current_dir) + test_dirs.append(current_dir) # If someone has configured a directory, use that if cli.config.user.overlay_dir is not None: current_dir = Path(cli.config.user.overlay_dir).expanduser().resolve() if current_dir.is_dir(): - test_dirs.add(current_dir) + test_dirs.append(current_dir) - return list(test_dirs) + # remove duplicates while maintaining the current order + return list(dict.fromkeys(test_dirs)) def qmk_userspace_validate(path): diff --git a/modules/qmk/flow_led_matrix_effect/led_matrix_module.inc b/modules/qmk/flow_led_matrix_effect/led_matrix_module.inc new file mode 100644 index 0000000000..734e0f3494 --- /dev/null +++ b/modules/qmk/flow_led_matrix_effect/led_matrix_module.inc @@ -0,0 +1,58 @@ +// Copyright 2024-2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +LED_MATRIX_EFFECT(FLOW) + +#ifdef LED_MATRIX_CUSTOM_EFFECT_IMPLS + +// "Flow" animated effect. Draws moving wave patterns mimicking the appearance +// of flowing liquid. For interesting variety of patterns, space coordinates are +// slowly rotated and a function of several sine waves is evaluated. +static bool FLOW(effect_params_t* params) { + LED_MATRIX_USE_LIMITS(led_min, led_max); + + static uint16_t wrap_correction = 0; + static uint8_t last_high_byte = 0; + const uint8_t time_scale = 1 + led_matrix_eeconfig.speed / 8; + const uint8_t high_byte = (uint8_t)(g_led_timer >> 16); + if (last_high_byte != high_byte) { + last_high_byte = high_byte; + wrap_correction += ((uint16_t)time_scale) << 8; + } + const uint16_t time = scale16by8(g_led_timer, time_scale) + wrap_correction; + + // Compute rotation coefficients with 7 fractional bits. + const int8_t rot_c = cos8(time / 4) - 128; + const int8_t rot_s = sin8(time / 4) - 128; + const uint8_t omega = 32 + sin8(time) / 4; + + for (uint8_t i = led_min; i < led_max; ++i) { + LED_MATRIX_TEST_LED_FLAGS(); + const uint8_t x = g_led_config.point[i].x; + const uint8_t y = g_led_config.point[i].y; + + // Rotate (x, y) by the 2x2 rotation matrix described by rot_c, rot_s. + const uint8_t x1 = (uint8_t)((((int16_t)rot_c) * ((int16_t)x)) / 128) - (uint8_t)((((int16_t)rot_s) * ((int16_t)y)) / 128); + const uint8_t y1 = (uint8_t)((((int16_t)rot_s) * ((int16_t)x)) / 128) + (uint8_t)((((int16_t)rot_c) * ((int16_t)y)) / 128); + + uint8_t value = scale8(sin8(x1 - 2 * time), omega) + y1 + time / 4; + value = (value <= 127) ? value : (255 - value); + + led_matrix_set_value(i, scale8(led_matrix_eeconfig.val, value)); + } + + return led_matrix_check_finished_leds(led_max); +} + +#endif // LED_MATRIX_CUSTOM_EFFECT_IMPLS diff --git a/modules/qmk/flow_led_matrix_effect/qmk_module.json b/modules/qmk/flow_led_matrix_effect/qmk_module.json new file mode 100644 index 0000000000..2d047cd0d0 --- /dev/null +++ b/modules/qmk/flow_led_matrix_effect/qmk_module.json @@ -0,0 +1,8 @@ +{ + "module_name": "Flow LED matrix effect", + "maintainer": "QMK Maintainers", + "license": "Apache-2.0", + "features": { + "led_matrix": true + } +} diff --git a/modules/qmk/flow_rgb_matrix_effect/qmk_module.json b/modules/qmk/flow_rgb_matrix_effect/qmk_module.json new file mode 100644 index 0000000000..3e42fe1ef4 --- /dev/null +++ b/modules/qmk/flow_rgb_matrix_effect/qmk_module.json @@ -0,0 +1,8 @@ +{ + "module_name": "Flow RGB matrix effect", + "maintainer": "QMK Maintainers", + "license": "Apache-2.0", + "features": { + "rgb_matrix": true + } +} diff --git a/modules/qmk/flow_rgb_matrix_effect/rgb_matrix_module.inc b/modules/qmk/flow_rgb_matrix_effect/rgb_matrix_module.inc new file mode 100644 index 0000000000..410838f7ec --- /dev/null +++ b/modules/qmk/flow_rgb_matrix_effect/rgb_matrix_module.inc @@ -0,0 +1,64 @@ +// Copyright 2024-2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +RGB_MATRIX_EFFECT(FLOW) + +#ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS + +// "Flow" animated effect. Draws moving wave patterns mimicking the appearance +// of flowing liquid. For interesting variety of patterns, space coordinates are +// slowly rotated and a function of several sine waves is evaluated. +static bool FLOW(effect_params_t* params) { + RGB_MATRIX_USE_LIMITS(led_min, led_max); + + static uint16_t wrap_correction = 0; + static uint8_t last_high_byte = 0; + const uint8_t time_scale = 1 + rgb_matrix_config.speed / 8; + const uint8_t high_byte = (uint8_t)(g_rgb_timer >> 16); + if (last_high_byte != high_byte) { + last_high_byte = high_byte; + wrap_correction += ((uint16_t)time_scale) << 8; + } + const uint16_t time = scale16by8(g_rgb_timer, time_scale) + wrap_correction; + + // Compute rotation coefficients with 7 fractional bits. + const int8_t rot_c = cos8(time / 4) - 128; + const int8_t rot_s = sin8(time / 4) - 128; + const uint8_t omega = 32 + sin8(time) / 4; + + for (uint8_t i = led_min; i < led_max; ++i) { + RGB_MATRIX_TEST_LED_FLAGS(); + const uint8_t x = g_led_config.point[i].x; + const uint8_t y = g_led_config.point[i].y; + + // Rotate (x, y) by the 2x2 rotation matrix described by rot_c, rot_s. + const uint8_t x1 = (uint8_t)((((int16_t)rot_c) * ((int16_t)x)) / 128) - (uint8_t)((((int16_t)rot_s) * ((int16_t)y)) / 128); + const uint8_t y1 = (uint8_t)((((int16_t)rot_s) * ((int16_t)x)) / 128) + (uint8_t)((((int16_t)rot_c) * ((int16_t)y)) / 128); + + uint8_t value = scale8(sin8(x1 - 2 * time), omega) + y1 + time / 4; + value = (value <= 127) ? value : (255 - value); + + hsv_t hsv = rgb_matrix_config.hsv; + hsv.h -= value / 4; + hsv.s = scale8(hsv.s, (value < 74) ? 255 : (549 - 4 * value)); + hsv.v = scale8(hsv.v, (value < 95) ? (64 + 2 * value) : 255); + + rgb_t rgb = rgb_matrix_hsv_to_rgb(hsv); + rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); + } + + return rgb_matrix_check_finished_leds(led_max); +} + +#endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS diff --git a/modules/qmk/hello_world/hello_world.c b/modules/qmk/hello_world/hello_world.c index d9dd366100..dcabfc60ea 100644 --- a/modules/qmk/hello_world/hello_world.c +++ b/modules/qmk/hello_world/hello_world.c @@ -7,7 +7,7 @@ ASSERT_COMMUNITY_MODULES_MIN_API_VERSION(1, 0, 0); uint32_t delayed_hello_world(uint32_t trigger_time, void *cb_arg) { - printf("Hello, world! I'm a QMK based keyboard! The keymap array size is %d bytes.\n", (int)hello_world_introspection().total_size); + dprintf("Hello, world! I'm a QMK based keyboard! The keymap array size is %d bytes.\n", (int)hello_world_introspection().total_size); return 0; } diff --git a/modules/qmk/hello_world/qmk_module.json b/modules/qmk/hello_world/qmk_module.json index fd855a6e23..bbd00f3fcc 100644 --- a/modules/qmk/hello_world/qmk_module.json +++ b/modules/qmk/hello_world/qmk_module.json @@ -1,6 +1,7 @@ { "module_name": "Hello World", "maintainer": "QMK Maintainers", + "license": "GPL-2.0-or-later", "features": { "console": true, "deferred_exec": true diff --git a/modules/qmk/super_alt_tab/qmk_module.json b/modules/qmk/super_alt_tab/qmk_module.json index 002f7fb69e..142613a23e 100644 --- a/modules/qmk/super_alt_tab/qmk_module.json +++ b/modules/qmk/super_alt_tab/qmk_module.json @@ -1,6 +1,7 @@ { "module_name": "Super Alt Tab", "maintainer": "QMK Maintainers", + "license": "GPL-2.0-or-later", "keycodes": [ { "key": "COMMUNITY_MODULE_SUPER_ALT_TAB", diff --git a/modules/zsa/oryx/introspection.h b/modules/zsa/oryx/introspection.h new file mode 100644 index 0000000000..f8426d4dfc --- /dev/null +++ b/modules/zsa/oryx/introspection.h @@ -0,0 +1,6 @@ +// Copyright 2024 ZSA Technology Labs, Inc <@zsa> +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "oryx.h" diff --git a/modules/zsa/oryx/oryx.c b/modules/zsa/oryx/oryx.c index dafce5dbdc..5131a18665 100644 --- a/modules/zsa/oryx/oryx.c +++ b/modules/zsa/oryx/oryx.c @@ -6,7 +6,7 @@ #include "oryx.h" #include "action_util.h" -ASSERT_COMMUNITY_MODULES_MIN_API_VERSION(1, 1, 0); +ASSERT_COMMUNITY_MODULES_MIN_API_VERSION(1, 1, 1); uint8_t current_layer = 0; @@ -51,7 +51,7 @@ void oryx_error(uint8_t code) { void oryx_layer_event(void) { uint8_t layer; uint8_t event[RAW_EPSIZE]; - layer = get_highest_layer(layer_state); + layer = get_highest_layer(layer_state | default_layer_state); event[0] = ORYX_EVT_LAYER; event[1] = layer; event[2] = ORYX_STOP_BIT; @@ -72,6 +72,7 @@ void pairing_success_event(void) { event[0] = ORYX_EVT_PAIRING_SUCCESS; event[1] = ORYX_STOP_BIT; raw_hid_send_oryx(event, sizeof(event)); + oryx_layer_event(); } void toggle_smart_layer(void) { @@ -89,7 +90,7 @@ void trigger_smart_layer(void) { } void set_webhid_effect(void) { -#if defined(RGB_MATRIX_ENABLE) && !defined(PROTOCOL_LUFA) +#if defined(RGB_MATRIX_ENABLE) && !defined(PROTOCOL_LUFA) && defined(RGB_MATRIX_CUSTOM_KB) rgb_matrix_mode_noeeprom(RGB_MATRIX_CUSTOM_oryx_webhid_effect); rawhid_state.rgb_control = true; #endif @@ -111,32 +112,30 @@ void raw_hid_receive(uint8_t *data, uint8_t length) { uint8_t *param = &data[1]; switch (command) { - case ORYX_CMD_GET_FW_VERSION: - { - uint8_t event[RAW_EPSIZE]; - uint8_t fw_version_size = sizeof(SERIAL_NUMBER); - uint8_t stop[1]; + case ORYX_CMD_GET_FW_VERSION: { + uint8_t event[RAW_EPSIZE]; + uint8_t fw_version_size = sizeof(SERIAL_NUMBER); + uint8_t stop[1]; - event[0] = ORYX_EVT_GET_FW_VERSION; - stop[0] = ORYX_STOP_BIT; + event[0] = ORYX_EVT_GET_FW_VERSION; + stop[0] = ORYX_STOP_BIT; - memcpy(event + 1, SERIAL_NUMBER, fw_version_size); - memcpy(event + fw_version_size, stop, 1); + memcpy(event + 1, SERIAL_NUMBER, fw_version_size); + memcpy(event + fw_version_size, stop, 1); - raw_hid_send_oryx(event, RAW_EPSIZE); - break; - } + raw_hid_send_oryx(event, RAW_EPSIZE); + break; + } - case ORYX_GET_PROTOCOL_VERSION: - { - uint8_t event[RAW_EPSIZE]; - event[0] = ORYX_EVT_GET_PROTOCOL_VERSION; - event[1] = ORYX_PROTOCOL_VERSION; - event[2] = ORYX_STOP_BIT; + case ORYX_GET_PROTOCOL_VERSION: { + uint8_t event[RAW_EPSIZE]; + event[0] = ORYX_EVT_GET_PROTOCOL_VERSION; + event[1] = ORYX_PROTOCOL_VERSION; + event[2] = ORYX_STOP_BIT; - raw_hid_send_oryx(event, RAW_EPSIZE); - break; - } + raw_hid_send_oryx(event, RAW_EPSIZE); + break; + } case ORYX_CMD_PAIRING_INIT: pairing_success_event(); @@ -245,48 +244,46 @@ void raw_hid_receive(uint8_t *data, uint8_t length) { break; } break; - case ORYX_UPDATE_BRIGHTNESS: - { + case ORYX_UPDATE_BRIGHTNESS: { #if defined(RGB_MATRIX_ENABLE) && !defined(PROTOCOL_LUFA) - if (param[0]) { - rgb_matrix_increase_val_noeeprom(); - } else { - rgb_matrix_decrease_val_noeeprom(); - } -#else - oryx_error(ORYX_ERR_RGB_MATRIX_NOT_ENABLED); -#endif - break; + if (param[0]) { + rgb_matrix_increase_val_noeeprom(); + } else { + rgb_matrix_decrease_val_noeeprom(); } - case ORYX_STATUS_LED_CONTROL: - { - rawhid_state.status_led_control = param[0]; - if (!param[0]) { +#else + oryx_error(ORYX_ERR_RGB_MATRIX_NOT_ENABLED); +#endif + break; + } + case ORYX_STATUS_LED_CONTROL: { + rawhid_state.status_led_control = param[0]; + if (!param[0]) { #ifdef STATUS_LED_1 - STATUS_LED_1(0); + STATUS_LED_1(0); #endif #ifdef STATUS_LED_2 - STATUS_LED_2(0); + STATUS_LED_2(0); #endif #ifdef STATUS_LED_3 - STATUS_LED_3(0); + STATUS_LED_3(0); #endif #ifdef STATUS_LED_4 - STATUS_LED_4(0); + STATUS_LED_4(0); #endif #ifdef STATUS_LED_5 - STATUS_LED_5(0); + STATUS_LED_5(0); #endif #ifdef STATUS_LED_6 - STATUS_LED_6(0); + STATUS_LED_6(0); #endif - } - uint8_t event[RAW_EPSIZE]; - event[0] = ORYX_EVT_STATUS_LED_CONTROL; - event[1] = rawhid_state.status_led_control; - raw_hid_send_oryx(event, RAW_EPSIZE); - break; } + uint8_t event[RAW_EPSIZE]; + event[0] = ORYX_EVT_STATUS_LED_CONTROL; + event[1] = rawhid_state.status_led_control; + raw_hid_send_oryx(event, RAW_EPSIZE); + break; + } default: oryx_error(ORYX_ERR_UNKNOWN_COMMAND); } @@ -294,7 +291,7 @@ void raw_hid_receive(uint8_t *data, uint8_t length) { bool pre_process_record_oryx(uint16_t keycode, keyrecord_t *record) { if (!pre_process_record_oryx_kb(keycode, record)) { - return false; + return true; } // While paired, the keyboard sends keystrokes positions to the host if (rawhid_state.paired == true) { @@ -309,12 +306,13 @@ bool pre_process_record_oryx(uint16_t keycode, keyrecord_t *record) { } layer_state_t layer_state_set_oryx(layer_state_t state) { + state = layer_state_set_oryx_kb(state); if (rawhid_state.paired) { - uint8_t layer = get_highest_layer(state); + uint8_t layer = get_highest_layer(state | default_layer_state); // Some layer actions (OSL) trigger the layer state change thrice, // so we need to check if the layer has actually changed if (current_layer == layer) { - return layer_state_set_oryx_kb(state); + return state; } current_layer = layer; #if defined(PROTOCOL_LUFA) @@ -327,5 +325,10 @@ layer_state_t layer_state_set_oryx(layer_state_t state) { event[2] = ORYX_STOP_BIT; raw_hid_send_oryx(event, sizeof(event)); } - return layer_state_set_oryx_kb(state); + return state; +} + +layer_state_t default_layer_state_set_oryx(layer_state_t state) { + layer_state_set_oryx(state | layer_state); + return default_layer_state_set_oryx_kb(state); } diff --git a/modules/zsa/oryx/oryx.h b/modules/zsa/oryx/oryx.h index 9497182716..4f3011cfbf 100644 --- a/modules/zsa/oryx/oryx.h +++ b/modules/zsa/oryx/oryx.h @@ -25,7 +25,7 @@ always respond with a Oryx_Event_Code or a Oryx_Error_Code. #endif #define ORYX_PROTOCOL_VERSION 0x04 -#define ORYX_STOP_BIT -2 +#define ORYX_STOP_BIT -2 enum Oryx_Command_Code { ORYX_CMD_GET_FW_VERSION, diff --git a/modules/zsa/oryx/post_config.h b/modules/zsa/oryx/post_config.h index 20f729958c..3681f019e7 100644 --- a/modules/zsa/oryx/post_config.h +++ b/modules/zsa/oryx/post_config.h @@ -3,6 +3,8 @@ #pragma once +#include "keycode_aliases.h" + #ifndef SERIAL_NUMBER # define SERIAL_NUMBER "default/latest" #endif // SERIAL_NUMBER diff --git a/modules/zsa/oryx/qmk_module.json b/modules/zsa/oryx/qmk_module.json index b912218d6d..962cfd2f9f 100644 --- a/modules/zsa/oryx/qmk_module.json +++ b/modules/zsa/oryx/qmk_module.json @@ -1,5 +1,5 @@ { - "maintainer": "drashna", + "maintainer": "ZSA", "module_name": "oryx", "features": { "raw": true, diff --git a/modules/zsa/oryx/rgb_matrix_kb.inc b/modules/zsa/oryx/rgb_matrix_module.inc similarity index 100% rename from modules/zsa/oryx/rgb_matrix_kb.inc rename to modules/zsa/oryx/rgb_matrix_module.inc diff --git a/modules/zsa/oryx/rules.mk b/modules/zsa/oryx/rules.mk index 80dfc8683a..bd86c2e08d 100644 --- a/modules/zsa/oryx/rules.mk +++ b/modules/zsa/oryx/rules.mk @@ -1,2 +1 @@ POST_CONFIG_H += keyboards/zsa/common/keycode_aliases.h -RGB_MATRIX_CUSTOM_KB = yes diff --git a/platforms/atomic_util.h b/platforms/atomic_util.h index 21286d72eb..8e81eacdb8 100644 --- a/platforms/atomic_util.h +++ b/platforms/atomic_util.h @@ -15,17 +15,19 @@ */ #pragma once +#include "compiler_support.h" + // Macro to help make GPIO and other controls atomic. #ifndef IGNORE_ATOMIC_BLOCK # if __has_include_next("atomic_util.h") # include_next "atomic_util.h" /* Include the platforms atomic.h */ # else -# define ATOMIC_BLOCK _Static_assert(0, "ATOMIC_BLOCK not implemented") -# define ATOMIC_BLOCK_RESTORESTATE _Static_assert(0, "ATOMIC_BLOCK_RESTORESTATE not implemented") -# define ATOMIC_BLOCK_FORCEON _Static_assert(0, "ATOMIC_BLOCK_FORCEON not implemented") -# define ATOMIC_FORCEON _Static_assert(0, "ATOMIC_FORCEON not implemented") -# define ATOMIC_RESTORESTATE _Static_assert(0, "ATOMIC_RESTORESTATE not implemented") +# define ATOMIC_BLOCK STATIC_ASSERT(0, "ATOMIC_BLOCK not implemented") +# define ATOMIC_BLOCK_RESTORESTATE STATIC_ASSERT(0, "ATOMIC_BLOCK_RESTORESTATE not implemented") +# define ATOMIC_BLOCK_FORCEON STATIC_ASSERT(0, "ATOMIC_BLOCK_FORCEON not implemented") +# define ATOMIC_FORCEON STATIC_ASSERT(0, "ATOMIC_FORCEON not implemented") +# define ATOMIC_RESTORESTATE STATIC_ASSERT(0, "ATOMIC_RESTORESTATE not implemented") # endif #else /* do nothing atomic macro */ # define ATOMIC_BLOCK(t) for (uint8_t __ToDo = 1; __ToDo; __ToDo = 0) diff --git a/platforms/avr/drivers/i2c_master.c b/platforms/avr/drivers/i2c_master.c index 64083d862a..9136f4a7b9 100644 --- a/platforms/avr/drivers/i2c_master.c +++ b/platforms/avr/drivers/i2c_master.c @@ -315,4 +315,4 @@ __attribute__((weak)) i2c_status_t i2c_ping_address(uint8_t address, uint16_t ti i2c_status_t status = i2c_start(address, timeout); i2c_stop(); return status; -} \ No newline at end of file +} diff --git a/platforms/avr/drivers/i2c_slave.h b/platforms/avr/drivers/i2c_slave.h index 178b6a29df..8614bd865a 100644 --- a/platforms/avr/drivers/i2c_slave.h +++ b/platforms/avr/drivers/i2c_slave.h @@ -22,6 +22,8 @@ #pragma once +#include "compiler_support.h" + #ifndef I2C_SLAVE_REG_COUNT # if defined(USE_I2C) && defined(SPLIT_COMMON_TRANSACTIONS) @@ -33,7 +35,7 @@ #endif // I2C_SLAVE_REG_COUNT -_Static_assert(I2C_SLAVE_REG_COUNT < 256, "I2C target registers must be single byte"); +STATIC_ASSERT(I2C_SLAVE_REG_COUNT < 256, "I2C target registers must be single byte"); extern volatile uint8_t i2c_slave_reg[I2C_SLAVE_REG_COUNT]; diff --git a/platforms/avr/gpio.h b/platforms/avr/gpio.h index 6f089bc663..4c09619772 100644 --- a/platforms/avr/gpio.h +++ b/platforms/avr/gpio.h @@ -16,6 +16,8 @@ #pragma once #include + +#include "compiler_support.h" #include "pin_defs.h" typedef uint8_t pin_t; @@ -24,9 +26,9 @@ typedef uint8_t pin_t; #define gpio_set_pin_input(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) &= ~_BV((pin)&0xF)) #define gpio_set_pin_input_high(pin) (DDRx_ADDRESS(pin) &= ~_BV((pin)&0xF), PORTx_ADDRESS(pin) |= _BV((pin)&0xF)) -#define gpio_set_pin_input_low(pin) _Static_assert(0, "GPIO pulldowns in input mode are not available on AVR") +#define gpio_set_pin_input_low(pin) STATIC_ASSERT(0, "GPIO pulldowns in input mode are not available on AVR") #define gpio_set_pin_output_push_pull(pin) (DDRx_ADDRESS(pin) |= _BV((pin)&0xF)) -#define gpio_set_pin_output_open_drain(pin) _Static_assert(0, "Open-drain outputs are not available on AVR") +#define gpio_set_pin_output_open_drain(pin) STATIC_ASSERT(0, "Open-drain outputs are not available on AVR") #define gpio_set_pin_output(pin) gpio_set_pin_output_push_pull(pin) #define gpio_write_pin_high(pin) (PORTx_ADDRESS(pin) |= _BV((pin)&0xF)) diff --git a/platforms/avr/platform.mk b/platforms/avr/platform.mk index 79bd647159..3616afdd4a 100644 --- a/platforms/avr/platform.mk +++ b/platforms/avr/platform.mk @@ -12,9 +12,10 @@ HEX = $(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock -R .signature EEP = $(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) BIN = -ifeq ("$(shell echo "int main(){}" | $(CC) --param=min-pagesize=0 -x c - -o /dev/null 2>&1)", "") -COMPILEFLAGS += --param=min-pagesize=0 -endif +COMPILEFLAGS += $(call cc-option,--param=min-pagesize=0) + +# Fix ICE's: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116389 +COMPILEFLAGS += $(call cc-option,-mlra) COMPILEFLAGS += -funsigned-char COMPILEFLAGS += -funsigned-bitfields @@ -25,10 +26,12 @@ COMPILEFLAGS += -fshort-enums COMPILEFLAGS += -mcall-prologues COMPILEFLAGS += -fno-builtin-printf -# Linker relaxation is only possible if -# link time optimizations are not enabled. +# On older compilers, linker relaxation is only possible if link time optimizations are not enabled. ifeq ($(strip $(LTO_ENABLE)), no) COMPILEFLAGS += -mrelax +else + # Newer compilers may support both, so quickly check before adding `-mrelax`. + COMPILEFLAGS += $(call cc-option,-mrelax,,-flto=auto) endif ASFLAGS += $(AVR_ASFLAGS) diff --git a/platforms/chibios/boards/BONSAI_C4/configs/board.h b/platforms/chibios/boards/BONSAI_C4/configs/board.h index 372b9bb8bc..81c80b2773 100644 --- a/platforms/chibios/boards/BONSAI_C4/configs/board.h +++ b/platforms/chibios/boards/BONSAI_C4/configs/board.h @@ -17,4 +17,4 @@ #include_next -#undef STM32_HSE_BYPASS \ No newline at end of file +#undef STM32_HSE_BYPASS diff --git a/platforms/chibios/boards/BONSAI_C4/configs/config.h b/platforms/chibios/boards/BONSAI_C4/configs/config.h index e933cd6fd1..e0e95eda25 100644 --- a/platforms/chibios/boards/BONSAI_C4/configs/config.h +++ b/platforms/chibios/boards/BONSAI_C4/configs/config.h @@ -87,4 +87,4 @@ #ifndef USB_VBUS_PIN # define USB_VBUS_PIN PAL_LINE(GPIOA, 9) -#endif \ No newline at end of file +#endif diff --git a/platforms/chibios/boards/BONSAI_C4/configs/halconf.h b/platforms/chibios/boards/BONSAI_C4/configs/halconf.h index 6bab6fbcff..55bafe5cfa 100644 --- a/platforms/chibios/boards/BONSAI_C4/configs/halconf.h +++ b/platforms/chibios/boards/BONSAI_C4/configs/halconf.h @@ -46,4 +46,4 @@ # define SPI_USE_WAIT TRUE #endif -#include_next \ No newline at end of file +#include_next diff --git a/platforms/chibios/boards/GENERIC_STM32_F405XG/board/board.mk b/platforms/chibios/boards/GENERIC_STM32_F405XG/board/board.mk index 6c837bb8ee..00cc9b20b2 100644 --- a/platforms/chibios/boards/GENERIC_STM32_F405XG/board/board.mk +++ b/platforms/chibios/boards/GENERIC_STM32_F405XG/board/board.mk @@ -6,4 +6,4 @@ BOARDINC = $(CHIBIOS)/os/hal/boards/ST_STM32F4_DISCOVERY # Shared variables ALLCSRC += $(BOARDSRC) -ALLINC += $(BOARDINC) \ No newline at end of file +ALLINC += $(BOARDINC) diff --git a/platforms/chibios/boards/GENERIC_STM32_F407XE/board/board.mk b/platforms/chibios/boards/GENERIC_STM32_F407XE/board/board.mk index 6c837bb8ee..00cc9b20b2 100644 --- a/platforms/chibios/boards/GENERIC_STM32_F407XE/board/board.mk +++ b/platforms/chibios/boards/GENERIC_STM32_F407XE/board/board.mk @@ -6,4 +6,4 @@ BOARDINC = $(CHIBIOS)/os/hal/boards/ST_STM32F4_DISCOVERY # Shared variables ALLCSRC += $(BOARDSRC) -ALLINC += $(BOARDINC) \ No newline at end of file +ALLINC += $(BOARDINC) diff --git a/platforms/chibios/boards/GENERIC_STM32_F407XE/configs/board.h b/platforms/chibios/boards/GENERIC_STM32_F407XE/configs/board.h index a0d53d86e7..c2f25db810 100644 --- a/platforms/chibios/boards/GENERIC_STM32_F407XE/configs/board.h +++ b/platforms/chibios/boards/GENERIC_STM32_F407XE/configs/board.h @@ -21,4 +21,4 @@ #include_next -#undef STM32_HSE_BYPASS \ No newline at end of file +#undef STM32_HSE_BYPASS diff --git a/platforms/chibios/boards/GENERIC_STM32_G0B1XB/board/board.mk b/platforms/chibios/boards/GENERIC_STM32_G0B1XB/board/board.mk new file mode 100644 index 0000000000..7e551e4dc7 --- /dev/null +++ b/platforms/chibios/boards/GENERIC_STM32_G0B1XB/board/board.mk @@ -0,0 +1,12 @@ +# List of all the board related files. +BOARDSRC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_G0B1RE/board.c + +# Extra files +BOARDSRC += $(BOARD_PATH)/board/extra.c + +# Required include directories +BOARDINC = $(CHIBIOS)/os/hal/boards/ST_NUCLEO64_G0B1RE + +# Shared variables +ALLCSRC += $(BOARDSRC) +ALLINC += $(BOARDINC) diff --git a/platforms/chibios/boards/GENERIC_STM32_G0B1XB/board/extra.c b/platforms/chibios/boards/GENERIC_STM32_G0B1XB/board/extra.c new file mode 100644 index 0000000000..4dbc5dd8b4 --- /dev/null +++ b/platforms/chibios/boards/GENERIC_STM32_G0B1XB/board/extra.c @@ -0,0 +1,68 @@ +// Copyright 2025 Stefan Kerkmann (@karlk90) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include + +#define FLASH_KEY1 0x45670123U +#define FLASH_KEY2 0xCDEF89ABU +#define FLASH_OPTKEY1 0x08192A3BU +#define FLASH_OPTKEY2 0x4C5D6E7FU +#define FLASH_OPTR_CLR_MASK (FLASH_OPTR_nBOOT_SEL) +#define FLASH_OPTR_SET_MASK (FLASH_OPTR_NRST_MODE_Msk) + +static void wait_for_flash(void) { + while (READ_BIT(FLASH->SR, FLASH_SR_BSY1)) { + } +} + +void __attribute__((constructor)) enable_boot0_and_nrst_pin(void) { + // Only apply on STM32G0x1 devices, see RM0444 Rev 6, Table 265: "DEV_ID + // and REV_ID field values." + switch (READ_BIT(DBG->IDCODE, DBG_IDCODE_DEV_ID)) { + case 0x467: // STM32G0B1xx and STM32G0C1xx + case 0x460: // STM32G071xx and STM32G081xx + case 0x456: // STM32G051xx and STM32G061xx + case 0x466: // STM32G041xx and STM32G031xx + break; + default: + return; + } + + uint32_t optr = FLASH->OPTR; + + // Make sure that: + // 1. legacy boot0 pin handling is enabled. + // OPTR[24] = 0 + // 2. legacy nRST pin handling is enabled. + // OPTR[28:27] = 0b11 + // To match the default behavior found in older (F0/F1/F3/F4) STM32 devices. + if (READ_BIT(optr, FLASH_OPTR_CLR_MASK) || (READ_BIT(optr, FLASH_OPTR_SET_MASK) != FLASH_OPTR_SET_MASK)) { + if (READ_BIT(FLASH->CR, FLASH_CR_LOCK)) { + WRITE_REG(FLASH->KEYR, FLASH_KEY1); + WRITE_REG(FLASH->KEYR, FLASH_KEY2); + while (READ_BIT(FLASH->CR, FLASH_CR_LOCK)) { + } + wait_for_flash(); + } + if (READ_BIT(FLASH->CR, FLASH_CR_OPTLOCK)) { + WRITE_REG(FLASH->OPTKEYR, FLASH_OPTKEY1); + WRITE_REG(FLASH->OPTKEYR, FLASH_OPTKEY2); + while (READ_BIT(FLASH->CR, FLASH_CR_OPTLOCK)) { + } + wait_for_flash(); + } + + MODIFY_REG(FLASH->OPTR, FLASH_OPTR_CLR_MASK, FLASH_OPTR_SET_MASK); + wait_for_flash(); + + SET_BIT(FLASH->CR, FLASH_CR_OPTSTRT); + wait_for_flash(); + + CLEAR_BIT(FLASH->CR, FLASH_CR_OPTSTRT); + wait_for_flash(); + + // Launch the option byte (re)loading, which resets the device. This + // should not return. + SET_BIT(FLASH->CR, FLASH_CR_OBL_LAUNCH); + } +} diff --git a/platforms/chibios/boards/GENERIC_STM32_G0B1XB/configs/config.h b/platforms/chibios/boards/GENERIC_STM32_G0B1XB/configs/config.h new file mode 100644 index 0000000000..bb2d1b5816 --- /dev/null +++ b/platforms/chibios/boards/GENERIC_STM32_G0B1XB/configs/config.h @@ -0,0 +1,7 @@ +// Copyright 2024 Stefan Kerkmann (@karlk90) +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +#ifndef EARLY_INIT_PERFORM_BOOTLOADER_JUMP +# define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE +#endif diff --git a/platforms/chibios/boards/GENERIC_STM32_G0B1XB/configs/mcuconf.h b/platforms/chibios/boards/GENERIC_STM32_G0B1XB/configs/mcuconf.h new file mode 100644 index 0000000000..80726e0308 --- /dev/null +++ b/platforms/chibios/boards/GENERIC_STM32_G0B1XB/configs/mcuconf.h @@ -0,0 +1,310 @@ +/* + ChibiOS - Copyright (C) 2006..2020 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/* + * STM32G0xx drivers configuration. + * The following settings override the default settings present in + * the various device driver implementation headers. + * Note that the settings for each driver only have effect if the whole + * driver is enabled in halconf.h. + * + * IRQ priorities: + * 3...0 Lowest...Highest. + * + * DMA priorities: + * 0...3 Lowest...Highest. + */ + +#ifndef MCUCONF_H +#define MCUCONF_H + +#define STM32G0xx_MCUCONF +#define STM32G0B1_MCUCONF +#define STM32G0C1_MCUCONF + +/* + * HAL driver system settings. + */ +#define STM32_NO_INIT FALSE +#define STM32_CLOCK_DYNAMIC TRUE +#define STM32_VOS STM32_VOS_RANGE1 +#define STM32_PWR_CR2 (STM32_PVDRT_LEV0 | STM32_PVDFT_LEV0 | STM32_PVDE_DISABLED) +#define STM32_PWR_CR3 (PWR_CR3_EIWUL) +#define STM32_PWR_CR4 (0U) +#define STM32_PWR_PUCRA (0U) +#define STM32_PWR_PDCRA (0U) +#define STM32_PWR_PUCRB (0U) +#define STM32_PWR_PDCRB (0U) +#define STM32_PWR_PUCRC (0U) +#define STM32_PWR_PDCRC (0U) +#define STM32_PWR_PUCRD (0U) +#define STM32_PWR_PDCRD (0U) +#define STM32_PWR_PUCRE (0U) +#define STM32_PWR_PDCRE (0U) +#define STM32_PWR_PUCRF (0U) +#define STM32_PWR_PDCRF (0U) +#define STM32_HSIDIV_VALUE 1 +#define STM32_HSI16_ENABLED TRUE +#define STM32_HSI48_ENABLED TRUE +#define STM32_HSE_ENABLED FALSE +#define STM32_LSI_ENABLED FALSE +#define STM32_LSE_ENABLED FALSE +#define STM32_SW STM32_SW_PLLRCLK +#define STM32_PLLSRC STM32_PLLSRC_HSI16 +#define STM32_PLLM_VALUE 2 +#define STM32_PLLN_VALUE 16 +#define STM32_PLLP_VALUE 2 +#define STM32_PLLQ_VALUE 4 +#define STM32_PLLR_VALUE 2 +#define STM32_HPRE STM32_HPRE_DIV1 +#define STM32_PPRE STM32_PPRE_DIV1 +#define STM32_MCOSEL STM32_MCOSEL_NOCLOCK +#define STM32_MCOPRE STM32_MCOPRE_DIV1 +#define STM32_LSCOSEL STM32_LSCOSEL_NOCLOCK + +/* + * Peripherals clocks and sources. + */ +#define STM32_FDCANSEL STM32_USBSEL_HSI48 +#define STM32_USBSEL STM32_USBSEL_HSI48 +#define STM32_USART1SEL STM32_USART1SEL_SYSCLK +#define STM32_USART2SEL STM32_USART2SEL_SYSCLK +#define STM32_USART3SEL STM32_USART3SEL_SYSCLK +#define STM32_LPUART1SEL STM32_LPUART1SEL_SYSCLK +#define STM32_LPUART2SEL STM32_LPUART2SEL_SYSCLK +#define STM32_CECSEL STM32_CECSEL_HSI16DIV +#define STM32_I2C1SEL STM32_I2C1SEL_PCLK +#define STM32_I2C2SEL STM32_I2C1SEL_PCLK +#define STM32_I2S1SEL STM32_I2S1SEL_SYSCLK +#define STM32_I2S2SEL STM32_I2S2SEL_SYSCLK +#define STM32_LPTIM1SEL STM32_LPTIM1SEL_PCLK +#define STM32_LPTIM2SEL STM32_LPTIM2SEL_PCLK +#define STM32_TIM1SEL STM32_TIM1SEL_TIMPCLK +#define STM32_TIM15SEL STM32_TIM15SEL_TIMPCLK +#define STM32_RNGSEL STM32_RNGSEL_HSI16 +#define STM32_RNGDIV_VALUE 1 +#define STM32_ADCSEL STM32_ADCSEL_PLLPCLK +#define STM32_RTCSEL STM32_RTCSEL_NOCLOCK + +/* + * Shared IRQ settings. + */ +#define STM32_IRQ_EXTI0_1_PRIORITY 3 +#define STM32_IRQ_EXTI2_3_PRIORITY 3 +#define STM32_IRQ_EXTI4_15_PRIORITY 3 +#define STM32_IRQ_EXTI1921_PRIORITY 3 + +#define STM32_IRQ_USART1_PRIORITY 2 +#define STM32_IRQ_USART2_LP2_PRIORITY 2 +#define STM32_IRQ_USART3_4_5_6_LP1_PRIORITY 2 + +#define STM32_IRQ_TIM1_UP_PRIORITY 1 +#define STM32_IRQ_TIM1_CC_PRIORITY 1 +#define STM32_IRQ_TIM2_PRIORITY 1 +#define STM32_IRQ_TIM3_4_PRIORITY 1 +#define STM32_IRQ_TIM6_PRIORITY 1 +#define STM32_IRQ_TIM7_PRIORITY 1 +#define STM32_IRQ_TIM14_PRIORITY 1 +#define STM32_IRQ_TIM15_PRIORITY 1 +#define STM32_IRQ_TIM16_PRIORITY 1 +#define STM32_IRQ_TIM17_PRIORITY 1 + +/* + * ADC driver system settings. + */ +#define STM32_ADC_USE_ADC1 FALSE +#define STM32_ADC_ADC1_CFGR2 ADC_CFGR2_CKMODE_ADCCLK +#define STM32_ADC_ADC1_DMA_PRIORITY 2 +#define STM32_ADC_ADC1_DMA_IRQ_PRIORITY 2 +#define STM32_ADC_ADC1_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_ADC_PRESCALER_VALUE 2 + +/* + * DAC driver system settings. + */ +#define STM32_DAC_DUAL_MODE FALSE +#define STM32_DAC_USE_DAC1_CH1 FALSE +#define STM32_DAC_USE_DAC1_CH2 FALSE +#define STM32_DAC_DAC1_CH1_IRQ_PRIORITY 3 +#define STM32_DAC_DAC1_CH2_IRQ_PRIORITY 3 +#define STM32_DAC_DAC1_CH1_DMA_PRIORITY 2 +#define STM32_DAC_DAC1_CH2_DMA_PRIORITY 2 +#define STM32_DAC_DAC1_CH1_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_DAC_DAC1_CH2_DMA_STREAM STM32_DMA_STREAM_ID_ANY + +/* + * GPT driver system settings. + */ +#define STM32_GPT_USE_TIM1 FALSE +#define STM32_GPT_USE_TIM2 FALSE +#define STM32_GPT_USE_TIM3 FALSE +#define STM32_GPT_USE_TIM4 FALSE +#define STM32_GPT_USE_TIM6 FALSE +#define STM32_GPT_USE_TIM7 FALSE +#define STM32_GPT_USE_TIM14 FALSE +#define STM32_GPT_USE_TIM15 FALSE +#define STM32_GPT_USE_TIM16 FALSE +#define STM32_GPT_USE_TIM17 FALSE + +/* + * I2C driver system settings. + */ +#define STM32_I2C_USE_I2C1 FALSE +#define STM32_I2C_USE_I2C2 FALSE +#define STM32_I2C_USE_I2C3 FALSE +#define STM32_I2C_BUSY_TIMEOUT 50 +#define STM32_I2C_I2C1_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_I2C_I2C1_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_I2C_I2C2_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_I2C_I2C2_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_I2C_I2C3_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_I2C_I2C3_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_I2C_I2C1_IRQ_PRIORITY 3 +#define STM32_I2C_I2C2_IRQ_PRIORITY 3 +#define STM32_I2C_I2C1_DMA_PRIORITY 3 +#define STM32_I2C_I2C2_DMA_PRIORITY 3 +#define STM32_I2C_DMA_ERROR_HOOK(i2cp) osalSysHalt("DMA failure") + +/* + * ICU driver system settings. + */ +#define STM32_ICU_USE_TIM1 FALSE +#define STM32_ICU_USE_TIM2 FALSE +#define STM32_ICU_USE_TIM3 FALSE +#define STM32_ICU_USE_TIM4 FALSE +#define STM32_ICU_USE_TIM15 FALSE + +/* + * PWM driver system settings. + */ +#define STM32_PWM_USE_TIM1 FALSE +#define STM32_PWM_USE_TIM2 FALSE +#define STM32_PWM_USE_TIM3 FALSE +#define STM32_PWM_USE_TIM4 FALSE +#define STM32_PWM_USE_TIM14 FALSE +#define STM32_PWM_USE_TIM15 FALSE +#define STM32_PWM_USE_TIM16 FALSE +#define STM32_PWM_USE_TIM17 FALSE + +/* + * RTC driver system settings. + */ +#define STM32_RTC_PRESA_VALUE 32 +#define STM32_RTC_PRESS_VALUE 1024 +#define STM32_RTC_CR_INIT 0 +#define STM32_RTC_TAMPCR_INIT 0 + +/* + * SERIAL driver system settings. + */ +#define STM32_SERIAL_USE_USART1 FALSE +#define STM32_SERIAL_USE_USART2 FALSE +#define STM32_SERIAL_USE_USART3 FALSE +#define STM32_SERIAL_USE_UART4 FALSE +#define STM32_SERIAL_USE_UART5 FALSE +#define STM32_SERIAL_USE_USART6 FALSE +#define STM32_SERIAL_USE_LPUART1 FALSE +#define STM32_SERIAL_USE_LPUART2 FALSE + +/* + * SIO driver system settings. + */ +#define STM32_SIO_USE_USART1 FALSE +#define STM32_SIO_USE_USART2 FALSE +#define STM32_SIO_USE_USART3 FALSE +#define STM32_SIO_USE_UART4 FALSE +#define STM32_SIO_USE_UART5 FALSE +#define STM32_SIO_USE_USART6 FALSE +#define STM32_SIO_USE_LPUART1 FALSE +#define STM32_SIO_USE_LPUART2 FALSE + +/* + * SPI driver system settings. + */ +#define STM32_SPI_USE_SPI1 FALSE +#define STM32_SPI_USE_SPI2 FALSE +#define STM32_SPI_USE_SPI3 FALSE +#define STM32_SPI_SPI1_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_SPI_SPI1_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_SPI_SPI2_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_SPI_SPI2_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_SPI_SPI3_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_SPI_SPI3_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_SPI_SPI1_DMA_PRIORITY 1 +#define STM32_SPI_SPI2_DMA_PRIORITY 1 +#define STM32_SPI_SPI3_DMA_PRIORITY 1 +#define STM32_SPI_SPI1_IRQ_PRIORITY 2 +#define STM32_SPI_SPI2_IRQ_PRIORITY 2 +#define STM32_SPI_SPI3_IRQ_PRIORITY 2 +#define STM32_SPI_DMA_ERROR_HOOK(spip) osalSysHalt("DMA failure") + +/* + * ST driver system settings. + */ +#define STM32_ST_IRQ_PRIORITY 2 +#define STM32_ST_USE_TIMER 2 + +/* + * TRNG driver system settings. + * NOTE: STM32G0C1 only. + */ +#define STM32_TRNG_USE_RNG1 FALSE + +/* + * UART driver system settings. + */ +#define STM32_UART_USE_USART1 FALSE +#define STM32_UART_USE_USART2 FALSE +#define STM32_UART_USE_USART3 FALSE +#define STM32_UART_USE_UART4 FALSE +#define STM32_UART_USE_UART5 FALSE +#define STM32_UART_USE_USART6 FALSE +#define STM32_UART_USART1_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_UART_USART1_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_UART_USART2_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_UART_USART2_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_UART_USART3_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_UART_USART3_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_UART_UART4_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_UART_UART4_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_UART_UART5_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_UART_UART5_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_UART_USART6_RX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_UART_USART6_TX_DMA_STREAM STM32_DMA_STREAM_ID_ANY +#define STM32_UART_USART1_DMA_PRIORITY 0 +#define STM32_UART_USART2_DMA_PRIORITY 0 +#define STM32_UART_USART3_DMA_PRIORITY 0 +#define STM32_UART_UART4_DMA_PRIORITY 0 +#define STM32_UART_UART5_DMA_PRIORITY 0 +#define STM32_UART_USART6_DMA_PRIORITY 0 +#define STM32_UART_DMA_ERROR_HOOK(uartp) osalSysHalt("DMA failure") + +/* + * USB driver system settings. + */ +#define STM32_USB_USE_USB1 TRUE +#define STM32_USB_USB1_LP_IRQ_PRIORITY 3 +#define STM32_USB_USE_ISOCHRONOUS FALSE +#define STM32_USB_USE_FAST_COPY TRUE +#define STM32_USB_HOST_WAKEUP_DURATION 2 +#define STM32_USB_48MHZ_DELTA 0 + +/* + * WDG driver system settings. + */ +#define STM32_WDG_USE_IWDG FALSE + +#endif /* MCUCONF_H */ diff --git a/platforms/chibios/boards/GENERIC_STM32_G474XE/configs/config.h b/platforms/chibios/boards/GENERIC_STM32_G474XE/configs/config.h index eb74d68e85..da0a634bb5 100644 --- a/platforms/chibios/boards/GENERIC_STM32_G474XE/configs/config.h +++ b/platforms/chibios/boards/GENERIC_STM32_G474XE/configs/config.h @@ -27,4 +27,4 @@ #if 0 #define STM32_BOOTLOADER_DUAL_BANK TRUE #define STM32_BOOTLOADER_DUAL_BANK_GPIO B7 -#endif \ No newline at end of file +#endif diff --git a/platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/chconf.h b/platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/chconf.h index e4afddb6a5..fa0b6f11d0 100644 --- a/platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/chconf.h +++ b/platforms/chibios/boards/GENERIC_WB32_F3G71XX/configs/chconf.h @@ -23,4 +23,4 @@ #define CH_CFG_ST_TIMEDELTA 0 -#include_next \ No newline at end of file +#include_next diff --git a/platforms/chibios/boards/GENERIC_WB32_FQ95XX/configs/chconf.h b/platforms/chibios/boards/GENERIC_WB32_FQ95XX/configs/chconf.h index e4afddb6a5..fa0b6f11d0 100644 --- a/platforms/chibios/boards/GENERIC_WB32_FQ95XX/configs/chconf.h +++ b/platforms/chibios/boards/GENERIC_WB32_FQ95XX/configs/chconf.h @@ -23,4 +23,4 @@ #define CH_CFG_ST_TIMEDELTA 0 -#include_next \ No newline at end of file +#include_next diff --git a/platforms/chibios/boards/SIPEED_LONGAN_NANO/configs/chconf.h b/platforms/chibios/boards/SIPEED_LONGAN_NANO/configs/chconf.h index 6e5adb0fe1..ca0348e4e0 100644 --- a/platforms/chibios/boards/SIPEED_LONGAN_NANO/configs/chconf.h +++ b/platforms/chibios/boards/SIPEED_LONGAN_NANO/configs/chconf.h @@ -20,4 +20,4 @@ struct _reent; #endif -#include_next \ No newline at end of file +#include_next diff --git a/platforms/chibios/boards/common/ld/STM32G0B1xB.ld b/platforms/chibios/boards/common/ld/STM32G0B1xB.ld new file mode 100644 index 0000000000..0109504992 --- /dev/null +++ b/platforms/chibios/boards/common/ld/STM32G0B1xB.ld @@ -0,0 +1,85 @@ +/* + ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/* + * STM32G0B1xB memory setup. + */ +MEMORY +{ + flash0 (rx) : org = 0x08000000, len = 128k + flash1 (rx) : org = 0x00000000, len = 0 + flash2 (rx) : org = 0x00000000, len = 0 + flash3 (rx) : org = 0x00000000, len = 0 + flash4 (rx) : org = 0x00000000, len = 0 + flash5 (rx) : org = 0x00000000, len = 0 + flash6 (rx) : org = 0x00000000, len = 0 + flash7 (rx) : org = 0x00000000, len = 0 + ram0 (wx) : org = 0x20000000, len = 144k + ram1 (wx) : org = 0x00000000, len = 0 + ram2 (wx) : org = 0x00000000, len = 0 + ram3 (wx) : org = 0x00000000, len = 0 + ram4 (wx) : org = 0x00000000, len = 0 + ram5 (wx) : org = 0x00000000, len = 0 + ram6 (wx) : org = 0x00000000, len = 0 + ram7 (wx) : org = 0x00000000, len = 0 +} + +/* For each data/text section two region are defined, a virtual region + and a load region (_LMA suffix).*/ + +/* Flash region to be used for exception vectors.*/ +REGION_ALIAS("VECTORS_FLASH", flash0); +REGION_ALIAS("VECTORS_FLASH_LMA", flash0); + +/* Flash region to be used for constructors and destructors.*/ +REGION_ALIAS("XTORS_FLASH", flash0); +REGION_ALIAS("XTORS_FLASH_LMA", flash0); + +/* Flash region to be used for code text.*/ +REGION_ALIAS("TEXT_FLASH", flash0); +REGION_ALIAS("TEXT_FLASH_LMA", flash0); + +/* Flash region to be used for read only data.*/ +REGION_ALIAS("RODATA_FLASH", flash0); +REGION_ALIAS("RODATA_FLASH_LMA", flash0); + +/* Flash region to be used for various.*/ +REGION_ALIAS("VARIOUS_FLASH", flash0); +REGION_ALIAS("VARIOUS_FLASH_LMA", flash0); + +/* Flash region to be used for RAM(n) initialization data.*/ +REGION_ALIAS("RAM_INIT_FLASH_LMA", flash0); + +/* RAM region to be used for Main stack. This stack accommodates the processing + of all exceptions and interrupts.*/ +REGION_ALIAS("MAIN_STACK_RAM", ram0); + +/* RAM region to be used for the process stack. This is the stack used by + the main() function.*/ +REGION_ALIAS("PROCESS_STACK_RAM", ram0); + +/* RAM region to be used for data segment.*/ +REGION_ALIAS("DATA_RAM", ram0); +REGION_ALIAS("DATA_RAM_LMA", flash0); + +/* RAM region to be used for BSS segment.*/ +REGION_ALIAS("BSS_RAM", ram0); + +/* RAM region to be used for the default heap.*/ +REGION_ALIAS("HEAP_RAM", ram0); + +/* Generic rules inclusion.*/ +INCLUDE rules.ld diff --git a/platforms/chibios/bootloaders/stm32duino.c b/platforms/chibios/bootloaders/stm32duino.c index e2db7fa16c..cc3f6be2df 100644 --- a/platforms/chibios/bootloaders/stm32duino.c +++ b/platforms/chibios/bootloaders/stm32duino.c @@ -25,4 +25,4 @@ __attribute__((weak)) void bootloader_jump(void) { __attribute__((weak)) void mcu_reset(void) { BKP->DR10 = RTC_BOOTLOADER_JUST_UPLOADED; NVIC_SystemReset(); -} \ No newline at end of file +} diff --git a/platforms/chibios/bootloaders/uf2boot.c b/platforms/chibios/bootloaders/uf2boot.c index f5b1a64334..1c736b8356 100644 --- a/platforms/chibios/bootloaders/uf2boot.c +++ b/platforms/chibios/bootloaders/uf2boot.c @@ -1,6 +1,8 @@ // Copyright 2023 QMK // SPDX-License-Identifier: GPL-2.0-or-later +#include +#include #include "bootloader.h" // From mmoskal/uf2-stm32f103's backup.c diff --git a/platforms/chibios/chibios_config.h b/platforms/chibios/chibios_config.h index 9ef8e9b4fe..41546e3e50 100644 --- a/platforms/chibios/chibios_config.h +++ b/platforms/chibios/chibios_config.h @@ -15,6 +15,8 @@ */ #pragma once +#include "compiler_support.h" + #ifndef USB_VBUS_PIN # define SPLIT_USB_DETECT // Force this on when dedicated pin is not used #endif @@ -26,7 +28,7 @@ # define REALTIME_COUNTER_CLOCK 1000000 # define USE_GPIOV1 -# define PAL_OUTPUT_TYPE_OPENDRAIN _Static_assert(0, "RP2040 has no Open Drain GPIO configuration, setting this is not possible"); +# define PAL_OUTPUT_TYPE_OPENDRAIN STATIC_ASSERT(0, "RP2040 has no Open Drain GPIO configuration, setting this is not possible"); /* Aliases for GPIO PWM channels - every pin has at least one PWM channel * assigned */ diff --git a/platforms/chibios/converters/promicro_to_bonsai_c4/_pin_defs.h b/platforms/chibios/converters/promicro_to_bonsai_c4/_pin_defs.h index 7e6b8ddaf2..deb0628ef8 100644 --- a/platforms/chibios/converters/promicro_to_bonsai_c4/_pin_defs.h +++ b/platforms/chibios/converters/promicro_to_bonsai_c4/_pin_defs.h @@ -37,4 +37,4 @@ // If this is undesirable, either B0 or B5 can be redefined by // using #undef and #define to change its assignment #define B0 PAL_LINE(GPIOB, 2) -#define D5 PAL_LINE(GPIOB, 2) \ No newline at end of file +#define D5 PAL_LINE(GPIOB, 2) diff --git a/platforms/chibios/converters/promicro_to_bonsai_c4/post_converter.mk b/platforms/chibios/converters/promicro_to_bonsai_c4/post_converter.mk index 5f49b17f8a..beefb9de23 100644 --- a/platforms/chibios/converters/promicro_to_bonsai_c4/post_converter.mk +++ b/platforms/chibios/converters/promicro_to_bonsai_c4/post_converter.mk @@ -2,4 +2,4 @@ BACKLIGHT_DRIVER ?= pwm WS2812_DRIVER ?= pwm SERIAL_DRIVER ?= usart FLASH_DRIVER ?= spi -EEPROM_DRIVER ?= spi \ No newline at end of file +EEPROM_DRIVER ?= spi diff --git a/platforms/chibios/converters/promicro_to_promicro_rp2040/pre_converter.mk b/platforms/chibios/converters/promicro_to_promicro_rp2040/pre_converter.mk index 303d3135ce..80111d0f78 100644 --- a/platforms/chibios/converters/promicro_to_promicro_rp2040/pre_converter.mk +++ b/platforms/chibios/converters/promicro_to_promicro_rp2040/pre_converter.mk @@ -1,2 +1,8 @@ CONVERTER:=platforms/chibios/converters/promicro_to_sparkfun_pm2040 ACTIVE_CONVERTER:=sparkfun_pm2040 + +$(info @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@) +$(info The 'CONVERT_TO=promicro_rp2040' option is now deprecated.) +$(info Depending on hardware either 'CONVERT_TO=sparkfun_pm2040' or 'CONVERT_TO=rp2040_ce' should be used instead.) +$(info See https://docs.qmk.fm/feature_converters#pro-micro documentation for more information.) +$(info @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@) diff --git a/platforms/chibios/drivers/analog.c b/platforms/chibios/drivers/analog.c index 7e1f87e6c9..a916cc9a1d 100644 --- a/platforms/chibios/drivers/analog.c +++ b/platforms/chibios/drivers/analog.c @@ -43,7 +43,7 @@ #endif // Otherwise assume V3 -#if defined(STM32F0XX) || defined(STM32L0XX) +#if defined(STM32F0XX) || defined(STM32L0XX) || defined(STM32G0XX) # define USE_ADCV1 #elif defined(STM32F1XX) || defined(STM32F2XX) || defined(STM32F4XX) || defined(GD32VF103) || defined(WB32F3G71xx) || defined(WB32FQ95xx) || defined(AT32F415) # define USE_ADCV2 @@ -82,7 +82,7 @@ /* User configurable ADC options */ #ifndef ADC_COUNT -# if defined(RP2040) || defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F4XX) || defined(GD32VF103) || defined(WB32F3G71xx) || defined(WB32FQ95xx) || defined(AT32F415) +# if defined(RP2040) || defined(STM32F0XX) || defined(STM32F1XX) || defined(STM32F4XX) || defined(STM32G0XX) || defined(GD32VF103) || defined(WB32F3G71xx) || defined(WB32FQ95xx) || defined(AT32F415) # define ADC_COUNT 1 # elif defined(STM32F3XX) || defined(STM32G4XX) # define ADC_COUNT 4 @@ -114,6 +114,8 @@ # define ADC_SAMPLING_RATE ADC_SMPR_SMP_1P5 # elif defined(ADC_SMPR_SMP_2P5) // STM32L4XX, STM32L4XXP, STM32G4XX, STM32WBXX # define ADC_SAMPLING_RATE ADC_SMPR_SMP_2P5 +# elif defined(ADC_SMPR_SMP1_1P5) // STM32G0XX +# define ADC_SAMPLING_RATE ADC_SMPR_SMP1_1P5 # else # error "Cannot determine the default ADC_SAMPLING_RATE for this MCU." # endif @@ -293,6 +295,23 @@ __attribute__((weak)) adc_mux pinToMux(pin_t pin) { case F9: return TO_MUX( ADC_CHANNEL_IN12, 2 ); case F10: return TO_MUX( ADC_CHANNEL_IN13, 2 ); # endif +#elif defined(STM32G0XX) + case A0: return TO_MUX( 0, 0 ); + case A1: return TO_MUX( 1, 0 ); + case A2: return TO_MUX( 2, 0 ); + case A3: return TO_MUX( 3, 0 ); + case A4: return TO_MUX( 4, 0 ); + case A5: return TO_MUX( 5, 0 ); + case A6: return TO_MUX( 6, 0 ); + case A7: return TO_MUX( 7, 0 ); + case B0: return TO_MUX( 8, 0 ); + case B1: return TO_MUX( 9, 0 ); + case B2: return TO_MUX( 10, 0 ); + case B10: return TO_MUX( 11, 0 ); + case B11: return TO_MUX( 15, 0 ); + case B12: return TO_MUX( 16, 0 ); + case C4: return TO_MUX( 17, 0 ); + case C5: return TO_MUX( 18, 0 ); #elif defined(STM32G4XX) case A0: return TO_MUX( ADC_CHANNEL_IN1, 0 ); // Can also be ADC2 case A1: return TO_MUX( ADC_CHANNEL_IN2, 0 ); // Can also be ADC2 diff --git a/platforms/chibios/drivers/i2c_master.c b/platforms/chibios/drivers/i2c_master.c index 1d7fe27633..20850859b5 100644 --- a/platforms/chibios/drivers/i2c_master.c +++ b/platforms/chibios/drivers/i2c_master.c @@ -206,4 +206,4 @@ __attribute__((weak)) i2c_status_t i2c_ping_address(uint8_t address, uint16_t ti // This approach may produce false negative results for I2C devices that do not respond to a register 0 read request. uint8_t data = 0; return i2c_read_register(address, 0, &data, sizeof(data), timeout); -} \ No newline at end of file +} diff --git a/platforms/chibios/drivers/usbpd_stm32g4.c b/platforms/chibios/drivers/usbpd_stm32g4.c index 21b8f6db95..7603b5627b 100644 --- a/platforms/chibios/drivers/usbpd_stm32g4.c +++ b/platforms/chibios/drivers/usbpd_stm32g4.c @@ -76,4 +76,4 @@ __attribute__((weak)) usbpd_allowance_t usbpd_get_allowance(void) { } return USBPD_500MA; -} \ No newline at end of file +} diff --git a/platforms/chibios/drivers/wear_leveling/wear_leveling_efl.c b/platforms/chibios/drivers/wear_leveling/wear_leveling_efl.c index fed16d20b1..fec4646a5b 100644 --- a/platforms/chibios/drivers/wear_leveling/wear_leveling_efl.c +++ b/platforms/chibios/drivers/wear_leveling/wear_leveling_efl.c @@ -4,6 +4,7 @@ #include #include "timer.h" #include "wear_leveling.h" +#include "wear_leveling_efl_config.h" #include "wear_leveling_internal.h" static flash_offset_t base_offset = UINT32_MAX; diff --git a/platforms/chibios/drivers/wear_leveling/wear_leveling_legacy.c b/platforms/chibios/drivers/wear_leveling/wear_leveling_legacy.c index 7c6fd2d808..3d2af625ca 100644 --- a/platforms/chibios/drivers/wear_leveling/wear_leveling_legacy.c +++ b/platforms/chibios/drivers/wear_leveling/wear_leveling_legacy.c @@ -4,6 +4,7 @@ #include #include "timer.h" #include "wear_leveling.h" +#include "wear_leveling_legacy_config.h" #include "wear_leveling_internal.h" #include "legacy_flash_ops.h" diff --git a/platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash.c b/platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash.c index 6624c30b5b..2f3c7c58ca 100644 --- a/platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash.c +++ b/platforms/chibios/drivers/wear_leveling/wear_leveling_rp2040_flash.c @@ -6,15 +6,18 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include + #include "pico/bootrom.h" #include "hardware/flash.h" #include "hardware/sync.h" #include "hardware/structs/ssi.h" #include "hardware/structs/ioqspi.h" -#include +#include "compiler_support.h" #include "timer.h" #include "wear_leveling.h" +#include "wear_leveling_rp2040_flash_config.h" #include "wear_leveling_internal.h" #ifndef WEAR_LEVELING_RP2040_FLASH_BULK_COUNT @@ -177,7 +180,7 @@ bool backing_store_erase(void) { #endif // Ensure the backing size can be cleanly subtracted from the flash size without alignment issues. - _Static_assert((WEAR_LEVELING_BACKING_SIZE) % (FLASH_SECTOR_SIZE) == 0, "Backing size must be a multiple of FLASH_SECTOR_SIZE"); + STATIC_ASSERT((WEAR_LEVELING_BACKING_SIZE) % (FLASH_SECTOR_SIZE) == 0, "Backing size must be a multiple of FLASH_SECTOR_SIZE"); interrupts = save_and_disable_interrupts(); flash_range_erase((WEAR_LEVELING_RP2040_FLASH_BASE), (WEAR_LEVELING_BACKING_SIZE)); diff --git a/platforms/chibios/errno.h b/platforms/chibios/errno.h new file mode 100644 index 0000000000..a411ed9821 --- /dev/null +++ b/platforms/chibios/errno.h @@ -0,0 +1,13 @@ +// Copyright 2025 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once +#include_next + +// Newer versions of picolibc don't seem to provide `__errno_r(r)` in the header file, but is used by ChibiOS. +#ifndef __errno_r +# ifdef __REENT_ERRNO +# define __errno_r(r) _REENT_ERRNO(r) +# else +# define __errno_r(r) (errno) +# endif +#endif diff --git a/platforms/chibios/mcu_selection.mk b/platforms/chibios/mcu_selection.mk index 086a2b31c6..199bdb2321 100644 --- a/platforms/chibios/mcu_selection.mk +++ b/platforms/chibios/mcu_selection.mk @@ -511,6 +511,41 @@ ifneq ($(findstring STM32F446, $(MCU)),) EEPROM_DRIVER ?= transient endif +ifneq ($(findstring STM32G0B1, $(MCU)),) + # Cortex version + MCU = cortex-m0plus + + # ARM version, CORTEX-M0/M1 are 6, CORTEX-M3/M4/M7 are 7 + ARMV = 6 + + ## chip/board settings + # - the next two should match the directories in + # /os/hal/ports/$(MCU_PORT_NAME)/$(MCU_SERIES) + # OR + # /os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES) + MCU_FAMILY = STM32 + MCU_SERIES = STM32G0xx + + # Linker script to use + # - it should exist either in /os/common/startup/ARMCMx/compilers/GCC/ld/ + # or /ld/ + MCU_LDSCRIPT ?= STM32G0B1xB + + # Startup code to use + # - it should exist in /os/common/startup/ARMCMx/compilers/GCC/mk/ + MCU_STARTUP ?= stm32g0xx + + # Board: it should exist either in /os/hal/boards/, + # /boards/, or drivers/boards/ + BOARD ?= GENERIC_STM32_G0B1XB + + # UF2 settings + UF2_FAMILY ?= STM32G0 + + # Bootloader address for STM32 DFU + STM32_BOOTLOADER_ADDRESS ?= 0x1FFF0000 +endif + ifneq ($(findstring STM32G431, $(MCU)),) # Cortex version MCU = cortex-m4 diff --git a/platforms/chibios/platform.c b/platforms/chibios/platform.c index d4a229f278..e559f178cd 100644 --- a/platforms/chibios/platform.c +++ b/platforms/chibios/platform.c @@ -19,4 +19,4 @@ void platform_setup(void) { halInit(); chSysInit(); -} \ No newline at end of file +} diff --git a/platforms/chibios/vendors/RP/RP2040.mk b/platforms/chibios/vendors/RP/RP2040.mk index 94f023d72b..27d1fa4472 100644 --- a/platforms/chibios/vendors/RP/RP2040.mk +++ b/platforms/chibios/vendors/RP/RP2040.mk @@ -78,7 +78,7 @@ PICOSDKINTRINSICSSRC = $(PICOSDKROOT)/src/rp2_common/pico_divider/divider.S \ $(PICOSDKROOT)/src/rp2_common/pico_int64_ops/pico_int64_ops_aeabi.S PICOSDKINTRINSICSINC = $(PICOSDKROOT)/src/common/pico_base/include \ - $(PICOSDKROOT)/src/rp2_common/pico_platfrom/include \ + $(PICOSDKROOT)/src/rp2_common/pico_platform/include \ $(PICOSDKROOT)/src/rp2_common/hardware_divider/include # integer division intrinsics utilizing the RP2040 hardware divider diff --git a/platforms/eeprom.h b/platforms/eeprom.h index 067fa01616..557bfb030c 100644 --- a/platforms/eeprom.h +++ b/platforms/eeprom.h @@ -37,6 +37,7 @@ void eeprom_update_block(const void *__src, void *__dst, size_t __n); # endif # define TOTAL_EEPROM_BYTE_COUNT (EEPROM_SIZE) #elif defined(EEPROM_WEAR_LEVELING) +# include "wear_leveling_drivers.h" # define TOTAL_EEPROM_BYTE_COUNT (WEAR_LEVELING_LOGICAL_SIZE) #elif defined(EEPROM_TRANSIENT) # include "eeprom_transient.h" diff --git a/platforms/test/platform.c b/platforms/test/platform.c index 8ddceeda8f..3e35b4fe4c 100644 --- a/platforms/test/platform.c +++ b/platforms/test/platform.c @@ -18,4 +18,4 @@ void platform_setup(void) { // do nothing -} \ No newline at end of file +} diff --git a/quantum/action.c b/quantum/action.c index be85192d25..dd82c9ec99 100644 --- a/quantum/action.c +++ b/quantum/action.c @@ -281,6 +281,9 @@ void process_record(keyrecord_t *record) { if (IS_NOEVENT(record->event)) { return; } +#ifdef FLOW_TAP_TERM + flow_tap_update_last_event(record); +#endif // FLOW_TAP_TERM if (!process_record_quantum(record)) { #ifndef NO_ACTION_ONESHOT @@ -1183,6 +1186,23 @@ bool is_tap_action(action_t action) { return false; } +uint16_t get_tap_keycode(uint16_t keycode) { + switch (keycode) { + case QK_MOD_TAP ... QK_MOD_TAP_MAX: + return QK_MOD_TAP_GET_TAP_KEYCODE(keycode); + case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: + return QK_LAYER_TAP_GET_TAP_KEYCODE(keycode); + case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX: + // IS_SWAP_HANDS_KEYCODE() tests for the special action keycodes + // like SH_TOGG, SH_TT, ..., which overlap the SH_T(kc) range. + if (!IS_SWAP_HANDS_KEYCODE(keycode)) { + return QK_SWAP_HANDS_GET_TAP_KEYCODE(keycode); + } + break; + } + return keycode; +} + /** \brief Debug print (FIXME: Needs better description) * * FIXME: Needs documentation. diff --git a/quantum/action.h b/quantum/action.h index 7596688f31..7616486c6d 100644 --- a/quantum/action.h +++ b/quantum/action.h @@ -128,6 +128,12 @@ void layer_switch(uint8_t new_layer); bool is_tap_record(keyrecord_t *record); bool is_tap_action(action_t action); +/** + * Given an MT or LT keycode, returns the tap keycode. Otherwise returns the + * original keycode unchanged. + */ +uint16_t get_tap_keycode(uint16_t keycode); + #ifndef NO_ACTION_TAPPING void process_record_tap_hint(keyrecord_t *record); #endif diff --git a/quantum/action_tapping.c b/quantum/action_tapping.c index e42a98554d..b105cd60a9 100644 --- a/quantum/action_tapping.c +++ b/quantum/action_tapping.c @@ -4,7 +4,9 @@ #include "action.h" #include "action_layer.h" #include "action_tapping.h" +#include "action_util.h" #include "keycode.h" +#include "quantum_keycodes.h" #include "timer.h" #ifndef NO_ACTION_TAPPING @@ -49,9 +51,7 @@ __attribute__((weak)) bool get_permissive_hold(uint16_t keycode, keyrecord_t *re } # endif -# if defined(CHORDAL_HOLD) -extern const char chordal_hold_layout[MATRIX_ROWS][MATRIX_COLS] PROGMEM; - +# if defined(CHORDAL_HOLD) || defined(FLOW_TAP_TERM) # define REGISTERED_TAPS_SIZE 8 // Array of tap-hold keys that have been settled as tapped but not yet released. static keypos_t registered_taps[REGISTERED_TAPS_SIZE] = {}; @@ -66,6 +66,14 @@ static void registered_taps_del_index(uint8_t i); /** Logs the registered_taps array for debugging. */ static void debug_registered_taps(void); +static bool is_mt_or_lt(uint16_t keycode) { + return IS_QK_MOD_TAP(keycode) || IS_QK_LAYER_TAP(keycode); +} +# endif // defined(CHORDAL_HOLD) || defined(FLOW_TAP_TERM) + +# if defined(CHORDAL_HOLD) +extern const char chordal_hold_layout[MATRIX_ROWS][MATRIX_COLS] PROGMEM; + /** \brief Finds which queued events should be held according to Chordal Hold. * * In a situation with multiple unsettled tap-hold key presses, scan the queue @@ -82,10 +90,6 @@ static void waiting_buffer_chordal_hold_taps_until(keypos_t key); /** \brief Processes and pops buffered events until the first tap-hold event. */ static void waiting_buffer_process_regular(void); - -static bool is_mt_or_lt(uint16_t keycode) { - return IS_QK_MOD_TAP(keycode) || IS_QK_LAYER_TAP(keycode); -} # endif // CHORDAL_HOLD # ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY @@ -98,6 +102,14 @@ __attribute__((weak)) bool get_hold_on_other_key_press(uint16_t keycode, keyreco # include "process_auto_shift.h" # endif +# if defined(FLOW_TAP_TERM) +static uint16_t flow_tap_prev_keycode = KC_NO; +static uint16_t flow_tap_prev_time = 0; +static bool flow_tap_expired = true; + +static bool flow_tap_key_if_within_term(keyrecord_t *record, uint16_t prev_time); +# endif // defined(FLOW_TAP_TERM) + static keyrecord_t tapping_key = {}; static keyrecord_t waiting_buffer[WAITING_BUFFER_SIZE] = {}; static uint8_t waiting_buffer_head = 0; @@ -148,6 +160,12 @@ void action_tapping_process(keyrecord_t record) { } if (IS_EVENT(record.event)) { ac_dprintf("\n"); + } else { +# ifdef FLOW_TAP_TERM + if (!flow_tap_expired && TIMER_DIFF_16(record.event.time, flow_tap_prev_time) >= INT16_MAX / 2) { + flow_tap_expired = true; + } +# endif // FLOW_TAP_TERM } } @@ -205,7 +223,7 @@ void action_tapping_process(keyrecord_t record) { bool process_tapping(keyrecord_t *keyp) { const keyevent_t event = keyp->event; -# if defined(CHORDAL_HOLD) +# if defined(CHORDAL_HOLD) || defined(FLOW_TAP_TERM) if (!event.pressed) { const int8_t i = registered_tap_find(event.key); if (i != -1) { @@ -217,7 +235,7 @@ bool process_tapping(keyrecord_t *keyp) { debug_registered_taps(); } } -# endif // CHORDAL_HOLD +# endif // defined(CHORDAL_HOLD) || defined(FLOW_TAP_TERM) // state machine is in the "reset" state, no tapping key is to be // processed @@ -227,6 +245,13 @@ bool process_tapping(keyrecord_t *keyp) { } else if (event.pressed && is_tap_record(keyp)) { // the currently pressed key is a tapping key, therefore transition // into the "pressed" tapping key state + +# if defined(FLOW_TAP_TERM) + if (flow_tap_key_if_within_term(keyp, flow_tap_prev_time)) { + return true; + } +# endif // defined(FLOW_TAP_TERM) + ac_dprintf("Tapping: Start(Press tap key).\n"); tapping_key = *keyp; process_record_tap_hint(&tapping_key); @@ -263,6 +288,27 @@ bool process_tapping(keyrecord_t *keyp) { // copy tapping state keyp->tap = tapping_key.tap; + +# if defined(FLOW_TAP_TERM) + // Now that tapping_key has settled as tapped, check whether + // Flow Tap applies to following yet-unsettled keys. + uint16_t prev_time = tapping_key.event.time; + for (; waiting_buffer_tail != waiting_buffer_head; waiting_buffer_tail = (waiting_buffer_tail + 1) % WAITING_BUFFER_SIZE) { + keyrecord_t *record = &waiting_buffer[waiting_buffer_tail]; + if (!record->event.pressed) { + break; + } + const int16_t next_time = record->event.time; + if (!is_tap_record(record)) { + process_record(record); + } else if (!flow_tap_key_if_within_term(record, prev_time)) { + break; + } + prev_time = next_time; + } + debug_waiting_buffer(); +# endif // defined(FLOW_TAP_TERM) + // enqueue return false; } @@ -538,6 +584,13 @@ bool process_tapping(keyrecord_t *keyp) { return true; } else if (is_tap_record(keyp)) { // Sequential tap can be interfered with other tap key. +# if defined(FLOW_TAP_TERM) + if (flow_tap_key_if_within_term(keyp, flow_tap_prev_time)) { + tapping_key = (keyrecord_t){0}; + debug_tapping_key(); + return true; + } +# endif // defined(FLOW_TAP_TERM) ac_dprintf("Tapping: Start with interfering other tap.\n"); tapping_key = *keyp; waiting_buffer_scan_tap(); @@ -655,28 +708,7 @@ void waiting_buffer_scan_tap(void) { } } -# ifdef CHORDAL_HOLD -__attribute__((weak)) bool get_chordal_hold(uint16_t tap_hold_keycode, keyrecord_t *tap_hold_record, uint16_t other_keycode, keyrecord_t *other_record) { - return get_chordal_hold_default(tap_hold_record, other_record); -} - -bool get_chordal_hold_default(keyrecord_t *tap_hold_record, keyrecord_t *other_record) { - if (tap_hold_record->event.type != KEY_EVENT || other_record->event.type != KEY_EVENT) { - return true; // Return true on combos or other non-key events. - } - - char tap_hold_hand = chordal_hold_handedness(tap_hold_record->event.key); - if (tap_hold_hand == '*') { - return true; - } - char other_hand = chordal_hold_handedness(other_record->event.key); - return other_hand == '*' || tap_hold_hand != other_hand; -} - -__attribute__((weak)) char chordal_hold_handedness(keypos_t key) { - return (char)pgm_read_byte(&chordal_hold_layout[key.row][key.col]); -} - +# if defined(CHORDAL_HOLD) || defined(FLOW_TAP_TERM) static void registered_taps_add(keypos_t key) { if (num_registered_taps >= REGISTERED_TAPS_SIZE) { ac_dprintf("TAPS OVERFLOW: CLEAR ALL STATES\n"); @@ -714,6 +746,30 @@ static void debug_registered_taps(void) { ac_dprintf("}\n"); } +# endif // defined(CHORDAL_HOLD) || defined(FLOW_TAP_TERM) + +# ifdef CHORDAL_HOLD +__attribute__((weak)) bool get_chordal_hold(uint16_t tap_hold_keycode, keyrecord_t *tap_hold_record, uint16_t other_keycode, keyrecord_t *other_record) { + return get_chordal_hold_default(tap_hold_record, other_record); +} + +bool get_chordal_hold_default(keyrecord_t *tap_hold_record, keyrecord_t *other_record) { + if (tap_hold_record->event.type != KEY_EVENT || other_record->event.type != KEY_EVENT) { + return true; // Return true on combos or other non-key events. + } + + char tap_hold_hand = chordal_hold_handedness(tap_hold_record->event.key); + if (tap_hold_hand == '*') { + return true; + } + char other_hand = chordal_hold_handedness(other_record->event.key); + return other_hand == '*' || tap_hold_hand != other_hand; +} + +__attribute__((weak)) char chordal_hold_handedness(keypos_t key) { + return (char)pgm_read_byte(&chordal_hold_layout[key.row][key.col]); +} + static uint8_t waiting_buffer_find_chordal_hold_tap(void) { keyrecord_t *prev = &tapping_key; uint16_t prev_keycode = get_record_keycode(&tapping_key, false); @@ -761,6 +817,100 @@ static void waiting_buffer_process_regular(void) { } # endif // CHORDAL_HOLD +# ifdef FLOW_TAP_TERM +void flow_tap_update_last_event(keyrecord_t *record) { + const uint16_t keycode = get_record_keycode(record, false); + // Don't update while a tap-hold key is unsettled. + if (record->tap.count == 0 && (waiting_buffer_tail != waiting_buffer_head || (tapping_key.event.pressed && tapping_key.tap.count == 0))) { + return; + } + // Ignore releases of modifiers and held layer switches. + if (!record->event.pressed) { + switch (keycode) { + case MODIFIER_KEYCODE_RANGE: + case QK_MOMENTARY ... QK_MOMENTARY_MAX: + case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX: +# ifndef NO_ACTION_ONESHOT // Ignore one-shot keys. + case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX: + case QK_ONE_SHOT_LAYER ... QK_ONE_SHOT_LAYER_MAX: +# endif // NO_ACTION_ONESHOT +# ifdef TRI_LAYER_ENABLE // Ignore Tri Layer keys. + case QK_TRI_LAYER_LOWER: + case QK_TRI_LAYER_UPPER: +# endif // TRI_LAYER_ENABLE + return; + case QK_MODS ... QK_MODS_MAX: + if (QK_MODS_GET_BASIC_KEYCODE(keycode) == KC_NO) { + return; + } + break; + case QK_MOD_TAP ... QK_MOD_TAP_MAX: + case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: + if (record->tap.count == 0) { + return; + } + break; + } + } + + flow_tap_prev_keycode = keycode; + flow_tap_prev_time = record->event.time; + flow_tap_expired = false; +} + +static bool flow_tap_key_if_within_term(keyrecord_t *record, uint16_t prev_time) { + const uint16_t idle_time = TIMER_DIFF_16(record->event.time, prev_time); + if (flow_tap_expired || idle_time >= 500) { + return false; + } + + const uint16_t keycode = get_record_keycode(record, false); + if (is_mt_or_lt(keycode)) { + uint16_t term = get_flow_tap_term(keycode, record, flow_tap_prev_keycode); + if (term > 500) { + term = 500; + } + if (idle_time < term) { + debug_event(record->event); + ac_dprintf(" within flow tap term (%u < %u) considered a tap\n", idle_time, term); + record->tap.count = 1; + registered_taps_add(record->event.key); + debug_registered_taps(); + process_record(record); + return true; + } + } + return false; +} + +// By default, enable Flow Tap for the keys in the main alphas area and Space. +// This should work reasonably even if the layout is remapped on the host to an +// alt layout or international layout (e.g. Dvorak or AZERTY), where these same +// key positions are mostly used for typing letters. +__attribute__((weak)) bool is_flow_tap_key(uint16_t keycode) { + if ((get_mods() & (MOD_MASK_CG | MOD_BIT_LALT)) != 0) { + return false; // Disable Flow Tap on hotkeys. + } + switch (get_tap_keycode(keycode)) { + case KC_SPC: + case KC_A ... KC_Z: + case KC_DOT: + case KC_COMM: + case KC_SCLN: + case KC_SLSH: + return true; + } + return false; +} + +__attribute__((weak)) uint16_t get_flow_tap_term(uint16_t keycode, keyrecord_t *record, uint16_t prev_keycode) { + if (is_flow_tap_key(keycode) && is_flow_tap_key(prev_keycode)) { + return FLOW_TAP_TERM; + } + return 0; +} +# endif // FLOW_TAP_TERM + /** \brief Logs tapping key if ACTION_DEBUG is enabled. */ static void debug_tapping_key(void) { ac_dprintf("TAPPING_KEY="); diff --git a/quantum/action_tapping.h b/quantum/action_tapping.h index c3c7b999ec..0cf4aa1200 100644 --- a/quantum/action_tapping.h +++ b/quantum/action_tapping.h @@ -111,6 +111,66 @@ char chordal_hold_handedness(keypos_t key); extern const char chordal_hold_layout[MATRIX_ROWS][MATRIX_COLS] PROGMEM; #endif +#ifdef FLOW_TAP_TERM +/** + * Callback to specify the keys where Flow Tap is enabled. + * + * Flow Tap is constrained to certain keys by the following rule: this callback + * is called for both the tap-hold key *and* the key press immediately preceding + * it. If the callback returns true for both keycodes, Flow Tap is enabled. + * + * The default implementation of this callback corresponds to + * + * bool is_flow_tap_key(uint16_t keycode) { + * switch (get_tap_keycode(keycode)) { + * case KC_SPC: + * case KC_A ... KC_Z: + * case KC_DOT: + * case KC_COMM: + * case KC_SCLN: + * case KC_SLSH: + * return true; + * } + * return false; + * } + * + * @param keycode Keycode of the key. + * @return Whether to enable Flow Tap for this key. + */ +bool is_flow_tap_key(uint16_t keycode); + +/** + * Callback to customize Flow Tap filtering. + * + * Flow Tap acts only when key events are closer together than this time. + * + * Return a time of 0 to disable filtering. In this way, Flow Tap may be + * disabled for certain tap-hold keys, or when following certain previous keys. + * + * The default implementation of this callback is + * + * uint16_t get_flow_tap_term(uint16_t keycode, keyrecord_t* record, + * uint16_t prev_keycode) { + * if (is_flow_tap_key(keycode) && is_flow_tap_key(prev_keycode)) { + * return g_flow_tap_term; + * } + * return 0; + * } + * + * NOTE: If both `is_flow_tap_key()` and `get_flow_tap_term()` are defined, then + * `get_flow_tap_term()` takes precedence. + * + * @param keycode Keycode of the tap-hold key. + * @param record keyrecord_t of the tap-hold event. + * @param prev_keycode Keycode of the previously pressed key. + * @return Time in milliseconds. + */ +uint16_t get_flow_tap_term(uint16_t keycode, keyrecord_t *record, uint16_t prev_keycode); + +/** Updates the Flow Tap last key and timer. */ +void flow_tap_update_last_event(keyrecord_t *record); +#endif // FLOW_TAP_TERM + #ifdef DYNAMIC_TAPPING_TERM_ENABLE extern uint16_t g_tapping_term; #endif diff --git a/quantum/action_util.c b/quantum/action_util.c index c0dc4f3822..e821e113ef 100644 --- a/quantum/action_util.c +++ b/quantum/action_util.c @@ -21,7 +21,6 @@ along with this program. If not, see . #include "action_layer.h" #include "timer.h" #include "keycode_config.h" -#include "usb_device_state.h" #include extern keymap_config_t keymap_config; @@ -220,7 +219,7 @@ bool is_oneshot_layer_active(void) { void oneshot_set(bool active) { if (keymap_config.oneshot_enable != active) { keymap_config.oneshot_enable = active; - eeconfig_update_keymap(keymap_config.raw); + eeconfig_update_keymap(&keymap_config); clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); dprintf("Oneshot: active: %d\n", active); } @@ -319,14 +318,12 @@ void send_nkro_report(void) { */ void send_keyboard_report(void) { #ifdef NKRO_ENABLE - if (usb_device_state_get_protocol() == USB_PROTOCOL_REPORT && keymap_config.nkro) { + if (host_can_send_nkro() && keymap_config.nkro) { send_nkro_report(); - } else { - send_6kro_report(); + return; } -#else - send_6kro_report(); #endif + send_6kro_report(); } /** \brief Get mods diff --git a/quantum/audio/audio.c b/quantum/audio/audio.c index 2cc3c2d661..4e223f0c9a 100644 --- a/quantum/audio/audio.c +++ b/quantum/audio/audio.c @@ -149,14 +149,14 @@ void audio_driver_start(void) { } void eeconfig_update_audio_current(void) { - eeconfig_update_audio(audio_config.raw); + eeconfig_update_audio(&audio_config); } void eeconfig_update_audio_default(void) { audio_config.valid = true; audio_config.enable = AUDIO_DEFAULT_ON; audio_config.clicky_enable = AUDIO_DEFAULT_CLICKY_ON; - eeconfig_update_audio(audio_config.raw); + eeconfig_update_audio(&audio_config); } void audio_init(void) { @@ -164,7 +164,7 @@ void audio_init(void) { return; } - audio_config.raw = eeconfig_read_audio(); + eeconfig_read_audio(&audio_config); if (!audio_config.valid) { dprintf("audio_init audio_config.valid = 0. Write default values to EEPROM.\n"); eeconfig_update_audio_default(); @@ -196,7 +196,7 @@ void audio_toggle(void) { stop_all_notes(); } audio_config.enable ^= 1; - eeconfig_update_audio(audio_config.raw); + eeconfig_update_audio(&audio_config); if (audio_config.enable) { audio_on_user(); } else { @@ -206,7 +206,7 @@ void audio_toggle(void) { void audio_on(void) { audio_config.enable = 1; - eeconfig_update_audio(audio_config.raw); + eeconfig_update_audio(&audio_config); audio_on_user(); PLAY_SONG(audio_on_song); } @@ -217,7 +217,7 @@ void audio_off(void) { wait_ms(100); audio_stop_all(); audio_config.enable = 0; - eeconfig_update_audio(audio_config.raw); + eeconfig_update_audio(&audio_config); } bool audio_is_on(void) { diff --git a/quantum/audio/audio.h b/quantum/audio/audio.h index 054331d6f3..647744a686 100644 --- a/quantum/audio/audio.h +++ b/quantum/audio/audio.h @@ -18,6 +18,8 @@ #include #include + +#include "compiler_support.h" #include "musical_notes.h" #include "song_list.h" #include "voices.h" @@ -28,7 +30,7 @@ # include "audio_dac.h" #endif -typedef union { +typedef union audio_config_t { uint8_t raw; struct { bool enable : 1; @@ -38,7 +40,7 @@ typedef union { }; } audio_config_t; -_Static_assert(sizeof(audio_config_t) == sizeof(uint8_t), "Audio EECONFIG out of spec."); +STATIC_ASSERT(sizeof(audio_config_t) == sizeof(uint8_t), "Audio EECONFIG out of spec."); /* * a 'musical note' is represented by pitch and duration; a 'musical tone' adds intensity and timbre diff --git a/quantum/backlight/backlight.c b/quantum/backlight/backlight.c index eb64dd71e8..a7d2a45a51 100644 --- a/quantum/backlight/backlight.c +++ b/quantum/backlight/backlight.c @@ -16,7 +16,6 @@ along with this program. If not, see . */ #include "backlight.h" -#include "eeprom.h" #include "eeconfig.h" #include "debug.h" @@ -55,7 +54,7 @@ static void backlight_check_config(void) { * FIXME: needs doc */ void backlight_init(void) { - backlight_config.raw = eeconfig_read_backlight(); + eeconfig_read_backlight(&backlight_config); if (!backlight_config.valid) { dprintf("backlight_init backlight_config.valid = 0. Write default values to EEPROM.\n"); eeconfig_update_backlight_default(); @@ -74,7 +73,7 @@ void backlight_increase(void) { backlight_config.level++; } backlight_config.enable = 1; - eeconfig_update_backlight(backlight_config.raw); + eeconfig_update_backlight(&backlight_config); dprintf("backlight increase: %u\n", backlight_config.level); backlight_set(backlight_config.level); } @@ -87,7 +86,7 @@ void backlight_decrease(void) { if (backlight_config.level > 0) { backlight_config.level--; backlight_config.enable = !!backlight_config.level; - eeconfig_update_backlight(backlight_config.raw); + eeconfig_update_backlight(&backlight_config); } dprintf("backlight decrease: %u\n", backlight_config.level); backlight_set(backlight_config.level); @@ -116,7 +115,7 @@ void backlight_enable(void) { backlight_config.enable = true; if (backlight_config.raw == 1) // enabled but level == 0 backlight_config.level = 1; - eeconfig_update_backlight(backlight_config.raw); + eeconfig_update_backlight(&backlight_config); dprintf("backlight enable\n"); backlight_set(backlight_config.level); } @@ -129,7 +128,7 @@ void backlight_disable(void) { if (!backlight_config.enable) return; // do nothing if backlight is already off backlight_config.enable = false; - eeconfig_update_backlight(backlight_config.raw); + eeconfig_update_backlight(&backlight_config); dprintf("backlight disable\n"); backlight_set(0); } @@ -152,7 +151,7 @@ void backlight_step(void) { backlight_config.level = 0; } backlight_config.enable = !!backlight_config.level; - eeconfig_update_backlight(backlight_config.raw); + eeconfig_update_backlight(&backlight_config); dprintf("backlight step: %u\n", backlight_config.level); backlight_set(backlight_config.level); } @@ -173,19 +172,11 @@ void backlight_level_noeeprom(uint8_t level) { */ void backlight_level(uint8_t level) { backlight_level_noeeprom(level); - eeconfig_update_backlight(backlight_config.raw); -} - -uint8_t eeconfig_read_backlight(void) { - return eeprom_read_byte(EECONFIG_BACKLIGHT); -} - -void eeconfig_update_backlight(uint8_t val) { - eeprom_update_byte(EECONFIG_BACKLIGHT, val); + eeconfig_update_backlight(&backlight_config); } void eeconfig_update_backlight_current(void) { - eeconfig_update_backlight(backlight_config.raw); + eeconfig_update_backlight(&backlight_config); } void eeconfig_update_backlight_default(void) { @@ -193,7 +184,7 @@ void eeconfig_update_backlight_default(void) { backlight_config.enable = BACKLIGHT_DEFAULT_ON; backlight_config.breathing = BACKLIGHT_DEFAULT_BREATHING; backlight_config.level = BACKLIGHT_DEFAULT_LEVEL; - eeconfig_update_backlight(backlight_config.raw); + eeconfig_update_backlight(&backlight_config); } /** \brief Get backlight level @@ -226,7 +217,7 @@ void backlight_enable_breathing(void) { if (backlight_config.breathing) return; // do nothing if breathing is already on backlight_config.breathing = true; - eeconfig_update_backlight(backlight_config.raw); + eeconfig_update_backlight(&backlight_config); dprintf("backlight breathing enable\n"); breathing_enable(); } @@ -239,7 +230,7 @@ void backlight_disable_breathing(void) { if (!backlight_config.breathing) return; // do nothing if breathing is already off backlight_config.breathing = false; - eeconfig_update_backlight(backlight_config.raw); + eeconfig_update_backlight(&backlight_config); dprintf("backlight breathing disable\n"); breathing_disable(); } diff --git a/quantum/backlight/backlight.h b/quantum/backlight/backlight.h index c34fb5858d..2faa8fc4f2 100644 --- a/quantum/backlight/backlight.h +++ b/quantum/backlight/backlight.h @@ -20,6 +20,8 @@ along with this program. If not, see . #include #include +#include "compiler_support.h" + #ifndef BACKLIGHT_LEVELS # define BACKLIGHT_LEVELS 3 #elif BACKLIGHT_LEVELS > 31 @@ -34,7 +36,7 @@ along with this program. If not, see . # define BREATHING_PERIOD 6 #endif -typedef union { +typedef union backlight_config_t { uint8_t raw; struct { bool enable : 1; @@ -44,7 +46,7 @@ typedef union { }; } backlight_config_t; -_Static_assert(sizeof(backlight_config_t) == sizeof(uint8_t), "Backlight EECONFIG out of spec."); +STATIC_ASSERT(sizeof(backlight_config_t) == sizeof(uint8_t), "Backlight EECONFIG out of spec."); void backlight_init(void); void backlight_toggle(void); @@ -58,10 +60,8 @@ void backlight_level_noeeprom(uint8_t level); void backlight_level(uint8_t level); uint8_t get_backlight_level(void); -uint8_t eeconfig_read_backlight(void); -void eeconfig_update_backlight(uint8_t val); -void eeconfig_update_backlight_current(void); -void eeconfig_update_backlight_default(void); +void eeconfig_update_backlight_current(void); +void eeconfig_update_backlight_default(void); // implementation specific void backlight_init_ports(void); diff --git a/quantum/bits.h b/quantum/bits.h index 2f3c343762..41f11e7b9c 100644 --- a/quantum/bits.h +++ b/quantum/bits.h @@ -4,7 +4,7 @@ #include -/* Remove these once we transitioned to C23 across all platfroms */ +/* Remove these once we transitioned to C23 across all platforms */ #define UINT32_WIDTH 32 #define UINT64_WIDTH 64 diff --git a/quantum/command.c b/quantum/command.c index 024d96917d..998d9b9aa1 100644 --- a/quantum/command.c +++ b/quantum/command.c @@ -243,10 +243,10 @@ static void print_status(void) { #if !defined(NO_PRINT) && !defined(USER_PRINT) static void print_eeconfig(void) { - xprintf("eeconfig:\ndefault_layer: %u\n", eeconfig_read_default_layer()); + xprintf("eeconfig:\ndefault_layer: %" PRIu32 "\n", (uint32_t)eeconfig_read_default_layer()); debug_config_t dc; - dc.raw = eeconfig_read_debug(); + eeconfig_read_debug(&dc); xprintf(/* clang-format off */ "debug_config.raw: %02X\n" @@ -263,7 +263,7 @@ static void print_eeconfig(void) { ); /* clang-format on */ keymap_config_t kc; - kc.raw = eeconfig_read_keymap(); + eeconfig_read_keymap(&kc); xprintf(/* clang-format off */ "keymap_config.raw: %02X\n" @@ -296,7 +296,7 @@ static void print_eeconfig(void) { # ifdef BACKLIGHT_ENABLE backlight_config_t bc; - bc.raw = eeconfig_read_backlight(); + eeconfig_read_backlight(&bc); xprintf(/* clang-format off */ "backlight_config" diff --git a/quantum/compiler_support.h b/quantum/compiler_support.h new file mode 100644 index 0000000000..5c0c4d2835 --- /dev/null +++ b/quantum/compiler_support.h @@ -0,0 +1,15 @@ +// Copyright 2025 QMK Contributors +// SPDX-License-Identifier: GPL-2.0-or-later + +/** + * @brief Perfom an assertion at compile time. + * + * `_Static_assert` is C<23, while `static_assert` is C++/C23. + */ +#if !defined(STATIC_ASSERT) +# ifdef __cplusplus +# define STATIC_ASSERT static_assert +# else +# define STATIC_ASSERT _Static_assert +# endif +#endif diff --git a/quantum/connection/connection.c b/quantum/connection/connection.c new file mode 100644 index 0000000000..1ff8876876 --- /dev/null +++ b/quantum/connection/connection.c @@ -0,0 +1,141 @@ +// Copyright 2025 QMK +// SPDX-License-Identifier: GPL-2.0-or-later +#include "connection.h" +#include "eeconfig.h" +#include "usb_util.h" +#include "util.h" + +#ifdef BLUETOOTH_ENABLE +# include "bluetooth.h" +#endif + +// ======== DEPRECATED DEFINES - DO NOT USE ======== +#ifdef OUTPUT_DEFAULT +# undef CONNECTION_HOST_DEFAULT +# define CONNECTION_HOST_DEFAULT OUTPUT_DEFAULT +#endif + +__attribute__((weak)) void set_output_user(uint8_t output) {} +// ======== + +#define CONNECTION_HOST_INVALID 0xFF + +#ifndef CONNECTION_HOST_DEFAULT +# define CONNECTION_HOST_DEFAULT CONNECTION_HOST_AUTO +#endif + +static const connection_host_t host_candidates[] = { + CONNECTION_HOST_AUTO, + CONNECTION_HOST_USB, +#ifdef BLUETOOTH_ENABLE + CONNECTION_HOST_BLUETOOTH, +#endif +#if 0 + CONNECTION_HOST_2P4GHZ, +#endif +}; + +#define HOST_CANDIDATES_COUNT ARRAY_SIZE(host_candidates) + +static connection_config_t config = {.desired_host = CONNECTION_HOST_INVALID}; + +void eeconfig_update_connection_default(void) { + config.desired_host = CONNECTION_HOST_DEFAULT; + + eeconfig_update_connection(&config); +} + +void connection_init(void) { + eeconfig_read_connection(&config); + if (config.desired_host == CONNECTION_HOST_INVALID) { + eeconfig_update_connection_default(); + } +} + +__attribute__((weak)) void connection_host_changed_user(connection_host_t host) {} +__attribute__((weak)) void connection_host_changed_kb(connection_host_t host) {} + +static void handle_host_changed(void) { + connection_host_changed_user(config.desired_host); + connection_host_changed_kb(config.desired_host); + + // TODO: Remove deprecated callback + set_output_user(config.desired_host); +} + +void connection_set_host_noeeprom(connection_host_t host) { + if (config.desired_host == host) { + return; + } + + config.desired_host = host; + + handle_host_changed(); +} + +void connection_set_host(connection_host_t host) { + connection_set_host_noeeprom(host); + + eeconfig_update_connection(&config); +} + +void connection_next_host_noeeprom(void) { + uint8_t next = 0; + for (uint8_t i = 0; i < HOST_CANDIDATES_COUNT; i++) { + if (host_candidates[i] == config.desired_host) { + next = i == HOST_CANDIDATES_COUNT - 1 ? 0 : i + 1; + break; + } + } + + connection_set_host_noeeprom(host_candidates[next]); +} + +void connection_next_host(void) { + connection_next_host_noeeprom(); + + eeconfig_update_connection(&config); +} + +void connection_prev_host_noeeprom(void) { + uint8_t next = 0; + for (uint8_t i = 0; i < HOST_CANDIDATES_COUNT; i++) { + if (host_candidates[i] == config.desired_host) { + next = i == 0 ? HOST_CANDIDATES_COUNT - 1 : i - 1; + break; + } + } + + connection_set_host_noeeprom(host_candidates[next]); +} + +void connection_prev_host(void) { + connection_prev_host_noeeprom(); + + eeconfig_update_connection(&config); +} + +connection_host_t connection_get_host_raw(void) { + return config.desired_host; +} + +connection_host_t connection_auto_detect_host(void) { + if (usb_connected_state()) { + return CONNECTION_HOST_USB; + } + +#ifdef BLUETOOTH_ENABLE + if (bluetooth_is_connected()) { + return CONNECTION_HOST_BLUETOOTH; + } +#endif + + return CONNECTION_HOST_NONE; +} + +connection_host_t connection_get_host(void) { + if (config.desired_host == CONNECTION_HOST_AUTO) { + return connection_auto_detect_host(); + } + return config.desired_host; +} diff --git a/quantum/connection/connection.h b/quantum/connection/connection.h new file mode 100644 index 0000000000..b25160c759 --- /dev/null +++ b/quantum/connection/connection.h @@ -0,0 +1,112 @@ +// Copyright 2025 QMK +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +#include + +#include "compiler_support.h" +#include "util.h" + +/** + * \enum connection_host_t + * + * An enumeration of the possible hosts. + */ +typedef enum connection_host_t { + CONNECTION_HOST_AUTO, + + CONNECTION_HOST_NONE, + CONNECTION_HOST_USB, + CONNECTION_HOST_BLUETOOTH, + CONNECTION_HOST_2P4GHZ +} connection_host_t; + +/** + * \union connection_config_t + * + * Configuration structure for the connection subsystem. + */ +typedef union connection_config_t { + uint8_t raw; + connection_host_t desired_host : 8; +} PACKED connection_config_t; + +STATIC_ASSERT(sizeof(connection_config_t) == sizeof(uint8_t), "Connection EECONFIG out of spec."); + +/** + * \brief Initialize the subsystem. + * + * This function must be called only once, before any of the below functions can be called. + */ +void connection_init(void); + +/** + * \brief Get currently configured host. Does not resolve 'CONNECTION_HOST_AUTO'. + * + * \return 'connection_host_t' of the configured host. + */ +connection_host_t connection_get_host_raw(void); + +/** + * \brief Get current active host. + * + * \return 'connection_host_t' of the configured host. + */ +connection_host_t connection_auto_detect_host(void); + +/** + * \brief Get currently configured host. Resolves 'CONNECTION_HOST_AUTO' using 'connection_auto_detect_host()'. + * + * \return 'connection_host_t' of the configured host. + */ +connection_host_t connection_get_host(void); + +/** + * \brief Get current host. New state is not written to EEPROM. + * + * \param host The host to configure. + */ +void connection_set_host_noeeprom(connection_host_t host); + +/** + * \brief Get current host. + * + * \param host The host to configure. + */ +void connection_set_host(connection_host_t host); + +/** + * \brief Move to the next potential host. New state is not written to EEPROM. + * + */ +void connection_next_host_noeeprom(void); + +/** + * \brief Move to the next potential host. + * + */ +void connection_next_host(void); + +/** + * \brief Move to the previous potential host. New state is not written to EEPROM. + * + */ +void connection_prev_host_noeeprom(void); + +/** + * \brief Move to the previous potential host. + * + */ +void connection_prev_host(void); + +/** + * \brief user hook called when changing configured host + * + */ +void connection_host_changed_user(connection_host_t host); + +/** + * \brief keyboard hook called when changing configured host + * + */ +void connection_host_changed_kb(connection_host_t host); diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c index beb7f9d18f..59027fb694 100644 --- a/quantum/dynamic_keymap.c +++ b/quantum/dynamic_keymap.c @@ -1,4 +1,5 @@ /* Copyright 2017 Jason Williams (Wilba) + * Copyright 2024-2025 Nick Brassel (@tzarc) * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,18 +18,9 @@ #include "dynamic_keymap.h" #include "keymap_introspection.h" #include "action.h" -#include "eeprom.h" -#include "progmem.h" #include "send_string.h" #include "keycodes.h" - -#ifdef VIA_ENABLE -# include "via.h" -# define DYNAMIC_KEYMAP_EEPROM_START (VIA_EEPROM_CONFIG_END) -#else -# include "eeconfig.h" -# define DYNAMIC_KEYMAP_EEPROM_START (EECONFIG_SIZE) -#endif +#include "nvm_dynamic_keymap.h" #ifdef ENCODER_ENABLE # include "encoder.h" @@ -36,67 +28,6 @@ # define NUM_ENCODERS 0 #endif -#ifndef DYNAMIC_KEYMAP_LAYER_COUNT -# define DYNAMIC_KEYMAP_LAYER_COUNT 4 -#endif - -#ifndef DYNAMIC_KEYMAP_MACRO_COUNT -# define DYNAMIC_KEYMAP_MACRO_COUNT 16 -#endif - -#ifndef TOTAL_EEPROM_BYTE_COUNT -# error Unknown total EEPROM size. Cannot derive maximum for dynamic keymaps. -#endif - -#ifndef DYNAMIC_KEYMAP_EEPROM_MAX_ADDR -# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR (TOTAL_EEPROM_BYTE_COUNT - 1) -#endif - -#if DYNAMIC_KEYMAP_EEPROM_MAX_ADDR > (TOTAL_EEPROM_BYTE_COUNT - 1) -# pragma message STR(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR) " > " STR((TOTAL_EEPROM_BYTE_COUNT - 1)) -# error DYNAMIC_KEYMAP_EEPROM_MAX_ADDR is configured to use more space than what is available for the selected EEPROM driver -#endif - -// Due to usage of uint16_t check for max 65535 -#if DYNAMIC_KEYMAP_EEPROM_MAX_ADDR > 65535 -# pragma message STR(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR) " > 65535" -# error DYNAMIC_KEYMAP_EEPROM_MAX_ADDR must be less than 65536 -#endif - -// If DYNAMIC_KEYMAP_EEPROM_ADDR not explicitly defined in config.h, -#ifndef DYNAMIC_KEYMAP_EEPROM_ADDR -# define DYNAMIC_KEYMAP_EEPROM_ADDR DYNAMIC_KEYMAP_EEPROM_START -#endif - -// Dynamic encoders starts after dynamic keymaps -#ifndef DYNAMIC_KEYMAP_ENCODER_EEPROM_ADDR -# define DYNAMIC_KEYMAP_ENCODER_EEPROM_ADDR (DYNAMIC_KEYMAP_EEPROM_ADDR + (DYNAMIC_KEYMAP_LAYER_COUNT * MATRIX_ROWS * MATRIX_COLS * 2)) -#endif - -// Dynamic macro starts after dynamic encoders, but only when using ENCODER_MAP -#ifdef ENCODER_MAP_ENABLE -# ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR -# define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR (DYNAMIC_KEYMAP_ENCODER_EEPROM_ADDR + (DYNAMIC_KEYMAP_LAYER_COUNT * NUM_ENCODERS * 2 * 2)) -# endif // DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR -#else // ENCODER_MAP_ENABLE -# ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR -# define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR (DYNAMIC_KEYMAP_ENCODER_EEPROM_ADDR) -# endif // DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR -#endif // ENCODER_MAP_ENABLE - -// Sanity check that dynamic keymaps fit in available EEPROM -// If there's not 100 bytes available for macros, then something is wrong. -// The keyboard should override DYNAMIC_KEYMAP_LAYER_COUNT to reduce it, -// or DYNAMIC_KEYMAP_EEPROM_MAX_ADDR to increase it, *only if* the microcontroller has -// more than the default. -_Static_assert((DYNAMIC_KEYMAP_EEPROM_MAX_ADDR) - (DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR) >= 100, "Dynamic keymaps are configured to use more EEPROM than is available."); - -// Dynamic macros are stored after the keymaps and use what is available -// up to and including DYNAMIC_KEYMAP_EEPROM_MAX_ADDR. -#ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE -# define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE (DYNAMIC_KEYMAP_EEPROM_MAX_ADDR - DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + 1) -#endif - #ifndef DYNAMIC_KEYMAP_MACRO_DELAY # define DYNAMIC_KEYMAP_MACRO_DELAY TAP_CODE_DELAY #endif @@ -105,52 +36,28 @@ uint8_t dynamic_keymap_get_layer_count(void) { return DYNAMIC_KEYMAP_LAYER_COUNT; } -void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column) { - // TODO: optimize this with some left shifts - return ((void *)DYNAMIC_KEYMAP_EEPROM_ADDR) + (layer * MATRIX_ROWS * MATRIX_COLS * 2) + (row * MATRIX_COLS * 2) + (column * 2); -} - uint16_t dynamic_keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t column) { - if (layer >= DYNAMIC_KEYMAP_LAYER_COUNT || row >= MATRIX_ROWS || column >= MATRIX_COLS) return KC_NO; - void *address = dynamic_keymap_key_to_eeprom_address(layer, row, column); - // Big endian, so we can read/write EEPROM directly from host if we want - uint16_t keycode = eeprom_read_byte(address) << 8; - keycode |= eeprom_read_byte(address + 1); - return keycode; + return nvm_dynamic_keymap_read_keycode(layer, row, column); } void dynamic_keymap_set_keycode(uint8_t layer, uint8_t row, uint8_t column, uint16_t keycode) { - if (layer >= DYNAMIC_KEYMAP_LAYER_COUNT || row >= MATRIX_ROWS || column >= MATRIX_COLS) return; - void *address = dynamic_keymap_key_to_eeprom_address(layer, row, column); - // Big endian, so we can read/write EEPROM directly from host if we want - eeprom_update_byte(address, (uint8_t)(keycode >> 8)); - eeprom_update_byte(address + 1, (uint8_t)(keycode & 0xFF)); + nvm_dynamic_keymap_update_keycode(layer, row, column, keycode); } #ifdef ENCODER_MAP_ENABLE -void *dynamic_keymap_encoder_to_eeprom_address(uint8_t layer, uint8_t encoder_id) { - return ((void *)DYNAMIC_KEYMAP_ENCODER_EEPROM_ADDR) + (layer * NUM_ENCODERS * 2 * 2) + (encoder_id * 2 * 2); -} - uint16_t dynamic_keymap_get_encoder(uint8_t layer, uint8_t encoder_id, bool clockwise) { - if (layer >= DYNAMIC_KEYMAP_LAYER_COUNT || encoder_id >= NUM_ENCODERS) return KC_NO; - void *address = dynamic_keymap_encoder_to_eeprom_address(layer, encoder_id); - // Big endian, so we can read/write EEPROM directly from host if we want - uint16_t keycode = ((uint16_t)eeprom_read_byte(address + (clockwise ? 0 : 2))) << 8; - keycode |= eeprom_read_byte(address + (clockwise ? 0 : 2) + 1); - return keycode; + return nvm_dynamic_keymap_read_encoder(layer, encoder_id, clockwise); } void dynamic_keymap_set_encoder(uint8_t layer, uint8_t encoder_id, bool clockwise, uint16_t keycode) { - if (layer >= DYNAMIC_KEYMAP_LAYER_COUNT || encoder_id >= NUM_ENCODERS) return; - void *address = dynamic_keymap_encoder_to_eeprom_address(layer, encoder_id); - // Big endian, so we can read/write EEPROM directly from host if we want - eeprom_update_byte(address + (clockwise ? 0 : 2), (uint8_t)(keycode >> 8)); - eeprom_update_byte(address + (clockwise ? 0 : 2) + 1, (uint8_t)(keycode & 0xFF)); + nvm_dynamic_keymap_update_encoder(layer, encoder_id, clockwise, keycode); } #endif // ENCODER_MAP_ENABLE void dynamic_keymap_reset(void) { + // Erase the keymaps, if necessary. + nvm_dynamic_keymap_erase(); + // Reset the keymaps in EEPROM to what is in flash. for (int layer = 0; layer < DYNAMIC_KEYMAP_LAYER_COUNT; layer++) { for (int row = 0; row < MATRIX_ROWS; row++) { @@ -168,31 +75,11 @@ void dynamic_keymap_reset(void) { } void dynamic_keymap_get_buffer(uint16_t offset, uint16_t size, uint8_t *data) { - uint16_t dynamic_keymap_eeprom_size = DYNAMIC_KEYMAP_LAYER_COUNT * MATRIX_ROWS * MATRIX_COLS * 2; - void * source = (void *)(DYNAMIC_KEYMAP_EEPROM_ADDR + offset); - uint8_t *target = data; - for (uint16_t i = 0; i < size; i++) { - if (offset + i < dynamic_keymap_eeprom_size) { - *target = eeprom_read_byte(source); - } else { - *target = 0x00; - } - source++; - target++; - } + nvm_dynamic_keymap_read_buffer(offset, size, data); } void dynamic_keymap_set_buffer(uint16_t offset, uint16_t size, uint8_t *data) { - uint16_t dynamic_keymap_eeprom_size = DYNAMIC_KEYMAP_LAYER_COUNT * MATRIX_ROWS * MATRIX_COLS * 2; - void * target = (void *)(DYNAMIC_KEYMAP_EEPROM_ADDR + offset); - uint8_t *source = data; - for (uint16_t i = 0; i < size; i++) { - if (offset + i < dynamic_keymap_eeprom_size) { - eeprom_update_byte(target, *source); - } - source++; - target++; - } + nvm_dynamic_keymap_update_buffer(offset, size, data); } uint16_t keycode_at_keymap_location(uint8_t layer_num, uint8_t row, uint8_t column) { @@ -216,53 +103,38 @@ uint8_t dynamic_keymap_macro_get_count(void) { } uint16_t dynamic_keymap_macro_get_buffer_size(void) { - return DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE; + return (uint16_t)nvm_dynamic_keymap_macro_size(); } void dynamic_keymap_macro_get_buffer(uint16_t offset, uint16_t size, uint8_t *data) { - void * source = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + offset); - uint8_t *target = data; - for (uint16_t i = 0; i < size; i++) { - if (offset + i < DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE) { - *target = eeprom_read_byte(source); - } else { - *target = 0x00; - } - source++; - target++; - } + nvm_dynamic_keymap_macro_read_buffer(offset, size, data); } void dynamic_keymap_macro_set_buffer(uint16_t offset, uint16_t size, uint8_t *data) { - void * target = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + offset); - uint8_t *source = data; - for (uint16_t i = 0; i < size; i++) { - if (offset + i < DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE) { - eeprom_update_byte(target, *source); - } - source++; - target++; - } + nvm_dynamic_keymap_macro_update_buffer(offset, size, data); } -typedef struct send_string_eeprom_state_t { - const uint8_t *ptr; -} send_string_eeprom_state_t; +static uint8_t dynamic_keymap_read_byte(uint32_t offset) { + uint8_t d; + nvm_dynamic_keymap_macro_read_buffer(offset, 1, &d); + return d; +} -char send_string_get_next_eeprom(void *arg) { - send_string_eeprom_state_t *state = (send_string_eeprom_state_t *)arg; - char ret = eeprom_read_byte(state->ptr); - state->ptr++; +typedef struct send_string_nvm_state_t { + uint32_t offset; +} send_string_nvm_state_t; + +char send_string_get_next_nvm(void *arg) { + send_string_nvm_state_t *state = (send_string_nvm_state_t *)arg; + char ret = dynamic_keymap_read_byte(state->offset); + state->offset++; return ret; } void dynamic_keymap_macro_reset(void) { - void *p = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR); - void *end = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE); - while (p != end) { - eeprom_update_byte(p, 0); - ++p; - } + // Erase the macros, if necessary. + nvm_dynamic_keymap_macro_erase(); + nvm_dynamic_keymap_macro_reset(); } void dynamic_keymap_macro_send(uint8_t id) { @@ -274,27 +146,26 @@ void dynamic_keymap_macro_send(uint8_t id) { // If it's not zero, then we are in the middle // of buffer writing, possibly an aborted buffer // write. So do nothing. - void *p = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE - 1); - if (eeprom_read_byte(p) != 0) { + if (dynamic_keymap_read_byte(nvm_dynamic_keymap_macro_size() - 1) != 0) { return; } // Skip N null characters // p will then point to the Nth macro - p = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR); - void *end = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE); + uint32_t offset = 0; + uint32_t end = nvm_dynamic_keymap_macro_size(); while (id > 0) { // If we are past the end of the buffer, then there is // no Nth macro in the buffer. - if (p == end) { + if (offset == end) { return; } - if (eeprom_read_byte(p) == 0) { + if (dynamic_keymap_read_byte(offset) == 0) { --id; } - ++p; + ++offset; } - send_string_eeprom_state_t state = {p}; - send_string_with_delay_impl(send_string_get_next_eeprom, &state, DYNAMIC_KEYMAP_MACRO_DELAY); + send_string_nvm_state_t state = {.offset = 0}; + send_string_with_delay_impl(send_string_get_next_nvm, &state, DYNAMIC_KEYMAP_MACRO_DELAY); } diff --git a/quantum/dynamic_keymap.h b/quantum/dynamic_keymap.h index 806342efa3..f1d8077b12 100644 --- a/quantum/dynamic_keymap.h +++ b/quantum/dynamic_keymap.h @@ -18,8 +18,15 @@ #include #include +#ifndef DYNAMIC_KEYMAP_LAYER_COUNT +# define DYNAMIC_KEYMAP_LAYER_COUNT 4 +#endif + +#ifndef DYNAMIC_KEYMAP_MACRO_COUNT +# define DYNAMIC_KEYMAP_MACRO_COUNT 16 +#endif + uint8_t dynamic_keymap_get_layer_count(void); -void * dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column); uint16_t dynamic_keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t column); void dynamic_keymap_set_keycode(uint8_t layer, uint8_t row, uint8_t column, uint16_t keycode); #ifdef ENCODER_MAP_ENABLE diff --git a/quantum/eeconfig.c b/quantum/eeconfig.c index e27f604f12..f14e6ddf97 100644 --- a/quantum/eeconfig.c +++ b/quantum/eeconfig.c @@ -1,355 +1,359 @@ #include #include #include -#include "eeprom.h" +#include "debug.h" #include "eeconfig.h" +#include "action_layer.h" +#include "nvm_eeconfig.h" +#include "keycode_config.h" -#if defined(EEPROM_DRIVER) -# include "eeprom_driver.h" -#endif +#ifdef BACKLIGHT_ENABLE +# include "backlight.h" +#endif // BACKLIGHT_ENABLE -#if defined(HAPTIC_ENABLE) +#ifdef AUDIO_ENABLE +# include "audio.h" +#endif // AUDIO_ENABLE + +#ifdef RGBLIGHT_ENABLE +# include "rgblight.h" +#endif // RGBLIGHT_ENABLE + +#ifdef RGB_MATRIX_ENABLE +# include "rgb_matrix_types.h" +#endif // RGB_MATRIX_ENABLE + +#ifdef LED_MATRIX_ENABLE +# include "led_matrix_types.h" +#endif // LED_MATRIX_ENABLE + +#ifdef UNICODE_COMMON_ENABLE +# include "unicode.h" +#endif // UNICODE_COMMON_ENABLE + +#ifdef HAPTIC_ENABLE # include "haptic.h" -#endif +#endif // HAPTIC_ENABLE -#if defined(VIA_ENABLE) +#ifdef CONNECTION_ENABLE +# include "connection.h" +#endif // CONNECTION_ENABLE + +#ifdef VIA_ENABLE bool via_eeprom_is_valid(void); void via_eeprom_set_valid(bool valid); void eeconfig_init_via(void); +#else +void dynamic_keymap_reset(void); +#endif // VIA_ENABLE + +#ifndef NKRO_DEFAULT_ON +# define NKRO_DEFAULT_ON false #endif -_Static_assert((intptr_t)EECONFIG_HANDEDNESS == 14, "EEPROM handedness offset is incorrect"); - -/** \brief eeconfig enable - * - * FIXME: needs doc - */ __attribute__((weak)) void eeconfig_init_user(void) { #if (EECONFIG_USER_DATA_SIZE) == 0 // Reset user EEPROM value to blank, rather than to a set value eeconfig_update_user(0); -#endif +#endif // (EECONFIG_USER_DATA_SIZE) == 0 } __attribute__((weak)) void eeconfig_init_kb(void) { #if (EECONFIG_KB_DATA_SIZE) == 0 // Reset Keyboard EEPROM value to blank, rather than to a set value eeconfig_update_kb(0); -#endif +#endif // (EECONFIG_KB_DATA_SIZE) == 0 eeconfig_init_user(); } -/* - * FIXME: needs doc - */ void eeconfig_init_quantum(void) { -#if defined(EEPROM_DRIVER) - eeprom_driver_format(false); -#endif + nvm_eeconfig_erase(); + + eeconfig_enable(); + + debug_config_t debug_config = {0}; + eeconfig_update_debug(&debug_config); - eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER); - eeprom_update_byte(EECONFIG_DEBUG, 0); default_layer_state = (layer_state_t)1 << 0; eeconfig_update_default_layer(default_layer_state); - // Enable oneshot and autocorrect by default: 0b0001 0100 0000 0000 - eeprom_update_word(EECONFIG_KEYMAP, 0x1400); - eeprom_update_byte(EECONFIG_BACKLIGHT, 0); - eeprom_update_byte(EECONFIG_AUDIO, 0); - eeprom_update_dword(EECONFIG_RGBLIGHT, 0); - eeprom_update_byte(EECONFIG_RGBLIGHT_EXTENDED, 0); - eeprom_update_byte(EECONFIG_UNICODEMODE, 0); - eeprom_update_byte(EECONFIG_STENOMODE, 0); - eeprom_write_qword(EECONFIG_RGB_MATRIX, 0); - eeprom_update_dword(EECONFIG_HAPTIC, 0); -#if defined(HAPTIC_ENABLE) - haptic_reset(); + + keymap_config_t keymap_config = { + .swap_control_capslock = false, + .capslock_to_control = false, + .swap_lalt_lgui = false, + .swap_ralt_rgui = false, + .no_gui = false, + .swap_grave_esc = false, + .swap_backslash_backspace = false, + .nkro = NKRO_DEFAULT_ON, + .swap_lctl_lgui = false, + .swap_rctl_rgui = false, + .oneshot_enable = true, // Enable oneshot by default + .swap_escape_capslock = false, + .autocorrect_enable = true, // Enable autocorrect by default + }; + eeconfig_update_keymap(&keymap_config); + +#ifdef BACKLIGHT_ENABLE + backlight_config_t backlight_config = {0}; + eeconfig_update_backlight(&backlight_config); +#endif // BACKLIGHT_ENABLE + +#ifdef AUDIO_ENABLE + audio_config_t audio_config = {0}; + eeconfig_update_audio(&audio_config); +#endif // AUDIO_ENABLE + +#ifdef RGBLIGHT_ENABLE + extern void eeconfig_update_rgblight_default(void); + eeconfig_update_rgblight_default(); +#endif // RGBLIGHT_ENABLE + +#ifdef UNICODE_COMMON_ENABLE + unicode_config_t unicode_config = {0}; + eeconfig_update_unicode_mode(&unicode_config); +#endif // UNICODE_COMMON_ENABLE + +#ifdef STENO_ENABLE + eeconfig_update_steno_mode(0); +#endif // STENO_ENABLE + +#ifdef RGB_MATRIX_ENABLE + extern void eeconfig_update_rgb_matrix_default(void); + eeconfig_update_rgb_matrix_default(); #endif +#ifdef LED_MATRIX_ENABLE + extern void eeconfig_update_led_matrix_default(void); + eeconfig_update_led_matrix_default(); +#endif // LED_MATRIX_ENABLE + +#ifdef HAPTIC_ENABLE + haptic_config_t haptic_config = {0}; + eeconfig_update_haptic(&haptic_config); + haptic_reset(); +#endif // HAPTIC_ENABLE + +#ifdef CONNECTION_ENABLE + extern void eeconfig_update_connection_default(void); + eeconfig_update_connection_default(); +#endif // CONNECTION_ENABLE + #if (EECONFIG_KB_DATA_SIZE) > 0 eeconfig_init_kb_datablock(); -#endif +#endif // (EECONFIG_KB_DATA_SIZE) > 0 #if (EECONFIG_USER_DATA_SIZE) > 0 eeconfig_init_user_datablock(); -#endif +#endif // (EECONFIG_USER_DATA_SIZE) > 0 #if defined(VIA_ENABLE) // Invalidate VIA eeprom config, and then reset. - // Just in case if power is lost mid init, this makes sure that it pets + // Just in case if power is lost mid init, this makes sure that it gets // properly re-initialized. - via_eeprom_set_valid(false); eeconfig_init_via(); +#elif defined(DYNAMIC_KEYMAP_ENABLE) + dynamic_keymap_reset(); #endif eeconfig_init_kb(); + +#ifdef RGB_MATRIX_ENABLE + extern void eeconfig_force_flush_rgb_matrix(void); + eeconfig_force_flush_rgb_matrix(); +#endif // RGB_MATRIX_ENABLE +#ifdef LED_MATRIX_ENABLE + extern void eeconfig_force_flush_led_matrix(void); + eeconfig_force_flush_led_matrix(); +#endif // LED_MATRIX_ENABLE } -/** \brief eeconfig initialization - * - * FIXME: needs doc - */ void eeconfig_init(void) { eeconfig_init_quantum(); } -/** \brief eeconfig enable - * - * FIXME: needs doc - */ void eeconfig_enable(void) { - eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER); + nvm_eeconfig_enable(); } -/** \brief eeconfig disable - * - * FIXME: needs doc - */ void eeconfig_disable(void) { -#if defined(EEPROM_DRIVER) - eeprom_driver_format(false); -#endif - eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER_OFF); + nvm_eeconfig_disable(); } -/** \brief eeconfig is enabled - * - * FIXME: needs doc - */ bool eeconfig_is_enabled(void) { - bool is_eeprom_enabled = (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER); + bool is_eeprom_enabled = nvm_eeconfig_is_enabled(); #ifdef VIA_ENABLE if (is_eeprom_enabled) { is_eeprom_enabled = via_eeprom_is_valid(); } -#endif +#endif // VIA_ENABLE return is_eeprom_enabled; } -/** \brief eeconfig is disabled - * - * FIXME: needs doc - */ bool eeconfig_is_disabled(void) { - bool is_eeprom_disabled = (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER_OFF); + bool is_eeprom_disabled = nvm_eeconfig_is_disabled(); #ifdef VIA_ENABLE if (!is_eeprom_disabled) { is_eeprom_disabled = !via_eeprom_is_valid(); } -#endif +#endif // VIA_ENABLE return is_eeprom_disabled; } -/** \brief eeconfig read debug - * - * FIXME: needs doc - */ -uint8_t eeconfig_read_debug(void) { - return eeprom_read_byte(EECONFIG_DEBUG); +void eeconfig_read_debug(debug_config_t *debug_config) { + nvm_eeconfig_read_debug(debug_config); } -/** \brief eeconfig update debug - * - * FIXME: needs doc - */ -void eeconfig_update_debug(uint8_t val) { - eeprom_update_byte(EECONFIG_DEBUG, val); +void eeconfig_update_debug(const debug_config_t *debug_config) { + nvm_eeconfig_update_debug(debug_config); } -/** \brief eeconfig read default layer - * - * FIXME: needs doc - */ layer_state_t eeconfig_read_default_layer(void) { - uint8_t val = eeprom_read_byte(EECONFIG_DEFAULT_LAYER); - -#ifdef DEFAULT_LAYER_STATE_IS_VALUE_NOT_BITMASK - // stored as a layer number, so convert back to bitmask - return 1 << val; -#else - // stored as 8-bit-wide bitmask, so read the value directly - handling padding to 16/32 bit layer_state_t - return val; -#endif + return nvm_eeconfig_read_default_layer(); } -/** \brief eeconfig update default layer - * - * FIXME: needs doc - */ void eeconfig_update_default_layer(layer_state_t state) { -#ifdef DEFAULT_LAYER_STATE_IS_VALUE_NOT_BITMASK - // stored as a layer number, so only store the highest layer - uint8_t val = get_highest_layer(state); -#else - // stored as 8-bit-wide bitmask, so write the value directly - handling truncation from 16/32 bit layer_state_t - uint8_t val = state; -#endif - - eeprom_update_byte(EECONFIG_DEFAULT_LAYER, val); + nvm_eeconfig_update_default_layer(state); } -/** \brief eeconfig read keymap - * - * FIXME: needs doc - */ -uint16_t eeconfig_read_keymap(void) { - return eeprom_read_word(EECONFIG_KEYMAP); +void eeconfig_read_keymap(keymap_config_t *keymap_config) { + nvm_eeconfig_read_keymap(keymap_config); } -/** \brief eeconfig update keymap - * - * FIXME: needs doc - */ -void eeconfig_update_keymap(uint16_t val) { - eeprom_update_word(EECONFIG_KEYMAP, val); +void eeconfig_update_keymap(const keymap_config_t *keymap_config) { + nvm_eeconfig_update_keymap(keymap_config); } -/** \brief eeconfig read audio - * - * FIXME: needs doc - */ -uint8_t eeconfig_read_audio(void) { - return eeprom_read_byte(EECONFIG_AUDIO); +#ifdef AUDIO_ENABLE +void eeconfig_read_audio(audio_config_t *audio_config) { + nvm_eeconfig_read_audio(audio_config); } -/** \brief eeconfig update audio - * - * FIXME: needs doc - */ -void eeconfig_update_audio(uint8_t val) { - eeprom_update_byte(EECONFIG_AUDIO, val); +void eeconfig_update_audio(const audio_config_t *audio_config) { + nvm_eeconfig_update_audio(audio_config); } +#endif // AUDIO_ENABLE + +#ifdef UNICODE_COMMON_ENABLE +void eeconfig_read_unicode_mode(unicode_config_t *unicode_config) { + return nvm_eeconfig_read_unicode_mode(unicode_config); +} +void eeconfig_update_unicode_mode(const unicode_config_t *unicode_config) { + nvm_eeconfig_update_unicode_mode(unicode_config); +} +#endif // UNICODE_COMMON_ENABLE + +#ifdef BACKLIGHT_ENABLE +void eeconfig_read_backlight(backlight_config_t *backlight_config) { + nvm_eeconfig_read_backlight(backlight_config); +} +void eeconfig_update_backlight(const backlight_config_t *backlight_config) { + nvm_eeconfig_update_backlight(backlight_config); +} +#endif // BACKLIGHT_ENABLE + +#ifdef STENO_ENABLE +uint8_t eeconfig_read_steno_mode(void) { + return nvm_eeconfig_read_steno_mode(); +} +void eeconfig_update_steno_mode(uint8_t val) { + nvm_eeconfig_update_steno_mode(val); +} +#endif // STENO_ENABLE + +#ifdef RGB_MATRIX_ENABLE +void eeconfig_read_rgb_matrix(rgb_config_t *rgb_matrix_config) { + nvm_eeconfig_read_rgb_matrix(rgb_matrix_config); +} +void eeconfig_update_rgb_matrix(const rgb_config_t *rgb_matrix_config) { + nvm_eeconfig_update_rgb_matrix(rgb_matrix_config); +} +#endif // RGB_MATRIX_ENABLE + +#ifdef LED_MATRIX_ENABLE +void eeconfig_read_led_matrix(led_eeconfig_t *led_matrix_config) { + nvm_eeconfig_read_led_matrix(led_matrix_config); +} +void eeconfig_update_led_matrix(const led_eeconfig_t *led_matrix_config) { + nvm_eeconfig_update_led_matrix(led_matrix_config); +} +#endif // LED_MATRIX_ENABLE + +#ifdef RGBLIGHT_ENABLE +void eeconfig_read_rgblight(rgblight_config_t *rgblight_config) { + nvm_eeconfig_read_rgblight(rgblight_config); +} +void eeconfig_update_rgblight(const rgblight_config_t *rgblight_config) { + nvm_eeconfig_update_rgblight(rgblight_config); +} +#endif // RGBLIGHT_ENABLE #if (EECONFIG_KB_DATA_SIZE) == 0 -/** \brief eeconfig read kb - * - * FIXME: needs doc - */ uint32_t eeconfig_read_kb(void) { - return eeprom_read_dword(EECONFIG_KEYBOARD); + return nvm_eeconfig_read_kb(); } -/** \brief eeconfig update kb - * - * FIXME: needs doc - */ void eeconfig_update_kb(uint32_t val) { - eeprom_update_dword(EECONFIG_KEYBOARD, val); + nvm_eeconfig_update_kb(val); } #endif // (EECONFIG_KB_DATA_SIZE) == 0 #if (EECONFIG_USER_DATA_SIZE) == 0 -/** \brief eeconfig read user - * - * FIXME: needs doc - */ uint32_t eeconfig_read_user(void) { - return eeprom_read_dword(EECONFIG_USER); + return nvm_eeconfig_read_user(); } -/** \brief eeconfig update user - * - * FIXME: needs doc - */ void eeconfig_update_user(uint32_t val) { - eeprom_update_dword(EECONFIG_USER, val); + nvm_eeconfig_update_user(val); } #endif // (EECONFIG_USER_DATA_SIZE) == 0 -/** \brief eeconfig read haptic - * - * FIXME: needs doc - */ -uint32_t eeconfig_read_haptic(void) { - return eeprom_read_dword(EECONFIG_HAPTIC); +#ifdef HAPTIC_ENABLE +void eeconfig_read_haptic(haptic_config_t *haptic_config) { + nvm_eeconfig_read_haptic(haptic_config); } -/** \brief eeconfig update haptic - * - * FIXME: needs doc - */ -void eeconfig_update_haptic(uint32_t val) { - eeprom_update_dword(EECONFIG_HAPTIC, val); +void eeconfig_update_haptic(const haptic_config_t *haptic_config) { + nvm_eeconfig_update_haptic(haptic_config); } +#endif // HAPTIC_ENABLE -/** \brief eeconfig read split handedness - * - * FIXME: needs doc - */ -bool eeconfig_read_handedness(void) { - return !!eeprom_read_byte(EECONFIG_HANDEDNESS); +#ifdef CONNECTION_ENABLE +void eeconfig_read_connection(connection_config_t *config) { + nvm_eeconfig_read_connection(config); +} +void eeconfig_update_connection(const connection_config_t *config) { + nvm_eeconfig_update_connection(config); +} +#endif // CONNECTION_ENABLE + +bool eeconfig_read_handedness(void) { + return nvm_eeconfig_read_handedness(); } -/** \brief eeconfig update split handedness - * - * FIXME: needs doc - */ void eeconfig_update_handedness(bool val) { - eeprom_update_byte(EECONFIG_HANDEDNESS, !!val); + nvm_eeconfig_update_handedness(val); } #if (EECONFIG_KB_DATA_SIZE) > 0 -/** \brief eeconfig assert keyboard data block version - * - * FIXME: needs doc - */ bool eeconfig_is_kb_datablock_valid(void) { - return eeprom_read_dword(EECONFIG_KEYBOARD) == (EECONFIG_KB_DATA_VERSION); + return nvm_eeconfig_is_kb_datablock_valid(); } -/** \brief eeconfig read keyboard data block - * - * FIXME: needs doc - */ -void eeconfig_read_kb_datablock(void *data) { - if (eeconfig_is_kb_datablock_valid()) { - eeprom_read_block(data, EECONFIG_KB_DATABLOCK, (EECONFIG_KB_DATA_SIZE)); - } else { - memset(data, 0, (EECONFIG_KB_DATA_SIZE)); - } +uint32_t eeconfig_read_kb_datablock(void *data, uint32_t offset, uint32_t length) { + return nvm_eeconfig_read_kb_datablock(data, offset, length); } -/** \brief eeconfig update keyboard data block - * - * FIXME: needs doc - */ -void eeconfig_update_kb_datablock(const void *data) { - eeprom_update_dword(EECONFIG_KEYBOARD, (EECONFIG_KB_DATA_VERSION)); - eeprom_update_block(data, EECONFIG_KB_DATABLOCK, (EECONFIG_KB_DATA_SIZE)); +uint32_t eeconfig_update_kb_datablock(const void *data, uint32_t offset, uint32_t length) { + return nvm_eeconfig_update_kb_datablock(data, offset, length); } -/** \brief eeconfig init keyboard data block - * - * FIXME: needs doc - */ __attribute__((weak)) void eeconfig_init_kb_datablock(void) { - uint8_t dummy_kb[(EECONFIG_KB_DATA_SIZE)] = {0}; - eeconfig_update_kb_datablock(dummy_kb); + nvm_eeconfig_init_kb_datablock(); } #endif // (EECONFIG_KB_DATA_SIZE) > 0 #if (EECONFIG_USER_DATA_SIZE) > 0 -/** \brief eeconfig assert user data block version - * - * FIXME: needs doc - */ bool eeconfig_is_user_datablock_valid(void) { - return eeprom_read_dword(EECONFIG_USER) == (EECONFIG_USER_DATA_VERSION); + return nvm_eeconfig_is_user_datablock_valid(); } -/** \brief eeconfig read user data block - * - * FIXME: needs doc - */ -void eeconfig_read_user_datablock(void *data) { - if (eeconfig_is_user_datablock_valid()) { - eeprom_read_block(data, EECONFIG_USER_DATABLOCK, (EECONFIG_USER_DATA_SIZE)); - } else { - memset(data, 0, (EECONFIG_USER_DATA_SIZE)); - } +uint32_t eeconfig_read_user_datablock(void *data, uint32_t offset, uint32_t length) { + return nvm_eeconfig_read_user_datablock(data, offset, length); } -/** \brief eeconfig update user data block - * - * FIXME: needs doc - */ -void eeconfig_update_user_datablock(const void *data) { - eeprom_update_dword(EECONFIG_USER, (EECONFIG_USER_DATA_VERSION)); - eeprom_update_block(data, EECONFIG_USER_DATABLOCK, (EECONFIG_USER_DATA_SIZE)); +uint32_t eeconfig_update_user_datablock(const void *data, uint32_t offset, uint32_t length) { + return nvm_eeconfig_update_user_datablock(data, offset, length); } -/** \brief eeconfig init user data block - * - * FIXME: needs doc - */ __attribute__((weak)) void eeconfig_init_user_datablock(void) { - uint8_t dummy_user[(EECONFIG_USER_DATA_SIZE)] = {0}; - eeconfig_update_user_datablock(dummy_user); + nvm_eeconfig_init_user_datablock(); } #endif // (EECONFIG_USER_DATA_SIZE) > 0 diff --git a/quantum/eeconfig.h b/quantum/eeconfig.h index 11cf1ccbca..d4d8d957be 100644 --- a/quantum/eeconfig.h +++ b/quantum/eeconfig.h @@ -19,59 +19,9 @@ along with this program. If not, see . #include #include -#include // offsetof -#include "eeprom.h" -#include "util.h" +#include // offsetof #include "action_layer.h" // layer_state_t -#ifndef EECONFIG_MAGIC_NUMBER -# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEE5 // When changing, decrement this value to avoid future re-init issues -#endif -#define EECONFIG_MAGIC_NUMBER_OFF (uint16_t)0xFFFF - -// Dummy struct only used to calculate offsets -typedef struct PACKED { - uint16_t magic; - uint8_t debug; - uint8_t default_layer; - uint16_t keymap; - uint8_t backlight; - uint8_t audio; - uint32_t rgblight; - uint8_t unicode; - uint8_t steno; - uint8_t handedness; - uint32_t keyboard; - uint32_t user; - union { // Mutually exclusive - uint32_t led_matrix; - uint64_t rgb_matrix; - }; - uint32_t haptic; - uint8_t rgblight_ext; -} eeprom_core_t; - -/* EEPROM parameter address */ -#define EECONFIG_MAGIC (uint16_t *)(offsetof(eeprom_core_t, magic)) -#define EECONFIG_DEBUG (uint8_t *)(offsetof(eeprom_core_t, debug)) -#define EECONFIG_DEFAULT_LAYER (uint8_t *)(offsetof(eeprom_core_t, default_layer)) -#define EECONFIG_KEYMAP (uint16_t *)(offsetof(eeprom_core_t, keymap)) -#define EECONFIG_BACKLIGHT (uint8_t *)(offsetof(eeprom_core_t, backlight)) -#define EECONFIG_AUDIO (uint8_t *)(offsetof(eeprom_core_t, audio)) -#define EECONFIG_RGBLIGHT (uint32_t *)(offsetof(eeprom_core_t, rgblight)) -#define EECONFIG_UNICODEMODE (uint8_t *)(offsetof(eeprom_core_t, unicode)) -#define EECONFIG_STENOMODE (uint8_t *)(offsetof(eeprom_core_t, steno)) -#define EECONFIG_HANDEDNESS (uint8_t *)(offsetof(eeprom_core_t, handedness)) -#define EECONFIG_KEYBOARD (uint32_t *)(offsetof(eeprom_core_t, keyboard)) -#define EECONFIG_USER (uint32_t *)(offsetof(eeprom_core_t, user)) -#define EECONFIG_LED_MATRIX (uint32_t *)(offsetof(eeprom_core_t, led_matrix)) -#define EECONFIG_RGB_MATRIX (uint64_t *)(offsetof(eeprom_core_t, rgb_matrix)) -#define EECONFIG_HAPTIC (uint32_t *)(offsetof(eeprom_core_t, haptic)) -#define EECONFIG_RGBLIGHT_EXTENDED (uint8_t *)(offsetof(eeprom_core_t, rgblight_ext)) - -// Size of EEPROM being used for core data storage -#define EECONFIG_BASE_SIZE ((uint8_t)sizeof(eeprom_core_t)) - // Size of EEPROM dedicated to keyboard- and user-specific data #ifndef EECONFIG_KB_DATA_SIZE # define EECONFIG_KB_DATA_SIZE 0 @@ -86,12 +36,6 @@ typedef struct PACKED { # define EECONFIG_USER_DATA_VERSION (EECONFIG_USER_DATA_SIZE) #endif -#define EECONFIG_KB_DATABLOCK ((uint8_t *)(EECONFIG_BASE_SIZE)) -#define EECONFIG_USER_DATABLOCK ((uint8_t *)((EECONFIG_BASE_SIZE) + (EECONFIG_KB_DATA_SIZE))) - -// Size of EEPROM being used, other code can refer to this for available EEPROM -#define EECONFIG_SIZE ((EECONFIG_BASE_SIZE) + (EECONFIG_KB_DATA_SIZE) + (EECONFIG_USER_DATA_SIZE)) - /* debug bit */ #define EECONFIG_DEBUG_ENABLE (1 << 0) #define EECONFIG_DEBUG_MATRIX (1 << 1) @@ -117,22 +61,59 @@ void eeconfig_init_kb(void); void eeconfig_init_user(void); void eeconfig_enable(void); - void eeconfig_disable(void); -uint8_t eeconfig_read_debug(void); -void eeconfig_update_debug(uint8_t val); +typedef union debug_config_t debug_config_t; +void eeconfig_read_debug(debug_config_t *debug_config) __attribute__((nonnull)); +void eeconfig_update_debug(const debug_config_t *debug_config) __attribute__((nonnull)); layer_state_t eeconfig_read_default_layer(void); -void eeconfig_update_default_layer(layer_state_t val); +void eeconfig_update_default_layer(layer_state_t state); -uint16_t eeconfig_read_keymap(void); -void eeconfig_update_keymap(uint16_t val); +typedef union keymap_config_t keymap_config_t; +void eeconfig_read_keymap(keymap_config_t *keymap_config) __attribute__((nonnull)); +void eeconfig_update_keymap(const keymap_config_t *keymap_config) __attribute__((nonnull)); #ifdef AUDIO_ENABLE -uint8_t eeconfig_read_audio(void); -void eeconfig_update_audio(uint8_t val); -#endif +typedef union audio_config_t audio_config_t; +void eeconfig_read_audio(audio_config_t *audio_config) __attribute__((nonnull)); +void eeconfig_update_audio(const audio_config_t *audio_config) __attribute__((nonnull)); +#endif // AUDIO_ENABLE + +#ifdef UNICODE_COMMON_ENABLE +typedef union unicode_config_t unicode_config_t; +void eeconfig_read_unicode_mode(unicode_config_t *unicode_config) __attribute__((nonnull)); +void eeconfig_update_unicode_mode(const unicode_config_t *unicode_config) __attribute__((nonnull)); +#endif // UNICODE_COMMON_ENABLE + +#ifdef BACKLIGHT_ENABLE +typedef union backlight_config_t backlight_config_t; +void eeconfig_read_backlight(backlight_config_t *backlight_config) __attribute__((nonnull)); +void eeconfig_update_backlight(const backlight_config_t *backlight_config) __attribute__((nonnull)); +#endif // BACKLIGHT_ENABLE + +#ifdef STENO_ENABLE +uint8_t eeconfig_read_steno_mode(void); +void eeconfig_update_steno_mode(uint8_t val); +#endif // STENO_ENABLE + +#ifdef RGB_MATRIX_ENABLE +typedef union rgb_config_t rgb_config_t; +void eeconfig_read_rgb_matrix(rgb_config_t *rgb_matrix_config) __attribute__((nonnull)); +void eeconfig_update_rgb_matrix(const rgb_config_t *rgb_matrix_config) __attribute__((nonnull)); +#endif // RGB_MATRIX_ENABLE + +#ifdef LED_MATRIX_ENABLE +typedef union led_eeconfig_t led_eeconfig_t; +void eeconfig_read_led_matrix(led_eeconfig_t *led_matrix_config) __attribute__((nonnull)); +void eeconfig_update_led_matrix(const led_eeconfig_t *led_matrix_config) __attribute__((nonnull)); +#endif // LED_MATRIX_ENABLE + +#ifdef RGBLIGHT_ENABLE +typedef union rgblight_config_t rgblight_config_t; +void eeconfig_read_rgblight(rgblight_config_t *rgblight_config) __attribute__((nonnull)); +void eeconfig_update_rgblight(const rgblight_config_t *rgblight_config) __attribute__((nonnull)); +#endif // RGBLIGHT_ENABLE #if (EECONFIG_KB_DATA_SIZE) == 0 uint32_t eeconfig_read_kb(void); @@ -145,31 +126,42 @@ void eeconfig_update_user(uint32_t val); #endif // (EECONFIG_USER_DATA_SIZE) == 0 #ifdef HAPTIC_ENABLE -uint32_t eeconfig_read_haptic(void); -void eeconfig_update_haptic(uint32_t val); +typedef union haptic_config_t haptic_config_t; +void eeconfig_read_haptic(haptic_config_t *haptic_config) __attribute__((nonnull)); +void eeconfig_update_haptic(const haptic_config_t *haptic_config) __attribute__((nonnull)); +#endif + +#ifdef CONNECTION_ENABLE +typedef union connection_config_t connection_config_t; +void eeconfig_read_connection(connection_config_t *config); +void eeconfig_update_connection(const connection_config_t *config); #endif bool eeconfig_read_handedness(void); void eeconfig_update_handedness(bool val); #if (EECONFIG_KB_DATA_SIZE) > 0 -bool eeconfig_is_kb_datablock_valid(void); -void eeconfig_read_kb_datablock(void *data); -void eeconfig_update_kb_datablock(const void *data); -void eeconfig_init_kb_datablock(void); +bool eeconfig_is_kb_datablock_valid(void); +uint32_t eeconfig_read_kb_datablock(void *data, uint32_t offset, uint32_t length) __attribute__((nonnull)); +uint32_t eeconfig_update_kb_datablock(const void *data, uint32_t offset, uint32_t length) __attribute__((nonnull)); +void eeconfig_init_kb_datablock(void); +# define eeconfig_read_kb_datablock_field(__object, __field) eeconfig_read_kb_datablock(&(__object.__field), offsetof(typeof(__object), __field), sizeof(__object.__field)) +# define eeconfig_update_kb_datablock_field(__object, __field) eeconfig_update_kb_datablock(&(__object.__field), offsetof(typeof(__object), __field), sizeof(__object.__field)) #endif // (EECONFIG_KB_DATA_SIZE) > 0 #if (EECONFIG_USER_DATA_SIZE) > 0 -bool eeconfig_is_user_datablock_valid(void); -void eeconfig_read_user_datablock(void *data); -void eeconfig_update_user_datablock(const void *data); -void eeconfig_init_user_datablock(void); +bool eeconfig_is_user_datablock_valid(void); +uint32_t eeconfig_read_user_datablock(void *data, uint32_t offset, uint32_t length) __attribute__((nonnull)); +uint32_t eeconfig_update_user_datablock(const void *data, uint32_t offset, uint32_t length) __attribute__((nonnull)); +void eeconfig_init_user_datablock(void); +# define eeconfig_read_user_datablock_field(__object, __field) eeconfig_read_user_datablock(&(__object.__field), offsetof(__object, __field), sizeof(__object.__field)) +# define eeconfig_update_user_datablock_field(__object, __field) eeconfig_update_user_datablock(&(__object.__field), offsetof(__object, __field), sizeof(__object.__field)) #endif // (EECONFIG_USER_DATA_SIZE) > 0 // Any "checked" debounce variant used requires implementation of: // -- bool eeconfig_check_valid_##name(void) // -- void eeconfig_post_flush_##name(void) -#define EECONFIG_DEBOUNCE_HELPER_CHECKED(name, offset, config) \ +#define EECONFIG_DEBOUNCE_HELPER_CHECKED(name, config) \ static uint8_t dirty_##name = false; \ \ bool eeconfig_check_valid_##name(void); \ @@ -178,13 +170,13 @@ void eeconfig_init_user_datablock(void); static inline void eeconfig_init_##name(void) { \ dirty_##name = true; \ if (eeconfig_check_valid_##name()) { \ - eeprom_read_block(&config, offset, sizeof(config)); \ + eeconfig_read_##name(&config); \ dirty_##name = false; \ } \ } \ static inline void eeconfig_flush_##name(bool force) { \ if (force || dirty_##name) { \ - eeprom_update_block(&config, offset, sizeof(config)); \ + eeconfig_update_##name(&config); \ eeconfig_post_flush_##name(); \ dirty_##name = false; \ } \ @@ -206,10 +198,10 @@ void eeconfig_init_user_datablock(void); } \ } -#define EECONFIG_DEBOUNCE_HELPER(name, offset, config) \ - EECONFIG_DEBOUNCE_HELPER_CHECKED(name, offset, config) \ - \ - bool eeconfig_check_valid_##name(void) { \ - return true; \ - } \ +#define EECONFIG_DEBOUNCE_HELPER(name, config) \ + EECONFIG_DEBOUNCE_HELPER_CHECKED(name, config) \ + \ + bool eeconfig_check_valid_##name(void) { \ + return true; \ + } \ void eeconfig_post_flush_##name(void) {} diff --git a/quantum/haptic.c b/quantum/haptic.c index 81bad469b3..8a743480ff 100644 --- a/quantum/haptic.c +++ b/quantum/haptic.c @@ -67,7 +67,7 @@ void haptic_init(void) { if (!eeconfig_is_enabled()) { eeconfig_init(); } - haptic_config.raw = eeconfig_read_haptic(); + eeconfig_read_haptic(&haptic_config); #ifdef HAPTIC_SOLENOID solenoid_set_dwell(haptic_config.dwell); #endif @@ -122,13 +122,13 @@ void eeconfig_debug_haptic(void) { void haptic_enable(void) { set_haptic_config_enable(true); dprintf("haptic_config.enable = %u\n", haptic_config.enable); - eeconfig_update_haptic(haptic_config.raw); + eeconfig_update_haptic(&haptic_config); } void haptic_disable(void) { set_haptic_config_enable(false); dprintf("haptic_config.enable = %u\n", haptic_config.enable); - eeconfig_update_haptic(haptic_config.raw); + eeconfig_update_haptic(&haptic_config); } void haptic_toggle(void) { @@ -137,14 +137,14 @@ void haptic_toggle(void) { } else { haptic_enable(); } - eeconfig_update_haptic(haptic_config.raw); + eeconfig_update_haptic(&haptic_config); } void haptic_feedback_toggle(void) { haptic_config.feedback++; if (haptic_config.feedback >= HAPTIC_FEEDBACK_MAX) haptic_config.feedback = KEY_PRESS; dprintf("haptic_config.feedback = %u\n", !haptic_config.feedback); - eeconfig_update_haptic(haptic_config.raw); + eeconfig_update_haptic(&haptic_config); } void haptic_buzz_toggle(void) { @@ -225,26 +225,26 @@ void haptic_reset(void) { haptic_config.dwell = 0; haptic_config.buzz = 0; #endif - eeconfig_update_haptic(haptic_config.raw); + eeconfig_update_haptic(&haptic_config); dprintf("haptic_config.feedback = %u\n", haptic_config.feedback); dprintf("haptic_config.mode = %u\n", haptic_config.mode); } void haptic_set_feedback(uint8_t feedback) { haptic_config.feedback = feedback; - eeconfig_update_haptic(haptic_config.raw); + eeconfig_update_haptic(&haptic_config); dprintf("haptic_config.feedback = %u\n", haptic_config.feedback); } void haptic_set_mode(uint8_t mode) { haptic_config.mode = mode; - eeconfig_update_haptic(haptic_config.raw); + eeconfig_update_haptic(&haptic_config); dprintf("haptic_config.mode = %u\n", haptic_config.mode); } void haptic_set_amplitude(uint8_t amp) { haptic_config.amplitude = amp; - eeconfig_update_haptic(haptic_config.raw); + eeconfig_update_haptic(&haptic_config); dprintf("haptic_config.amplitude = %u\n", haptic_config.amplitude); #ifdef HAPTIC_DRV2605L drv2605l_amplitude(amp); @@ -253,13 +253,13 @@ void haptic_set_amplitude(uint8_t amp) { void haptic_set_buzz(uint8_t buzz) { haptic_config.buzz = buzz; - eeconfig_update_haptic(haptic_config.raw); + eeconfig_update_haptic(&haptic_config); dprintf("haptic_config.buzz = %u\n", haptic_config.buzz); } void haptic_set_dwell(uint8_t dwell) { haptic_config.dwell = dwell; - eeconfig_update_haptic(haptic_config.raw); + eeconfig_update_haptic(&haptic_config); dprintf("haptic_config.dwell = %u\n", haptic_config.dwell); } @@ -291,7 +291,7 @@ uint8_t haptic_get_dwell(void) { void haptic_enable_continuous(void) { haptic_config.cont = 1; dprintf("haptic_config.cont = %u\n", haptic_config.cont); - eeconfig_update_haptic(haptic_config.raw); + eeconfig_update_haptic(&haptic_config); #ifdef HAPTIC_DRV2605L drv2605l_rtp_init(); #endif @@ -300,7 +300,7 @@ void haptic_enable_continuous(void) { void haptic_disable_continuous(void) { haptic_config.cont = 0; dprintf("haptic_config.cont = %u\n", haptic_config.cont); - eeconfig_update_haptic(haptic_config.raw); + eeconfig_update_haptic(&haptic_config); #ifdef HAPTIC_DRV2605L drv2605l_write(DRV2605L_REG_MODE, 0x00); #endif diff --git a/quantum/haptic.h b/quantum/haptic.h index b283d5d268..f854c75ec3 100644 --- a/quantum/haptic.h +++ b/quantum/haptic.h @@ -20,6 +20,8 @@ #include #include +#include "compiler_support.h" + #ifndef HAPTIC_DEFAULT_FEEDBACK # define HAPTIC_DEFAULT_FEEDBACK 0 #endif @@ -28,7 +30,7 @@ #endif /* EEPROM config settings */ -typedef union { +typedef union haptic_config_t { uint32_t raw; struct { bool enable : 1; @@ -42,7 +44,7 @@ typedef union { }; } haptic_config_t; -_Static_assert(sizeof(haptic_config_t) == sizeof(uint32_t), "Haptic EECONFIG out of spec."); +STATIC_ASSERT(sizeof(haptic_config_t) == sizeof(uint32_t), "Haptic EECONFIG out of spec."); typedef enum HAPTIC_FEEDBACK { KEY_PRESS, diff --git a/quantum/keyboard.c b/quantum/keyboard.c index ad740de4b3..c1a6d444a5 100644 --- a/quantum/keyboard.c +++ b/quantum/keyboard.c @@ -122,6 +122,9 @@ along with this program. If not, see . #ifdef SPLIT_KEYBOARD # include "split_util.h" #endif +#ifdef BATTERY_DRIVER +# include "battery.h" +#endif #ifdef BLUETOOTH_ENABLE # include "bluetooth.h" #endif @@ -143,6 +146,9 @@ along with this program. If not, see . #ifdef LAYER_LOCK_ENABLE # include "layer_lock.h" #endif +#ifdef CONNECTION_ENABLE +# include "connection.h" +#endif static uint32_t last_input_modification_time = 0; uint32_t last_input_activity_time(void) { @@ -429,8 +435,8 @@ void quantum_init(void) { } /* init globals */ - debug_config.raw = eeconfig_read_debug(); - keymap_config.raw = eeconfig_read_keymap(); + eeconfig_read_debug(&debug_config); + eeconfig_read_keymap(&keymap_config); #ifdef BOOTMAGIC_ENABLE bootmagic(); @@ -462,6 +468,9 @@ void keyboard_init(void) { #endif matrix_init(); quantum_init(); +#ifdef CONNECTION_ENABLE + connection_init(); +#endif led_init_ports(); #ifdef BACKLIGHT_ENABLE backlight_init_ports(); @@ -500,8 +509,9 @@ void keyboard_init(void) { steno_init(); #endif #if defined(NKRO_ENABLE) && defined(FORCE_NKRO) +# pragma message "FORCE_NKRO option is now deprecated - Please migrate to NKRO_DEFAULT_ON instead." keymap_config.nkro = 1; - eeconfig_update_keymap(keymap_config.raw); + eeconfig_update_keymap(&keymap_config); #endif #ifdef DIP_SWITCH_ENABLE dip_switch_init(); @@ -522,6 +532,9 @@ void keyboard_init(void) { // init after split init pointing_device_init(); #endif +#ifdef BATTERY_DRIVER + battery_init(); +#endif #ifdef BLUETOOTH_ENABLE bluetooth_init(); #endif @@ -782,6 +795,10 @@ void keyboard_task(void) { joystick_task(); #endif +#ifdef BATTERY_DRIVER + battery_task(); +#endif + #ifdef BLUETOOTH_ENABLE bluetooth_task(); #endif diff --git a/quantum/keycode_config.h b/quantum/keycode_config.h index d1352c302e..804f1381d0 100644 --- a/quantum/keycode_config.h +++ b/quantum/keycode_config.h @@ -16,9 +16,7 @@ #pragma once -#ifdef __cplusplus -# define _Static_assert static_assert -#endif +#include "compiler_support.h" #include "eeconfig.h" #include "keycode.h" @@ -28,7 +26,7 @@ uint16_t keycode_config(uint16_t keycode); uint8_t mod_config(uint8_t mod); /* NOTE: Not portable. Bit field order depends on implementation */ -typedef union { +typedef union keymap_config_t { uint16_t raw; struct { bool swap_control_capslock : 1; @@ -47,6 +45,6 @@ typedef union { }; } keymap_config_t; -_Static_assert(sizeof(keymap_config_t) == sizeof(uint16_t), "Keycode (magic) EECONFIG out of spec."); +STATIC_ASSERT(sizeof(keymap_config_t) == sizeof(uint16_t), "Keycode (magic) EECONFIG out of spec."); extern keymap_config_t keymap_config; diff --git a/quantum/keycode_string.c b/quantum/keycode_string.c new file mode 100644 index 0000000000..18044f2ef6 --- /dev/null +++ b/quantum/keycode_string.c @@ -0,0 +1,564 @@ +// Copyright 2024-2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "keycode_string.h" + +#include +#include "bitwise.h" +#include "keycode.h" +#include "progmem.h" +#include "quantum_keycodes.h" +#include "util.h" + +typedef int_fast8_t index_t; + +// clang-format off +/** Packs a 7-char keycode name, ignoring the third char, as 3 words. */ +#define KEYCODE_NAME7(c0, c1, unused_c2, c3, c4, c5, c6) \ + ((uint16_t)c0) | (((uint16_t)c1) << 8), \ + ((uint16_t)c3) | (((uint16_t)c4) << 8), \ + ((uint16_t)c5) | (((uint16_t)c6) << 8) + +/** + * @brief Names of some common keycodes. + * + * Each (keycode, name) entry is stored flat in 8 bytes in PROGMEM. Names in + * this table must be at most 7 chars long and have an underscore '_' for the + * third char. This underscore is assumed and not actually stored. + * + * To save memory, feature-specific key entries are ifdef'd to include them only + * when their feature is enabled. + */ +static const uint16_t common_names[] PROGMEM = { + KC_TRNS, KEYCODE_NAME7('K', 'C', '_', 'T', 'R', 'N', 'S'), + KC_ENT , KEYCODE_NAME7('K', 'C', '_', 'E', 'N', 'T', 0 ), + KC_ESC , KEYCODE_NAME7('K', 'C', '_', 'E', 'S', 'C', 0 ), + KC_BSPC, KEYCODE_NAME7('K', 'C', '_', 'B', 'S', 'P', 'C'), + KC_TAB , KEYCODE_NAME7('K', 'C', '_', 'T', 'A', 'B', 0 ), + KC_SPC , KEYCODE_NAME7('K', 'C', '_', 'S', 'P', 'C', 0 ), + KC_MINS, KEYCODE_NAME7('K', 'C', '_', 'M', 'I', 'N', 'S'), + KC_EQL , KEYCODE_NAME7('K', 'C', '_', 'E', 'Q', 'L', 0 ), + KC_LBRC, KEYCODE_NAME7('K', 'C', '_', 'L', 'B', 'R', 'C'), + KC_RBRC, KEYCODE_NAME7('K', 'C', '_', 'R', 'B', 'R', 'C'), + KC_BSLS, KEYCODE_NAME7('K', 'C', '_', 'B', 'S', 'L', 'S'), + KC_NUHS, KEYCODE_NAME7('K', 'C', '_', 'N', 'U', 'H', 'S'), + KC_SCLN, KEYCODE_NAME7('K', 'C', '_', 'S', 'C', 'L', 'N'), + KC_QUOT, KEYCODE_NAME7('K', 'C', '_', 'Q', 'U', 'O', 'T'), + KC_GRV , KEYCODE_NAME7('K', 'C', '_', 'G', 'R', 'V', 0 ), + KC_COMM, KEYCODE_NAME7('K', 'C', '_', 'C', 'O', 'M', 'M'), + KC_DOT , KEYCODE_NAME7('K', 'C', '_', 'D', 'O', 'T', 0 ), + KC_SLSH, KEYCODE_NAME7('K', 'C', '_', 'S', 'L', 'S', 'H'), + KC_CAPS, KEYCODE_NAME7('K', 'C', '_', 'C', 'A', 'P', 'S'), + KC_PSCR, KEYCODE_NAME7('K', 'C', '_', 'P', 'S', 'C', 'R'), + KC_PAUS, KEYCODE_NAME7('K', 'C', '_', 'P', 'A', 'U', 'S'), + KC_INS , KEYCODE_NAME7('K', 'C', '_', 'I', 'N', 'S', 0 ), + KC_HOME, KEYCODE_NAME7('K', 'C', '_', 'H', 'O', 'M', 'E'), + KC_PGUP, KEYCODE_NAME7('K', 'C', '_', 'P', 'G', 'U', 'P'), + KC_DEL , KEYCODE_NAME7('K', 'C', '_', 'D', 'E', 'L', 0 ), + KC_END , KEYCODE_NAME7('K', 'C', '_', 'E', 'N', 'D', 0 ), + KC_PGDN, KEYCODE_NAME7('K', 'C', '_', 'P', 'G', 'D', 'N'), + KC_RGHT, KEYCODE_NAME7('K', 'C', '_', 'R', 'G', 'H', 'T'), + KC_LEFT, KEYCODE_NAME7('K', 'C', '_', 'L', 'E', 'F', 'T'), + KC_DOWN, KEYCODE_NAME7('K', 'C', '_', 'D', 'O', 'W', 'N'), + KC_UP , KEYCODE_NAME7('K', 'C', '_', 'U', 'P', 0 , 0 ), + KC_NUBS, KEYCODE_NAME7('K', 'C', '_', 'N', 'U', 'B', 'S'), + KC_HYPR, KEYCODE_NAME7('K', 'C', '_', 'H', 'Y', 'P', 'R'), + KC_MEH , KEYCODE_NAME7('K', 'C', '_', 'M', 'E', 'H', 0 ), +#ifdef EXTRAKEY_ENABLE + KC_WHOM, KEYCODE_NAME7('K', 'C', '_', 'W', 'H', 'O', 'M'), + KC_WBAK, KEYCODE_NAME7('K', 'C', '_', 'W', 'B', 'A', 'K'), + KC_WFWD, KEYCODE_NAME7('K', 'C', '_', 'W', 'F', 'W', 'D'), + KC_WSTP, KEYCODE_NAME7('K', 'C', '_', 'W', 'S', 'T', 'P'), + KC_WREF, KEYCODE_NAME7('K', 'C', '_', 'W', 'R', 'E', 'F'), + KC_MNXT, KEYCODE_NAME7('K', 'C', '_', 'M', 'N', 'X', 'T'), + KC_MPRV, KEYCODE_NAME7('K', 'C', '_', 'M', 'P', 'R', 'V'), + KC_MPLY, KEYCODE_NAME7('K', 'C', '_', 'M', 'P', 'L', 'Y'), + KC_MUTE, KEYCODE_NAME7('K', 'C', '_', 'M', 'U', 'T', 'E'), + KC_VOLU, KEYCODE_NAME7('K', 'C', '_', 'V', 'O', 'L', 'U'), + KC_VOLD, KEYCODE_NAME7('K', 'C', '_', 'V', 'O', 'L', 'D'), +#endif // EXTRAKEY_ENABLE +#ifdef MOUSEKEY_ENABLE + MS_LEFT, KEYCODE_NAME7('M', 'S', '_', 'L', 'E', 'F', 'T'), + MS_RGHT, KEYCODE_NAME7('M', 'S', '_', 'R', 'G', 'H', 'T'), + MS_UP , KEYCODE_NAME7('M', 'S', '_', 'U', 'P', 0 , 0 ), + MS_DOWN, KEYCODE_NAME7('M', 'S', '_', 'D', 'O', 'W', 'N'), + MS_WHLL, KEYCODE_NAME7('M', 'S', '_', 'W', 'H', 'L', 'L'), + MS_WHLR, KEYCODE_NAME7('M', 'S', '_', 'W', 'H', 'L', 'R'), + MS_WHLU, KEYCODE_NAME7('M', 'S', '_', 'W', 'H', 'L', 'U'), + MS_WHLD, KEYCODE_NAME7('M', 'S', '_', 'W', 'H', 'L', 'D'), +#endif // MOUSEKEY_ENABLE +#ifdef SWAP_HANDS_ENABLE + SH_ON , KEYCODE_NAME7('S', 'H', '_', 'O', 'N', 0 , 0 ), + SH_OFF , KEYCODE_NAME7('S', 'H', '_', 'O', 'F', 'F', 0 ), + SH_MON , KEYCODE_NAME7('S', 'H', '_', 'M', 'O', 'N', 0 ), + SH_MOFF, KEYCODE_NAME7('S', 'H', '_', 'M', 'O', 'F', 'F'), + SH_TOGG, KEYCODE_NAME7('S', 'H', '_', 'T', 'O', 'G', 'G'), + SH_TT , KEYCODE_NAME7('S', 'H', '_', 'T', 'T', 0 , 0 ), +# if !defined(NO_ACTION_ONESHOT) + SH_OS , KEYCODE_NAME7('S', 'H', '_', 'O', 'S', 0 , 0 ), +# endif // !defined(NO_ACTION_ONESHOT) +#endif // SWAP_HANDS_ENABLE +#ifdef LEADER_ENABLE + QK_LEAD, KEYCODE_NAME7('Q', 'K', '_', 'L', 'E', 'A', 'D'), +#endif // LEADER_ENABLE +#ifdef KEY_LOCK_ENABLE + QK_LOCK, KEYCODE_NAME7('Q', 'K', '_', 'L', 'O', 'C', 'K'), +#endif // KEY_LOCK_ENABLE +#ifdef TRI_LAYER_ENABLE + TL_LOWR, KEYCODE_NAME7('T', 'L', '_', 'L', 'O', 'W', 'R'), + TL_UPPR, KEYCODE_NAME7('T', 'L', '_', 'U', 'P', 'P', 'R'), +#endif // TRI_LAYER_ENABLE +#ifdef GRAVE_ESC_ENABLE + QK_GESC, KEYCODE_NAME7('Q', 'K', '_', 'G', 'E', 'S', 'C'), +#endif // GRAVE_ESC_ENABLE +#ifdef CAPS_WORD_ENABLE + CW_TOGG, KEYCODE_NAME7('C', 'W', '_', 'T', 'O', 'G', 'G'), +#endif // CAPS_WORD_ENABLE +#ifdef SECURE_ENABLE + SE_LOCK, KEYCODE_NAME7('S', 'E', '_', 'L', 'O', 'C', 'K'), + SE_UNLK, KEYCODE_NAME7('S', 'E', '_', 'U', 'N', 'L', 'K'), + SE_TOGG, KEYCODE_NAME7('S', 'E', '_', 'T', 'O', 'G', 'G'), + SE_REQ , KEYCODE_NAME7('S', 'E', '_', 'R', 'E', 'Q', 0 ), +#endif // SECURE_ENABLE +#ifdef LAYER_LOCK_ENABLE + QK_LLCK, KEYCODE_NAME7('Q', 'K', '_', 'L', 'L', 'C', 'K'), +#endif // LAYER_LOCK_ENABLE + EE_CLR , KEYCODE_NAME7('E', 'E', '_', 'C', 'L', 'R', 0 ), + QK_BOOT, KEYCODE_NAME7('Q', 'K', '_', 'B', 'O', 'O', 'T'), + DB_TOGG, KEYCODE_NAME7('D', 'B', '_', 'T', 'O', 'G', 'G'), +}; +// clang-format on + +/** Users can override this to define names of additional keycodes. */ +__attribute__((weak)) const keycode_string_name_t* keycode_string_names_data_user = NULL; +__attribute__((weak)) uint16_t keycode_string_names_size_user = 0; +/** Keyboard vendors can override this to define names of additional keycodes. */ +__attribute__((weak)) const keycode_string_name_t* keycode_string_names_data_kb = NULL; +__attribute__((weak)) uint16_t keycode_string_names_size_kb = 0; +/** Names of the 4 mods on each hand. */ +static const char mod_names[] PROGMEM = "CTL\0SFT\0ALT\0GUI"; +/** Internal buffer for holding a stringified keycode. */ +static char buffer[32]; +#define BUFFER_MAX_LEN (sizeof(buffer) - 1) +static index_t buffer_len; + +/** Finds the name of a keycode in `common_names` or returns NULL. */ +static const char* search_common_names(uint16_t keycode) { + static uint8_t buffer[8]; + + for (int_fast16_t offset = 0; offset < ARRAY_SIZE(common_names); offset += 4) { + if (keycode == pgm_read_word(common_names + offset)) { + const uint16_t w0 = pgm_read_word(common_names + offset + 1); + const uint16_t w1 = pgm_read_word(common_names + offset + 2); + const uint16_t w2 = pgm_read_word(common_names + offset + 3); + buffer[0] = (uint8_t)w0; + buffer[1] = (uint8_t)(w0 >> 8); + buffer[2] = '_'; + buffer[3] = (uint8_t)w1; + buffer[4] = (uint8_t)(w1 >> 8); + buffer[5] = (uint8_t)w2; + buffer[6] = (uint8_t)(w2 >> 8); + buffer[7] = 0; + return (const char*)buffer; + } + } + + return NULL; +} + +/** + * @brief Finds the name of a keycode in table or returns NULL. + * + * @param data Pointer to table to be searched. + * @param size Numer of entries in the table. + * @return Name string for the keycode, or NULL if not found. + */ +static const char* search_table(const keycode_string_name_t* data, uint16_t size, uint16_t keycode) { + if (data != NULL) { + for (uint16_t i = 0; i < size; ++i) { + if (data[i].keycode == keycode) { + return data[i].name; + } + } + } + return NULL; +} + +/** Formats `number` in `base`, either 10 or 16. */ +static char* number_string(uint16_t number, int8_t base) { + static char result[7]; + result[sizeof(result) - 1] = '\0'; + index_t i = sizeof(result) - 1; + do { + const uint8_t digit = number % base; + number /= base; + result[--i] = (digit < 10) ? (char)(digit + UINT8_C('0')) : (char)(digit + (UINT8_C('A') - 10)); + } while (number > 0 && i > 0); + + if (base == 16 && i >= 2) { + result[--i] = 'x'; + result[--i] = '0'; + } + return result + i; +} + +/** Appends `str` to `buffer`, truncating if the result would overflow. */ +static void append(const char* str) { + char* dest = buffer + buffer_len; + index_t i; + for (i = 0; buffer_len + i < BUFFER_MAX_LEN && str[i]; ++i) { + dest[i] = str[i]; + } + buffer_len += i; + buffer[buffer_len] = '\0'; +} + +/** Same as append(), but where `str` is a PROGMEM string. */ +static void append_P(const char* str) { + char* dest = buffer + buffer_len; + index_t i; + for (i = 0; buffer_len + i < BUFFER_MAX_LEN; ++i) { + const char c = pgm_read_byte(&str[i]); + if (c == '\0') { + break; + } + dest[i] = c; + } + buffer_len += i; + buffer[buffer_len] = '\0'; +} + +/** Appends a single char to `buffer` if there is space. */ +static void append_char(char c) { + if (buffer_len < BUFFER_MAX_LEN) { + buffer[buffer_len] = c; + buffer[++buffer_len] = '\0'; + } +} + +/** Formats `number` in `base`, either 10 or 16, and appends it to `buffer`. */ +static void append_number(uint16_t number, int8_t base) { + append(number_string(number, base)); +} + +/** Stringifies 5-bit mods and appends it to `buffer`. */ +static void append_5_bit_mods(uint8_t mods) { + const bool is_rhs = mods > 15; + const uint8_t csag = mods & 15; + if (csag != 0 && (csag & (csag - 1)) == 0) { // One mod is set. + append_P(PSTR("MOD_")); + append_char(is_rhs ? 'R' : 'L'); + append_P(&mod_names[4 * biton(csag)]); + } else { // Fallback: write the mod as a hex value. + append_number(mods, 16); + } +} + +/** + * @brief Writes a keycode of the format `name` + "(" + `param` + ")". + * @note `name` is a PROGMEM string, `param` is not. + */ +static void append_unary_keycode(const char* name, const char* param) { + append_P(name); + append_char('('); + append(param); + append_char(')'); +} + +/** + * @brief Writes a keycode of the format `name` + `number`. + * @note `name` is a PROGMEM string. + */ +static void append_numbered_keycode(const char* name, uint16_t number) { + append_P(name); + append_number(number, 10); +} + +/** Stringifies `keycode` and appends it to `buffer`. */ +static void append_keycode(uint16_t keycode) { + // In case there is overlap among tables, search `keycode_string_names_user` + // first so that it takes precedence. + const char* keycode_name = search_table(keycode_string_names_data_user, keycode_string_names_size_user, keycode); + if (keycode_name) { + append(keycode_name); + return; + } + keycode_name = search_table(keycode_string_names_data_kb, keycode_string_names_size_kb, keycode); + if (keycode_name) { + append(keycode_name); + return; + } + keycode_name = search_common_names(keycode); + if (keycode_name) { + append(keycode_name); + return; + } + + if (keycode <= 255) { // Basic keycodes. + switch (keycode) { + // Modifiers KC_LSFT, KC_RCTL, etc. + case MODIFIER_KEYCODE_RANGE: { + const uint8_t i = keycode - KC_LCTL; + const bool is_rhs = i > 3; + append_P(PSTR("KC_")); + append_char(is_rhs ? 'R' : 'L'); + append_P(&mod_names[4 * (i & 3)]); + } + return; + + // Letters A-Z. + case KC_A ... KC_Z: + append_P(PSTR("KC_")); + append_char((char)(keycode + (UINT8_C('A') - KC_A))); + return; + + // Digits 0-9 (NOTE: Unlike the ASCII order, KC_0 comes *after* KC_9.) + case KC_1 ... KC_0: + append_numbered_keycode(PSTR("KC_"), (keycode - (KC_1 - 1)) % 10); + return; + + // Keypad digits. + case KC_KP_1 ... KC_KP_0: + append_numbered_keycode(PSTR("KC_KP_"), (keycode - (KC_KP_1 - 1)) % 10); + return; + + // Function keys. F1-F12 and F13-F24 are coded in separate ranges. + case KC_F1 ... KC_F12: + append_numbered_keycode(PSTR("KC_F"), keycode - (KC_F1 - 1)); + return; + + case KC_F13 ... KC_F24: + append_numbered_keycode(PSTR("KC_F"), keycode - (KC_F13 - 13)); + return; + } + } + + // clang-format off + switch (keycode) { + // A modified keycode, like S(KC_1) for Shift + 1 = !. This implementation + // only covers modified keycodes where one modifier is applied, e.g. a + // Ctrl + Shift + kc or Hyper + kc keycode is not formatted. + case QK_MODS ... QK_MODS_MAX: { + uint8_t mods = QK_MODS_GET_MODS(keycode); + const bool is_rhs = mods > 15; + mods &= 15; + if (mods != 0 && (mods & (mods - 1)) == 0) { // One mod is set. + const char* name = &mod_names[4 * biton(mods)]; + if (is_rhs) { + append_char('R'); + append_P(name); + } else { + append_char(pgm_read_byte(&name[0])); + } + append_char('('); + append_keycode(QK_MODS_GET_BASIC_KEYCODE(keycode)); + append_char(')'); + return; + } + } break; + +#if !defined(NO_ACTION_ONESHOT) + case QK_ONE_SHOT_MOD ... QK_ONE_SHOT_MOD_MAX: // One-shot mod OSM(mod) key. + append_P(PSTR("OSM(")); + append_5_bit_mods(QK_ONE_SHOT_MOD_GET_MODS(keycode)); + append_char(')'); + return; +#endif // !defined(NO_ACTION_ONESHOT) + + // Various layer switch keys. + case QK_LAYER_TAP ... QK_LAYER_TAP_MAX: // Layer-tap LT(layer,kc) key. + append_P(PSTR("LT(")); + append_number(QK_LAYER_TAP_GET_LAYER(keycode), 10); + append_char(','); + append_keycode(QK_LAYER_TAP_GET_TAP_KEYCODE(keycode)); + append_char(')'); + return; + + case QK_LAYER_MOD ... QK_LAYER_MOD_MAX: // LM(layer,mod) key. + append_P(PSTR("LM(")); + append_number(QK_LAYER_MOD_GET_LAYER(keycode), 10); + append_char(','); + append_5_bit_mods(QK_LAYER_MOD_GET_MODS(keycode)); + append_char(')'); + return; + + case QK_TO ... QK_TO_MAX: // TO(layer) key. + append_unary_keycode(PSTR("TO"), number_string(QK_TO_GET_LAYER(keycode), 10)); + return; + + case QK_MOMENTARY ... QK_MOMENTARY_MAX: // MO(layer) key. + append_unary_keycode(PSTR("MO"), number_string(QK_MOMENTARY_GET_LAYER(keycode), 10)); + return; + + case QK_DEF_LAYER ... QK_DEF_LAYER_MAX: // DF(layer) key. + append_unary_keycode(PSTR("DF"), number_string(QK_DEF_LAYER_GET_LAYER(keycode), 10)); + return; + + case QK_TOGGLE_LAYER ... QK_TOGGLE_LAYER_MAX: // TG(layer) key. + append_unary_keycode(PSTR("TG"), number_string(QK_TOGGLE_LAYER_GET_LAYER(keycode), 10)); + return; + +#if !defined(NO_ACTION_ONESHOT) + case QK_ONE_SHOT_LAYER ... QK_ONE_SHOT_LAYER_MAX: // OSL(layer) key. + append_unary_keycode(PSTR("OSL"), number_string(QK_ONE_SHOT_LAYER_GET_LAYER(keycode), 10)); + return; +#endif // !defined(NO_ACTION_ONESHOT) + + case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX: // TT(layer) key. + append_unary_keycode(PSTR("TT"), number_string(QK_LAYER_TAP_TOGGLE_GET_LAYER(keycode), 10)); + return; + + case QK_PERSISTENT_DEF_LAYER ... QK_PERSISTENT_DEF_LAYER_MAX: // PDF(layer) key. + append_unary_keycode(PSTR("PDF"), number_string(QK_PERSISTENT_DEF_LAYER_GET_LAYER(keycode), 10)); + return; + + // Mod-tap MT(mod,kc) key. This implementation formats the MT keys where + // one modifier is applied. For MT keys with multiple modifiers, the mod + // arg is written numerically as a hex code. + case QK_MOD_TAP ... QK_MOD_TAP_MAX: { + uint8_t mods = QK_MOD_TAP_GET_MODS(keycode); + const bool is_rhs = mods > 15; + const uint8_t csag = mods & 15; + if (csag != 0 && (csag & (csag - 1)) == 0) { // One mod is set. + append_char(is_rhs ? 'R' : 'L'); + append_P(&mod_names[4 * biton(csag)]); + append_P(PSTR("_T(")); + } else if (mods == MOD_HYPR) { + append_P(PSTR("HYPR_T(")); + } else if (mods == MOD_MEH) { + append_P(PSTR("MEH_T(")); + } else { + append_P(PSTR("MT(")); + append_number(mods, 16); + append_char(','); + } + append_keycode(QK_MOD_TAP_GET_TAP_KEYCODE(keycode)); + append_char(')'); + } return; + + case QK_TAP_DANCE ... QK_TAP_DANCE_MAX: // Tap dance TD(i) key. + append_unary_keycode(PSTR("TD"), number_string(QK_TAP_DANCE_GET_INDEX(keycode), 10)); + return; + +#ifdef UNICODE_ENABLE + case QK_UNICODE ... QK_UNICODE_MAX: // Unicode UC(codepoint) key. + append_unary_keycode(PSTR("UC"), number_string(QK_UNICODE_GET_CODE_POINT(keycode), 16)); + return; +#elif defined(UNICODEMAP_ENABLE) + case QK_UNICODEMAP ... QK_UNICODEMAP_MAX: // Unicode Map UM(i) key. + append_unary_keycode(PSTR("UM"), number_string(QK_UNICODEMAP_GET_INDEX(keycode), 10)); + return; + + case QK_UNICODEMAP_PAIR ... QK_UNICODEMAP_PAIR_MAX: { // UP(i,j) key. + const uint8_t i = QK_UNICODEMAP_PAIR_GET_UNSHIFTED_INDEX(keycode); + const uint8_t j = QK_UNICODEMAP_PAIR_GET_SHIFTED_INDEX(keycode); + append_P(PSTR("UP(")); + append_number(i, 10); + append_char(','); + append_number(j, 10); + append_char(')'); + } return; +#endif +#ifdef MOUSEKEY_ENABLE + case MS_BTN1 ... MS_BTN8: // Mouse button keycode. + append_numbered_keycode(PSTR("MS_BTN"), keycode - (MS_BTN1 - 1)); + return; +#endif // MOUSEKEY_ENABLE +#ifdef SWAP_HANDS_ENABLE + case QK_SWAP_HANDS ... QK_SWAP_HANDS_MAX: // Swap Hands SH_T(kc) key. + if (!IS_SWAP_HANDS_KEYCODE(keycode)) { + append_P(PSTR("SH_T(")); + append_keycode(QK_SWAP_HANDS_GET_TAP_KEYCODE(keycode)); + append_char(')'); + return; + } + break; +#endif // SWAP_HANDS_ENABLE +#ifdef JOYSTICK_ENABLE + case JOYSTICK_KEYCODE_RANGE: // Joystick JS_ key. + append_numbered_keycode(PSTR("JS_"), keycode - JS_0); + return; +#endif // JOYSTICK_ENABLE +#ifdef PROGRAMMABLE_BUTTON_ENABLE + case PROGRAMMABLE_BUTTON_KEYCODE_RANGE: // Programmable button PB_ key. + append_numbered_keycode(PSTR("PB_"), keycode - (PB_1 - 1)); + return; +#endif // PROGRAMMABLE_BUTTON_ENABLE + + case MACRO_KEYCODE_RANGE: // Macro range MC_ keycode. + append_numbered_keycode(PSTR("MC_"), keycode - MC_0); + return; + + case KB_KEYCODE_RANGE: // Keyboard range keycode. + append_numbered_keycode(PSTR("QK_KB_"), keycode - QK_KB_0); + return; + + case USER_KEYCODE_RANGE: // User range keycode. + append_numbered_keycode(PSTR("QK_USER_"), keycode - QK_USER_0); + return; + + // It would take a nontrivial amount of string data to cover some + // feature-specific keycodes, such as those for MIDI and lighting. As a + // fallback while still providing some information, we stringify + // remaining keys in known code ranges as "QK_+". +#ifdef MAGIC_ENABLE + case MAGIC_KEYCODE_RANGE: + append_numbered_keycode(PSTR("QK_MAGIC+"), keycode - QK_MAGIC); + return; +#endif // MAGIC_ENABLE +#ifdef MIDI_ENABLE + case MIDI_KEYCODE_RANGE: + append_numbered_keycode(PSTR("QK_MIDI+"), keycode - QK_MIDI); + return; +#endif // MIDI_ENABLE +#ifdef SEQUENCER_ENABLE + case SEQUENCER_KEYCODE_RANGE: + append_numbered_keycode(PSTR("QK_SEQUENCER+"), keycode - QK_SEQUENCER); + return; +#endif // SEQUENCER_ENABLE +#ifdef AUDIO_ENABLE + case AUDIO_KEYCODE_RANGE: + append_numbered_keycode(PSTR("QK_AUDIO+"), keycode - QK_AUDIO); + return; +#endif // AUDIO_ENABLE +#if defined(BACKLIGHT_ENABLE) || defined(LED_MATRIX_ENABLE) || defined(RGBLIGHT_ENABLED) || defined(RGB_MATRIX_ENABLE) // Lighting-related features. + case QK_LIGHTING ... QK_LIGHTING_MAX: + append_numbered_keycode(PSTR("QK_LIGHTING+"), keycode - QK_LIGHTING); + return; +#endif // defined(BACKLIGHT_ENABLE) || defined(LED_MATRIX_ENABLE) || defined(RGBLIGHT_ENABLED) || defined(RGB_MATRIX_ENABLE) +#ifdef STENO_ENABLE + case STENO_KEYCODE_RANGE: + append_numbered_keycode(PSTR("QK_STENO+"), keycode - QK_STENO); + return; +#endif // AUDIO_ENABLE +#ifdef BLUETOOTH_ENABLE + case CONNECTION_KEYCODE_RANGE: + append_numbered_keycode(PSTR("QK_CONNECTION+"), keycode - QK_CONNECTION); + return; +#endif // BLUETOOTH_ENABLE + case QUANTUM_KEYCODE_RANGE: + append_numbered_keycode(PSTR("QK_QUANTUM+"), keycode - QK_QUANTUM); + return; + } + // clang-format on + + append_number(keycode, 16); // Fallback: write keycode as hex value. +} + +const char* get_keycode_string(uint16_t keycode) { + buffer_len = 0; + buffer[0] = '\0'; + append_keycode(keycode); + return buffer; +} diff --git a/quantum/keycode_string.h b/quantum/keycode_string.h new file mode 100644 index 0000000000..1315613a80 --- /dev/null +++ b/quantum/keycode_string.h @@ -0,0 +1,134 @@ +// Copyright 2024-2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include + +#if KEYCODE_STRING_ENABLE + +/** + * @brief Formats a QMK keycode as a human-readable string. + * + * Given a keycode, like `KC_A`, this function returns a formatted string, like + * "KC_A". This is useful for debugging and diagnostics so that keys are more + * easily identified than they would be by raw numerical codes. + * + * @note The returned char* string should be used right away. The string memory + * is reused and will be overwritten by the next call to `keycode_string()`. + * + * Many common QMK keycodes are understood by this function, but not all. + * Recognized keycodes include: + * + * - Most basic keycodes, including letters `KC_A` - `KC_Z`, digits `KC_0` - + * `KC_9`, function keys `KC_F1` - `KC_F24`, and modifiers like `KC_LSFT`. + * + * - Modified basic keycodes, like `S(KC_1)` (Shift + 1 = !). + * + * - `MO`, `TO`, `TG`, `OSL`, `LM(layer,mod)`, `LT(layer,kc)` layer switches. + * + * - One-shot mod `OSM(mod)` keycodes. + * + * - Mod-tap `MT(mod, kc)` keycodes. + * + * - Tap dance keycodes `TD(i)`. + * + * - Swap hands keycodes `SH_T(kc)`, `SH_TOGG`, etc. + * + * - Joystick keycodes `JS_n`. + * + * - Programmable button keycodes `PB_n`. + * + * - Unicode `UC(codepoint)` and Unicode Map `UM(i)` and `UP(i,j)` keycodes. + * + * - Keyboard range keycodes `QK_KB_*`. + * + * - User range (SAFE_RANGE) keycodes `QK_USER_*`. + * + * Keycodes involving mods like `OSM`, `LM`, `MT` are fully supported only where + * a single mod is applied. + * + * Unrecognized keycodes are printed numerically as hex values like `0x1ABC`. + * + * Optionally, use `keycode_string_names_user` or `keycode_string_names_kb` to + * define names for additional keycodes or override how any of the above are + * formatted. + * + * @param keycode QMK keycode. + * @return Stringified keycode. + */ +const char* get_keycode_string(uint16_t keycode); + +/** Defines a human-readable name for a keycode. */ +typedef struct { + uint16_t keycode; + const char* name; +} keycode_string_name_t; + +// clang-format off +/** + * @brief Defines names for additional keycodes for `get_keycode_string()`. + * + * Define `KEYCODE_STRING_NAMES_USER` in your keymap.c to add names for + * additional keycodes to `keycode_string()`. This table may also be used to + * override how `keycode_string()` formats a keycode. For example, supposing + * keymap.c defines `MYMACRO1` and `MYMACRO2` as custom keycodes: + * + * KEYCODE_STRING_NAMES_USER( + * KEYCODE_STRING_NAME(MYMACRO1), + * KEYCODE_STRING_NAME(MYMACRO2), + * KEYCODE_STRING_NAME(KC_EXLM), + * ); + * + * The above defines names for `MYMACRO1` and `MYMACRO2`, and overrides + * `KC_EXLM` to format as "KC_EXLM" instead of the default "S(KC_1)". + */ +# define KEYCODE_STRING_NAMES_USER(...) \ + static const keycode_string_name_t keycode_string_names_user[] = {__VA_ARGS__}; \ + uint16_t keycode_string_names_size_user = \ + sizeof(keycode_string_names_user) / sizeof(keycode_string_name_t); \ + const keycode_string_name_t* keycode_string_names_data_user = \ + keycode_string_names_user + +/** Same as above, but defines keycode string names at the keyboard level. */ +# define KEYCODE_STRING_NAMES_KB(...) \ + static const keycode_string_name_t keycode_string_names_kb[] = {__VA_ARGS__}; \ + uint16_t keycode_string_names_size_kb = \ + sizeof(keycode_string_names_kb) / sizeof(keycode_string_name_t); \ + const keycode_string_name_t* keycode_string_names_data_kb = \ + keycode_string_names_kb + +/** Helper to define a keycode_string_name_t. */ +# define KEYCODE_STRING_NAME(kc) \ + { (kc), #kc } +// clang-format on + +extern const keycode_string_name_t* keycode_string_names_data_user; +extern uint16_t keycode_string_names_size_user; +extern const keycode_string_name_t* keycode_string_names_data_kb; +extern uint16_t keycode_string_names_size_kb; + +#else + +// When keycode_string is disabled, fall back to printing keycodes numerically +// as decimal values, using get_u16_str() from quantum.c. +# define get_keycode_string(kc) get_u16_str(kc, ' ') + +const char* get_u16_str(uint16_t curr_num, char curr_pad); + +# define KEYCODE_STRING_NAMES_USER(...) +# define KEYCODE_STRING_NAMES_KB(...) +# define KEYCODE_STRING_NAME(kc) + +#endif // KEYCODE_STRING_ENABLE diff --git a/quantum/keycodes.h b/quantum/keycodes.h index b4fc38f5ff..6a59aa376d 100644 --- a/quantum/keycodes.h +++ b/quantum/keycodes.h @@ -26,6 +26,12 @@ #pragma once // clang-format off +#define QMK_KEYCODES_VERSION "0.0.7" +#define QMK_KEYCODES_VERSION_BCD 0x00000007 +#define QMK_KEYCODES_VERSION_MAJOR 0 +#define QMK_KEYCODES_VERSION_MINOR 0 +#define QMK_KEYCODES_VERSION_PATCH 7 + enum qk_keycode_ranges { // Ranges QK_BASIC = 0x0000, diff --git a/quantum/keymap_extras/keymap_belgian.h b/quantum/keymap_extras/keymap_belgian.h index 1869e66d9a..b41ed9d20b 100644 --- a/quantum/keymap_extras/keymap_belgian.h +++ b/quantum/keymap_extras/keymap_belgian.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_BELGIAN_KEYCODES_VERSION "0.0.1" +#define QMK_BELGIAN_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_BELGIAN_KEYCODES_VERSION_MAJOR 0 +#define QMK_BELGIAN_KEYCODES_VERSION_MINOR 0 +#define QMK_BELGIAN_KEYCODES_VERSION_PATCH 1 + // Aliases #define BE_SUP2 KC_GRV // ² #define BE_AMPR KC_1 // & diff --git a/quantum/keymap_extras/keymap_bepo.h b/quantum/keymap_extras/keymap_bepo.h index f2ddb99180..c0bb703ecc 100644 --- a/quantum/keymap_extras/keymap_bepo.h +++ b/quantum/keymap_extras/keymap_bepo.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_BEPO_KEYCODES_VERSION "0.0.1" +#define QMK_BEPO_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_BEPO_KEYCODES_VERSION_MAJOR 0 +#define QMK_BEPO_KEYCODES_VERSION_MINOR 0 +#define QMK_BEPO_KEYCODES_VERSION_PATCH 1 + // Aliases #define BP_DLR KC_GRV // $ #define BP_DQUO KC_1 // " diff --git a/quantum/keymap_extras/keymap_brazilian_abnt2.h b/quantum/keymap_extras/keymap_brazilian_abnt2.h index 730fe5069f..267b5490c9 100644 --- a/quantum/keymap_extras/keymap_brazilian_abnt2.h +++ b/quantum/keymap_extras/keymap_brazilian_abnt2.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_BRAZILIAN_ABNT2_KEYCODES_VERSION "0.0.1" +#define QMK_BRAZILIAN_ABNT2_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_BRAZILIAN_ABNT2_KEYCODES_VERSION_MAJOR 0 +#define QMK_BRAZILIAN_ABNT2_KEYCODES_VERSION_MINOR 0 +#define QMK_BRAZILIAN_ABNT2_KEYCODES_VERSION_PATCH 1 + // Aliases #define BR_QUOT KC_GRV // ' #define BR_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_canadian_french.h b/quantum/keymap_extras/keymap_canadian_french.h index 5771cf6193..df9c73c016 100644 --- a/quantum/keymap_extras/keymap_canadian_french.h +++ b/quantum/keymap_extras/keymap_canadian_french.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_CANADIAN_FRENCH_KEYCODES_VERSION "0.0.1" +#define QMK_CANADIAN_FRENCH_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_CANADIAN_FRENCH_KEYCODES_VERSION_MAJOR 0 +#define QMK_CANADIAN_FRENCH_KEYCODES_VERSION_MINOR 0 +#define QMK_CANADIAN_FRENCH_KEYCODES_VERSION_PATCH 1 + // Aliases #define FR_HASH KC_GRV // # #define FR_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_canadian_multilingual.h b/quantum/keymap_extras/keymap_canadian_multilingual.h index 2a4326b406..4b42457396 100644 --- a/quantum/keymap_extras/keymap_canadian_multilingual.h +++ b/quantum/keymap_extras/keymap_canadian_multilingual.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_CANADIAN_MULTILINGUAL_KEYCODES_VERSION "0.0.1" +#define QMK_CANADIAN_MULTILINGUAL_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_CANADIAN_MULTILINGUAL_KEYCODES_VERSION_MAJOR 0 +#define QMK_CANADIAN_MULTILINGUAL_KEYCODES_VERSION_MINOR 0 +#define QMK_CANADIAN_MULTILINGUAL_KEYCODES_VERSION_PATCH 1 + // Aliases #define CA_SLSH KC_GRV // / #define CA_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_colemak.h b/quantum/keymap_extras/keymap_colemak.h index 0170339aad..a4fc77e80f 100644 --- a/quantum/keymap_extras/keymap_colemak.h +++ b/quantum/keymap_extras/keymap_colemak.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_COLEMAK_KEYCODES_VERSION "0.0.1" +#define QMK_COLEMAK_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_COLEMAK_KEYCODES_VERSION_MAJOR 0 +#define QMK_COLEMAK_KEYCODES_VERSION_MINOR 0 +#define QMK_COLEMAK_KEYCODES_VERSION_PATCH 1 + // Aliases #define CM_GRV KC_GRV // ` #define CM_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_croatian.h b/quantum/keymap_extras/keymap_croatian.h index 7e11a85710..cdc032a9eb 100644 --- a/quantum/keymap_extras/keymap_croatian.h +++ b/quantum/keymap_extras/keymap_croatian.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_CROATIAN_KEYCODES_VERSION "0.0.1" +#define QMK_CROATIAN_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_CROATIAN_KEYCODES_VERSION_MAJOR 0 +#define QMK_CROATIAN_KEYCODES_VERSION_MINOR 0 +#define QMK_CROATIAN_KEYCODES_VERSION_PATCH 1 + // Aliases #define HR_CEDL KC_GRV // ¸ (dead) #define HR_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_czech.h b/quantum/keymap_extras/keymap_czech.h index 8e65a4ed0a..cae16cdb9f 100644 --- a/quantum/keymap_extras/keymap_czech.h +++ b/quantum/keymap_extras/keymap_czech.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_CZECH_KEYCODES_VERSION "0.0.1" +#define QMK_CZECH_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_CZECH_KEYCODES_VERSION_MAJOR 0 +#define QMK_CZECH_KEYCODES_VERSION_MINOR 0 +#define QMK_CZECH_KEYCODES_VERSION_PATCH 1 + // Aliases #define CZ_SCLN KC_GRV // ; #define CZ_PLUS KC_1 // + diff --git a/quantum/keymap_extras/keymap_czech_mac_ansi.h b/quantum/keymap_extras/keymap_czech_mac_ansi.h index ed46a78f1c..bdfda933b0 100644 --- a/quantum/keymap_extras/keymap_czech_mac_ansi.h +++ b/quantum/keymap_extras/keymap_czech_mac_ansi.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_CZECH_MAC_ANSI_KEYCODES_VERSION "0.0.1" +#define QMK_CZECH_MAC_ANSI_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_CZECH_MAC_ANSI_KEYCODES_VERSION_MAJOR 0 +#define QMK_CZECH_MAC_ANSI_KEYCODES_VERSION_MINOR 0 +#define QMK_CZECH_MAC_ANSI_KEYCODES_VERSION_PATCH 1 + // Aliases #define CZ_BSLS KC_GRV // (backslash) #define CZ_PLUS KC_1 // + diff --git a/quantum/keymap_extras/keymap_czech_mac_iso.h b/quantum/keymap_extras/keymap_czech_mac_iso.h index 08285b7952..9c05d8dae0 100644 --- a/quantum/keymap_extras/keymap_czech_mac_iso.h +++ b/quantum/keymap_extras/keymap_czech_mac_iso.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_CZECH_MAC_ISO_KEYCODES_VERSION "0.0.1" +#define QMK_CZECH_MAC_ISO_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_CZECH_MAC_ISO_KEYCODES_VERSION_MAJOR 0 +#define QMK_CZECH_MAC_ISO_KEYCODES_VERSION_MINOR 0 +#define QMK_CZECH_MAC_ISO_KEYCODES_VERSION_PATCH 1 + // Aliases #define CZ_PLUS KC_1 // + #define CZ_ECAR KC_2 // ě diff --git a/quantum/keymap_extras/keymap_danish.h b/quantum/keymap_extras/keymap_danish.h index a84923007c..1f1ee90e23 100644 --- a/quantum/keymap_extras/keymap_danish.h +++ b/quantum/keymap_extras/keymap_danish.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_DANISH_KEYCODES_VERSION "0.0.1" +#define QMK_DANISH_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_DANISH_KEYCODES_VERSION_MAJOR 0 +#define QMK_DANISH_KEYCODES_VERSION_MINOR 0 +#define QMK_DANISH_KEYCODES_VERSION_PATCH 1 + // Aliases #define DK_HALF KC_GRV // ½ #define DK_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_dvorak.h b/quantum/keymap_extras/keymap_dvorak.h index a926e48295..5cb2c4564a 100644 --- a/quantum/keymap_extras/keymap_dvorak.h +++ b/quantum/keymap_extras/keymap_dvorak.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_DVORAK_KEYCODES_VERSION "0.0.1" +#define QMK_DVORAK_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_DVORAK_KEYCODES_VERSION_MAJOR 0 +#define QMK_DVORAK_KEYCODES_VERSION_MINOR 0 +#define QMK_DVORAK_KEYCODES_VERSION_PATCH 1 + // Aliases #define DV_GRV KC_GRV // ` #define DV_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_dvorak_fr.h b/quantum/keymap_extras/keymap_dvorak_fr.h index 6e6498e598..d01bf7fec7 100644 --- a/quantum/keymap_extras/keymap_dvorak_fr.h +++ b/quantum/keymap_extras/keymap_dvorak_fr.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_DVORAK_FR_KEYCODES_VERSION "0.0.1" +#define QMK_DVORAK_FR_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_DVORAK_FR_KEYCODES_VERSION_MAJOR 0 +#define QMK_DVORAK_FR_KEYCODES_VERSION_MINOR 0 +#define QMK_DVORAK_FR_KEYCODES_VERSION_PATCH 1 + // Aliases #define DV_LDAQ KC_GRV // « #define DV_RDAQ KC_1 // » diff --git a/quantum/keymap_extras/keymap_dvorak_programmer.h b/quantum/keymap_extras/keymap_dvorak_programmer.h index 43d9a702bb..f17900105f 100644 --- a/quantum/keymap_extras/keymap_dvorak_programmer.h +++ b/quantum/keymap_extras/keymap_dvorak_programmer.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_DVORAK_PROGRAMMER_KEYCODES_VERSION "0.0.1" +#define QMK_DVORAK_PROGRAMMER_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_DVORAK_PROGRAMMER_KEYCODES_VERSION_MAJOR 0 +#define QMK_DVORAK_PROGRAMMER_KEYCODES_VERSION_MINOR 0 +#define QMK_DVORAK_PROGRAMMER_KEYCODES_VERSION_PATCH 1 + // Aliases #define DP_DLR KC_GRV // $ #define DP_AMPR KC_1 // & diff --git a/quantum/keymap_extras/keymap_estonian.h b/quantum/keymap_extras/keymap_estonian.h index 3e87bbc5f8..5fbeedcbe9 100644 --- a/quantum/keymap_extras/keymap_estonian.h +++ b/quantum/keymap_extras/keymap_estonian.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_ESTONIAN_KEYCODES_VERSION "0.0.1" +#define QMK_ESTONIAN_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_ESTONIAN_KEYCODES_VERSION_MAJOR 0 +#define QMK_ESTONIAN_KEYCODES_VERSION_MINOR 0 +#define QMK_ESTONIAN_KEYCODES_VERSION_PATCH 1 + // Aliases #define EE_CARN KC_GRV // ˇ (dead) #define EE_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_eurkey.h b/quantum/keymap_extras/keymap_eurkey.h index 20f7f58683..5a13d48163 100644 --- a/quantum/keymap_extras/keymap_eurkey.h +++ b/quantum/keymap_extras/keymap_eurkey.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_EURKEY_KEYCODES_VERSION "0.0.1" +#define QMK_EURKEY_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_EURKEY_KEYCODES_VERSION_MAJOR 0 +#define QMK_EURKEY_KEYCODES_VERSION_MINOR 0 +#define QMK_EURKEY_KEYCODES_VERSION_PATCH 1 + // Aliases #define EU_GRV KC_GRV // ` #define EU_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_farsi.h b/quantum/keymap_extras/keymap_farsi.h index 4f34b08d92..e115d9c1c0 100644 --- a/quantum/keymap_extras/keymap_farsi.h +++ b/quantum/keymap_extras/keymap_farsi.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_FARSI_KEYCODES_VERSION "0.0.1" +#define QMK_FARSI_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_FARSI_KEYCODES_VERSION_MAJOR 0 +#define QMK_FARSI_KEYCODES_VERSION_MINOR 0 +#define QMK_FARSI_KEYCODES_VERSION_PATCH 1 + // Aliases #define FA_ZWJ KC_GRV // (zero-width joiner) #define FA_1A KC_1 // ۱ diff --git a/quantum/keymap_extras/keymap_finnish.h b/quantum/keymap_extras/keymap_finnish.h index 045f7295a0..cb21da9962 100644 --- a/quantum/keymap_extras/keymap_finnish.h +++ b/quantum/keymap_extras/keymap_finnish.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_FINNISH_KEYCODES_VERSION "0.0.1" +#define QMK_FINNISH_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_FINNISH_KEYCODES_VERSION_MAJOR 0 +#define QMK_FINNISH_KEYCODES_VERSION_MINOR 0 +#define QMK_FINNISH_KEYCODES_VERSION_PATCH 1 + // Aliases #define FI_SECT KC_GRV // § #define FI_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_french.h b/quantum/keymap_extras/keymap_french.h index 9ff3694a73..d4352c6481 100644 --- a/quantum/keymap_extras/keymap_french.h +++ b/quantum/keymap_extras/keymap_french.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_FRENCH_KEYCODES_VERSION "0.0.1" +#define QMK_FRENCH_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_FRENCH_KEYCODES_VERSION_MAJOR 0 +#define QMK_FRENCH_KEYCODES_VERSION_MINOR 0 +#define QMK_FRENCH_KEYCODES_VERSION_PATCH 1 + // Aliases #define FR_SUP2 KC_GRV // ² #define FR_AMPR KC_1 // & diff --git a/quantum/keymap_extras/keymap_french_afnor.h b/quantum/keymap_extras/keymap_french_afnor.h index 07506e0f6e..8e6905cc01 100644 --- a/quantum/keymap_extras/keymap_french_afnor.h +++ b/quantum/keymap_extras/keymap_french_afnor.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_FRENCH_AFNOR_KEYCODES_VERSION "0.0.1" +#define QMK_FRENCH_AFNOR_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_FRENCH_AFNOR_KEYCODES_VERSION_MAJOR 0 +#define QMK_FRENCH_AFNOR_KEYCODES_VERSION_MINOR 0 +#define QMK_FRENCH_AFNOR_KEYCODES_VERSION_PATCH 1 + // Aliases #define FR_AT KC_GRV // @ #define FR_AGRV KC_1 // à diff --git a/quantum/keymap_extras/keymap_french_mac_iso.h b/quantum/keymap_extras/keymap_french_mac_iso.h index b036ca2009..ad9d280f2a 100644 --- a/quantum/keymap_extras/keymap_french_mac_iso.h +++ b/quantum/keymap_extras/keymap_french_mac_iso.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_FRENCH_MAC_ISO_KEYCODES_VERSION "0.0.1" +#define QMK_FRENCH_MAC_ISO_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_FRENCH_MAC_ISO_KEYCODES_VERSION_MAJOR 0 +#define QMK_FRENCH_MAC_ISO_KEYCODES_VERSION_MINOR 0 +#define QMK_FRENCH_MAC_ISO_KEYCODES_VERSION_PATCH 1 + // Aliases #define FR_AT KC_GRV // @ #define FR_AMPR KC_1 // & diff --git a/quantum/keymap_extras/keymap_german.h b/quantum/keymap_extras/keymap_german.h index 7ac807934b..bc98daa2fd 100644 --- a/quantum/keymap_extras/keymap_german.h +++ b/quantum/keymap_extras/keymap_german.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_GERMAN_KEYCODES_VERSION "0.0.1" +#define QMK_GERMAN_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_GERMAN_KEYCODES_VERSION_MAJOR 0 +#define QMK_GERMAN_KEYCODES_VERSION_MINOR 0 +#define QMK_GERMAN_KEYCODES_VERSION_PATCH 1 + // Aliases #define DE_CIRC KC_GRV // ^ (dead) #define DE_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_german_mac_iso.h b/quantum/keymap_extras/keymap_german_mac_iso.h index 56d077c36c..ba3143c570 100644 --- a/quantum/keymap_extras/keymap_german_mac_iso.h +++ b/quantum/keymap_extras/keymap_german_mac_iso.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_GERMAN_MAC_ISO_KEYCODES_VERSION "0.0.1" +#define QMK_GERMAN_MAC_ISO_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_GERMAN_MAC_ISO_KEYCODES_VERSION_MAJOR 0 +#define QMK_GERMAN_MAC_ISO_KEYCODES_VERSION_MINOR 0 +#define QMK_GERMAN_MAC_ISO_KEYCODES_VERSION_PATCH 1 + // Aliases #define DE_CIRC KC_GRV // ^ (dead) #define DE_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_greek.h b/quantum/keymap_extras/keymap_greek.h index 0d2e15dfd8..fb2f02a04f 100644 --- a/quantum/keymap_extras/keymap_greek.h +++ b/quantum/keymap_extras/keymap_greek.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_GREEK_KEYCODES_VERSION "0.0.1" +#define QMK_GREEK_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_GREEK_KEYCODES_VERSION_MAJOR 0 +#define QMK_GREEK_KEYCODES_VERSION_MINOR 0 +#define QMK_GREEK_KEYCODES_VERSION_PATCH 1 + // Aliases #define GR_GRV KC_GRV // ` #define GR_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_hebrew.h b/quantum/keymap_extras/keymap_hebrew.h index a927364737..5d1d4a29c6 100644 --- a/quantum/keymap_extras/keymap_hebrew.h +++ b/quantum/keymap_extras/keymap_hebrew.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_HEBREW_KEYCODES_VERSION "0.0.1" +#define QMK_HEBREW_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_HEBREW_KEYCODES_VERSION_MAJOR 0 +#define QMK_HEBREW_KEYCODES_VERSION_MINOR 0 +#define QMK_HEBREW_KEYCODES_VERSION_PATCH 1 + // Aliases #define IL_SCLN KC_GRV // ; #define IL_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_hungarian.h b/quantum/keymap_extras/keymap_hungarian.h index 81a842a0fe..27236553e8 100644 --- a/quantum/keymap_extras/keymap_hungarian.h +++ b/quantum/keymap_extras/keymap_hungarian.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_HUNGARIAN_KEYCODES_VERSION "0.0.1" +#define QMK_HUNGARIAN_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_HUNGARIAN_KEYCODES_VERSION_MAJOR 0 +#define QMK_HUNGARIAN_KEYCODES_VERSION_MINOR 0 +#define QMK_HUNGARIAN_KEYCODES_VERSION_PATCH 1 + // Aliases #define HU_0 KC_GRV // 0 #define HU_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_icelandic.h b/quantum/keymap_extras/keymap_icelandic.h index 8e4e04b0f1..409be27b77 100644 --- a/quantum/keymap_extras/keymap_icelandic.h +++ b/quantum/keymap_extras/keymap_icelandic.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_ICELANDIC_KEYCODES_VERSION "0.0.1" +#define QMK_ICELANDIC_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_ICELANDIC_KEYCODES_VERSION_MAJOR 0 +#define QMK_ICELANDIC_KEYCODES_VERSION_MINOR 0 +#define QMK_ICELANDIC_KEYCODES_VERSION_PATCH 1 + // Aliases #define IS_RNGA KC_GRV // ° (dead) #define IS_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_irish.h b/quantum/keymap_extras/keymap_irish.h index 6cb85dc7a7..587467bcbe 100644 --- a/quantum/keymap_extras/keymap_irish.h +++ b/quantum/keymap_extras/keymap_irish.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_IRISH_KEYCODES_VERSION "0.0.1" +#define QMK_IRISH_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_IRISH_KEYCODES_VERSION_MAJOR 0 +#define QMK_IRISH_KEYCODES_VERSION_MINOR 0 +#define QMK_IRISH_KEYCODES_VERSION_PATCH 1 + // Aliases #define IE_GRV KC_GRV // ` #define IE_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_italian.h b/quantum/keymap_extras/keymap_italian.h index 57c12ba9b6..9fd7f1b15c 100644 --- a/quantum/keymap_extras/keymap_italian.h +++ b/quantum/keymap_extras/keymap_italian.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_ITALIAN_KEYCODES_VERSION "0.0.1" +#define QMK_ITALIAN_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_ITALIAN_KEYCODES_VERSION_MAJOR 0 +#define QMK_ITALIAN_KEYCODES_VERSION_MINOR 0 +#define QMK_ITALIAN_KEYCODES_VERSION_PATCH 1 + // Aliases #define IT_BSLS KC_GRV // (backslash) #define IT_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_italian_mac_ansi.h b/quantum/keymap_extras/keymap_italian_mac_ansi.h index 4774c2d5ee..9ef38c0d87 100644 --- a/quantum/keymap_extras/keymap_italian_mac_ansi.h +++ b/quantum/keymap_extras/keymap_italian_mac_ansi.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_ITALIAN_MAC_ANSI_KEYCODES_VERSION "0.0.1" +#define QMK_ITALIAN_MAC_ANSI_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_ITALIAN_MAC_ANSI_KEYCODES_VERSION_MAJOR 0 +#define QMK_ITALIAN_MAC_ANSI_KEYCODES_VERSION_MINOR 0 +#define QMK_ITALIAN_MAC_ANSI_KEYCODES_VERSION_PATCH 1 + // Aliases #define IT_LABK KC_GRV // < #define IT_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_italian_mac_iso.h b/quantum/keymap_extras/keymap_italian_mac_iso.h index 35ec978ef9..e80cfa450c 100644 --- a/quantum/keymap_extras/keymap_italian_mac_iso.h +++ b/quantum/keymap_extras/keymap_italian_mac_iso.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_ITALIAN_MAC_ISO_KEYCODES_VERSION "0.0.1" +#define QMK_ITALIAN_MAC_ISO_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_ITALIAN_MAC_ISO_KEYCODES_VERSION_MAJOR 0 +#define QMK_ITALIAN_MAC_ISO_KEYCODES_VERSION_MINOR 0 +#define QMK_ITALIAN_MAC_ISO_KEYCODES_VERSION_PATCH 1 + // Aliases #define IT_BSLS KC_GRV // (backslash) #define IT_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_japanese.h b/quantum/keymap_extras/keymap_japanese.h index 3ad9495353..55df86e16d 100644 --- a/quantum/keymap_extras/keymap_japanese.h +++ b/quantum/keymap_extras/keymap_japanese.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_JAPANESE_KEYCODES_VERSION "0.0.1" +#define QMK_JAPANESE_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_JAPANESE_KEYCODES_VERSION_MAJOR 0 +#define QMK_JAPANESE_KEYCODES_VERSION_MINOR 0 +#define QMK_JAPANESE_KEYCODES_VERSION_PATCH 1 + // Aliases #define JP_ZKHK KC_GRV // Zenkaku ↔ Hankaku ↔ Kanji (半角 ↔ 全角 ↔ 漢字) #define JP_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_korean.h b/quantum/keymap_extras/keymap_korean.h index 644837734e..7bf64c4841 100644 --- a/quantum/keymap_extras/keymap_korean.h +++ b/quantum/keymap_extras/keymap_korean.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_KOREAN_KEYCODES_VERSION "0.0.1" +#define QMK_KOREAN_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_KOREAN_KEYCODES_VERSION_MAJOR 0 +#define QMK_KOREAN_KEYCODES_VERSION_MINOR 0 +#define QMK_KOREAN_KEYCODES_VERSION_PATCH 1 + // Aliases #define KR_GRV KC_GRV // ` #define KR_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_latvian.h b/quantum/keymap_extras/keymap_latvian.h index b1750ed759..4d60c45163 100644 --- a/quantum/keymap_extras/keymap_latvian.h +++ b/quantum/keymap_extras/keymap_latvian.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_LATVIAN_KEYCODES_VERSION "0.0.1" +#define QMK_LATVIAN_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_LATVIAN_KEYCODES_VERSION_MAJOR 0 +#define QMK_LATVIAN_KEYCODES_VERSION_MINOR 0 +#define QMK_LATVIAN_KEYCODES_VERSION_PATCH 1 + // Aliases #define LV_GRV KC_GRV // ` #define LV_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_lithuanian_azerty.h b/quantum/keymap_extras/keymap_lithuanian_azerty.h index 9d6c1b92f0..e88cc75e07 100644 --- a/quantum/keymap_extras/keymap_lithuanian_azerty.h +++ b/quantum/keymap_extras/keymap_lithuanian_azerty.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_LITHUANIAN_AZERTY_KEYCODES_VERSION "0.0.1" +#define QMK_LITHUANIAN_AZERTY_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_LITHUANIAN_AZERTY_KEYCODES_VERSION_MAJOR 0 +#define QMK_LITHUANIAN_AZERTY_KEYCODES_VERSION_MINOR 0 +#define QMK_LITHUANIAN_AZERTY_KEYCODES_VERSION_PATCH 1 + // Aliases #define LT_GRV KC_GRV // ` #define LT_EXLM KC_1 // ! diff --git a/quantum/keymap_extras/keymap_lithuanian_qwerty.h b/quantum/keymap_extras/keymap_lithuanian_qwerty.h index 84df4c8bd2..3321615c1e 100644 --- a/quantum/keymap_extras/keymap_lithuanian_qwerty.h +++ b/quantum/keymap_extras/keymap_lithuanian_qwerty.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_LITHUANIAN_QWERTY_KEYCODES_VERSION "0.0.1" +#define QMK_LITHUANIAN_QWERTY_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_LITHUANIAN_QWERTY_KEYCODES_VERSION_MAJOR 0 +#define QMK_LITHUANIAN_QWERTY_KEYCODES_VERSION_MINOR 0 +#define QMK_LITHUANIAN_QWERTY_KEYCODES_VERSION_PATCH 1 + // Aliases #define LT_GRV KC_GRV // ` #define LT_AOGO KC_1 // Ą diff --git a/quantum/keymap_extras/keymap_neo2.h b/quantum/keymap_extras/keymap_neo2.h index ad285f7d18..5d10f19fd5 100644 --- a/quantum/keymap_extras/keymap_neo2.h +++ b/quantum/keymap_extras/keymap_neo2.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_NEO2_KEYCODES_VERSION "0.0.1" +#define QMK_NEO2_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_NEO2_KEYCODES_VERSION_MAJOR 0 +#define QMK_NEO2_KEYCODES_VERSION_MINOR 0 +#define QMK_NEO2_KEYCODES_VERSION_PATCH 1 + // Aliases #define NE_CIRC KC_GRV // ^ (dead) #define NE_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_nordic.h b/quantum/keymap_extras/keymap_nordic.h index ff952e6c43..3a11b29fc8 100644 --- a/quantum/keymap_extras/keymap_nordic.h +++ b/quantum/keymap_extras/keymap_nordic.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_NORDIC_KEYCODES_VERSION "0.0.1" +#define QMK_NORDIC_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_NORDIC_KEYCODES_VERSION_MAJOR 0 +#define QMK_NORDIC_KEYCODES_VERSION_MINOR 0 +#define QMK_NORDIC_KEYCODES_VERSION_PATCH 1 + // Aliases #define NO_HALF KC_GRV #define NO_PLUS KC_MINS diff --git a/quantum/keymap_extras/keymap_norman.h b/quantum/keymap_extras/keymap_norman.h index 166a2f22a1..d47c2ff8a7 100644 --- a/quantum/keymap_extras/keymap_norman.h +++ b/quantum/keymap_extras/keymap_norman.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_NORMAN_KEYCODES_VERSION "0.0.1" +#define QMK_NORMAN_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_NORMAN_KEYCODES_VERSION_MAJOR 0 +#define QMK_NORMAN_KEYCODES_VERSION_MINOR 0 +#define QMK_NORMAN_KEYCODES_VERSION_PATCH 1 + // Aliases #define NM_GRV KC_GRV // ` #define NM_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_norwegian.h b/quantum/keymap_extras/keymap_norwegian.h index 0b0cf65813..021b8c3b9c 100644 --- a/quantum/keymap_extras/keymap_norwegian.h +++ b/quantum/keymap_extras/keymap_norwegian.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_NORWEGIAN_KEYCODES_VERSION "0.0.1" +#define QMK_NORWEGIAN_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_NORWEGIAN_KEYCODES_VERSION_MAJOR 0 +#define QMK_NORWEGIAN_KEYCODES_VERSION_MINOR 0 +#define QMK_NORWEGIAN_KEYCODES_VERSION_PATCH 1 + // Aliases #define NO_PIPE KC_GRV // | #define NO_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_plover.h b/quantum/keymap_extras/keymap_plover.h index a01a23c8a3..e7facfd623 100644 --- a/quantum/keymap_extras/keymap_plover.h +++ b/quantum/keymap_extras/keymap_plover.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_PLOVER_KEYCODES_VERSION "0.0.1" +#define QMK_PLOVER_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_PLOVER_KEYCODES_VERSION_MAJOR 0 +#define QMK_PLOVER_KEYCODES_VERSION_MINOR 0 +#define QMK_PLOVER_KEYCODES_VERSION_PATCH 1 + // Aliases #define PV_NUM KC_1 #define PV_LS KC_Q diff --git a/quantum/keymap_extras/keymap_plover_dvorak.h b/quantum/keymap_extras/keymap_plover_dvorak.h index 0ec7b9acd3..5c8a4f9ada 100644 --- a/quantum/keymap_extras/keymap_plover_dvorak.h +++ b/quantum/keymap_extras/keymap_plover_dvorak.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_PLOVER_DVORAK_KEYCODES_VERSION "0.0.1" +#define QMK_PLOVER_DVORAK_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_PLOVER_DVORAK_KEYCODES_VERSION_MAJOR 0 +#define QMK_PLOVER_DVORAK_KEYCODES_VERSION_MINOR 0 +#define QMK_PLOVER_DVORAK_KEYCODES_VERSION_PATCH 1 + // Aliases #define PD_NUM DV_1 #define PD_LS DV_Q diff --git a/quantum/keymap_extras/keymap_polish.h b/quantum/keymap_extras/keymap_polish.h index 2448ef1fef..e5e48097f7 100644 --- a/quantum/keymap_extras/keymap_polish.h +++ b/quantum/keymap_extras/keymap_polish.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_POLISH_KEYCODES_VERSION "0.0.1" +#define QMK_POLISH_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_POLISH_KEYCODES_VERSION_MAJOR 0 +#define QMK_POLISH_KEYCODES_VERSION_MINOR 0 +#define QMK_POLISH_KEYCODES_VERSION_PATCH 1 + // Aliases #define PL_GRV KC_GRV // ` #define PL_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_portuguese.h b/quantum/keymap_extras/keymap_portuguese.h index 9f79862679..44abaf6537 100644 --- a/quantum/keymap_extras/keymap_portuguese.h +++ b/quantum/keymap_extras/keymap_portuguese.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_PORTUGUESE_KEYCODES_VERSION "0.0.1" +#define QMK_PORTUGUESE_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_PORTUGUESE_KEYCODES_VERSION_MAJOR 0 +#define QMK_PORTUGUESE_KEYCODES_VERSION_MINOR 0 +#define QMK_PORTUGUESE_KEYCODES_VERSION_PATCH 1 + // Aliases #define PT_BSLS KC_GRV // (backslash) #define PT_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_portuguese_mac_iso.h b/quantum/keymap_extras/keymap_portuguese_mac_iso.h index 5381956b4c..f2d04440fb 100644 --- a/quantum/keymap_extras/keymap_portuguese_mac_iso.h +++ b/quantum/keymap_extras/keymap_portuguese_mac_iso.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_PORTUGUESE_MAC_ISO_KEYCODES_VERSION "0.0.1" +#define QMK_PORTUGUESE_MAC_ISO_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_PORTUGUESE_MAC_ISO_KEYCODES_VERSION_MAJOR 0 +#define QMK_PORTUGUESE_MAC_ISO_KEYCODES_VERSION_MINOR 0 +#define QMK_PORTUGUESE_MAC_ISO_KEYCODES_VERSION_PATCH 1 + // Aliases #define PT_SECT KC_GRV // § #define PT_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_romanian.h b/quantum/keymap_extras/keymap_romanian.h index 6410fbbe48..9a7239e032 100644 --- a/quantum/keymap_extras/keymap_romanian.h +++ b/quantum/keymap_extras/keymap_romanian.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_ROMANIAN_KEYCODES_VERSION "0.0.1" +#define QMK_ROMANIAN_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_ROMANIAN_KEYCODES_VERSION_MAJOR 0 +#define QMK_ROMANIAN_KEYCODES_VERSION_MINOR 0 +#define QMK_ROMANIAN_KEYCODES_VERSION_PATCH 1 + // Aliases #define RO_DLQU KC_GRV // „ #define RO_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_russian.h b/quantum/keymap_extras/keymap_russian.h index 364e7aba5c..b756a657df 100644 --- a/quantum/keymap_extras/keymap_russian.h +++ b/quantum/keymap_extras/keymap_russian.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_RUSSIAN_KEYCODES_VERSION "0.0.1" +#define QMK_RUSSIAN_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_RUSSIAN_KEYCODES_VERSION_MAJOR 0 +#define QMK_RUSSIAN_KEYCODES_VERSION_MINOR 0 +#define QMK_RUSSIAN_KEYCODES_VERSION_PATCH 1 + // Aliases #define RU_YO KC_GRV // Ё #define RU_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_russian_typewriter.h b/quantum/keymap_extras/keymap_russian_typewriter.h index 18157726ad..45fb1ede04 100644 --- a/quantum/keymap_extras/keymap_russian_typewriter.h +++ b/quantum/keymap_extras/keymap_russian_typewriter.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_RUSSIAN_TYPEWRITER_KEYCODES_VERSION "0.0.1" +#define QMK_RUSSIAN_TYPEWRITER_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_RUSSIAN_TYPEWRITER_KEYCODES_VERSION_MAJOR 0 +#define QMK_RUSSIAN_TYPEWRITER_KEYCODES_VERSION_MINOR 0 +#define QMK_RUSSIAN_TYPEWRITER_KEYCODES_VERSION_PATCH 1 + // Aliases #define RU_PIPE KC_GRV // | #define RU_NUM KC_1 // № diff --git a/quantum/keymap_extras/keymap_serbian.h b/quantum/keymap_extras/keymap_serbian.h index 6421577c22..202322b591 100644 --- a/quantum/keymap_extras/keymap_serbian.h +++ b/quantum/keymap_extras/keymap_serbian.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_SERBIAN_KEYCODES_VERSION "0.0.1" +#define QMK_SERBIAN_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_SERBIAN_KEYCODES_VERSION_MAJOR 0 +#define QMK_SERBIAN_KEYCODES_VERSION_MINOR 0 +#define QMK_SERBIAN_KEYCODES_VERSION_PATCH 1 + // Aliases #define RS_GRV KC_GRV // ` #define RS_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_serbian_latin.h b/quantum/keymap_extras/keymap_serbian_latin.h index 358c6c76ed..e863aa4ed8 100644 --- a/quantum/keymap_extras/keymap_serbian_latin.h +++ b/quantum/keymap_extras/keymap_serbian_latin.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_SERBIAN_LATIN_KEYCODES_VERSION "0.0.1" +#define QMK_SERBIAN_LATIN_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_SERBIAN_LATIN_KEYCODES_VERSION_MAJOR 0 +#define QMK_SERBIAN_LATIN_KEYCODES_VERSION_MINOR 0 +#define QMK_SERBIAN_LATIN_KEYCODES_VERSION_PATCH 1 + // Aliases #define RS_SLQU KC_GRV // ‚ (dead) #define RS_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_slovak.h b/quantum/keymap_extras/keymap_slovak.h index a777fce16f..f5848a6aaf 100644 --- a/quantum/keymap_extras/keymap_slovak.h +++ b/quantum/keymap_extras/keymap_slovak.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_SLOVAK_KEYCODES_VERSION "0.0.1" +#define QMK_SLOVAK_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_SLOVAK_KEYCODES_VERSION_MAJOR 0 +#define QMK_SLOVAK_KEYCODES_VERSION_MINOR 0 +#define QMK_SLOVAK_KEYCODES_VERSION_PATCH 1 + // Aliases #define SK_SCLN KC_GRV // ; #define SK_PLUS KC_1 // + diff --git a/quantum/keymap_extras/keymap_slovenian.h b/quantum/keymap_extras/keymap_slovenian.h index 402a53cd44..502f06ad64 100644 --- a/quantum/keymap_extras/keymap_slovenian.h +++ b/quantum/keymap_extras/keymap_slovenian.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_SLOVENIAN_KEYCODES_VERSION "0.0.1" +#define QMK_SLOVENIAN_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_SLOVENIAN_KEYCODES_VERSION_MAJOR 0 +#define QMK_SLOVENIAN_KEYCODES_VERSION_MINOR 0 +#define QMK_SLOVENIAN_KEYCODES_VERSION_PATCH 1 + // Aliases #define SI_CEDL KC_GRV // ¸ (dead) #define SI_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_spanish.h b/quantum/keymap_extras/keymap_spanish.h index 714c8cbb7c..dc23aea639 100644 --- a/quantum/keymap_extras/keymap_spanish.h +++ b/quantum/keymap_extras/keymap_spanish.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_SPANISH_KEYCODES_VERSION "0.0.1" +#define QMK_SPANISH_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_SPANISH_KEYCODES_VERSION_MAJOR 0 +#define QMK_SPANISH_KEYCODES_VERSION_MINOR 0 +#define QMK_SPANISH_KEYCODES_VERSION_PATCH 1 + // Aliases #define ES_MORD KC_GRV // º #define ES_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_spanish_dvorak.h b/quantum/keymap_extras/keymap_spanish_dvorak.h index b5a6463452..e19a84b7e5 100644 --- a/quantum/keymap_extras/keymap_spanish_dvorak.h +++ b/quantum/keymap_extras/keymap_spanish_dvorak.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_SPANISH_DVORAK_KEYCODES_VERSION "0.0.1" +#define QMK_SPANISH_DVORAK_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_SPANISH_DVORAK_KEYCODES_VERSION_MAJOR 0 +#define QMK_SPANISH_DVORAK_KEYCODES_VERSION_MINOR 0 +#define QMK_SPANISH_DVORAK_KEYCODES_VERSION_PATCH 1 + // Aliases #define DV_MORD KC_GRV // º #define DV_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_spanish_latin_america.h b/quantum/keymap_extras/keymap_spanish_latin_america.h index 651212d4bf..57329d20cd 100644 --- a/quantum/keymap_extras/keymap_spanish_latin_america.h +++ b/quantum/keymap_extras/keymap_spanish_latin_america.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_SPANISH_LATIN_AMERICA_KEYCODES_VERSION "0.0.1" +#define QMK_SPANISH_LATIN_AMERICA_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_SPANISH_LATIN_AMERICA_KEYCODES_VERSION_MAJOR 0 +#define QMK_SPANISH_LATIN_AMERICA_KEYCODES_VERSION_MINOR 0 +#define QMK_SPANISH_LATIN_AMERICA_KEYCODES_VERSION_PATCH 1 + // Aliases #define ES_PIPE KC_GRV // | #define ES_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_swedish.h b/quantum/keymap_extras/keymap_swedish.h index 23ec4102d8..a50f8af30d 100644 --- a/quantum/keymap_extras/keymap_swedish.h +++ b/quantum/keymap_extras/keymap_swedish.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_SWEDISH_KEYCODES_VERSION "0.0.1" +#define QMK_SWEDISH_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_SWEDISH_KEYCODES_VERSION_MAJOR 0 +#define QMK_SWEDISH_KEYCODES_VERSION_MINOR 0 +#define QMK_SWEDISH_KEYCODES_VERSION_PATCH 1 + // Aliases #define SE_SECT KC_GRV // § #define SE_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_swedish_mac_ansi.h b/quantum/keymap_extras/keymap_swedish_mac_ansi.h index 18061f0be9..642c161dab 100644 --- a/quantum/keymap_extras/keymap_swedish_mac_ansi.h +++ b/quantum/keymap_extras/keymap_swedish_mac_ansi.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_SWEDISH_MAC_ANSI_KEYCODES_VERSION "0.0.1" +#define QMK_SWEDISH_MAC_ANSI_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_SWEDISH_MAC_ANSI_KEYCODES_VERSION_MAJOR 0 +#define QMK_SWEDISH_MAC_ANSI_KEYCODES_VERSION_MINOR 0 +#define QMK_SWEDISH_MAC_ANSI_KEYCODES_VERSION_PATCH 1 + // Aliases #define SE_LABK KC_GRV // < #define SE_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_swedish_mac_iso.h b/quantum/keymap_extras/keymap_swedish_mac_iso.h index 0c68ffcbd4..50387364cf 100644 --- a/quantum/keymap_extras/keymap_swedish_mac_iso.h +++ b/quantum/keymap_extras/keymap_swedish_mac_iso.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_SWEDISH_MAC_ISO_KEYCODES_VERSION "0.0.1" +#define QMK_SWEDISH_MAC_ISO_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_SWEDISH_MAC_ISO_KEYCODES_VERSION_MAJOR 0 +#define QMK_SWEDISH_MAC_ISO_KEYCODES_VERSION_MINOR 0 +#define QMK_SWEDISH_MAC_ISO_KEYCODES_VERSION_PATCH 1 + // Aliases #define SE_SECT KC_GRV // § #define SE_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_swedish_pro_mac_ansi.h b/quantum/keymap_extras/keymap_swedish_pro_mac_ansi.h index 043a7c9fc2..be1581bb3d 100644 --- a/quantum/keymap_extras/keymap_swedish_pro_mac_ansi.h +++ b/quantum/keymap_extras/keymap_swedish_pro_mac_ansi.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_SWEDISH_PRO_MAC_ANSI_KEYCODES_VERSION "0.0.1" +#define QMK_SWEDISH_PRO_MAC_ANSI_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_SWEDISH_PRO_MAC_ANSI_KEYCODES_VERSION_MAJOR 0 +#define QMK_SWEDISH_PRO_MAC_ANSI_KEYCODES_VERSION_MINOR 0 +#define QMK_SWEDISH_PRO_MAC_ANSI_KEYCODES_VERSION_PATCH 1 + // Aliases #define SE_LABK KC_GRV // < #define SE_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_swedish_pro_mac_iso.h b/quantum/keymap_extras/keymap_swedish_pro_mac_iso.h index 1d691feef1..d50213f987 100644 --- a/quantum/keymap_extras/keymap_swedish_pro_mac_iso.h +++ b/quantum/keymap_extras/keymap_swedish_pro_mac_iso.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_SWEDISH_PRO_MAC_ISO_KEYCODES_VERSION "0.0.1" +#define QMK_SWEDISH_PRO_MAC_ISO_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_SWEDISH_PRO_MAC_ISO_KEYCODES_VERSION_MAJOR 0 +#define QMK_SWEDISH_PRO_MAC_ISO_KEYCODES_VERSION_MINOR 0 +#define QMK_SWEDISH_PRO_MAC_ISO_KEYCODES_VERSION_PATCH 1 + // Aliases #define SE_SECT KC_GRV // § #define SE_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_swiss_de.h b/quantum/keymap_extras/keymap_swiss_de.h index 5411353a5f..4ebdb5c610 100644 --- a/quantum/keymap_extras/keymap_swiss_de.h +++ b/quantum/keymap_extras/keymap_swiss_de.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_SWISS_DE_KEYCODES_VERSION "0.0.1" +#define QMK_SWISS_DE_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_SWISS_DE_KEYCODES_VERSION_MAJOR 0 +#define QMK_SWISS_DE_KEYCODES_VERSION_MINOR 0 +#define QMK_SWISS_DE_KEYCODES_VERSION_PATCH 1 + #undef CH_H // Aliases diff --git a/quantum/keymap_extras/keymap_swiss_fr.h b/quantum/keymap_extras/keymap_swiss_fr.h index a9a9cab162..11fcc6536d 100644 --- a/quantum/keymap_extras/keymap_swiss_fr.h +++ b/quantum/keymap_extras/keymap_swiss_fr.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_SWISS_FR_KEYCODES_VERSION "0.0.1" +#define QMK_SWISS_FR_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_SWISS_FR_KEYCODES_VERSION_MAJOR 0 +#define QMK_SWISS_FR_KEYCODES_VERSION_MINOR 0 +#define QMK_SWISS_FR_KEYCODES_VERSION_PATCH 1 + #undef CH_H // Aliases diff --git a/quantum/keymap_extras/keymap_turkish_f.h b/quantum/keymap_extras/keymap_turkish_f.h index dcf9e815d7..bbdaa3af25 100644 --- a/quantum/keymap_extras/keymap_turkish_f.h +++ b/quantum/keymap_extras/keymap_turkish_f.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_TURKISH_F_KEYCODES_VERSION "0.0.1" +#define QMK_TURKISH_F_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_TURKISH_F_KEYCODES_VERSION_MAJOR 0 +#define QMK_TURKISH_F_KEYCODES_VERSION_MINOR 0 +#define QMK_TURKISH_F_KEYCODES_VERSION_PATCH 1 + // Aliases #define TR_PLUS KC_GRV // + #define TR_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_turkish_q.h b/quantum/keymap_extras/keymap_turkish_q.h index a86af180cd..d3fa00d7ae 100644 --- a/quantum/keymap_extras/keymap_turkish_q.h +++ b/quantum/keymap_extras/keymap_turkish_q.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_TURKISH_Q_KEYCODES_VERSION "0.0.1" +#define QMK_TURKISH_Q_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_TURKISH_Q_KEYCODES_VERSION_MAJOR 0 +#define QMK_TURKISH_Q_KEYCODES_VERSION_MINOR 0 +#define QMK_TURKISH_Q_KEYCODES_VERSION_PATCH 1 + // Aliases #define TR_DQUO KC_GRV // " #define TR_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_uk.h b/quantum/keymap_extras/keymap_uk.h index 30f9b972db..7490af6cf6 100644 --- a/quantum/keymap_extras/keymap_uk.h +++ b/quantum/keymap_extras/keymap_uk.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_UK_KEYCODES_VERSION "0.0.1" +#define QMK_UK_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_UK_KEYCODES_VERSION_MAJOR 0 +#define QMK_UK_KEYCODES_VERSION_MINOR 0 +#define QMK_UK_KEYCODES_VERSION_PATCH 1 + // Aliases #define UK_GRV KC_GRV // ` #define UK_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_ukrainian.h b/quantum/keymap_extras/keymap_ukrainian.h index d3f82a2194..78e39f8c75 100644 --- a/quantum/keymap_extras/keymap_ukrainian.h +++ b/quantum/keymap_extras/keymap_ukrainian.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_UKRAINIAN_KEYCODES_VERSION "0.0.1" +#define QMK_UKRAINIAN_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_UKRAINIAN_KEYCODES_VERSION_MAJOR 0 +#define QMK_UKRAINIAN_KEYCODES_VERSION_MINOR 0 +#define QMK_UKRAINIAN_KEYCODES_VERSION_PATCH 1 + // Aliases #define UA_QUOT KC_GRV // ' #define UA_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_us.h b/quantum/keymap_extras/keymap_us.h index 74c9b8e7f8..b6e380ab23 100644 --- a/quantum/keymap_extras/keymap_us.h +++ b/quantum/keymap_extras/keymap_us.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_US_KEYCODES_VERSION "0.0.1" +#define QMK_US_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_US_KEYCODES_VERSION_MAJOR 0 +#define QMK_US_KEYCODES_VERSION_MINOR 0 +#define QMK_US_KEYCODES_VERSION_PATCH 1 + // Aliases #define KC_TILD S(KC_GRAVE) // ~ #define KC_EXLM S(KC_1) // ! diff --git a/quantum/keymap_extras/keymap_us_extended.h b/quantum/keymap_extras/keymap_us_extended.h index d17d3e603e..4262a7c44e 100644 --- a/quantum/keymap_extras/keymap_us_extended.h +++ b/quantum/keymap_extras/keymap_us_extended.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_US_EXTENDED_KEYCODES_VERSION "0.0.1" +#define QMK_US_EXTENDED_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_US_EXTENDED_KEYCODES_VERSION_MAJOR 0 +#define QMK_US_EXTENDED_KEYCODES_VERSION_MINOR 0 +#define QMK_US_EXTENDED_KEYCODES_VERSION_PATCH 1 + // Aliases #define US_GRV KC_GRV // ` #define US_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_us_international.h b/quantum/keymap_extras/keymap_us_international.h index a9617494a8..adc7051fe4 100644 --- a/quantum/keymap_extras/keymap_us_international.h +++ b/quantum/keymap_extras/keymap_us_international.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_US_INTERNATIONAL_KEYCODES_VERSION "0.0.1" +#define QMK_US_INTERNATIONAL_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_US_INTERNATIONAL_KEYCODES_VERSION_MAJOR 0 +#define QMK_US_INTERNATIONAL_KEYCODES_VERSION_MINOR 0 +#define QMK_US_INTERNATIONAL_KEYCODES_VERSION_PATCH 1 + // Aliases #define US_DGRV KC_GRV // ` (dead) #define US_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_us_international_linux.h b/quantum/keymap_extras/keymap_us_international_linux.h index b13039be05..db315968d6 100644 --- a/quantum/keymap_extras/keymap_us_international_linux.h +++ b/quantum/keymap_extras/keymap_us_international_linux.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_US_INTERNATIONAL_LINUX_KEYCODES_VERSION "0.0.1" +#define QMK_US_INTERNATIONAL_LINUX_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_US_INTERNATIONAL_LINUX_KEYCODES_VERSION_MAJOR 0 +#define QMK_US_INTERNATIONAL_LINUX_KEYCODES_VERSION_MINOR 0 +#define QMK_US_INTERNATIONAL_LINUX_KEYCODES_VERSION_PATCH 1 + // Aliases #define US_DGRV KC_GRV // ` (dead) #define US_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_workman.h b/quantum/keymap_extras/keymap_workman.h index 29396fdec1..727e44512c 100644 --- a/quantum/keymap_extras/keymap_workman.h +++ b/quantum/keymap_extras/keymap_workman.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_WORKMAN_KEYCODES_VERSION "0.0.1" +#define QMK_WORKMAN_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_WORKMAN_KEYCODES_VERSION_MAJOR 0 +#define QMK_WORKMAN_KEYCODES_VERSION_MINOR 0 +#define QMK_WORKMAN_KEYCODES_VERSION_PATCH 1 + // Aliases #define WK_GRV KC_GRV // ` #define WK_1 KC_1 // 1 diff --git a/quantum/keymap_extras/keymap_workman_zxcvm.h b/quantum/keymap_extras/keymap_workman_zxcvm.h index f7a5689f0f..4655af60d6 100644 --- a/quantum/keymap_extras/keymap_workman_zxcvm.h +++ b/quantum/keymap_extras/keymap_workman_zxcvm.h @@ -27,6 +27,12 @@ #include "keycodes.h" // clang-format off +#define QMK_WORKMAN_ZXCVM_KEYCODES_VERSION "0.0.1" +#define QMK_WORKMAN_ZXCVM_KEYCODES_VERSION_BCD 0x00000001 +#define QMK_WORKMAN_ZXCVM_KEYCODES_VERSION_MAJOR 0 +#define QMK_WORKMAN_ZXCVM_KEYCODES_VERSION_MINOR 0 +#define QMK_WORKMAN_ZXCVM_KEYCODES_VERSION_PATCH 1 + // Aliases #define WK_GRV KC_GRV // ` #define WK_1 KC_1 // 1 diff --git a/quantum/keymap_introspection.c b/quantum/keymap_introspection.c index 23e842353a..99fd3f929e 100644 --- a/quantum/keymap_introspection.c +++ b/quantum/keymap_introspection.c @@ -13,6 +13,7 @@ # include INTROSPECTION_KEYMAP_C #endif // INTROSPECTION_KEYMAP_C +#include "compiler_support.h" #include "keymap_introspection.h" #include "util.h" @@ -30,9 +31,9 @@ __attribute__((weak)) uint8_t keymap_layer_count(void) { } #ifdef DYNAMIC_KEYMAP_ENABLE -_Static_assert(NUM_KEYMAP_LAYERS_RAW <= MAX_LAYER, "Number of keymap layers exceeds maximum set by DYNAMIC_KEYMAP_LAYER_COUNT"); +STATIC_ASSERT(NUM_KEYMAP_LAYERS_RAW <= MAX_LAYER, "Number of keymap layers exceeds maximum set by DYNAMIC_KEYMAP_LAYER_COUNT"); #else -_Static_assert(NUM_KEYMAP_LAYERS_RAW <= MAX_LAYER, "Number of keymap layers exceeds maximum set by LAYER_STATE_(8|16|32)BIT"); +STATIC_ASSERT(NUM_KEYMAP_LAYERS_RAW <= MAX_LAYER, "Number of keymap layers exceeds maximum set by LAYER_STATE_(8|16|32)BIT"); #endif uint16_t keycode_at_keymap_location_raw(uint8_t layer_num, uint8_t row, uint8_t column) { @@ -61,7 +62,7 @@ __attribute__((weak)) uint8_t encodermap_layer_count(void) { return encodermap_layer_count_raw(); } -_Static_assert(NUM_KEYMAP_LAYERS_RAW == NUM_ENCODERMAP_LAYERS_RAW, "Number of encoder_map layers doesn't match the number of keymap layers"); +STATIC_ASSERT(NUM_KEYMAP_LAYERS_RAW == NUM_ENCODERMAP_LAYERS_RAW, "Number of encoder_map layers doesn't match the number of keymap layers"); uint16_t keycode_at_encodermap_location_raw(uint8_t layer_num, uint8_t encoder_idx, bool clockwise) { if (layer_num < NUM_ENCODERMAP_LAYERS_RAW && encoder_idx < NUM_ENCODERS) { @@ -106,7 +107,7 @@ __attribute__((weak)) uint16_t combo_count(void) { return combo_count_raw(); } -_Static_assert(ARRAY_SIZE(key_combos) <= (QK_KB), "Number of combos is abnormally high. Are you using SAFE_RANGE in an enum for combos?"); +STATIC_ASSERT(ARRAY_SIZE(key_combos) <= (QK_KB), "Number of combos is abnormally high. Are you using SAFE_RANGE in an enum for combos?"); combo_t* combo_get_raw(uint16_t combo_idx) { if (combo_idx >= combo_count_raw()) { @@ -133,7 +134,7 @@ __attribute__((weak)) uint16_t tap_dance_count(void) { return tap_dance_count_raw(); } -_Static_assert(ARRAY_SIZE(tap_dance_actions) <= (QK_TAP_DANCE_MAX - QK_TAP_DANCE), "Number of tap dance actions exceeds maximum. Are you using SAFE_RANGE in tap dance enum?"); +STATIC_ASSERT(ARRAY_SIZE(tap_dance_actions) <= (QK_TAP_DANCE_MAX - QK_TAP_DANCE), "Number of tap dance actions exceeds maximum. Are you using SAFE_RANGE in tap dance enum?"); tap_dance_action_t* tap_dance_get_raw(uint16_t tap_dance_idx) { if (tap_dance_idx >= tap_dance_count_raw()) { @@ -161,7 +162,7 @@ __attribute__((weak)) uint16_t key_override_count(void) { return key_override_count_raw(); } -_Static_assert(ARRAY_SIZE(key_overrides) <= (QK_KB), "Number of key overrides is abnormally high. Are you using SAFE_RANGE in an enum for key overrides?"); +STATIC_ASSERT(ARRAY_SIZE(key_overrides) <= (QK_KB), "Number of key overrides is abnormally high. Are you using SAFE_RANGE in an enum for key overrides?"); const key_override_t* key_override_get_raw(uint16_t key_override_idx) { if (key_override_idx >= key_override_count_raw()) { diff --git a/quantum/led_matrix/led_matrix.c b/quantum/led_matrix/led_matrix.c index 58263c62e3..7a0e8a5ebb 100644 --- a/quantum/led_matrix/led_matrix.c +++ b/quantum/led_matrix/led_matrix.c @@ -19,7 +19,6 @@ #include "led_matrix.h" #include "progmem.h" -#include "eeprom.h" #include "eeconfig.h" #include "keyboard.h" #include "sync_timer.h" @@ -46,6 +45,9 @@ const led_point_t k_led_matrix_center = LED_MATRIX_CENTER; #define LED_MATRIX_CUSTOM_EFFECT_IMPLS #include "led_matrix_effects.inc" +#ifdef COMMUNITY_MODULES_ENABLE +# include "led_matrix_community_modules.inc" +#endif #ifdef LED_MATRIX_CUSTOM_KB # include "led_matrix_kb.inc" #endif @@ -86,9 +88,9 @@ static last_hit_t last_hit_buffer; const uint8_t k_led_matrix_split[2] = LED_MATRIX_SPLIT; #endif -EECONFIG_DEBOUNCE_HELPER(led_matrix, EECONFIG_LED_MATRIX, led_matrix_eeconfig); +EECONFIG_DEBOUNCE_HELPER(led_matrix, led_matrix_eeconfig); -void eeconfig_update_led_matrix(void) { +void eeconfig_force_flush_led_matrix(void) { eeconfig_flush_led_matrix(true); } @@ -283,6 +285,15 @@ static void led_task_render(uint8_t effect) { #include "led_matrix_effects.inc" #undef LED_MATRIX_EFFECT +#ifdef COMMUNITY_MODULES_ENABLE +# define LED_MATRIX_EFFECT(name, ...) \ + case LED_MATRIX_COMMUNITY_MODULE_##name: \ + rendering = name(&led_effect_params); \ + break; +# include "led_matrix_community_modules.inc" +# undef LED_MATRIX_EFFECT +#endif + #if defined(LED_MATRIX_CUSTOM_KB) || defined(LED_MATRIX_CUSTOM_USER) # define LED_MATRIX_EFFECT(name, ...) \ case LED_MATRIX_CUSTOM_##name: \ @@ -359,7 +370,12 @@ void led_matrix_task(void) { } } +__attribute__((weak)) bool led_matrix_indicators_modules(void) { + return true; +} + void led_matrix_indicators(void) { + led_matrix_indicators_modules(); led_matrix_indicators_kb(); } @@ -371,6 +387,10 @@ __attribute__((weak)) bool led_matrix_indicators_user(void) { return true; } +__attribute__((weak)) bool led_matrix_indicators_advanced_modules(uint8_t led_min, uint8_t led_max) { + return true; +} + void led_matrix_indicators_advanced(effect_params_t *params) { /* special handling is needed for "params->iter", since it's already been incremented. * Could move the invocations to led_task_render, but then it's missing a few checks @@ -378,6 +398,7 @@ void led_matrix_indicators_advanced(effect_params_t *params) { * led_task_render, right before the iter++ line. */ LED_MATRIX_USE_LIMITS_ITER(min, max, params->iter - 1); + led_matrix_indicators_advanced_modules(min, max); led_matrix_indicators_advanced_kb(min, max); } diff --git a/quantum/led_matrix/led_matrix.h b/quantum/led_matrix/led_matrix.h index a3468a2003..0dfe33ffab 100644 --- a/quantum/led_matrix/led_matrix.h +++ b/quantum/led_matrix/led_matrix.h @@ -98,6 +98,12 @@ enum led_matrix_effects { #include "led_matrix_effects.inc" #undef LED_MATRIX_EFFECT +#ifdef COMMUNITY_MODULES_ENABLE +# define LED_MATRIX_EFFECT(name, ...) LED_MATRIX_COMMUNITY_MODULE_##name, +# include "led_matrix_community_modules.inc" +# undef LED_MATRIX_EFFECT +#endif + #if defined(LED_MATRIX_CUSTOM_KB) || defined(LED_MATRIX_CUSTOM_USER) # define LED_MATRIX_EFFECT(name, ...) LED_MATRIX_CUSTOM_##name, # ifdef LED_MATRIX_CUSTOM_KB @@ -115,7 +121,7 @@ enum led_matrix_effects { }; void eeconfig_update_led_matrix_default(void); -void eeconfig_update_led_matrix(void); +void eeconfig_force_flush_led_matrix(void); void eeconfig_debug_led_matrix(void); uint8_t led_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i); diff --git a/quantum/led_matrix/led_matrix_types.h b/quantum/led_matrix/led_matrix_types.h index 5a516ceb10..26a199701e 100644 --- a/quantum/led_matrix/led_matrix_types.h +++ b/quantum/led_matrix/led_matrix_types.h @@ -18,6 +18,8 @@ #include #include + +#include "compiler_support.h" #include "util.h" #if defined(LED_MATRIX_KEYPRESSES) || defined(LED_MATRIX_KEYRELEASES) @@ -71,7 +73,7 @@ typedef struct PACKED { uint8_t flags[LED_MATRIX_LED_COUNT]; } led_config_t; -typedef union { +typedef union led_eeconfig_t { uint32_t raw; struct PACKED { uint8_t enable : 2; @@ -82,4 +84,4 @@ typedef union { }; } led_eeconfig_t; -_Static_assert(sizeof(led_eeconfig_t) == sizeof(uint32_t), "LED Matrix EECONFIG out of spec."); +STATIC_ASSERT(sizeof(led_eeconfig_t) == sizeof(uint32_t), "LED Matrix EECONFIG out of spec."); diff --git a/quantum/logging/debug.h b/quantum/logging/debug.h index b0d9b9a10e..6675680ec7 100644 --- a/quantum/logging/debug.h +++ b/quantum/logging/debug.h @@ -28,7 +28,7 @@ extern "C" { /* * Debug output control */ -typedef union { +typedef union debug_config_t { struct { bool enable : 1; bool matrix : 1; diff --git a/quantum/nvm/eeprom/nvm_dynamic_keymap.c b/quantum/nvm/eeprom/nvm_dynamic_keymap.c new file mode 100644 index 0000000000..3e315f2bcb --- /dev/null +++ b/quantum/nvm/eeprom/nvm_dynamic_keymap.c @@ -0,0 +1,194 @@ +// Copyright 2024 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "compiler_support.h" +#include "keycodes.h" +#include "eeprom.h" +#include "dynamic_keymap.h" +#include "nvm_dynamic_keymap.h" +#include "nvm_eeprom_eeconfig_internal.h" +#include "nvm_eeprom_via_internal.h" + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +#ifdef ENCODER_ENABLE +# include "encoder.h" +#endif + +#ifdef VIA_ENABLE +# include "via.h" +# define DYNAMIC_KEYMAP_EEPROM_START (VIA_EEPROM_CONFIG_END) +#else +# define DYNAMIC_KEYMAP_EEPROM_START (EECONFIG_SIZE) +#endif + +#ifndef DYNAMIC_KEYMAP_EEPROM_MAX_ADDR +# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR (TOTAL_EEPROM_BYTE_COUNT - 1) +#endif + +STATIC_ASSERT(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR <= (TOTAL_EEPROM_BYTE_COUNT - 1), "DYNAMIC_KEYMAP_EEPROM_MAX_ADDR is configured to use more space than what is available for the selected EEPROM driver"); + +// Due to usage of uint16_t check for max 65535 +STATIC_ASSERT(DYNAMIC_KEYMAP_EEPROM_MAX_ADDR <= 65535, "DYNAMIC_KEYMAP_EEPROM_MAX_ADDR must be less than 65536"); + +// If DYNAMIC_KEYMAP_EEPROM_ADDR not explicitly defined in config.h, +#ifndef DYNAMIC_KEYMAP_EEPROM_ADDR +# define DYNAMIC_KEYMAP_EEPROM_ADDR DYNAMIC_KEYMAP_EEPROM_START +#endif + +// Dynamic encoders starts after dynamic keymaps +#ifndef DYNAMIC_KEYMAP_ENCODER_EEPROM_ADDR +# define DYNAMIC_KEYMAP_ENCODER_EEPROM_ADDR (DYNAMIC_KEYMAP_EEPROM_ADDR + (DYNAMIC_KEYMAP_LAYER_COUNT * MATRIX_ROWS * MATRIX_COLS * 2)) +#endif + +// Dynamic macro starts after dynamic encoders, but only when using ENCODER_MAP +#ifdef ENCODER_MAP_ENABLE +# ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR +# define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR (DYNAMIC_KEYMAP_ENCODER_EEPROM_ADDR + (DYNAMIC_KEYMAP_LAYER_COUNT * NUM_ENCODERS * 2 * 2)) +# endif // DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR +#else // ENCODER_MAP_ENABLE +# ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR +# define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR (DYNAMIC_KEYMAP_ENCODER_EEPROM_ADDR) +# endif // DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR +#endif // ENCODER_MAP_ENABLE + +// Sanity check that dynamic keymaps fit in available EEPROM +// If there's not 100 bytes available for macros, then something is wrong. +// The keyboard should override DYNAMIC_KEYMAP_LAYER_COUNT to reduce it, +// or DYNAMIC_KEYMAP_EEPROM_MAX_ADDR to increase it, *only if* the microcontroller has +// more than the default. +STATIC_ASSERT((DYNAMIC_KEYMAP_EEPROM_MAX_ADDR) - (DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR) >= 100, "Dynamic keymaps are configured to use more EEPROM than is available."); + +#ifndef TOTAL_EEPROM_BYTE_COUNT +# error Unknown total EEPROM size. Cannot derive maximum for dynamic keymaps. +#endif +// Dynamic macros are stored after the keymaps and use what is available +// up to and including DYNAMIC_KEYMAP_EEPROM_MAX_ADDR. +#ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE +# define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE (DYNAMIC_KEYMAP_EEPROM_MAX_ADDR - DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + 1) +#endif + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void nvm_dynamic_keymap_erase(void) { + // No-op, nvm_eeconfig_erase() will have already erased EEPROM if necessary. +} + +void nvm_dynamic_keymap_macro_erase(void) { + // No-op, nvm_eeconfig_erase() will have already erased EEPROM if necessary. +} + +static inline void *dynamic_keymap_key_to_eeprom_address(uint8_t layer, uint8_t row, uint8_t column) { + return ((void *)DYNAMIC_KEYMAP_EEPROM_ADDR) + (layer * MATRIX_ROWS * MATRIX_COLS * 2) + (row * MATRIX_COLS * 2) + (column * 2); +} + +uint16_t nvm_dynamic_keymap_read_keycode(uint8_t layer, uint8_t row, uint8_t column) { + if (layer >= DYNAMIC_KEYMAP_LAYER_COUNT || row >= MATRIX_ROWS || column >= MATRIX_COLS) return KC_NO; + void *address = dynamic_keymap_key_to_eeprom_address(layer, row, column); + // Big endian, so we can read/write EEPROM directly from host if we want + uint16_t keycode = eeprom_read_byte(address) << 8; + keycode |= eeprom_read_byte(address + 1); + return keycode; +} + +void nvm_dynamic_keymap_update_keycode(uint8_t layer, uint8_t row, uint8_t column, uint16_t keycode) { + if (layer >= DYNAMIC_KEYMAP_LAYER_COUNT || row >= MATRIX_ROWS || column >= MATRIX_COLS) return; + void *address = dynamic_keymap_key_to_eeprom_address(layer, row, column); + // Big endian, so we can read/write EEPROM directly from host if we want + eeprom_update_byte(address, (uint8_t)(keycode >> 8)); + eeprom_update_byte(address + 1, (uint8_t)(keycode & 0xFF)); +} + +#ifdef ENCODER_MAP_ENABLE +static void *dynamic_keymap_encoder_to_eeprom_address(uint8_t layer, uint8_t encoder_id) { + return ((void *)DYNAMIC_KEYMAP_ENCODER_EEPROM_ADDR) + (layer * NUM_ENCODERS * 2 * 2) + (encoder_id * 2 * 2); +} + +uint16_t nvm_dynamic_keymap_read_encoder(uint8_t layer, uint8_t encoder_id, bool clockwise) { + if (layer >= DYNAMIC_KEYMAP_LAYER_COUNT || encoder_id >= NUM_ENCODERS) return KC_NO; + void *address = dynamic_keymap_encoder_to_eeprom_address(layer, encoder_id); + // Big endian, so we can read/write EEPROM directly from host if we want + uint16_t keycode = ((uint16_t)eeprom_read_byte(address + (clockwise ? 0 : 2))) << 8; + keycode |= eeprom_read_byte(address + (clockwise ? 0 : 2) + 1); + return keycode; +} + +void nvm_dynamic_keymap_update_encoder(uint8_t layer, uint8_t encoder_id, bool clockwise, uint16_t keycode) { + if (layer >= DYNAMIC_KEYMAP_LAYER_COUNT || encoder_id >= NUM_ENCODERS) return; + void *address = dynamic_keymap_encoder_to_eeprom_address(layer, encoder_id); + // Big endian, so we can read/write EEPROM directly from host if we want + eeprom_update_byte(address + (clockwise ? 0 : 2), (uint8_t)(keycode >> 8)); + eeprom_update_byte(address + (clockwise ? 0 : 2) + 1, (uint8_t)(keycode & 0xFF)); +} +#endif // ENCODER_MAP_ENABLE + +void nvm_dynamic_keymap_read_buffer(uint32_t offset, uint32_t size, uint8_t *data) { + uint32_t dynamic_keymap_eeprom_size = DYNAMIC_KEYMAP_LAYER_COUNT * MATRIX_ROWS * MATRIX_COLS * 2; + void * source = (void *)(uintptr_t)(DYNAMIC_KEYMAP_EEPROM_ADDR + offset); + uint8_t *target = data; + for (uint32_t i = 0; i < size; i++) { + if (offset + i < dynamic_keymap_eeprom_size) { + *target = eeprom_read_byte(source); + } else { + *target = 0x00; + } + source++; + target++; + } +} + +void nvm_dynamic_keymap_update_buffer(uint32_t offset, uint32_t size, uint8_t *data) { + uint32_t dynamic_keymap_eeprom_size = DYNAMIC_KEYMAP_LAYER_COUNT * MATRIX_ROWS * MATRIX_COLS * 2; + void * target = (void *)(uintptr_t)(DYNAMIC_KEYMAP_EEPROM_ADDR + offset); + uint8_t *source = data; + for (uint32_t i = 0; i < size; i++) { + if (offset + i < dynamic_keymap_eeprom_size) { + eeprom_update_byte(target, *source); + } + source++; + target++; + } +} + +uint32_t nvm_dynamic_keymap_macro_size(void) { + return DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE; +} + +void nvm_dynamic_keymap_macro_read_buffer(uint32_t offset, uint32_t size, uint8_t *data) { + void * source = (void *)(uintptr_t)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + offset); + uint8_t *target = data; + for (uint16_t i = 0; i < size; i++) { + if (offset + i < DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE) { + *target = eeprom_read_byte(source); + } else { + *target = 0x00; + } + source++; + target++; + } +} + +void nvm_dynamic_keymap_macro_update_buffer(uint32_t offset, uint32_t size, uint8_t *data) { + void * target = (void *)(uintptr_t)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + offset); + uint8_t *source = data; + for (uint16_t i = 0; i < size; i++) { + if (offset + i < DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE) { + eeprom_update_byte(target, *source); + } + source++; + target++; + } +} + +void nvm_dynamic_keymap_macro_reset(void) { + void * start = (void *)(uintptr_t)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR); + void * end = (void *)(uintptr_t)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE); + long remaining = end - start; + uint8_t dummy[16] = {0}; + for (int i = 0; i < DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE; i += sizeof(dummy)) { + int this_loop = remaining < sizeof(dummy) ? remaining : sizeof(dummy); + eeprom_update_block(dummy, start, this_loop); + start += this_loop; + remaining -= this_loop; + } +} diff --git a/quantum/nvm/eeprom/nvm_eeconfig.c b/quantum/nvm/eeprom/nvm_eeconfig.c new file mode 100644 index 0000000000..d9495d2753 --- /dev/null +++ b/quantum/nvm/eeprom/nvm_eeconfig.c @@ -0,0 +1,305 @@ +// Copyright 2024 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-2.0-or-later +#include +#include "nvm_eeconfig.h" +#include "nvm_eeprom_eeconfig_internal.h" +#include "util.h" +#include "eeconfig.h" +#include "debug.h" +#include "eeprom.h" +#include "keycode_config.h" + +#ifdef EEPROM_DRIVER +# include "eeprom_driver.h" +#endif + +#ifdef AUDIO_ENABLE +# include "audio.h" +#endif + +#ifdef BACKLIGHT_ENABLE +# include "backlight.h" +#endif + +#ifdef RGBLIGHT_ENABLE +# include "rgblight.h" +#endif + +#ifdef RGB_MATRIX_ENABLE +# include "rgb_matrix_types.h" +#endif + +#ifdef LED_MATRIX_ENABLE +# include "led_matrix_types.h" +#endif + +#ifdef UNICODE_COMMON_ENABLE +# include "unicode.h" +#endif + +#ifdef HAPTIC_ENABLE +# include "haptic.h" +#endif + +#ifdef CONNECTION_ENABLE +# include "connection.h" +#endif + +void nvm_eeconfig_erase(void) { +#ifdef EEPROM_DRIVER + eeprom_driver_format(false); +#endif // EEPROM_DRIVER +} + +bool nvm_eeconfig_is_enabled(void) { + return eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER; +} + +bool nvm_eeconfig_is_disabled(void) { + return eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER_OFF; +} + +void nvm_eeconfig_enable(void) { + eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER); +} + +void nvm_eeconfig_disable(void) { +#if defined(EEPROM_DRIVER) + eeprom_driver_format(false); +#endif + eeprom_update_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER_OFF); +} + +void nvm_eeconfig_read_debug(debug_config_t *debug_config) { + debug_config->raw = eeprom_read_byte(EECONFIG_DEBUG); +} +void nvm_eeconfig_update_debug(const debug_config_t *debug_config) { + eeprom_update_byte(EECONFIG_DEBUG, debug_config->raw); +} + +layer_state_t nvm_eeconfig_read_default_layer(void) { + uint8_t val = eeprom_read_byte(EECONFIG_DEFAULT_LAYER); +#ifdef DEFAULT_LAYER_STATE_IS_VALUE_NOT_BITMASK + // stored as a layer number, so convert back to bitmask + return (layer_state_t)1 << val; +#else + // stored as 8-bit-wide bitmask, so read the value directly - handling padding to 16/32 bit layer_state_t + return (layer_state_t)val; +#endif +} +void nvm_eeconfig_update_default_layer(layer_state_t state) { +#ifdef DEFAULT_LAYER_STATE_IS_VALUE_NOT_BITMASK + // stored as a layer number, so only store the highest layer + uint8_t val = get_highest_layer(state); +#else + // stored as 8-bit-wide bitmask, so write the value directly - handling truncation from 16/32 bit layer_state_t + uint8_t val = (uint8_t)state; +#endif + eeprom_update_byte(EECONFIG_DEFAULT_LAYER, val); +} + +void nvm_eeconfig_read_keymap(keymap_config_t *keymap_config) { + keymap_config->raw = eeprom_read_word(EECONFIG_KEYMAP); +} +void nvm_eeconfig_update_keymap(const keymap_config_t *keymap_config) { + eeprom_update_word(EECONFIG_KEYMAP, keymap_config->raw); +} + +#ifdef AUDIO_ENABLE +void nvm_eeconfig_read_audio(audio_config_t *audio_config) { + audio_config->raw = eeprom_read_byte(EECONFIG_AUDIO); +} +void nvm_eeconfig_update_audio(const audio_config_t *audio_config) { + eeprom_update_byte(EECONFIG_AUDIO, audio_config->raw); +} +#endif // AUDIO_ENABLE + +#ifdef UNICODE_COMMON_ENABLE +void nvm_eeconfig_read_unicode_mode(unicode_config_t *unicode_config) { + unicode_config->raw = eeprom_read_byte(EECONFIG_UNICODEMODE); +} +void nvm_eeconfig_update_unicode_mode(const unicode_config_t *unicode_config) { + eeprom_update_byte(EECONFIG_UNICODEMODE, unicode_config->raw); +} +#endif // UNICODE_COMMON_ENABLE + +#ifdef BACKLIGHT_ENABLE +void nvm_eeconfig_read_backlight(backlight_config_t *backlight_config) { + backlight_config->raw = eeprom_read_byte(EECONFIG_BACKLIGHT); +} +void nvm_eeconfig_update_backlight(const backlight_config_t *backlight_config) { + eeprom_update_byte(EECONFIG_BACKLIGHT, backlight_config->raw); +} +#endif // BACKLIGHT_ENABLE + +#ifdef STENO_ENABLE +uint8_t nvm_eeconfig_read_steno_mode(void) { + return eeprom_read_byte(EECONFIG_STENOMODE); +} +void nvm_eeconfig_update_steno_mode(uint8_t val) { + eeprom_update_byte(EECONFIG_STENOMODE, val); +} +#endif // STENO_ENABLE + +#ifdef RGBLIGHT_ENABLE +#endif // RGBLIGHT_ENABLE + +#ifdef RGB_MATRIX_ENABLE +void nvm_eeconfig_read_rgb_matrix(rgb_config_t *rgb_matrix_config) { + eeprom_read_block(rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_config_t)); +} +void nvm_eeconfig_update_rgb_matrix(const rgb_config_t *rgb_matrix_config) { + eeprom_update_block(rgb_matrix_config, EECONFIG_RGB_MATRIX, sizeof(rgb_config_t)); +} +#endif // RGB_MATRIX_ENABLE + +#ifdef LED_MATRIX_ENABLE +void nvm_eeconfig_read_led_matrix(led_eeconfig_t *led_matrix_config) { + eeprom_read_block(led_matrix_config, EECONFIG_LED_MATRIX, sizeof(led_eeconfig_t)); +} +void nvm_eeconfig_update_led_matrix(const led_eeconfig_t *led_matrix_config) { + eeprom_update_block(led_matrix_config, EECONFIG_LED_MATRIX, sizeof(led_eeconfig_t)); +} +#endif // LED_MATRIX_ENABLE + +#ifdef RGBLIGHT_ENABLE +void nvm_eeconfig_read_rgblight(rgblight_config_t *rgblight_config) { + rgblight_config->raw = eeprom_read_dword(EECONFIG_RGBLIGHT); + rgblight_config->raw |= ((uint64_t)eeprom_read_byte(EECONFIG_RGBLIGHT_EXTENDED) << 32); +} +void nvm_eeconfig_update_rgblight(const rgblight_config_t *rgblight_config) { + eeprom_update_dword(EECONFIG_RGBLIGHT, rgblight_config->raw & 0xFFFFFFFF); + eeprom_update_byte(EECONFIG_RGBLIGHT_EXTENDED, (rgblight_config->raw >> 32) & 0xFF); +} +#endif // RGBLIGHT_ENABLE + +#if (EECONFIG_KB_DATA_SIZE) == 0 +uint32_t nvm_eeconfig_read_kb(void) { + return eeprom_read_dword(EECONFIG_KEYBOARD); +} +void nvm_eeconfig_update_kb(uint32_t val) { + eeprom_update_dword(EECONFIG_KEYBOARD, val); +} +#endif // (EECONFIG_KB_DATA_SIZE) == 0 + +#if (EECONFIG_USER_DATA_SIZE) == 0 +uint32_t nvm_eeconfig_read_user(void) { + return eeprom_read_dword(EECONFIG_USER); +} +void nvm_eeconfig_update_user(uint32_t val) { + eeprom_update_dword(EECONFIG_USER, val); +} +#endif // (EECONFIG_USER_DATA_SIZE) == 0 + +#ifdef HAPTIC_ENABLE +void nvm_eeconfig_read_haptic(haptic_config_t *haptic_config) { + haptic_config->raw = eeprom_read_dword(EECONFIG_HAPTIC); +} +void nvm_eeconfig_update_haptic(const haptic_config_t *haptic_config) { + eeprom_update_dword(EECONFIG_HAPTIC, haptic_config->raw); +} +#endif // HAPTIC_ENABLE + +#ifdef CONNECTION_ENABLE +void nvm_eeconfig_read_connection(connection_config_t *config) { + config->raw = eeprom_read_byte(EECONFIG_CONNECTION); +} +void nvm_eeconfig_update_connection(const connection_config_t *config) { + eeprom_update_byte(EECONFIG_CONNECTION, config->raw); +} +#endif // CONNECTION_ENABLE + +bool nvm_eeconfig_read_handedness(void) { + return !!eeprom_read_byte(EECONFIG_HANDEDNESS); +} +void nvm_eeconfig_update_handedness(bool val) { + eeprom_update_byte(EECONFIG_HANDEDNESS, !!val); +} + +#if (EECONFIG_KB_DATA_SIZE) > 0 + +bool nvm_eeconfig_is_kb_datablock_valid(void) { + return eeprom_read_dword(EECONFIG_KEYBOARD) == (EECONFIG_KB_DATA_VERSION); +} + +uint32_t nvm_eeconfig_read_kb_datablock(void *data, uint32_t offset, uint32_t length) { + if (eeconfig_is_kb_datablock_valid()) { + void *ee_start = (void *)(uintptr_t)(EECONFIG_KB_DATABLOCK + offset); + void *ee_end = (void *)(uintptr_t)(EECONFIG_KB_DATABLOCK + MIN(EECONFIG_KB_DATA_SIZE, offset + length)); + eeprom_read_block(data, ee_start, ee_end - ee_start); + return ee_end - ee_start; + } else { + memset(data, 0, length); + return length; + } +} + +uint32_t nvm_eeconfig_update_kb_datablock(const void *data, uint32_t offset, uint32_t length) { + eeprom_update_dword(EECONFIG_KEYBOARD, (EECONFIG_KB_DATA_VERSION)); + + void *ee_start = (void *)(uintptr_t)(EECONFIG_KB_DATABLOCK + offset); + void *ee_end = (void *)(uintptr_t)(EECONFIG_KB_DATABLOCK + MIN(EECONFIG_KB_DATA_SIZE, offset + length)); + eeprom_update_block(data, ee_start, ee_end - ee_start); + return ee_end - ee_start; +} + +void nvm_eeconfig_init_kb_datablock(void) { + eeprom_update_dword(EECONFIG_KEYBOARD, (EECONFIG_KB_DATA_VERSION)); + + void * start = (void *)(uintptr_t)(EECONFIG_KB_DATABLOCK); + void * end = (void *)(uintptr_t)(EECONFIG_KB_DATABLOCK + EECONFIG_KB_DATA_SIZE); + long remaining = end - start; + uint8_t dummy[16] = {0}; + for (int i = 0; i < EECONFIG_KB_DATA_SIZE; i += sizeof(dummy)) { + int this_loop = remaining < sizeof(dummy) ? remaining : sizeof(dummy); + eeprom_update_block(dummy, start, this_loop); + start += this_loop; + remaining -= this_loop; + } +} + +#endif // (EECONFIG_KB_DATA_SIZE) > 0 + +#if (EECONFIG_USER_DATA_SIZE) > 0 + +bool nvm_eeconfig_is_user_datablock_valid(void) { + return eeprom_read_dword(EECONFIG_USER) == (EECONFIG_USER_DATA_VERSION); +} + +uint32_t nvm_eeconfig_read_user_datablock(void *data, uint32_t offset, uint32_t length) { + if (eeconfig_is_user_datablock_valid()) { + void *ee_start = (void *)(uintptr_t)(EECONFIG_USER_DATABLOCK + offset); + void *ee_end = (void *)(uintptr_t)(EECONFIG_USER_DATABLOCK + MIN(EECONFIG_USER_DATA_SIZE, offset + length)); + eeprom_read_block(data, ee_start, ee_end - ee_start); + return ee_end - ee_start; + } else { + memset(data, 0, length); + return length; + } +} + +uint32_t nvm_eeconfig_update_user_datablock(const void *data, uint32_t offset, uint32_t length) { + eeprom_update_dword(EECONFIG_USER, (EECONFIG_USER_DATA_VERSION)); + + void *ee_start = (void *)(uintptr_t)(EECONFIG_USER_DATABLOCK + offset); + void *ee_end = (void *)(uintptr_t)(EECONFIG_USER_DATABLOCK + MIN(EECONFIG_USER_DATA_SIZE, offset + length)); + eeprom_update_block(data, ee_start, ee_end - ee_start); + return ee_end - ee_start; +} + +void nvm_eeconfig_init_user_datablock(void) { + eeprom_update_dword(EECONFIG_USER, (EECONFIG_USER_DATA_VERSION)); + + void * start = (void *)(uintptr_t)(EECONFIG_USER_DATABLOCK); + void * end = (void *)(uintptr_t)(EECONFIG_USER_DATABLOCK + EECONFIG_USER_DATA_SIZE); + long remaining = end - start; + uint8_t dummy[16] = {0}; + for (int i = 0; i < EECONFIG_USER_DATA_SIZE; i += sizeof(dummy)) { + int this_loop = remaining < sizeof(dummy) ? remaining : sizeof(dummy); + eeprom_update_block(dummy, start, this_loop); + start += this_loop; + remaining -= this_loop; + } +} + +#endif // (EECONFIG_USER_DATA_SIZE) > 0 diff --git a/quantum/nvm/eeprom/nvm_eeprom_eeconfig_internal.h b/quantum/nvm/eeprom/nvm_eeprom_eeconfig_internal.h new file mode 100644 index 0000000000..78b8190eaf --- /dev/null +++ b/quantum/nvm/eeprom/nvm_eeprom_eeconfig_internal.h @@ -0,0 +1,63 @@ +// Copyright 2024 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +#include +#include // offsetof + +#include "compiler_support.h" +#include "eeconfig.h" +#include "util.h" + +// Dummy struct only used to calculate offsets +typedef struct PACKED { + uint16_t magic; + uint8_t debug; + uint8_t default_layer; + uint16_t keymap; + uint8_t backlight; + uint8_t audio; + uint32_t rgblight; + uint8_t unicode; + uint8_t steno; + uint8_t handedness; + uint32_t keyboard; + uint32_t user; + union { // Mutually exclusive + uint32_t led_matrix; + uint64_t rgb_matrix; + }; + uint32_t haptic; + uint8_t rgblight_ext; + uint8_t connection; +} eeprom_core_t; + +/* EEPROM parameter address */ +#define EECONFIG_MAGIC (uint16_t *)(offsetof(eeprom_core_t, magic)) +#define EECONFIG_DEBUG (uint8_t *)(offsetof(eeprom_core_t, debug)) +#define EECONFIG_DEFAULT_LAYER (uint8_t *)(offsetof(eeprom_core_t, default_layer)) +#define EECONFIG_KEYMAP (uint16_t *)(offsetof(eeprom_core_t, keymap)) +#define EECONFIG_BACKLIGHT (uint8_t *)(offsetof(eeprom_core_t, backlight)) +#define EECONFIG_AUDIO (uint8_t *)(offsetof(eeprom_core_t, audio)) +#define EECONFIG_RGBLIGHT (uint32_t *)(offsetof(eeprom_core_t, rgblight)) +#define EECONFIG_UNICODEMODE (uint8_t *)(offsetof(eeprom_core_t, unicode)) +#define EECONFIG_STENOMODE (uint8_t *)(offsetof(eeprom_core_t, steno)) +#define EECONFIG_HANDEDNESS (uint8_t *)(offsetof(eeprom_core_t, handedness)) +#define EECONFIG_KEYBOARD (uint32_t *)(offsetof(eeprom_core_t, keyboard)) +#define EECONFIG_USER (uint32_t *)(offsetof(eeprom_core_t, user)) +#define EECONFIG_LED_MATRIX (uint32_t *)(offsetof(eeprom_core_t, led_matrix)) +#define EECONFIG_RGB_MATRIX (uint64_t *)(offsetof(eeprom_core_t, rgb_matrix)) +#define EECONFIG_HAPTIC (uint32_t *)(offsetof(eeprom_core_t, haptic)) +#define EECONFIG_RGBLIGHT_EXTENDED (uint8_t *)(offsetof(eeprom_core_t, rgblight_ext)) +#define EECONFIG_CONNECTION (uint8_t *)(offsetof(eeprom_core_t, connection)) + +// Size of EEPROM being used for core data storage +#define EECONFIG_BASE_SIZE ((uint8_t)sizeof(eeprom_core_t)) + +#define EECONFIG_KB_DATABLOCK ((uint8_t *)(EECONFIG_BASE_SIZE)) +#define EECONFIG_USER_DATABLOCK ((uint8_t *)((EECONFIG_BASE_SIZE) + (EECONFIG_KB_DATA_SIZE))) + +// Size of EEPROM being used, other code can refer to this for available EEPROM +#define EECONFIG_SIZE ((EECONFIG_BASE_SIZE) + (EECONFIG_KB_DATA_SIZE) + (EECONFIG_USER_DATA_SIZE)) + +STATIC_ASSERT((intptr_t)EECONFIG_HANDEDNESS == 14, "EEPROM handedness offset is incorrect"); diff --git a/quantum/nvm/eeprom/nvm_eeprom_via_internal.h b/quantum/nvm/eeprom/nvm_eeprom_via_internal.h new file mode 100644 index 0000000000..bf0d38e2ac --- /dev/null +++ b/quantum/nvm/eeprom/nvm_eeprom_via_internal.h @@ -0,0 +1,22 @@ +// Copyright 2024 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +// Keyboard level code can change where VIA stores the magic. +// The magic is the build date YYMMDD encoded as BCD in 3 bytes, +// thus installing firmware built on a different date to the one +// already installed can be detected and the EEPROM data is reset. +// The only reason this is important is in case EEPROM usage changes +// and the EEPROM was not explicitly reset by bootmagic lite. +#ifndef VIA_EEPROM_MAGIC_ADDR +# define VIA_EEPROM_MAGIC_ADDR (EECONFIG_SIZE) +#endif + +#define VIA_EEPROM_LAYOUT_OPTIONS_ADDR (VIA_EEPROM_MAGIC_ADDR + 3) + +// The end of the EEPROM memory used by VIA +// By default, dynamic keymaps will start at this if there is no +// custom config +#define VIA_EEPROM_CUSTOM_CONFIG_ADDR (VIA_EEPROM_LAYOUT_OPTIONS_ADDR + VIA_EEPROM_LAYOUT_OPTIONS_SIZE) + +#define VIA_EEPROM_CONFIG_END (VIA_EEPROM_CUSTOM_CONFIG_ADDR + VIA_EEPROM_CUSTOM_CONFIG_SIZE) diff --git a/quantum/nvm/eeprom/nvm_via.c b/quantum/nvm/eeprom/nvm_via.c new file mode 100644 index 0000000000..5372791fb7 --- /dev/null +++ b/quantum/nvm/eeprom/nvm_via.c @@ -0,0 +1,77 @@ +// Copyright 2024 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "eeprom.h" +#include "util.h" +#include "via.h" +#include "nvm_via.h" +#include "nvm_eeprom_eeconfig_internal.h" +#include "nvm_eeprom_via_internal.h" + +void nvm_via_erase(void) { + // No-op, nvm_eeconfig_erase() will have already erased EEPROM if necessary. +} + +void nvm_via_read_magic(uint8_t *magic0, uint8_t *magic1, uint8_t *magic2) { + if (magic0) { + *magic0 = eeprom_read_byte((void *)VIA_EEPROM_MAGIC_ADDR + 0); + } + + if (magic1) { + *magic1 = eeprom_read_byte((void *)VIA_EEPROM_MAGIC_ADDR + 1); + } + + if (magic2) { + *magic2 = eeprom_read_byte((void *)VIA_EEPROM_MAGIC_ADDR + 2); + } +} + +void nvm_via_update_magic(uint8_t magic0, uint8_t magic1, uint8_t magic2) { + eeprom_update_byte((void *)VIA_EEPROM_MAGIC_ADDR + 0, magic0); + eeprom_update_byte((void *)VIA_EEPROM_MAGIC_ADDR + 1, magic1); + eeprom_update_byte((void *)VIA_EEPROM_MAGIC_ADDR + 2, magic2); +} + +uint32_t nvm_via_read_layout_options(void) { + uint32_t value = 0; + // Start at the most significant byte + void *source = (void *)(VIA_EEPROM_LAYOUT_OPTIONS_ADDR); + for (uint8_t i = 0; i < VIA_EEPROM_LAYOUT_OPTIONS_SIZE; i++) { + value = value << 8; + value |= eeprom_read_byte(source); + source++; + } + return value; +} + +void nvm_via_update_layout_options(uint32_t val) { + // Start at the least significant byte + void *target = (void *)(VIA_EEPROM_LAYOUT_OPTIONS_ADDR + VIA_EEPROM_LAYOUT_OPTIONS_SIZE - 1); + for (uint8_t i = 0; i < VIA_EEPROM_LAYOUT_OPTIONS_SIZE; i++) { + eeprom_update_byte(target, val & 0xFF); + val = val >> 8; + target--; + } +} + +uint32_t nvm_via_read_custom_config(void *buf, uint32_t offset, uint32_t length) { +#if VIA_EEPROM_CUSTOM_CONFIG_SIZE > 0 + void *ee_start = (void *)(uintptr_t)(VIA_EEPROM_CUSTOM_CONFIG_ADDR + offset); + void *ee_end = (void *)(uintptr_t)(VIA_EEPROM_CUSTOM_CONFIG_ADDR + MIN(VIA_EEPROM_CUSTOM_CONFIG_SIZE, offset + length)); + eeprom_read_block(buf, ee_start, ee_end - ee_start); + return ee_end - ee_start; +#else + return 0; +#endif +} + +uint32_t nvm_via_update_custom_config(const void *buf, uint32_t offset, uint32_t length) { +#if VIA_EEPROM_CUSTOM_CONFIG_SIZE > 0 + void *ee_start = (void *)(uintptr_t)(VIA_EEPROM_CUSTOM_CONFIG_ADDR + offset); + void *ee_end = (void *)(uintptr_t)(VIA_EEPROM_CUSTOM_CONFIG_ADDR + MIN(VIA_EEPROM_CUSTOM_CONFIG_SIZE, offset + length)); + eeprom_update_block(buf, ee_start, ee_end - ee_start); + return ee_end - ee_start; +#else + return 0; +#endif +} diff --git a/quantum/nvm/nvm_dynamic_keymap.h b/quantum/nvm/nvm_dynamic_keymap.h new file mode 100644 index 0000000000..d6e4aaee51 --- /dev/null +++ b/quantum/nvm/nvm_dynamic_keymap.h @@ -0,0 +1,27 @@ +// Copyright 2024 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +#include +#include + +void nvm_dynamic_keymap_erase(void); +void nvm_dynamic_keymap_macro_erase(void); + +uint16_t nvm_dynamic_keymap_read_keycode(uint8_t layer, uint8_t row, uint8_t column); +void nvm_dynamic_keymap_update_keycode(uint8_t layer, uint8_t row, uint8_t column, uint16_t keycode); + +#ifdef ENCODER_MAP_ENABLE +uint16_t nvm_dynamic_keymap_read_encoder(uint8_t layer, uint8_t encoder_id, bool clockwise); +void nvm_dynamic_keymap_update_encoder(uint8_t layer, uint8_t encoder_id, bool clockwise, uint16_t keycode); +#endif // ENCODER_MAP_ENABLE + +void nvm_dynamic_keymap_read_buffer(uint32_t offset, uint32_t size, uint8_t *data); +void nvm_dynamic_keymap_update_buffer(uint32_t offset, uint32_t size, uint8_t *data); + +uint32_t nvm_dynamic_keymap_macro_size(void); + +void nvm_dynamic_keymap_macro_read_buffer(uint32_t offset, uint32_t size, uint8_t *data); +void nvm_dynamic_keymap_macro_update_buffer(uint32_t offset, uint32_t size, uint8_t *data); + +void nvm_dynamic_keymap_macro_reset(void); diff --git a/quantum/nvm/nvm_eeconfig.h b/quantum/nvm/nvm_eeconfig.h new file mode 100644 index 0000000000..40827361ca --- /dev/null +++ b/quantum/nvm/nvm_eeconfig.h @@ -0,0 +1,111 @@ +// Copyright 2024 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +#include +#include +#include "action_layer.h" // layer_state_t + +#ifndef EECONFIG_MAGIC_NUMBER +# define EECONFIG_MAGIC_NUMBER (uint16_t)0xFEE3 // When changing, decrement this value to avoid future re-init issues +#endif +#define EECONFIG_MAGIC_NUMBER_OFF (uint16_t)0xFFFF + +void nvm_eeconfig_erase(void); + +bool nvm_eeconfig_is_enabled(void); +bool nvm_eeconfig_is_disabled(void); + +void nvm_eeconfig_enable(void); +void nvm_eeconfig_disable(void); + +typedef union debug_config_t debug_config_t; +void nvm_eeconfig_read_debug(debug_config_t *debug_config); +void nvm_eeconfig_update_debug(const debug_config_t *debug_config); + +layer_state_t nvm_eeconfig_read_default_layer(void); +void nvm_eeconfig_update_default_layer(layer_state_t state); + +typedef union keymap_config_t keymap_config_t; +void nvm_eeconfig_read_keymap(keymap_config_t *keymap_config); +void nvm_eeconfig_update_keymap(const keymap_config_t *keymap_config); + +#ifdef AUDIO_ENABLE +typedef union audio_config_t audio_config_t; +void nvm_eeconfig_read_audio(audio_config_t *audio_config); +void nvm_eeconfig_update_audio(const audio_config_t *audio_config); +#endif // AUDIO_ENABLE + +#ifdef UNICODE_COMMON_ENABLE +typedef union unicode_config_t unicode_config_t; +void nvm_eeconfig_read_unicode_mode(unicode_config_t *unicode_config); +void nvm_eeconfig_update_unicode_mode(const unicode_config_t *unicode_config); +#endif // UNICODE_COMMON_ENABLE + +#ifdef BACKLIGHT_ENABLE +typedef union backlight_config_t backlight_config_t; +void nvm_eeconfig_read_backlight(backlight_config_t *backlight_config); +void nvm_eeconfig_update_backlight(const backlight_config_t *backlight_config); +#endif // BACKLIGHT_ENABLE + +#ifdef STENO_ENABLE +uint8_t nvm_eeconfig_read_steno_mode(void); +void nvm_eeconfig_update_steno_mode(uint8_t val); +#endif // STENO_ENABLE + +#ifdef RGB_MATRIX_ENABLE +typedef union rgb_config_t rgb_config_t; +void nvm_eeconfig_read_rgb_matrix(rgb_config_t *rgb_matrix_config); +void nvm_eeconfig_update_rgb_matrix(const rgb_config_t *rgb_matrix_config); +#endif + +#ifdef LED_MATRIX_ENABLE +typedef union led_eeconfig_t led_eeconfig_t; +void nvm_eeconfig_read_led_matrix(led_eeconfig_t *led_matrix_config); +void nvm_eeconfig_update_led_matrix(const led_eeconfig_t *led_matrix_config); +#endif // LED_MATRIX_ENABLE + +#ifdef RGBLIGHT_ENABLE +typedef union rgblight_config_t rgblight_config_t; +void nvm_eeconfig_read_rgblight(rgblight_config_t *rgblight_config); +void nvm_eeconfig_update_rgblight(const rgblight_config_t *rgblight_config); +#endif // RGBLIGHT_ENABLE + +#if (EECONFIG_KB_DATA_SIZE) == 0 +uint32_t nvm_eeconfig_read_kb(void); +void nvm_eeconfig_update_kb(uint32_t val); +#endif // (EECONFIG_KB_DATA_SIZE) == 0 + +#if (EECONFIG_USER_DATA_SIZE) == 0 +uint32_t nvm_eeconfig_read_user(void); +void nvm_eeconfig_update_user(uint32_t val); +#endif // (EECONFIG_USER_DATA_SIZE) == 0 + +#ifdef HAPTIC_ENABLE +typedef union haptic_config_t haptic_config_t; +void nvm_eeconfig_read_haptic(haptic_config_t *haptic_config); +void nvm_eeconfig_update_haptic(const haptic_config_t *haptic_config); +#endif // HAPTIC_ENABLE + +#ifdef CONNECTION_ENABLE +typedef union connection_config_t connection_config_t; +void nvm_eeconfig_read_connection(connection_config_t *config); +void nvm_eeconfig_update_connection(const connection_config_t *config); +#endif // CONNECTION_ENABLE + +bool nvm_eeconfig_read_handedness(void); +void nvm_eeconfig_update_handedness(bool val); + +#if (EECONFIG_KB_DATA_SIZE) > 0 +bool nvm_eeconfig_is_kb_datablock_valid(void); +uint32_t nvm_eeconfig_read_kb_datablock(void *data, uint32_t offset, uint32_t length); +uint32_t nvm_eeconfig_update_kb_datablock(const void *data, uint32_t offset, uint32_t length); +void nvm_eeconfig_init_kb_datablock(void); +#endif // (EECONFIG_KB_DATA_SIZE) > 0 + +#if (EECONFIG_USER_DATA_SIZE) > 0 +bool nvm_eeconfig_is_user_datablock_valid(void); +uint32_t nvm_eeconfig_read_user_datablock(void *data, uint32_t offset, uint32_t length); +uint32_t nvm_eeconfig_update_user_datablock(const void *data, uint32_t offset, uint32_t length); +void nvm_eeconfig_init_user_datablock(void); +#endif // (EECONFIG_USER_DATA_SIZE) > 0 diff --git a/quantum/nvm/nvm_via.h b/quantum/nvm/nvm_via.h new file mode 100644 index 0000000000..90c5e67421 --- /dev/null +++ b/quantum/nvm/nvm_via.h @@ -0,0 +1,17 @@ +// Copyright 2024 Nick Brassel (@tzarc) +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +#include +#include + +void nvm_via_erase(void); + +void nvm_via_read_magic(uint8_t *magic0, uint8_t *magic1, uint8_t *magic2); +void nvm_via_update_magic(uint8_t magic0, uint8_t magic1, uint8_t magic2); + +uint32_t nvm_via_read_layout_options(void); +void nvm_via_update_layout_options(uint32_t val); + +uint32_t nvm_via_read_custom_config(void *buf, uint32_t offset, uint32_t length); +uint32_t nvm_via_update_custom_config(const void *buf, uint32_t offset, uint32_t length); diff --git a/quantum/nvm/readme.md b/quantum/nvm/readme.md new file mode 100644 index 0000000000..0731695e92 --- /dev/null +++ b/quantum/nvm/readme.md @@ -0,0 +1,30 @@ +# Non-volatile Memory - Data Repositories + +This area is intentionally structured in the following way: + +``` +╰- quantum + ╰- nvm + ├- readme.md + ├- rules.mk + | + ├- nvm_eeconfig.h + ├- nvm_<>.h + | + ├- eeprom + | ├- nvm_eeconfig.c + | ├- nvm_<>.c + | ╰- ... + | + ├- <> + | ├- nvm_eeconfig.c + | ├- nvm_<>.c + | ╰- ... + ╰- ... +``` + +At the base `nvm` level, for every QMK core system which requires persistence there must be a corresponding `nvm_<>.h` header file. This provides the data repository API to the "owner" system, and allows the underlying data persistence mechanism to be abstracted away from upper code. Any conversion to/from a `.raw` field should occur inside the `nvm_<>.c` layer, with the API using values, such as structs or unions exposed to the rest of QMK. + +Each `nvm` "provider" is a corresponding child directory consisting of its name, such as `eeprom`, and corresponding `nvm_<>.c` implementation files which provide the concrete implementation of the upper `nvm_<>.h`. + +New systems requiring persistence can add the corresponding `nvm_<>.h` file, and in most circumstances must also implement equivalent `nvm_<>.c` files for every `nvm` provider. If persistence is not possible for that system, a `nvm_<>.c` file with simple stubs which ignore writes and provide sane defaults must be used instead. \ No newline at end of file diff --git a/quantum/nvm/rules.mk b/quantum/nvm/rules.mk new file mode 100644 index 0000000000..c9c1fabfd4 --- /dev/null +++ b/quantum/nvm/rules.mk @@ -0,0 +1,31 @@ +# Copyright 2024 Nick Brassel (@tzarc) +# SPDX-License-Identifier: GPL-2.0-or-later + +VPATH += $(QUANTUM_DIR)/nvm + +VALID_NVM_DRIVERS := eeprom custom none + +NVM_DRIVER ?= eeprom + +ifeq ($(filter $(NVM_DRIVER),$(VALID_NVM_DRIVERS)),) + $(call CATASTROPHIC_ERROR,Invalid NVM_DRIVER,NVM_DRIVER="$(NVM_DRIVER)" is not a valid NVM driver) +else + + # If we don't want one, fake it with transient eeprom. + ifeq ($(NVM_DRIVER),none) + NVM_DRIVER := eeprom + EEPROM_DRIVER := transient + endif + + NVM_DRIVER_UPPER := $(shell echo $(NVM_DRIVER) | tr '[:lower:]' '[:upper:]') + NVM_DRIVER_LOWER := $(shell echo $(NVM_DRIVER) | tr '[:upper:]' '[:lower:]') + + OPT_DEFS += -DNVM_DRIVER_$(NVM_DRIVER_UPPER) -DNVM_DRIVER="$(NVM_DRIVER)" + + ifneq ("$(wildcard $(QUANTUM_DIR)/nvm/$(NVM_DRIVER_LOWER))","") + COMMON_VPATH += $(QUANTUM_DIR)/nvm/$(NVM_DRIVER_LOWER) + endif + + QUANTUM_SRC += nvm_eeconfig.c + +endif diff --git a/quantum/os_detection.c b/quantum/os_detection.c index 9a9f9052f2..552375f61c 100644 --- a/quantum/os_detection.c +++ b/quantum/os_detection.c @@ -68,6 +68,15 @@ static volatile bool first_report = true; static volatile struct usb_device_state current_usb_device_state = {.configure_state = USB_DEVICE_STATE_NO_INIT}; static volatile struct usb_device_state maxprev_usb_device_state = {.configure_state = USB_DEVICE_STATE_NO_INIT}; +// to reset the keyboard on USB state change +#ifdef OS_DETECTION_KEYBOARD_RESET +# ifndef OS_DETECTION_RESET_DEBOUNCE +# define OS_DETECTION_RESET_DEBOUNCE OS_DETECTION_DEBOUNCE +# endif +static volatile fast_timer_t configured_since = 0; +static volatile bool reset_pending = false; +#endif + // the OS detection might be unstable for a while, "debounce" it static volatile bool debouncing = false; static volatile fast_timer_t last_time = 0; @@ -77,7 +86,10 @@ bool process_detected_host_os_modules(os_variant_t os); void os_detection_task(void) { #ifdef OS_DETECTION_KEYBOARD_RESET // resetting the keyboard on the USB device state change callback results in instability, so delegate that to this task - // only take action if it's been stable at least once, to avoid issues with some KVMs + if (reset_pending) { + soft_reset_keyboard(); + } + // reset the keyboard if it is stuck in the init state for longer than debounce duration, which can happen with some KVMs if (current_usb_device_state.configure_state <= USB_DEVICE_STATE_INIT && maxprev_usb_device_state.configure_state >= USB_DEVICE_STATE_CONFIGURED) { if (debouncing && timer_elapsed_fast(last_time) >= OS_DETECTION_DEBOUNCE) { soft_reset_keyboard(); @@ -187,6 +199,18 @@ void os_detection_notify_usb_device_state_change(struct usb_device_state usb_dev current_usb_device_state = usb_device_state; last_time = timer_read_fast(); debouncing = true; + +#ifdef OS_DETECTION_KEYBOARD_RESET + if (configured_since == 0 && current_usb_device_state.configure_state == USB_DEVICE_STATE_CONFIGURED) { + configured_since = timer_read_fast(); + } else if (current_usb_device_state.configure_state == USB_DEVICE_STATE_INIT) { + // reset the keyboard only if it's been stable for at least debounce duration, to avoid issues with some KVMs + if (configured_since > 0 && timer_elapsed_fast(configured_since) >= OS_DETECTION_RESET_DEBOUNCE) { + reset_pending = true; + } + configured_since = 0; + } +#endif } #if defined(SPLIT_KEYBOARD) && defined(SPLIT_DETECTED_OS_ENABLE) diff --git a/quantum/os_detection.h b/quantum/os_detection.h index 98a8e805e4..e9e7b25f1d 100644 --- a/quantum/os_detection.h +++ b/quantum/os_detection.h @@ -43,6 +43,9 @@ void slave_update_detected_host_os(os_variant_t os); #endif #ifdef OS_DETECTION_DEBUG_ENABLE +# if defined(DYNAMIC_KEYMAP_ENABLE) || defined(VIA_ENABLE) +# error Cannot enable OS Detection debug mode simultaneously with DYNAMIC_KEYMAP or VIA +# endif void print_stored_setups(void); void store_setups_in_eeprom(void); #endif diff --git a/quantum/painter/qff.h b/quantum/painter/qff.h index c3b831da17..ed88508d73 100644 --- a/quantum/painter/qff.h +++ b/quantum/painter/qff.h @@ -9,6 +9,7 @@ #include #include +#include "compiler_support.h" #include "qp_stream.h" #include "qp_internal.h" #include "qgf.h" @@ -36,7 +37,7 @@ typedef struct QP_PACKED qff_font_descriptor_v1_t { uint8_t transparency_index; // palette index used for transparent pixels (not yet implemented) } qff_font_descriptor_v1_t; -_Static_assert(sizeof(qff_font_descriptor_v1_t) == (sizeof(qgf_block_header_v1_t) + 20), "qff_font_descriptor_v1_t must be 25 bytes in v1 of QFF"); +STATIC_ASSERT(sizeof(qff_font_descriptor_v1_t) == (sizeof(qgf_block_header_v1_t) + 20), "qff_font_descriptor_v1_t must be 25 bytes in v1 of QFF"); #define QFF_MAGIC 0x464651 @@ -54,14 +55,14 @@ typedef struct QP_PACKED qff_ascii_glyph_v1_t { uint32_t value : 24; // Uses QFF_GLYPH_*_(BITS|MASK) as bitfield ordering is compiler-defined } qff_ascii_glyph_v1_t; -_Static_assert(sizeof(qff_ascii_glyph_v1_t) == 3, "qff_ascii_glyph_v1_t must be 3 bytes in v1 of QFF"); +STATIC_ASSERT(sizeof(qff_ascii_glyph_v1_t) == 3, "qff_ascii_glyph_v1_t must be 3 bytes in v1 of QFF"); typedef struct QP_PACKED qff_ascii_glyph_table_v1_t { qgf_block_header_v1_t header; // = { .type_id = 0x01, .neg_type_id = (~0x01), .length = 285 } qff_ascii_glyph_v1_t glyph[95]; // 95 glyphs, 0x20..0x7E } qff_ascii_glyph_table_v1_t; -_Static_assert(sizeof(qff_ascii_glyph_table_v1_t) == (sizeof(qgf_block_header_v1_t) + (95 * sizeof(qff_ascii_glyph_v1_t))), "qff_ascii_glyph_table_v1_t must be 290 bytes in v1 of QFF"); +STATIC_ASSERT(sizeof(qff_ascii_glyph_table_v1_t) == (sizeof(qgf_block_header_v1_t) + (95 * sizeof(qff_ascii_glyph_v1_t))), "qff_ascii_glyph_table_v1_t must be 290 bytes in v1 of QFF"); ///////////////////////////////////////// // Unicode glyph table descriptor @@ -73,7 +74,7 @@ typedef struct QP_PACKED qff_unicode_glyph_v1_t { uint32_t value : 24; // Uses QFF_GLYPH_*_(BITS|MASK) as bitfield ordering is compiler-defined } qff_unicode_glyph_v1_t; -_Static_assert(sizeof(qff_unicode_glyph_v1_t) == 6, "qff_unicode_glyph_v1_t must be 6 bytes in v1 of QFF"); +STATIC_ASSERT(sizeof(qff_unicode_glyph_v1_t) == 6, "qff_unicode_glyph_v1_t must be 6 bytes in v1 of QFF"); typedef struct QP_PACKED qff_unicode_glyph_table_v1_t { qgf_block_header_v1_t header; // = { .type_id = 0x02, .neg_type_id = (~0x02), .length = (N * 6) } diff --git a/quantum/painter/qgf.h b/quantum/painter/qgf.h index 33a37709e6..a1e245f15d 100644 --- a/quantum/painter/qgf.h +++ b/quantum/painter/qgf.h @@ -9,6 +9,7 @@ #include #include +#include "compiler_support.h" #include "qp_stream.h" #include "qp_internal.h" @@ -24,7 +25,7 @@ typedef struct QP_PACKED qgf_block_header_v1_t { uint32_t length : 24; // 24-bit blob length, allowing for block sizes of a maximum of 16MB. } qgf_block_header_v1_t; -_Static_assert(sizeof(qgf_block_header_v1_t) == 5, "qgf_block_header_v1_t must be 5 bytes in v1 of QGF"); +STATIC_ASSERT(sizeof(qgf_block_header_v1_t) == 5, "qgf_block_header_v1_t must be 5 bytes in v1 of QGF"); ///////////////////////////////////////// // Graphics descriptor @@ -42,7 +43,7 @@ typedef struct QP_PACKED qgf_graphics_descriptor_v1_t { uint16_t frame_count; // minimum of 1 } qgf_graphics_descriptor_v1_t; -_Static_assert(sizeof(qgf_graphics_descriptor_v1_t) == (sizeof(qgf_block_header_v1_t) + 18), "qgf_graphics_descriptor_v1_t must be 23 bytes in v1 of QGF"); +STATIC_ASSERT(sizeof(qgf_graphics_descriptor_v1_t) == (sizeof(qgf_block_header_v1_t) + 18), "qgf_graphics_descriptor_v1_t must be 23 bytes in v1 of QGF"); #define QGF_MAGIC 0x464751 @@ -56,7 +57,7 @@ typedef struct QP_PACKED qgf_frame_offsets_v1_t { uint32_t offset[0]; // '0' signifies that this struct is immediately followed by the frame offsets } qgf_frame_offsets_v1_t; -_Static_assert(sizeof(qgf_frame_offsets_v1_t) == sizeof(qgf_block_header_v1_t), "qgf_frame_offsets_v1_t must only contain qgf_block_header_v1_t in v1 of QGF"); +STATIC_ASSERT(sizeof(qgf_frame_offsets_v1_t) == sizeof(qgf_block_header_v1_t), "qgf_frame_offsets_v1_t must only contain qgf_block_header_v1_t in v1 of QGF"); ///////////////////////////////////////// // Frame descriptor @@ -72,7 +73,7 @@ typedef struct QP_PACKED qgf_frame_v1_t { uint16_t delay; // frame delay time for animations (in units of milliseconds) } qgf_frame_v1_t; -_Static_assert(sizeof(qgf_frame_v1_t) == (sizeof(qgf_block_header_v1_t) + 6), "qgf_frame_v1_t must be 11 bytes in v1 of QGF"); +STATIC_ASSERT(sizeof(qgf_frame_v1_t) == (sizeof(qgf_block_header_v1_t) + 6), "qgf_frame_v1_t must be 11 bytes in v1 of QGF"); #define QGF_FRAME_FLAG_DELTA 0x02 #define QGF_FRAME_FLAG_TRANSPARENT 0x01 @@ -88,14 +89,14 @@ typedef struct QP_PACKED qgf_palette_entry_v1_t { uint8_t v; // value component: `[0,1]` is mapped to `[0,255]` uint8_t. } qgf_palette_entry_v1_t; -_Static_assert(sizeof(qgf_palette_entry_v1_t) == 3, "Palette entry is not 3 bytes in size"); +STATIC_ASSERT(sizeof(qgf_palette_entry_v1_t) == 3, "Palette entry is not 3 bytes in size"); typedef struct QP_PACKED qgf_palette_v1_t { qgf_block_header_v1_t header; // = { .type_id = 0x03, .neg_type_id = (~0x03), .length = (N * 3 * sizeof(uint8_t)) } qgf_palette_entry_v1_t hsv[0]; // N * hsv, where N is the number of palette entries depending on the frame format in the descriptor } qgf_palette_v1_t; -_Static_assert(sizeof(qgf_palette_v1_t) == sizeof(qgf_block_header_v1_t), "qgf_palette_v1_t must only contain qgf_block_header_v1_t in v1 of QGF"); +STATIC_ASSERT(sizeof(qgf_palette_v1_t) == sizeof(qgf_block_header_v1_t), "qgf_palette_v1_t must only contain qgf_block_header_v1_t in v1 of QGF"); ///////////////////////////////////////// // Frame delta descriptor @@ -110,7 +111,7 @@ typedef struct QP_PACKED qgf_delta_v1_t { uint16_t bottom; // The bottom pixel location to to draw the delta image } qgf_delta_v1_t; -_Static_assert(sizeof(qgf_delta_v1_t) == (sizeof(qgf_block_header_v1_t) + 8), "qgf_delta_v1_t must be 13 bytes in v1 of QGF"); +STATIC_ASSERT(sizeof(qgf_delta_v1_t) == (sizeof(qgf_block_header_v1_t) + 8), "qgf_delta_v1_t must be 13 bytes in v1 of QGF"); ///////////////////////////////////////// // Frame data descriptor @@ -122,7 +123,7 @@ typedef struct QP_PACKED qgf_data_v1_t { uint8_t data[0]; // 0 signifies that this struct is immediately followed by the length of data specified in the header } qgf_data_v1_t; -_Static_assert(sizeof(qgf_data_v1_t) == sizeof(qgf_block_header_v1_t), "qgf_data_v1_t must only contain qgf_block_header_v1_t in v1 of QGF"); +STATIC_ASSERT(sizeof(qgf_data_v1_t) == sizeof(qgf_block_header_v1_t), "qgf_data_v1_t must only contain qgf_block_header_v1_t in v1 of QGF"); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // QGF API diff --git a/quantum/painter/qp_draw_core.c b/quantum/painter/qp_draw_core.c index aa5fa4aa76..852abb19e8 100644 --- a/quantum/painter/qp_draw_core.c +++ b/quantum/painter/qp_draw_core.c @@ -2,12 +2,13 @@ // Copyright 2021 Paul Cotter (@gr1mr3aver) // SPDX-License-Identifier: GPL-2.0-or-later +#include "compiler_support.h" #include "qp_internal.h" #include "qp_comms.h" #include "qp_draw.h" #include "qgf.h" -_Static_assert((QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE > 0) && (QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE % 16) == 0, "QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE needs to be a non-zero multiple of 16"); +STATIC_ASSERT((QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE > 0) && (QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE % 16) == 0, "QUANTUM_PAINTER_PIXDATA_BUFFER_SIZE needs to be a non-zero multiple of 16"); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Global variables diff --git a/quantum/painter/qp_internal.c b/quantum/painter/qp_internal.c index 24b881bd09..fe0c598d78 100644 --- a/quantum/painter/qp_internal.c +++ b/quantum/painter/qp_internal.c @@ -3,6 +3,8 @@ #include "qp_internal.h" +#include "compiler_support.h" + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Quantum Painter Core API: device registration @@ -67,7 +69,7 @@ static void qp_internal_display_timeout_task(void) { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Quantum Painter Core API: qp_internal_task -_Static_assert((QUANTUM_PAINTER_TASK_THROTTLE) > 0 && (QUANTUM_PAINTER_TASK_THROTTLE) < 1000, "QUANTUM_PAINTER_TASK_THROTTLE must be between 1 and 999"); +STATIC_ASSERT((QUANTUM_PAINTER_TASK_THROTTLE) > 0 && (QUANTUM_PAINTER_TASK_THROTTLE) < 1000, "QUANTUM_PAINTER_TASK_THROTTLE must be between 1 and 999"); void qp_internal_task(void) { // Perform throttling of the internal processing of Quantum Painter diff --git a/quantum/painter/qp_internal_formats.h b/quantum/painter/qp_internal_formats.h index 1beb604b9e..bd7105cab2 100644 --- a/quantum/painter/qp_internal_formats.h +++ b/quantum/painter/qp_internal_formats.h @@ -3,6 +3,7 @@ #pragma once +#include "compiler_support.h" #include "qp_internal.h" //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -29,7 +30,7 @@ typedef union QP_PACKED qp_pixel_t { uint32_t dummy; } qp_pixel_t; -_Static_assert(sizeof(qp_pixel_t) == 4, "Invalid size for qp_pixel_t"); +STATIC_ASSERT(sizeof(qp_pixel_t) == 4, "Invalid size for qp_pixel_t"); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Quantum Painter image format diff --git a/quantum/pointing_device/pointing_device.c b/quantum/pointing_device/pointing_device.c index 5ddaf0d394..44bb412b1a 100644 --- a/quantum/pointing_device/pointing_device.c +++ b/quantum/pointing_device/pointing_device.c @@ -25,6 +25,10 @@ # include "mousekey.h" #endif +#ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE +# include "usb_descriptor_common.h" +#endif + #if (defined(POINTING_DEVICE_ROTATION_90) + defined(POINTING_DEVICE_ROTATION_180) + defined(POINTING_DEVICE_ROTATION_270)) > 1 # error More than one rotation selected. This is not supported. #endif @@ -78,6 +82,9 @@ uint16_t pointing_device_get_shared_cpi(void) { static report_mouse_t local_mouse_report = {}; static bool pointing_device_force_send = false; +#ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE +static uint16_t hires_scroll_resolution; +#endif #define POINTING_DEVICE_DRIVER_CONCAT(name) name##_pointing_device_driver #define POINTING_DEVICE_DRIVER(name) POINTING_DEVICE_DRIVER_CONCAT(name) @@ -181,6 +188,12 @@ __attribute__((weak)) void pointing_device_init(void) { # endif #endif } +#ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE + hires_scroll_resolution = POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER; + for (int i = 0; i < POINTING_DEVICE_HIRES_SCROLL_EXPONENT; i++) { + hires_scroll_resolution *= 10; + } +#endif pointing_device_init_modules(); pointing_device_init_kb(); @@ -315,6 +328,8 @@ __attribute__((weak)) bool pointing_device_task(void) { local_mouse_report = pointing_device_task_modules(local_mouse_report); local_mouse_report = pointing_device_task_kb(local_mouse_report); #endif + local_mouse_report = pointing_device_task_modules(local_mouse_report); + local_mouse_report = pointing_device_task_kb(local_mouse_report); // automatic mouse layer function #ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE pointing_device_task_auto_mouse(local_mouse_report); @@ -411,10 +426,10 @@ void pointing_device_set_cpi_on_side(bool left, uint16_t cpi) { * @return mouse_hv_report_t clamped value */ static inline mouse_hv_report_t pointing_device_hv_clamp(hv_clamp_range_t value) { - if (value < HV_REPORT_MIN) { - return HV_REPORT_MIN; - } else if (value > HV_REPORT_MAX) { - return HV_REPORT_MAX; + if (value < MOUSE_REPORT_HV_MIN) { + return MOUSE_REPORT_HV_MIN; + } else if (value > MOUSE_REPORT_HV_MAX) { + return MOUSE_REPORT_HV_MAX; } else { return value; } @@ -427,10 +442,10 @@ static inline mouse_hv_report_t pointing_device_hv_clamp(hv_clamp_range_t value) * @return mouse_xy_report_t clamped value */ static inline mouse_xy_report_t pointing_device_xy_clamp(xy_clamp_range_t value) { - if (value < XY_REPORT_MIN) { - return XY_REPORT_MIN; - } else if (value > XY_REPORT_MAX) { - return XY_REPORT_MAX; + if (value < MOUSE_REPORT_XY_MIN) { + return MOUSE_REPORT_XY_MIN; + } else if (value > MOUSE_REPORT_XY_MAX) { + return MOUSE_REPORT_XY_MAX; } else { return value; } @@ -545,3 +560,9 @@ __attribute__((weak)) void pointing_device_keycode_handler(uint16_t keycode, boo pointing_device_send(); } } + +#ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE +uint16_t pointing_device_get_hires_scroll_resolution(void) { + return hires_scroll_resolution; +} +#endif \ No newline at end of file diff --git a/quantum/pointing_device/pointing_device.h b/quantum/pointing_device/pointing_device.h index fada02331a..1559645619 100644 --- a/quantum/pointing_device/pointing_device.h +++ b/quantum/pointing_device/pointing_device.h @@ -93,27 +93,19 @@ typedef enum { } pointing_device_buttons_t; #ifdef MOUSE_EXTENDED_REPORT -# define XY_REPORT_MIN INT16_MIN -# define XY_REPORT_MAX INT16_MAX typedef int32_t xy_clamp_range_t; #else -# define XY_REPORT_MIN INT8_MIN -# define XY_REPORT_MAX INT8_MAX typedef int16_t xy_clamp_range_t; #endif #ifdef WHEEL_EXTENDED_REPORT -# define HV_REPORT_MIN INT16_MIN -# define HV_REPORT_MAX INT16_MAX typedef int32_t hv_clamp_range_t; #else -# define HV_REPORT_MIN INT8_MIN -# define HV_REPORT_MAX INT8_MAX typedef int16_t hv_clamp_range_t; #endif #define CONSTRAIN_HID(amt) ((amt) < INT8_MIN ? INT8_MIN : ((amt) > INT8_MAX ? INT8_MAX : (amt))) -#define CONSTRAIN_HID_XY(amt) ((amt) < XY_REPORT_MIN ? XY_REPORT_MIN : ((amt) > XY_REPORT_MAX ? XY_REPORT_MAX : (amt))) +#define CONSTRAIN_HID_XY(amt) ((amt) < MOUSE_REPORT_XY_MIN ? MOUSE_REPORT_XY_MIN : ((amt) > MOUSE_REPORT_XY_MAX ? MOUSE_REPORT_XY_MAX : (amt))) void pointing_device_init(void); bool pointing_device_task(void); @@ -131,6 +123,10 @@ uint8_t pointing_device_handle_buttons(uint8_t buttons, bool pressed, poi report_mouse_t pointing_device_adjust_by_defines(report_mouse_t mouse_report); void pointing_device_keycode_handler(uint16_t keycode, bool pressed); +#ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE +uint16_t pointing_device_get_hires_scroll_resolution(void); +#endif + #if defined(SPLIT_POINTING_ENABLE) void pointing_device_set_shared_report(report_mouse_t report); uint16_t pointing_device_get_shared_cpi(void); diff --git a/quantum/process_keycode/process_autocorrect.c b/quantum/process_keycode/process_autocorrect.c index b7f9132acf..0cde520778 100644 --- a/quantum/process_keycode/process_autocorrect.c +++ b/quantum/process_keycode/process_autocorrect.c @@ -38,7 +38,7 @@ bool autocorrect_is_enabled(void) { */ void autocorrect_enable(void) { keymap_config.autocorrect_enable = true; - eeconfig_update_keymap(keymap_config.raw); + eeconfig_update_keymap(&keymap_config); } /** @@ -48,7 +48,7 @@ void autocorrect_enable(void) { void autocorrect_disable(void) { keymap_config.autocorrect_enable = false; typo_buffer_size = 0; - eeconfig_update_keymap(keymap_config.raw); + eeconfig_update_keymap(&keymap_config); } /** @@ -58,7 +58,7 @@ void autocorrect_disable(void) { void autocorrect_toggle(void) { keymap_config.autocorrect_enable = !keymap_config.autocorrect_enable; typo_buffer_size = 0; - eeconfig_update_keymap(keymap_config.raw); + eeconfig_update_keymap(&keymap_config); } /** diff --git a/quantum/process_keycode/process_caps_word.c b/quantum/process_keycode/process_caps_word.c index b8fb868c6d..8ab66cc521 100644 --- a/quantum/process_keycode/process_caps_word.c +++ b/quantum/process_keycode/process_caps_word.c @@ -160,8 +160,13 @@ bool process_caps_word(uint16_t keycode, keyrecord_t* record) { case QK_TOGGLE_LAYER ... QK_TOGGLE_LAYER_MAX: case QK_LAYER_TAP_TOGGLE ... QK_LAYER_TAP_TOGGLE_MAX: case QK_ONE_SHOT_LAYER ... QK_ONE_SHOT_LAYER_MAX: +#ifdef TRI_LAYER_ENABLE // Ignore Tri Layer keys. case QK_TRI_LAYER_LOWER ... QK_TRI_LAYER_UPPER: - // Ignore AltGr. +#endif // TRI_LAYER_ENABLE +#ifdef LAYER_LOCK_ENABLE // Ignore Layer Lock key. + case QK_LAYER_LOCK: +#endif // LAYER_LOCK_ENABLE + // Ignore AltGr. case KC_RALT: case OSM(MOD_RALT): return true; diff --git a/quantum/process_keycode/process_clicky.c b/quantum/process_keycode/process_clicky.c index 82000db9b3..f50761268a 100644 --- a/quantum/process_keycode/process_clicky.c +++ b/quantum/process_keycode/process_clicky.c @@ -66,17 +66,17 @@ void clicky_freq_reset(void) { void clicky_toggle(void) { audio_config.clicky_enable ^= 1; - eeconfig_update_audio(audio_config.raw); + eeconfig_update_audio(&audio_config); } void clicky_on(void) { audio_config.clicky_enable = 1; - eeconfig_update_audio(audio_config.raw); + eeconfig_update_audio(&audio_config); } void clicky_off(void) { audio_config.clicky_enable = 0; - eeconfig_update_audio(audio_config.raw); + eeconfig_update_audio(&audio_config); } bool is_clicky_on(void) { diff --git a/quantum/process_keycode/process_connection.c b/quantum/process_keycode/process_connection.c index b0e230d680..501529ede7 100644 --- a/quantum/process_keycode/process_connection.c +++ b/quantum/process_keycode/process_connection.c @@ -1,24 +1,34 @@ // Copyright 2024 Nick Brassel (@tzarc) // SPDX-License-Identifier: GPL-2.0-or-later -#include "outputselect.h" +#include "connection.h" #include "process_connection.h" bool process_connection(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { switch (keycode) { case QK_OUTPUT_NEXT: - set_output(OUTPUT_AUTO); // This should cycle through the outputs going forward. Ensure `docs/keycodes.md`, `docs/features/bluetooth.md` are updated when it does. + connection_next_host(); return false; - case QK_OUTPUT_USB: - set_output(OUTPUT_USB); - return false; - case QK_OUTPUT_BLUETOOTH: - set_output(OUTPUT_BLUETOOTH); + case QK_OUTPUT_PREV: + connection_prev_host(); return false; - case QK_OUTPUT_PREV: + case QK_OUTPUT_AUTO: + connection_set_host(CONNECTION_HOST_AUTO); + return false; case QK_OUTPUT_NONE: + connection_set_host(CONNECTION_HOST_NONE); + return false; + case QK_OUTPUT_USB: + connection_set_host(CONNECTION_HOST_USB); + return false; + case QK_OUTPUT_BLUETOOTH: + connection_set_host(CONNECTION_HOST_BLUETOOTH); + return false; case QK_OUTPUT_2P4GHZ: + connection_set_host(CONNECTION_HOST_2P4GHZ); + return false; + case QK_BLUETOOTH_PROFILE_NEXT: case QK_BLUETOOTH_PROFILE_PREV: case QK_BLUETOOTH_UNPAIR: diff --git a/quantum/process_keycode/process_leader.c b/quantum/process_keycode/process_leader.c index ca017a577d..a5466c513c 100644 --- a/quantum/process_keycode/process_leader.c +++ b/quantum/process_keycode/process_leader.c @@ -22,11 +22,7 @@ bool process_leader(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { if (leader_sequence_active() && !leader_sequence_timed_out()) { #ifndef LEADER_KEY_STRICT_KEY_PROCESSING - if (IS_QK_MOD_TAP(keycode)) { - keycode = QK_MOD_TAP_GET_TAP_KEYCODE(keycode); - } else if (IS_QK_LAYER_TAP(keycode)) { - keycode = QK_LAYER_TAP_GET_TAP_KEYCODE(keycode); - } + keycode = get_tap_keycode(keycode); #endif if (!leader_sequence_add(keycode)) { diff --git a/quantum/process_keycode/process_magic.c b/quantum/process_keycode/process_magic.c index 3b35884d68..d5280105de 100644 --- a/quantum/process_keycode/process_magic.c +++ b/quantum/process_keycode/process_magic.c @@ -47,7 +47,7 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { if (IS_MAGIC_KEYCODE(keycode)) { /* keymap config */ - keymap_config.raw = eeconfig_read_keymap(); + eeconfig_read_keymap(&keymap_config); switch (keycode) { case QK_MAGIC_SWAP_CONTROL_CAPS_LOCK: keymap_config.swap_control_capslock = true; @@ -187,7 +187,7 @@ bool process_magic(uint16_t keycode, keyrecord_t *record) { break; } - eeconfig_update_keymap(keymap_config.raw); + eeconfig_update_keymap(&keymap_config); clear_keyboard(); // clear to prevent stuck keys return false; diff --git a/quantum/process_keycode/process_repeat_key.c b/quantum/process_keycode/process_repeat_key.c index 73f4ddedcf..fdeed4f466 100644 --- a/quantum/process_keycode/process_repeat_key.c +++ b/quantum/process_keycode/process_repeat_key.c @@ -41,7 +41,10 @@ static bool remember_last_key(uint16_t keycode, keyrecord_t* record, uint8_t* re #ifdef TRI_LAYER_ENABLE // Ignore Tri Layer keys. case QK_TRI_LAYER_LOWER: case QK_TRI_LAYER_UPPER: -#endif // TRI_LAYER_ENABLE +#endif // TRI_LAYER_ENABLE +#ifdef LAYER_LOCK_ENABLE // Ignore Layer Lock key. + case QK_LAYER_LOCK: +#endif // LAYER_LOCK_ENABLE return false; // Ignore hold events on tap-hold keys. diff --git a/quantum/process_keycode/process_steno.c b/quantum/process_keycode/process_steno.c index c491d6f1d8..4789461352 100644 --- a/quantum/process_keycode/process_steno.c +++ b/quantum/process_keycode/process_steno.c @@ -20,9 +20,6 @@ #ifdef VIRTSER_ENABLE # include "virtser.h" #endif -#ifdef STENO_ENABLE_ALL -# include "eeprom.h" -#endif // All steno keys that have been pressed to form this chord, // stored in MAX_STROKE_SIZE groups of 8-bit arrays. @@ -128,13 +125,13 @@ static const uint16_t combinedmap_second[] PROGMEM = {STN_S2, STN_KL, STN_WL, ST #ifdef STENO_ENABLE_ALL void steno_init(void) { - mode = eeprom_read_byte(EECONFIG_STENOMODE); + mode = eeconfig_read_steno_mode(); } void steno_set_mode(steno_mode_t new_mode) { steno_clear_chord(); mode = new_mode; - eeprom_update_byte(EECONFIG_STENOMODE, mode); + eeconfig_update_steno_mode(mode); } #endif // STENO_ENABLE_ALL diff --git a/quantum/quantum.c b/quantum/quantum.c index d60cd9440e..0eae3caa78 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -20,7 +20,7 @@ # include "process_backlight.h" #endif -#ifdef BLUETOOTH_ENABLE +#ifdef CONNECTION_ENABLE # include "process_connection.h" #endif @@ -437,7 +437,7 @@ bool process_record_quantum(keyrecord_t *record) { #ifdef LAYER_LOCK_ENABLE process_layer_lock(keycode, record) && #endif -#ifdef BLUETOOTH_ENABLE +#ifdef CONNECTION_ENABLE process_connection(keycode, record) && #endif true)) { diff --git a/quantum/quantum.h b/quantum/quantum.h index d51cb5229a..a7ac1c874a 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h @@ -39,6 +39,7 @@ #include "keymap_common.h" #include "quantum_keycodes.h" #include "keycode_config.h" +#include "keycode_string.h" #include "action_layer.h" #include "eeconfig.h" #include "bootloader.h" diff --git a/quantum/raw_hid.c b/quantum/raw_hid.c new file mode 100644 index 0000000000..2c7a75f325 --- /dev/null +++ b/quantum/raw_hid.c @@ -0,0 +1,15 @@ +// Copyright 2025 QMK +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "raw_hid.h" +#include "host.h" + +void raw_hid_send(uint8_t *data, uint8_t length) { + host_raw_hid_send(data, length); +} + +__attribute__((weak)) void raw_hid_receive(uint8_t *data, uint8_t length) { + // Users should #include "raw_hid.h" in their own code + // and implement this function there. Leave this as weak linkage + // so users can opt to not handle data coming in. +} diff --git a/quantum/rgb_matrix/animations/pixel_flow_anim.h b/quantum/rgb_matrix/animations/pixel_flow_anim.h index 35170f9588..44b4b5c481 100644 --- a/quantum/rgb_matrix/animations/pixel_flow_anim.h +++ b/quantum/rgb_matrix/animations/pixel_flow_anim.h @@ -22,7 +22,7 @@ static bool PIXEL_FLOW(effect_params_t* params) { // Clear LEDs and fill the state array rgb_matrix_set_color_all(0, 0, 0); for (uint8_t j = 0; j < RGB_MATRIX_LED_COUNT; ++j) { - led[j] = (random8() & 2) ? (rgb_t){0, 0, 0} : hsv_to_rgb((hsv_t){random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v}); + led[j] = (random8() & 2) ? (rgb_t){0, 0, 0} : rgb_matrix_hsv_to_rgb((hsv_t){random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v}); } } @@ -39,7 +39,7 @@ static bool PIXEL_FLOW(effect_params_t* params) { led[j] = led[j + 1]; } // Fill last LED - led[led_max - 1] = (random8() & 2) ? (rgb_t){0, 0, 0} : hsv_to_rgb((hsv_t){random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v}); + led[led_max - 1] = (random8() & 2) ? (rgb_t){0, 0, 0} : rgb_matrix_hsv_to_rgb((hsv_t){random8(), random8_min_max(127, 255), rgb_matrix_config.hsv.v}); // Set pulse timer wait_timer = g_rgb_timer + interval(); } diff --git a/quantum/rgb_matrix/animations/rgb_matrix_effects.inc b/quantum/rgb_matrix/animations/rgb_matrix_effects.inc index a02238a2d1..abc2adf2cc 100644 --- a/quantum/rgb_matrix/animations/rgb_matrix_effects.inc +++ b/quantum/rgb_matrix/animations/rgb_matrix_effects.inc @@ -39,7 +39,8 @@ #include "solid_reactive_nexus.h" #include "splash_anim.h" #include "solid_splash_anim.h" +#include "starlight_smooth_anim.h" #include "starlight_anim.h" #include "starlight_dual_sat_anim.h" #include "starlight_dual_hue_anim.h" -#include "riverflow_anim.h" \ No newline at end of file +#include "riverflow_anim.h" diff --git a/quantum/rgb_matrix/animations/starlight_smooth_anim.h b/quantum/rgb_matrix/animations/starlight_smooth_anim.h new file mode 100644 index 0000000000..a87c06f9df --- /dev/null +++ b/quantum/rgb_matrix/animations/starlight_smooth_anim.h @@ -0,0 +1,26 @@ +// Copyright 2022 @art-was-here +// SPDX-License-Identifier: GPL-2.0+ + +#ifdef ENABLE_RGB_MATRIX_STARLIGHT_SMOOTH +RGB_MATRIX_EFFECT(STARLIGHT_SMOOTH) +# ifdef RGB_MATRIX_CUSTOM_EFFECT_IMPLS + +static uint8_t phase_offsets[RGB_MATRIX_LED_COUNT]; + +hsv_t STARLIGHT_SMOOTH_math(hsv_t hsv, uint8_t i, uint8_t time) { + if (phase_offsets[i] == 0) { + phase_offsets[i] = rand() % 255; + } + hsv.v = scale8(abs8(sin8((time + phase_offsets[i]) / 2) - 128) * 2, hsv.v); + return hsv; +} + +bool STARLIGHT_SMOOTH(effect_params_t* params) { + if (params->init) { + memset(phase_offsets, 0, sizeof(phase_offsets)); + } + return effect_runner_i(params, &STARLIGHT_SMOOTH_math); +} + +# endif // RGB_MATRIX_CUSTOM_EFFECT_IMPLS +#endif // ENABLE_RGB_MATRIX_STARLIGHT_SMOOTH diff --git a/quantum/rgb_matrix/rgb_matrix.c b/quantum/rgb_matrix/rgb_matrix.c index 6271b837a4..2679c48342 100644 --- a/quantum/rgb_matrix/rgb_matrix.c +++ b/quantum/rgb_matrix/rgb_matrix.c @@ -18,7 +18,6 @@ #include "rgb_matrix.h" #include "progmem.h" -#include "eeprom.h" #include "eeconfig.h" #include "keyboard.h" #include "sync_timer.h" @@ -48,6 +47,9 @@ __attribute__((weak)) rgb_t rgb_matrix_hsv_to_rgb(hsv_t hsv) { #define RGB_MATRIX_CUSTOM_EFFECT_IMPLS #include "rgb_matrix_effects.inc" +#ifdef COMMUNITY_MODULES_ENABLE +# include "rgb_matrix_community_modules.inc" +#endif #ifdef RGB_MATRIX_CUSTOM_KB # include "rgb_matrix_kb.inc" #endif @@ -88,9 +90,9 @@ static last_hit_t last_hit_buffer; const uint8_t k_rgb_matrix_split[2] = RGB_MATRIX_SPLIT; #endif -EECONFIG_DEBOUNCE_HELPER(rgb_matrix, EECONFIG_RGB_MATRIX, rgb_matrix_config); +EECONFIG_DEBOUNCE_HELPER(rgb_matrix, rgb_matrix_config); -void eeconfig_update_rgb_matrix(void) { +void eeconfig_force_flush_rgb_matrix(void) { eeconfig_flush_rgb_matrix(true); } @@ -311,6 +313,15 @@ static void rgb_task_render(uint8_t effect) { #include "rgb_matrix_effects.inc" #undef RGB_MATRIX_EFFECT +#ifdef COMMUNITY_MODULES_ENABLE +# define RGB_MATRIX_EFFECT(name, ...) \ + case RGB_MATRIX_COMMUNITY_MODULE_##name: \ + rendering = name(&rgb_effect_params); \ + break; +# include "rgb_matrix_community_modules.inc" +# undef RGB_MATRIX_EFFECT +#endif + #if defined(RGB_MATRIX_CUSTOM_KB) || defined(RGB_MATRIX_CUSTOM_USER) # define RGB_MATRIX_EFFECT(name, ...) \ case RGB_MATRIX_CUSTOM_##name: \ diff --git a/quantum/rgb_matrix/rgb_matrix.h b/quantum/rgb_matrix/rgb_matrix.h index 33f7e06a63..c6b302631e 100644 --- a/quantum/rgb_matrix/rgb_matrix.h +++ b/quantum/rgb_matrix/rgb_matrix.h @@ -123,6 +123,12 @@ enum rgb_matrix_effects { #include "rgb_matrix_effects.inc" #undef RGB_MATRIX_EFFECT +#ifdef COMMUNITY_MODULES_ENABLE +# define RGB_MATRIX_EFFECT(name, ...) RGB_MATRIX_COMMUNITY_MODULE_##name, +# include "rgb_matrix_community_modules.inc" +# undef RGB_MATRIX_EFFECT +#endif + #if defined(RGB_MATRIX_CUSTOM_KB) || defined(RGB_MATRIX_CUSTOM_USER) # define RGB_MATRIX_EFFECT(name, ...) RGB_MATRIX_CUSTOM_##name, # ifdef RGB_MATRIX_CUSTOM_KB @@ -140,7 +146,7 @@ enum rgb_matrix_effects { }; void eeconfig_update_rgb_matrix_default(void); -void eeconfig_update_rgb_matrix(void); +void eeconfig_force_flush_rgb_matrix(void); uint8_t rgb_matrix_map_row_column_to_led_kb(uint8_t row, uint8_t column, uint8_t *led_i); uint8_t rgb_matrix_map_row_column_to_led(uint8_t row, uint8_t column, uint8_t *led_i); @@ -215,7 +221,7 @@ void rgb_matrix_set_flags_noeeprom(led_flags_t flags); void rgb_matrix_update_pwm_buffers(void); #ifndef RGBLIGHT_ENABLE -# define eeconfig_update_rgblight_current eeconfig_update_rgb_matrix +# define eeconfig_update_rgblight_current eeconfig_force_flush_rgb_matrix # define rgblight_reload_from_eeprom rgb_matrix_reload_from_eeprom # define rgblight_toggle rgb_matrix_toggle # define rgblight_toggle_noeeprom rgb_matrix_toggle_noeeprom diff --git a/quantum/rgb_matrix/rgb_matrix_types.h b/quantum/rgb_matrix/rgb_matrix_types.h index 0834a7067c..0115edee6a 100644 --- a/quantum/rgb_matrix/rgb_matrix_types.h +++ b/quantum/rgb_matrix/rgb_matrix_types.h @@ -18,6 +18,8 @@ #include #include + +#include "compiler_support.h" #include "color.h" #include "util.h" @@ -73,7 +75,7 @@ typedef struct PACKED { uint8_t flags[RGB_MATRIX_LED_COUNT]; } led_config_t; -typedef union { +typedef union rgb_config_t { uint64_t raw; struct PACKED { uint8_t enable : 2; @@ -84,4 +86,4 @@ typedef union { }; } rgb_config_t; -_Static_assert(sizeof(rgb_config_t) == sizeof(uint64_t), "RGB Matrix EECONFIG out of spec."); +STATIC_ASSERT(sizeof(rgb_config_t) == sizeof(uint64_t), "RGB Matrix EECONFIG out of spec."); diff --git a/quantum/rgblight/rgblight.c b/quantum/rgblight/rgblight.c index ddccc9bae3..bfccb472b5 100644 --- a/quantum/rgblight/rgblight.c +++ b/quantum/rgblight/rgblight.c @@ -24,9 +24,7 @@ #include "util.h" #include "led_tables.h" #include -#ifdef EEPROM_ENABLE -# include "eeprom.h" -#endif +#include "eeconfig.h" #ifdef RGBLIGHT_SPLIT /* for split keyboard */ @@ -176,24 +174,9 @@ void rgblight_check_config(void) { } } -uint64_t eeconfig_read_rgblight(void) { -#ifdef EEPROM_ENABLE - return (uint64_t)((eeprom_read_dword(EECONFIG_RGBLIGHT)) | ((uint64_t)eeprom_read_byte(EECONFIG_RGBLIGHT_EXTENDED) << 32)); -#else - return 0; -#endif -} - -void eeconfig_update_rgblight(uint64_t val) { -#ifdef EEPROM_ENABLE - rgblight_check_config(); - eeprom_update_dword(EECONFIG_RGBLIGHT, val & 0xFFFFFFFF); - eeprom_update_byte(EECONFIG_RGBLIGHT_EXTENDED, (val >> 32) & 0xFF); -#endif -} - void eeconfig_update_rgblight_current(void) { - eeconfig_update_rgblight(rgblight_config.raw); + rgblight_check_config(); + eeconfig_update_rgblight(&rgblight_config); } void eeconfig_update_rgblight_default(void) { @@ -205,7 +188,7 @@ void eeconfig_update_rgblight_default(void) { rgblight_config.val = RGBLIGHT_DEFAULT_VAL; rgblight_config.speed = RGBLIGHT_DEFAULT_SPD; RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS; - eeconfig_update_rgblight(rgblight_config.raw); + eeconfig_update_rgblight(&rgblight_config); } void eeconfig_debug_rgblight(void) { @@ -228,12 +211,12 @@ void rgblight_init(void) { } dprintf("rgblight_init start!\n"); - rgblight_config.raw = eeconfig_read_rgblight(); + eeconfig_read_rgblight(&rgblight_config); RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS; if (!rgblight_config.mode) { dprintf("rgblight_init rgblight_config.mode = 0. Write default values to EEPROM.\n"); eeconfig_update_rgblight_default(); - rgblight_config.raw = eeconfig_read_rgblight(); + eeconfig_read_rgblight(&rgblight_config); } rgblight_check_config(); @@ -252,7 +235,7 @@ void rgblight_init(void) { void rgblight_reload_from_eeprom(void) { /* Reset back to what we have in eeprom */ - rgblight_config.raw = eeconfig_read_rgblight(); + eeconfig_read_rgblight(&rgblight_config); RGBLIGHT_SPLIT_SET_CHANGE_MODEHSVS; rgblight_check_config(); eeconfig_debug_rgblight(); // display current eeprom values @@ -341,7 +324,7 @@ void rgblight_mode_eeprom_helper(uint8_t mode, bool write_to_eeprom) { } RGBLIGHT_SPLIT_SET_CHANGE_MODE; if (write_to_eeprom) { - eeconfig_update_rgblight(rgblight_config.raw); + eeconfig_update_rgblight(&rgblight_config); dprintf("rgblight mode [EEPROM]: %u\n", rgblight_config.mode); } else { dprintf("rgblight mode [NOEEPROM]: %u\n", rgblight_config.mode); @@ -386,7 +369,7 @@ void rgblight_toggle_noeeprom(void) { void rgblight_enable(void) { rgblight_config.enable = 1; // No need to update EEPROM here. rgblight_mode() will do that, actually - // eeconfig_update_rgblight(rgblight_config.raw); + // eeconfig_update_rgblight(&rgblight_config); dprintf("rgblight enable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); rgblight_mode(rgblight_config.mode); } @@ -399,7 +382,7 @@ void rgblight_enable_noeeprom(void) { void rgblight_disable(void) { rgblight_config.enable = 0; - eeconfig_update_rgblight(rgblight_config.raw); + eeconfig_update_rgblight(&rgblight_config); dprintf("rgblight disable [EEPROM]: rgblight_config.enable = %u\n", rgblight_config.enable); rgblight_timer_disable(); RGBLIGHT_SPLIT_SET_CHANGE_MODE; @@ -487,7 +470,7 @@ void rgblight_increase_speed_helper(bool write_to_eeprom) { if (rgblight_config.speed < 3) rgblight_config.speed++; // RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED? if (write_to_eeprom) { - eeconfig_update_rgblight(rgblight_config.raw); + eeconfig_update_rgblight(&rgblight_config); } } void rgblight_increase_speed(void) { @@ -501,7 +484,7 @@ void rgblight_decrease_speed_helper(bool write_to_eeprom) { if (rgblight_config.speed > 0) rgblight_config.speed--; // RGBLIGHT_SPLIT_SET_CHANGE_HSVS; // NEED?? if (write_to_eeprom) { - eeconfig_update_rgblight(rgblight_config.raw); + eeconfig_update_rgblight(&rgblight_config); } } void rgblight_decrease_speed(void) { @@ -513,7 +496,7 @@ void rgblight_decrease_speed_noeeprom(void) { void rgblight_sethsv_noeeprom_old(uint8_t hue, uint8_t sat, uint8_t val) { if (rgblight_config.enable) { - rgb_t rgb = hsv_to_rgb((hsv_t){hue, sat, val > RGBLIGHT_LIMIT_VAL ? RGBLIGHT_LIMIT_VAL : val}); + rgb_t rgb = rgblight_hsv_to_rgb((hsv_t){hue, sat, val > RGBLIGHT_LIMIT_VAL ? RGBLIGHT_LIMIT_VAL : val}); rgblight_setrgb(rgb.r, rgb.g, rgb.b); } } @@ -532,7 +515,7 @@ void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool w // needed for rgblight_layers_write() to get the new val, since it reads rgblight_config.val rgblight_config.val = val; #endif - rgb_t rgb = hsv_to_rgb((hsv_t){hue, sat, val > RGBLIGHT_LIMIT_VAL ? RGBLIGHT_LIMIT_VAL : val}); + rgb_t rgb = rgblight_hsv_to_rgb((hsv_t){hue, sat, val > RGBLIGHT_LIMIT_VAL ? RGBLIGHT_LIMIT_VAL : val}); rgblight_setrgb(rgb.r, rgb.g, rgb.b); } else { // all LEDs in same color @@ -585,7 +568,7 @@ void rgblight_sethsv_eeprom_helper(uint8_t hue, uint8_t sat, uint8_t val, bool w rgblight_config.sat = sat; rgblight_config.val = val; if (write_to_eeprom) { - eeconfig_update_rgblight(rgblight_config.raw); + eeconfig_update_rgblight(&rgblight_config); dprintf("rgblight set hsv [EEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val); } else { dprintf("rgblight set hsv [NOEEPROM]: %u,%u,%u\n", rgblight_config.hue, rgblight_config.sat, rgblight_config.val); @@ -608,7 +591,7 @@ uint8_t rgblight_get_speed(void) { void rgblight_set_speed_eeprom_helper(uint8_t speed, bool write_to_eeprom) { rgblight_config.speed = speed; if (write_to_eeprom) { - eeconfig_update_rgblight(rgblight_config.raw); + eeconfig_update_rgblight(&rgblight_config); dprintf("rgblight set speed [EEPROM]: %u\n", rgblight_config.speed); } else { dprintf("rgblight set speed [NOEEPROM]: %u\n", rgblight_config.speed); @@ -664,7 +647,7 @@ void rgblight_sethsv_at(uint8_t hue, uint8_t sat, uint8_t val, uint8_t index) { return; } - rgb_t rgb = hsv_to_rgb((hsv_t){hue, sat, val > RGBLIGHT_LIMIT_VAL ? RGBLIGHT_LIMIT_VAL : val}); + rgb_t rgb = rgblight_hsv_to_rgb((hsv_t){hue, sat, val > RGBLIGHT_LIMIT_VAL ? RGBLIGHT_LIMIT_VAL : val}); rgblight_setrgb_at(rgb.r, rgb.g, rgb.b, index); } @@ -696,7 +679,7 @@ void rgblight_sethsv_range(uint8_t hue, uint8_t sat, uint8_t val, uint8_t start, return; } - rgb_t rgb = hsv_to_rgb((hsv_t){hue, sat, val > RGBLIGHT_LIMIT_VAL ? RGBLIGHT_LIMIT_VAL : val}); + rgb_t rgb = rgblight_hsv_to_rgb((hsv_t){hue, sat, val > RGBLIGHT_LIMIT_VAL ? RGBLIGHT_LIMIT_VAL : val}); rgblight_setrgb_range(rgb.r, rgb.g, rgb.b, start, end); } diff --git a/quantum/rgblight/rgblight.h b/quantum/rgblight/rgblight.h index f4b6e621e4..c061e71895 100644 --- a/quantum/rgblight/rgblight.h +++ b/quantum/rgblight/rgblight.h @@ -16,6 +16,8 @@ #pragma once +#include "compiler_support.h" + // DEPRECATED DEFINES - DO NOT USE #if defined(RGBLED_NUM) # define RGBLIGHT_LED_COUNT RGBLED_NUM @@ -168,7 +170,6 @@ enum RGBLIGHT_EFFECT_MODE { #include #include "rgblight_drivers.h" #include "progmem.h" -#include "eeconfig.h" #include "color.h" #ifdef RGBLIGHT_LAYERS @@ -248,7 +249,7 @@ extern const uint16_t RGBLED_RGBTEST_INTERVALS[1] PROGMEM; extern const uint8_t RGBLED_TWINKLE_INTERVALS[3] PROGMEM; extern bool is_rgblight_initialized; -typedef union { +typedef union rgblight_config_t { uint64_t raw; struct { bool enable : 1; @@ -261,7 +262,7 @@ typedef union { }; } rgblight_config_t; -_Static_assert(sizeof(rgblight_config_t) == sizeof(uint64_t), "RGB Light EECONFIG out of spec."); +STATIC_ASSERT(sizeof(rgblight_config_t) == sizeof(uint64_t), "RGB Light EECONFIG out of spec."); typedef struct _rgblight_status_t { uint8_t base_mode; @@ -370,8 +371,6 @@ void rgblight_suspend(void); void rgblight_wakeup(void); uint64_t rgblight_read_qword(void); void rgblight_update_qword(uint64_t qword); -uint64_t eeconfig_read_rgblight(void); -void eeconfig_update_rgblight(uint64_t val); void eeconfig_update_rgblight_current(void); void eeconfig_update_rgblight_default(void); void eeconfig_debug_rgblight(void); diff --git a/quantum/split_common/split_util.c b/quantum/split_common/split_util.c index 9af3c29d75..59b6009ec4 100644 --- a/quantum/split_common/split_util.c +++ b/quantum/split_common/split_util.c @@ -13,6 +13,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + +#include "compiler_support.h" #include "split_util.h" #include "matrix.h" #include "keyboard.h" @@ -62,7 +64,7 @@ static struct { } split_config; #if defined(SPLIT_USB_DETECT) -_Static_assert((SPLIT_USB_TIMEOUT / SPLIT_USB_TIMEOUT_POLL) <= UINT16_MAX, "Please lower SPLIT_USB_TIMEOUT and/or increase SPLIT_USB_TIMEOUT_POLL."); +STATIC_ASSERT((SPLIT_USB_TIMEOUT / SPLIT_USB_TIMEOUT_POLL) <= UINT16_MAX, "Please lower SPLIT_USB_TIMEOUT and/or increase SPLIT_USB_TIMEOUT_POLL."); static bool usb_bus_detected(void) { for (uint16_t i = 0; i < (SPLIT_USB_TIMEOUT / SPLIT_USB_TIMEOUT_POLL); i++) { // This will return true if a USB connection has been established @@ -88,9 +90,9 @@ static inline bool usb_bus_detected(void) { # endif # endif # if defined(SPLIT_USB_DETECT) -_Static_assert(SPLIT_USB_TIMEOUT < SPLIT_WATCHDOG_TIMEOUT, "SPLIT_WATCHDOG_TIMEOUT should not be below SPLIT_USB_TIMEOUT."); +STATIC_ASSERT(SPLIT_USB_TIMEOUT < SPLIT_WATCHDOG_TIMEOUT, "SPLIT_WATCHDOG_TIMEOUT should not be below SPLIT_USB_TIMEOUT."); # endif -_Static_assert(SPLIT_MAX_CONNECTION_ERRORS > 0, "SPLIT_WATCHDOG_ENABLE requires SPLIT_MAX_CONNECTION_ERRORS be above 0 for a functioning disconnection check."); +STATIC_ASSERT(SPLIT_MAX_CONNECTION_ERRORS > 0, "SPLIT_WATCHDOG_ENABLE requires SPLIT_MAX_CONNECTION_ERRORS be above 0 for a functioning disconnection check."); static uint32_t split_watchdog_started = 0; static bool split_watchdog_done = false; diff --git a/quantum/split_common/split_util.h b/quantum/split_common/split_util.h index f83b05b6a6..6f4c4dc660 100644 --- a/quantum/split_common/split_util.h +++ b/quantum/split_common/split_util.h @@ -15,4 +15,4 @@ bool is_transport_connected(void); void split_watchdog_update(bool done); void split_watchdog_task(void); -bool split_watchdog_check(void); \ No newline at end of file +bool split_watchdog_check(void); diff --git a/quantum/split_common/transaction_id_define.h b/quantum/split_common/transaction_id_define.h index 5bfbe2aec7..694737868a 100644 --- a/quantum/split_common/transaction_id_define.h +++ b/quantum/split_common/transaction_id_define.h @@ -16,6 +16,8 @@ #pragma once +#include "compiler_support.h" + enum serial_transaction_id { #ifdef USE_I2C I2C_EXECUTE_CALLBACK, @@ -122,4 +124,4 @@ enum serial_transaction_id { }; // Ensure we only use 5 bits for transaction -_Static_assert(NUM_TOTAL_TRANSACTIONS <= (1 << 5), "Max number of usable transactions exceeded"); +STATIC_ASSERT(NUM_TOTAL_TRANSACTIONS <= (1 << 5), "Max number of usable transactions exceeded"); diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c index 83edc34859..ea687af1c2 100644 --- a/quantum/split_common/transport.c +++ b/quantum/split_common/transport.c @@ -17,6 +17,7 @@ #include #include +#include "compiler_support.h" #include "transactions.h" #include "transport.h" #include "transaction_id_define.h" @@ -36,7 +37,7 @@ # include "i2c_slave.h" // Ensure the I2C buffer has enough space -_Static_assert(sizeof(split_shared_memory_t) <= I2C_SLAVE_REG_COUNT, "split_shared_memory_t too large for I2C_SLAVE_REG_COUNT"); +STATIC_ASSERT(sizeof(split_shared_memory_t) <= I2C_SLAVE_REG_COUNT, "split_shared_memory_t too large for I2C_SLAVE_REG_COUNT"); split_shared_memory_t *const split_shmem = (split_shared_memory_t *)i2c_slave_reg; diff --git a/quantum/unicode/unicode.c b/quantum/unicode/unicode.c index 78a4cad585..dff1d43fb4 100644 --- a/quantum/unicode/unicode.c +++ b/quantum/unicode/unicode.c @@ -16,7 +16,6 @@ #include "unicode.h" -#include "eeprom.h" #include "eeconfig.h" #include "action.h" #include "action_util.h" @@ -136,7 +135,7 @@ static void unicode_play_song(uint8_t mode) { #endif void unicode_input_mode_init(void) { - unicode_config.raw = eeprom_read_byte(EECONFIG_UNICODEMODE); + eeconfig_read_unicode_mode(&unicode_config); #if UNICODE_SELECTED_MODES != -1 # if UNICODE_CYCLE_PERSIST // Find input_mode in selected modes @@ -165,7 +164,7 @@ uint8_t get_unicode_input_mode(void) { } static void persist_unicode_input_mode(void) { - eeprom_update_byte(EECONFIG_UNICODEMODE, unicode_config.input_mode); + eeconfig_update_unicode_mode(&unicode_config); } void set_unicode_input_mode(uint8_t mode) { diff --git a/quantum/unicode/unicode.h b/quantum/unicode/unicode.h index 90a54c8b18..7cddc78b7a 100644 --- a/quantum/unicode/unicode.h +++ b/quantum/unicode/unicode.h @@ -17,6 +17,8 @@ #pragma once #include + +#include "compiler_support.h" #include "unicode_keycodes.h" /** @@ -26,14 +28,14 @@ * \{ */ -typedef union { +typedef union unicode_config_t { uint8_t raw; struct { uint8_t input_mode : 8; }; } unicode_config_t; -_Static_assert(sizeof(unicode_config_t) == sizeof(uint8_t), "Unicode EECONFIG out of spec."); +STATIC_ASSERT(sizeof(unicode_config_t) == sizeof(uint8_t), "Unicode EECONFIG out of spec."); extern unicode_config_t unicode_config; diff --git a/quantum/via.c b/quantum/via.c index 643d7aa3c3..3682b4ab2b 100644 --- a/quantum/via.c +++ b/quantum/via.c @@ -26,12 +26,12 @@ #include "raw_hid.h" #include "dynamic_keymap.h" -#include "eeprom.h" #include "eeconfig.h" #include "matrix.h" #include "timer.h" #include "wait.h" #include "version.h" // for QMK_BUILDDATE used in EEPROM magic +#include "nvm_via.h" #if defined(AUDIO_ENABLE) # include "audio.h" @@ -65,20 +65,26 @@ bool via_eeprom_is_valid(void) { uint8_t magic1 = ((p[5] & 0x0F) << 4) | (p[6] & 0x0F); uint8_t magic2 = ((p[8] & 0x0F) << 4) | (p[9] & 0x0F); - return (eeprom_read_byte((void *)VIA_EEPROM_MAGIC_ADDR + 0) == magic0 && eeprom_read_byte((void *)VIA_EEPROM_MAGIC_ADDR + 1) == magic1 && eeprom_read_byte((void *)VIA_EEPROM_MAGIC_ADDR + 2) == magic2); + uint8_t ee_magic0; + uint8_t ee_magic1; + uint8_t ee_magic2; + nvm_via_read_magic(&ee_magic0, &ee_magic1, &ee_magic2); + + return ee_magic0 == magic0 && ee_magic1 == magic1 && ee_magic2 == magic2; } // Sets VIA/keyboard level usage of EEPROM to valid/invalid // Keyboard level code (eg. via_init_kb()) should not call this void via_eeprom_set_valid(bool valid) { - char * p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54" - uint8_t magic0 = ((p[2] & 0x0F) << 4) | (p[3] & 0x0F); - uint8_t magic1 = ((p[5] & 0x0F) << 4) | (p[6] & 0x0F); - uint8_t magic2 = ((p[8] & 0x0F) << 4) | (p[9] & 0x0F); - - eeprom_update_byte((void *)VIA_EEPROM_MAGIC_ADDR + 0, valid ? magic0 : 0xFF); - eeprom_update_byte((void *)VIA_EEPROM_MAGIC_ADDR + 1, valid ? magic1 : 0xFF); - eeprom_update_byte((void *)VIA_EEPROM_MAGIC_ADDR + 2, valid ? magic2 : 0xFF); + if (valid) { + char * p = QMK_BUILDDATE; // e.g. "2019-11-05-11:29:54" + uint8_t magic0 = ((p[2] & 0x0F) << 4) | (p[3] & 0x0F); + uint8_t magic1 = ((p[5] & 0x0F) << 4) | (p[6] & 0x0F); + uint8_t magic2 = ((p[8] & 0x0F) << 4) | (p[9] & 0x0F); + nvm_via_update_magic(magic0, magic1, magic2); + } else { + nvm_via_update_magic(0xFF, 0xFF, 0xFF); + } } // Override this at the keyboard code level to check @@ -104,6 +110,8 @@ void via_init(void) { } void eeconfig_init_via(void) { + // Erase any NVM storage if necessary + nvm_via_erase(); // set the magic number to false, in case this gets interrupted via_eeprom_set_valid(false); // This resets the layout options @@ -119,30 +127,25 @@ void eeconfig_init_via(void) { // This is generalized so the layout options EEPROM usage can be // variable, between 1 and 4 bytes. uint32_t via_get_layout_options(void) { - uint32_t value = 0; - // Start at the most significant byte - void *source = (void *)(VIA_EEPROM_LAYOUT_OPTIONS_ADDR); - for (uint8_t i = 0; i < VIA_EEPROM_LAYOUT_OPTIONS_SIZE; i++) { - value = value << 8; - value |= eeprom_read_byte(source); - source++; - } - return value; + return nvm_via_read_layout_options(); } __attribute__((weak)) void via_set_layout_options_kb(uint32_t value) {} void via_set_layout_options(uint32_t value) { via_set_layout_options_kb(value); - // Start at the least significant byte - void *target = (void *)(VIA_EEPROM_LAYOUT_OPTIONS_ADDR + VIA_EEPROM_LAYOUT_OPTIONS_SIZE - 1); - for (uint8_t i = 0; i < VIA_EEPROM_LAYOUT_OPTIONS_SIZE; i++) { - eeprom_update_byte(target, value & 0xFF); - value = value >> 8; - target--; - } + nvm_via_update_layout_options(value); } +#if VIA_EEPROM_CUSTOM_CONFIG_SIZE > 0 +uint32_t via_read_custom_config(void *buf, uint32_t offset, uint32_t length) { + return nvm_via_read_custom_config(buf, offset, length); +} +uint32_t via_update_custom_config(const void *buf, uint32_t offset, uint32_t length) { + return nvm_via_update_custom_config(buf, offset, length); +} +#endif + #if defined(AUDIO_ENABLE) float via_device_indication_song[][2] = SONG(STARTUP_SOUND); #endif // AUDIO_ENABLE @@ -715,7 +718,7 @@ void via_qmk_rgb_matrix_set_value(uint8_t *data) { } void via_qmk_rgb_matrix_save(void) { - eeconfig_update_rgb_matrix(); + eeconfig_force_flush_rgb_matrix(); } #endif // RGB_MATRIX_ENABLE @@ -794,7 +797,7 @@ void via_qmk_led_matrix_set_value(uint8_t *data) { } void via_qmk_led_matrix_save(void) { - eeconfig_update_led_matrix(); + eeconfig_force_flush_led_matrix(); } #endif // LED_MATRIX_ENABLE @@ -861,7 +864,7 @@ void via_qmk_audio_set_value(uint8_t *data) { } void via_qmk_audio_save(void) { - eeconfig_update_audio(audio_config.raw); + eeconfig_update_audio(&audio_config); } #endif // QMK_AUDIO_ENABLE diff --git a/quantum/via.h b/quantum/via.h index 01d4c48b37..9f0eef10f7 100644 --- a/quantum/via.h +++ b/quantum/via.h @@ -16,21 +16,8 @@ #pragma once -#include "eeconfig.h" // for EECONFIG_SIZE #include "action.h" -// Keyboard level code can change where VIA stores the magic. -// The magic is the build date YYMMDD encoded as BCD in 3 bytes, -// thus installing firmware built on a different date to the one -// already installed can be detected and the EEPROM data is reset. -// The only reason this is important is in case EEPROM usage changes -// and the EEPROM was not explicitly reset by bootmagic lite. -#ifndef VIA_EEPROM_MAGIC_ADDR -# define VIA_EEPROM_MAGIC_ADDR (EECONFIG_SIZE) -#endif - -#define VIA_EEPROM_LAYOUT_OPTIONS_ADDR (VIA_EEPROM_MAGIC_ADDR + 3) - // Changing the layout options size after release will invalidate EEPROM, // but this is something that should be set correctly on initial implementation. // 1 byte is enough for most uses (i.e. 8 binary states, or 6 binary + 1 ternary/quaternary ) @@ -46,17 +33,10 @@ # define VIA_EEPROM_LAYOUT_OPTIONS_DEFAULT 0x00000000 #endif -// The end of the EEPROM memory used by VIA -// By default, dynamic keymaps will start at this if there is no -// custom config -#define VIA_EEPROM_CUSTOM_CONFIG_ADDR (VIA_EEPROM_LAYOUT_OPTIONS_ADDR + VIA_EEPROM_LAYOUT_OPTIONS_SIZE) - #ifndef VIA_EEPROM_CUSTOM_CONFIG_SIZE # define VIA_EEPROM_CUSTOM_CONFIG_SIZE 0 #endif -#define VIA_EEPROM_CONFIG_END (VIA_EEPROM_CUSTOM_CONFIG_ADDR + VIA_EEPROM_CUSTOM_CONFIG_SIZE) - // This is changed only when the command IDs change, // so VIA Configurator can detect compatible firmware. #define VIA_PROTOCOL_VERSION 0x000C @@ -160,6 +140,11 @@ uint32_t via_get_layout_options(void); void via_set_layout_options(uint32_t value); void via_set_layout_options_kb(uint32_t value); +#if VIA_EEPROM_CUSTOM_CONFIG_SIZE > 0 +uint32_t via_read_custom_config(void *buf, uint32_t offset, uint32_t length); +uint32_t via_update_custom_config(const void *buf, uint32_t offset, uint32_t length); +#endif + // Used by VIA to tell a device to flash LEDs (or do something else) when that // device becomes the active device being configured, on startup or switching // between devices. @@ -202,4 +187,4 @@ void via_qmk_audio_command(uint8_t *data, uint8_t length); void via_qmk_audio_set_value(uint8_t *data); void via_qmk_audio_get_value(uint8_t *data); void via_qmk_audio_save(void); -#endif \ No newline at end of file +#endif diff --git a/quantum/wear_leveling/tests/rules.mk b/quantum/wear_leveling/tests/rules.mk index 4d7a964049..f5f36e5b6e 100644 --- a/quantum/wear_leveling/tests/rules.mk +++ b/quantum/wear_leveling/tests/rules.mk @@ -63,4 +63,4 @@ wear_leveling_8byte_SRC := \ $(wear_leveling_common_SRC) \ $(QUANTUM_PATH)/wear_leveling/tests/wear_leveling_8byte.cpp wear_leveling_8byte_INC := \ - $(wear_leveling_common_INC) \ No newline at end of file + $(wear_leveling_common_INC) diff --git a/quantum/wear_leveling/wear_leveling.c b/quantum/wear_leveling/wear_leveling.c index 429df45df5..258f074a5c 100644 --- a/quantum/wear_leveling/wear_leveling.c +++ b/quantum/wear_leveling/wear_leveling.c @@ -3,6 +3,7 @@ #include #include "fnv.h" #include "wear_leveling.h" +#include "wear_leveling_drivers.h" #include "wear_leveling_internal.h" /* diff --git a/quantum/wear_leveling/wear_leveling_drivers.h b/quantum/wear_leveling/wear_leveling_drivers.h new file mode 100644 index 0000000000..e81f833fd1 --- /dev/null +++ b/quantum/wear_leveling/wear_leveling_drivers.h @@ -0,0 +1,13 @@ +// Copyright 2025 QMK +// SPDX-License-Identifier: GPL-2.0-or-later +#pragma once + +#if defined(WEAR_LEVELING_EMBEDDED_FLASH) +# include "wear_leveling/wear_leveling_efl_config.h" +#elif defined(WEAR_LEVELING_SPI_FLASH) +# include "wear_leveling/wear_leveling_flash_spi_config.h" +#elif defined(WEAR_LEVELING_RP2040_FLASH) +# include "wear_leveling/wear_leveling_rp2040_flash_config.h" +#elif defined(WEAR_LEVELING_LEGACY) +# include "wear_leveling/wear_leveling_legacy_config.h" +#endif diff --git a/quantum/wear_leveling/wear_leveling_internal.h b/quantum/wear_leveling/wear_leveling_internal.h index e83f9b22ea..c590f42235 100644 --- a/quantum/wear_leveling/wear_leveling_internal.h +++ b/quantum/wear_leveling/wear_leveling_internal.h @@ -2,9 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #pragma once -#ifdef __cplusplus -# define _Static_assert static_assert -#endif +#include "compiler_support.h" #include #include @@ -62,9 +60,9 @@ typedef uint64_t backing_store_int_t; #endif // WEAR_LEVELING_ASSERTS // Compile-time validation of configurable options -_Static_assert(WEAR_LEVELING_BACKING_SIZE >= (WEAR_LEVELING_LOGICAL_SIZE * 2), "Total backing size must be at least twice the size of the logical size"); -_Static_assert(WEAR_LEVELING_LOGICAL_SIZE % BACKING_STORE_WRITE_SIZE == 0, "Logical size must be a multiple of write size"); -_Static_assert(WEAR_LEVELING_BACKING_SIZE % WEAR_LEVELING_LOGICAL_SIZE == 0, "Backing size must be a multiple of logical size"); +STATIC_ASSERT(WEAR_LEVELING_BACKING_SIZE >= (WEAR_LEVELING_LOGICAL_SIZE * 2), "Total backing size must be at least twice the size of the logical size"); +STATIC_ASSERT(WEAR_LEVELING_LOGICAL_SIZE % BACKING_STORE_WRITE_SIZE == 0, "Logical size must be a multiple of write size"); +STATIC_ASSERT(WEAR_LEVELING_BACKING_SIZE % WEAR_LEVELING_LOGICAL_SIZE == 0, "Backing size must be a multiple of logical size"); // Backing Store API, to be implemented elsewhere by flash driver etc. bool backing_store_init(void); @@ -86,7 +84,7 @@ typedef union write_log_entry_t { uint8_t raw8[8]; } write_log_entry_t; -_Static_assert(sizeof(write_log_entry_t) == 8, "Wear leveling write log entry size was not 8"); +STATIC_ASSERT(sizeof(write_log_entry_t) == 8, "Wear leveling write log entry size was not 8"); /** * Log entry type discriminator. @@ -104,7 +102,7 @@ enum { LOG_ENTRY_TYPES }; -_Static_assert(LOG_ENTRY_TYPES <= (1 << 2), "Too many log entry types to fit into 2 bits of storage"); +STATIC_ASSERT(LOG_ENTRY_TYPES <= (1 << 2), "Too many log entry types to fit into 2 bits of storage"); #define BITMASK_FOR_BITCOUNT(n) ((1 << (n)) - 1) diff --git a/requirements.txt b/requirements.txt index fbee51ee57..68b05d64e6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ dotty-dict hid hjson jsonschema>=4 -milc>=1.4.2 +milc>=1.9.0 pygments pyserial pyusb diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 88822b0b17..0000000000 --- a/shell.nix +++ /dev/null @@ -1,72 +0,0 @@ -let - # We specify sources via Niv: use "niv update nixpkgs" to update nixpkgs, for example. - sources = import ./util/nix/sources.nix { }; -in -# However, if you want to override Niv's inputs, this will let you do that. -{ pkgs ? import sources.nixpkgs { } -, poetry2nix ? pkgs.callPackage (import sources.poetry2nix) { } -, avr ? true -, arm ? true -, teensy ? true }: -with pkgs; -let - avrlibc = pkgsCross.avr.libcCross; - - avr_incflags = [ - "-isystem ${avrlibc}/avr/include" - "-B${avrlibc}/avr/lib/avr5" - "-L${avrlibc}/avr/lib/avr5" - "-B${avrlibc}/avr/lib/avr35" - "-L${avrlibc}/avr/lib/avr35" - "-B${avrlibc}/avr/lib/avr51" - "-L${avrlibc}/avr/lib/avr51" - ]; - - # Builds the python env based on nix/pyproject.toml and - # nix/poetry.lock Use the "poetry update --lock", "poetry add - # --lock" etc. in the nix folder to adjust the contents of those - # files if the requirements*.txt files change - pythonEnv = poetry2nix.mkPoetryEnv { - projectDir = ./util/nix; - overrides = poetry2nix.overrides.withDefaults (self: super: { - qmk = super.qmk.overridePythonAttrs(old: { - # Allow QMK CLI to run "qmk" as a subprocess (the wrapper changes - # $PATH and breaks these invocations). - dontWrapPythonPrograms = true; - - # Fix "qmk setup" to use the Python interpreter from the environment - # when invoking "qmk doctor" (sys.executable gets its value from - # $NIX_PYTHONEXECUTABLE, which is set by the "qmk" wrapper from the - # Python environment, so "qmk doctor" then runs with the proper - # $NIX_PYTHONPATH too, because sys.executable actually points to - # another wrapper from the same Python environment). - postPatch = '' - substituteInPlace qmk_cli/subcommands/setup.py \ - --replace "[Path(sys.argv[0]).as_posix()" \ - "[Path(sys.executable).as_posix(), Path(sys.argv[0]).as_posix()" - ''; - }); - }); - }; -in -mkShell { - name = "qmk-firmware"; - - buildInputs = [ clang-tools_11 dfu-programmer dfu-util diffutils git pythonEnv niv ] - ++ lib.optional avr [ - pkgsCross.avr.buildPackages.binutils - pkgsCross.avr.buildPackages.gcc8 - avrlibc - avrdude - ] - ++ lib.optional arm [ gcc-arm-embedded ] - ++ lib.optional teensy [ teensy-loader-cli ]; - - AVR_CFLAGS = lib.optional avr avr_incflags; - AVR_ASFLAGS = lib.optional avr avr_incflags; - shellHook = '' - # Prevent the avr-gcc wrapper from picking up host GCC flags - # like -iframework, which is problematic on Darwin - unset NIX_CFLAGS_COMPILE_FOR_TARGET - ''; -} diff --git a/tests/basic/test_keycode_util.cpp b/tests/basic/test_keycode_util.cpp deleted file mode 100644 index 693334676e..0000000000 --- a/tests/basic/test_keycode_util.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2022 Stefan Kerkmann -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "test_common.hpp" - -class KeycodeToIdentifierSuite : public ::testing::TestWithParam> {}; - -TEST_P(KeycodeToIdentifierSuite, ConversionTests) { - ASSERT_EQ(get_keycode_identifier_or_default(GetParam().first), GetParam().second); -} - -INSTANTIATE_TEST_CASE_P(ConversionTestsP, KeycodeToIdentifierSuite, - // clang-format off -::testing::Values( - // Goto layer - std::make_pair(TO(0), "TO(0)"), - std::make_pair(TO(0x1F), "TO(31)"), - // Momentary switch layer - std::make_pair(MO(0), "MO(0)"), - std::make_pair(MO(0x1F), "MO(31)"), - // Set default layer - std::make_pair(DF(0), "DF(0)"), - std::make_pair(DF(0x1F), "DF(31)"), - // Toggle layer - std::make_pair(TG(0), "TG(0)"), - std::make_pair(TG(0x1F), "TG(31)"), - // One-shot layer - std::make_pair(OSL(0), "OSL(0)"), - std::make_pair(OSL(0x1F), "OSL(31)"), - // One-shot mod - std::make_pair(OSM(MOD_LSFT), "OSM(MOD_LSFT)"), - std::make_pair(OSM(MOD_LSFT | MOD_LCTL), "OSM(MOD_LCTL | MOD_LSFT)"), - // Layer Mod - std::make_pair(LM(0, MOD_LSFT), "LM(0, MOD_LSFT)"), - std::make_pair(LM(0xF, MOD_LSFT), "LM(15, MOD_LSFT)"), - std::make_pair(LM(0xF, MOD_LSFT | MOD_LCTL), "LM(15, MOD_LCTL | MOD_LSFT)"), - // Layer tap toggle - std::make_pair(TT(0), "TT(0)"), - std::make_pair(TT(0x1F), "TT(31)"), - // Layer tap - std::make_pair(LT(0, KC_A), "LT(0, KC_A)"), - std::make_pair(LT(0xF, KC_SPACE), "LT(15, KC_SPACE)"), - std::make_pair(LT(1, KC_SPC), "LT(1, KC_SPACE)"), - // Mod tap - std::make_pair(MT(MOD_LCTL, KC_A), "MT(MOD_LCTL, KC_A)"), - std::make_pair(MT(MOD_LCTL | MOD_LSFT, KC_A), "MT(MOD_LCTL | MOD_LSFT, KC_A)"), - std::make_pair(ALT_T(KC_TAB), "MT(MOD_LALT, KC_TAB)"), - // Mods - std::make_pair(LCTL(KC_A), "QK_MODS(KC_A, QK_LCTL)"), - std::make_pair(HYPR(KC_SPACE), "QK_MODS(KC_SPACE, QK_LCTL | QK_LSFT | QK_LALT | QK_LGUI)") -)); -// clang-format on diff --git a/tests/basic/test_one_shot_keys.cpp b/tests/basic/test_one_shot_keys.cpp index 92db52f811..4784c86694 100644 --- a/tests/basic/test_one_shot_keys.cpp +++ b/tests/basic/test_one_shot_keys.cpp @@ -686,4 +686,4 @@ TEST_F(OneShot, OSLWithLongModTapKeyAndRegularKey) { regular_key.release(); run_one_scan_loop(); VERIFY_AND_CLEAR(driver); -} \ No newline at end of file +} diff --git a/tests/caps_word/test.mk b/tests/caps_word/test.mk index 2509b01858..6d5664aa05 100644 --- a/tests/caps_word/test.mk +++ b/tests/caps_word/test.mk @@ -15,5 +15,7 @@ CAPS_WORD_ENABLE = yes COMMAND_ENABLE = no +LAYER_LOCK_ENABLE = yes SPACE_CADET_ENABLE = yes +TRI_LAYER_ENABLE = yes diff --git a/tests/caps_word/test_caps_word.cpp b/tests/caps_word/test_caps_word.cpp index 28d86e9324..4b58790915 100644 --- a/tests/caps_word/test_caps_word.cpp +++ b/tests/caps_word/test_caps_word.cpp @@ -156,21 +156,22 @@ TEST_F(CapsWord, IdleTimeout) { // Turn on Caps Word and tap "A". caps_word_on(); tap_key(key_a); - VERIFY_AND_CLEAR(driver); + EXPECT_EMPTY_REPORT(driver); idle_for(CAPS_WORD_IDLE_TIMEOUT); run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); // Caps Word should be off and mods should be clear. EXPECT_EQ(is_caps_word_on(), false); EXPECT_EQ(get_mods() | get_weak_mods(), 0); - EXPECT_EMPTY_REPORT(driver).Times(AnyNumber()); // Expect unshifted "A". EXPECT_REPORT(driver, (KC_A)); + EXPECT_EMPTY_REPORT(driver); tap_key(key_a); - + run_one_scan_loop(); VERIFY_AND_CLEAR(driver); } @@ -244,6 +245,7 @@ TEST_F(CapsWord, ShiftsAltGrSymbols) { // clang-format off EXPECT_CALL(driver, send_keyboard_mock(AnyOf( KeyboardReport(), + KeyboardReport(KC_LSFT), KeyboardReport(KC_RALT), KeyboardReport(KC_LSFT, KC_RALT)))) .Times(AnyNumber()); @@ -259,6 +261,9 @@ TEST_F(CapsWord, ShiftsAltGrSymbols) { tap_key(key_a); run_one_scan_loop(); key_altgr.release(); + run_one_scan_loop(); + + idle_for(CAPS_WORD_IDLE_TIMEOUT); VERIFY_AND_CLEAR(driver); } @@ -274,6 +279,7 @@ TEST_F(CapsWord, ShiftsModTapAltGrSymbols) { // clang-format off EXPECT_CALL(driver, send_keyboard_mock(AnyOf( KeyboardReport(), + KeyboardReport(KC_LSFT), KeyboardReport(KC_RALT), KeyboardReport(KC_LSFT, KC_RALT)))) .Times(AnyNumber()); @@ -289,8 +295,11 @@ TEST_F(CapsWord, ShiftsModTapAltGrSymbols) { tap_key(key_a); run_one_scan_loop(); key_altgr_t.release(); - + run_one_scan_loop(); EXPECT_TRUE(is_caps_word_on()); + + idle_for(CAPS_WORD_IDLE_TIMEOUT); + VERIFY_AND_CLEAR(driver); } @@ -535,7 +544,11 @@ TEST_P(CapsWordDoubleTapShift, Activation) { // machine at this point. This due to imperfect test isolation which can't // reset the caps word double shift timer on test case setup. idle_for(CAPS_WORD_IDLE_TIMEOUT); + + EXPECT_REPORT(driver, (KC_ESC)); + EXPECT_EMPTY_REPORT(driver); tap_key(esc); + VERIFY_AND_CLEAR(driver); } // Double tap doesn't count if another key is pressed between the taps. @@ -589,6 +602,7 @@ TEST_P(CapsWordDoubleTapShift, SlowTaps) { EXPECT_EQ(is_caps_word_on(), false); // Caps Word is still off. clear_oneshot_mods(); + send_keyboard_report(); VERIFY_AND_CLEAR(driver); } @@ -626,7 +640,7 @@ TEST_F(CapsWord, IgnoresOSLHold) { run_one_scan_loop(); tap_key(key_b); key_osl.release(); - run_one_scan_loop(); + idle_for(CAPS_WORD_IDLE_TIMEOUT + 1); VERIFY_AND_CLEAR(driver); } @@ -645,15 +659,39 @@ TEST_F(CapsWord, IgnoresOSLTap) { KeyboardReport(), KeyboardReport(KC_LSFT)))) .Times(AnyNumber()); + // clang-format on EXPECT_REPORT(driver, (KC_LSFT, KC_B)); caps_word_on(); tap_key(key_osl); tap_key(key_b); - run_one_scan_loop(); + idle_for(CAPS_WORD_IDLE_TIMEOUT); + + VERIFY_AND_CLEAR(driver); +} + +TEST_F(CapsWord, IgnoresLayerLockKey) { + TestDriver driver; + KeymapKey key_llock(0, 1, 0, QK_LAYER_LOCK); + KeymapKey key_b(0, 0, 0, KC_B); + set_keymap({key_llock, key_b}); + + // Allow any number of reports with no keys or only modifiers. + // clang-format off + EXPECT_CALL(driver, send_keyboard_mock(AnyOf( + KeyboardReport(), + KeyboardReport(KC_LSFT)))) + .Times(AnyNumber()); + // clang-format on + + EXPECT_REPORT(driver, (KC_LSFT, KC_B)); + caps_word_on(); + + tap_key(key_llock); + tap_key(key_b); + idle_for(CAPS_WORD_IDLE_TIMEOUT); VERIFY_AND_CLEAR(driver); } -// clang-format on } // namespace diff --git a/tests/combo/combo_repress/test_combo.cpp b/tests/combo/combo_repress/test_combo.cpp index 1488d5c1bd..b1a2d36cb3 100644 --- a/tests/combo/combo_repress/test_combo.cpp +++ b/tests/combo/combo_repress/test_combo.cpp @@ -2,9 +2,9 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "keyboard_report_util.hpp" -#include "quantum.h" #include "keycode.h" #include "test_common.h" +#include "test_common.hpp" #include "test_driver.hpp" #include "test_fixture.hpp" #include "test_keymap_key.hpp" diff --git a/tests/combo/test_combo.cpp b/tests/combo/test_combo.cpp index ac852f9d16..d78ec55990 100644 --- a/tests/combo/test_combo.cpp +++ b/tests/combo/test_combo.cpp @@ -3,7 +3,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "keyboard_report_util.hpp" -#include "quantum.h" #include "keycode.h" #include "test_common.h" #include "test_driver.hpp" diff --git a/tests/keycode_string/config.h b/tests/keycode_string/config.h new file mode 100644 index 0000000000..7fc76d7c2e --- /dev/null +++ b/tests/keycode_string/config.h @@ -0,0 +1,19 @@ +/* Copyright 2017 Fred Sundvik + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include "test_common.h" diff --git a/tests/keycode_string/test.mk b/tests/keycode_string/test.mk new file mode 100644 index 0000000000..aa255a1b6b --- /dev/null +++ b/tests/keycode_string/test.mk @@ -0,0 +1,22 @@ +# Copyright 2025 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +EXTRAKEY_ENABLE = yes +KEYCODE_STRING_ENABLE = yes +KEY_LOCK_ENABLE = yes +MAGIC_ENABLE = yes +MOUSEKEY_ENABLE = yes +PROGRAMMABLE_BUTTON_ENABLE = yes +SECURE_ENABLE = yes +SWAP_HANDS_ENABLE = yes diff --git a/tests/keycode_string/test_keycode_string.cpp b/tests/keycode_string/test_keycode_string.cpp new file mode 100644 index 0000000000..e1dec70e7a --- /dev/null +++ b/tests/keycode_string/test_keycode_string.cpp @@ -0,0 +1,153 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include "test_common.hpp" + +enum { + MYMACRO1 = SAFE_RANGE, + MYMACRO2, +}; + +// clang-format off +extern "C" { + +KEYCODE_STRING_NAMES_KB( + KEYCODE_STRING_NAME(MYMACRO1), +); + +KEYCODE_STRING_NAMES_USER( + KEYCODE_STRING_NAME(MYMACRO2), + KEYCODE_STRING_NAME(KC_EXLM), +); + +const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = { + {{9, 0}, {8, 0}, {7, 0}, {6, 0}, {5, 0}, {4, 0}, {3, 0}, {2, 0}, {1, 0}, {0, 0}}, + {{9, 1}, {8, 1}, {7, 1}, {6, 1}, {5, 1}, {4, 1}, {3, 1}, {2, 1}, {1, 1}, {0, 1}}, + {{9, 2}, {8, 2}, {7, 2}, {6, 2}, {5, 2}, {4, 2}, {3, 2}, {2, 2}, {1, 2}, {0, 2}}, + {{9, 3}, {8, 3}, {7, 3}, {6, 3}, {5, 3}, {4, 3}, {3, 3}, {2, 3}, {1, 3}, {0, 3}}, +}; + +} // extern "C" +// clang-format on + +class KeycodeStringTest : public TestFixture {}; + +TEST_F(KeycodeStringTest, get_keycode_string) { + struct TestParams { + uint16_t keycode; + std::string expected; + }; + for (const auto [keycode, expected] : std::vector({ + {KC_TRNS, "KC_TRNS"}, + {KC_ESC, "KC_ESC"}, + {KC_A, "KC_A"}, + {KC_Z, "KC_Z"}, + {KC_0, "KC_0"}, + {KC_9, "KC_9"}, + {KC_KP_0, "KC_KP_0"}, + {KC_KP_9, "KC_KP_9"}, + {KC_LBRC, "KC_LBRC"}, + {KC_NUHS, "KC_NUHS"}, + {KC_NUBS, "KC_NUBS"}, + {KC_CAPS, "KC_CAPS"}, + {DB_TOGG, "DB_TOGG"}, + {KC_LCTL, "KC_LCTL"}, + {KC_LSFT, "KC_LSFT"}, + {KC_RALT, "KC_RALT"}, + {KC_RGUI, "KC_RGUI"}, + {KC_UP, "KC_UP"}, + {KC_HYPR, "KC_HYPR"}, + {KC_MEH, "KC_MEH"}, + // F1-F24 keycodes. + {KC_F1, "KC_F1"}, + {KC_F12, "KC_F12"}, + {KC_F13, "KC_F13"}, + {KC_F24, "KC_F24"}, + // Macro keycodes. + {MC_0, "MC_0"}, + {MC_31, "MC_31"}, + // Keyboard range keycodes. + {QK_KB_0, "QK_KB_0"}, + {QK_KB_31, "QK_KB_31"}, + // User range keycodes. + {QK_USER_2, "QK_USER_2"}, + {QK_USER_31, "QK_USER_31"}, + // Modified keycodes. + {KC_COLN, "S(KC_SCLN)"}, + {C(KC_PGUP), "C(KC_PGUP)"}, + {RALT(KC_BSPC), "RALT(KC_BSPC)"}, + // One-shot mods. + {OSM(MOD_LSFT), "OSM(MOD_LSFT)"}, + {OSM(MOD_RGUI), "OSM(MOD_RGUI)"}, + {OSM(MOD_RCTL | MOD_RGUI), "OSM(0x19)"}, + // Layer switch keycodes. + {DF(2), "DF(2)"}, + {PDF(12), "PDF(12)"}, + {MO(3), "MO(3)"}, + {TO(0), "TO(0)"}, + {TT(1), "TT(1)"}, + {TG(3), "TG(3)"}, + {OSL(3), "OSL(3)"}, + {LM(3, MOD_RALT), "LM(3,MOD_RALT)"}, + {LT(15, KC_QUOT), "LT(15,KC_QUOT)"}, + // Tap dance keycodes. + {TD(0), "TD(0)"}, + {TD(31), "TD(31)"}, + // Mod-tap keycodes. + {LSFT_T(KC_ENT), "LSFT_T(KC_ENT)"}, + {RCTL_T(KC_RGHT), "RCTL_T(KC_RGHT)"}, + {HYPR_T(KC_GRV), "HYPR_T(KC_GRV)"}, + {MEH_T(KC_EQL), "MEH_T(KC_EQL)"}, + {RSA_T(KC_LBRC), "MT(0x16,KC_LBRC)"}, + // Extrakey keycodes. + {KC_WBAK, "KC_WBAK"}, + {KC_WFWD, "KC_WFWD"}, + {KC_WREF, "KC_WREF"}, + {KC_VOLU, "KC_VOLU"}, + {KC_VOLD, "KC_VOLD"}, + // Mouse Key keycodes. + {MS_LEFT, "MS_LEFT"}, + {MS_RGHT, "MS_RGHT"}, + {MS_UP, "MS_UP"}, + {MS_WHLU, "MS_WHLU"}, + {MS_WHLD, "MS_WHLD"}, + {MS_BTN1, "MS_BTN1"}, + {MS_BTN8, "MS_BTN8"}, + // Swap Hands keycodes. + {SH_MON, "SH_MON"}, + {SH_TOGG, "SH_TOGG"}, + {SH_T(KC_PSCR), "SH_T(KC_PSCR)"}, + // Secure keycodes. + {SE_LOCK, "SE_LOCK"}, + {SE_UNLK, "SE_UNLK"}, + {SE_TOGG, "SE_TOGG"}, + {SE_REQ, "SE_REQ"}, + // Programmable button keycodes. + {PB_1, "PB_1"}, + {PB_32, "PB_32"}, + // Magic button keycodes. + {QK_MAGIC + 7, "QK_MAGIC+7"}, + // Quantum keycodes. + {QK_LOCK, "QK_LOCK"}, + {QK_QUANTUM + 7, "QK_QUANTUM+7"}, + // Custom keycode names. + {MYMACRO1, "MYMACRO1"}, + {MYMACRO2, "MYMACRO2"}, + {KC_EXLM, "KC_EXLM"}, + })) { + EXPECT_EQ(get_keycode_string(keycode), expected) << "where keycode = 0x" << std::hex << keycode; + } +} diff --git a/tests/no_tapping/no_action_tapping/test.mk b/tests/no_tapping/no_action_tapping/test.mk index 29690d1adf..6ec384609c 100644 --- a/tests/no_tapping/no_action_tapping/test.mk +++ b/tests/no_tapping/no_action_tapping/test.mk @@ -15,4 +15,4 @@ # -------------------------------------------------------------------------------- # Keep this file, even if it is empty, as a marker that this folder contains tests -# -------------------------------------------------------------------------------- \ No newline at end of file +# -------------------------------------------------------------------------------- diff --git a/tests/no_tapping/no_mod_tap_mods/test.mk b/tests/no_tapping/no_mod_tap_mods/test.mk index 29690d1adf..6ec384609c 100644 --- a/tests/no_tapping/no_mod_tap_mods/test.mk +++ b/tests/no_tapping/no_mod_tap_mods/test.mk @@ -15,4 +15,4 @@ # -------------------------------------------------------------------------------- # Keep this file, even if it is empty, as a marker that this folder contains tests -# -------------------------------------------------------------------------------- \ No newline at end of file +# -------------------------------------------------------------------------------- diff --git a/tests/repeat_key/alt_repeat_key/test_alt_repeat_key.cpp b/tests/repeat_key/alt_repeat_key/test_alt_repeat_key.cpp index ae525acb45..e2eed3dbb6 100644 --- a/tests/repeat_key/alt_repeat_key/test_alt_repeat_key.cpp +++ b/tests/repeat_key/alt_repeat_key/test_alt_repeat_key.cpp @@ -210,7 +210,7 @@ TEST_F(AltRepeatKey, GetAltRepeatKeyKeycode) { {MO(1), 0, KC_NO}, // clang-format on })) { - SCOPED_TRACE(std::string("Input keycode: ") + get_keycode_identifier_or_default(params.keycode)); + SCOPED_TRACE(std::string("Input keycode: ") + get_keycode_string(params.keycode)); set_last_keycode(params.keycode); set_last_mods(params.mods); diff --git a/tests/repeat_key/test.mk b/tests/repeat_key/test.mk index aec8ff3bfb..186207ffc2 100644 --- a/tests/repeat_key/test.mk +++ b/tests/repeat_key/test.mk @@ -16,3 +16,4 @@ REPEAT_KEY_ENABLE = yes AUTO_SHIFT_ENABLE = yes +LAYER_LOCK_ENABLE = yes diff --git a/tests/repeat_key/test_repeat_key.cpp b/tests/repeat_key/test_repeat_key.cpp index eee44fc104..ed5d618761 100644 --- a/tests/repeat_key/test_repeat_key.cpp +++ b/tests/repeat_key/test_repeat_key.cpp @@ -751,4 +751,37 @@ TEST_F(RepeatKey, RepeatKeyInvoke) { testing::Mock::VerifyAndClearExpectations(&driver); } +// Check that mods and Layer Lock are not remembered. +TEST_F(RepeatKey, IgnoredKeys) { + TestDriver driver; + KeymapKey regular_key(0, 0, 0, KC_A); + KeymapKey key_repeat(0, 1, 0, QK_REP); + KeymapKey key_lsft(0, 2, 0, KC_LSFT); + KeymapKey key_lctl(0, 3, 0, KC_LCTL); + KeymapKey key_llck(0, 4, 0, QK_LAYER_LOCK); + set_keymap({regular_key, key_repeat, key_lsft, key_lctl, key_llck}); + + // Allow any number of empty reports. + EXPECT_EMPTY_REPORT(driver).Times(AnyNumber()); + { + InSequence seq; + EXPECT_REPORT(driver, (KC_A)); + EXPECT_REPORT(driver, (KC_LSFT)); + EXPECT_REPORT(driver, (KC_LCTL)); + EXPECT_REPORT(driver, (KC_A)); + EXPECT_REPORT(driver, (KC_A)); + } + + tap_key(regular_key); // Taps the KC_A key. + + // Tap Shift, Ctrl, and Layer Lock keys, which should not be remembered. + tap_keys(key_lsft, key_lctl, key_llck); + EXPECT_KEYCODE_EQ(get_last_keycode(), KC_A); + + // Tapping the Repeat Key should still reproduce KC_A. + tap_keys(key_repeat, key_repeat); + + testing::Mock::VerifyAndClearExpectations(&driver); +} + } // namespace diff --git a/tests/tap_hold_configurations/chordal_hold/permissive_hold_flow_tap/config.h b/tests/tap_hold_configurations/chordal_hold/permissive_hold_flow_tap/config.h new file mode 100644 index 0000000000..9267b94bec --- /dev/null +++ b/tests/tap_hold_configurations/chordal_hold/permissive_hold_flow_tap/config.h @@ -0,0 +1,23 @@ +/* Copyright 2022 Vladislav Kucheriavykh + * Copyright 2024-2025 Google LLC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include "test_common.h" +#define CHORDAL_HOLD +#define PERMISSIVE_HOLD +#define FLOW_TAP_TERM 150 diff --git a/tests/tap_hold_configurations/chordal_hold/permissive_hold_flow_tap/test.mk b/tests/tap_hold_configurations/chordal_hold/permissive_hold_flow_tap/test.mk new file mode 100644 index 0000000000..2b049cea3b --- /dev/null +++ b/tests/tap_hold_configurations/chordal_hold/permissive_hold_flow_tap/test.mk @@ -0,0 +1,17 @@ +# Copyright 2022 Vladislav Kucheriavykh +# Copyright 2024 Google LLC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +INTROSPECTION_KEYMAP_C = test_keymap.c diff --git a/tests/tap_hold_configurations/chordal_hold/permissive_hold_flow_tap/test_keymap.c b/tests/tap_hold_configurations/chordal_hold/permissive_hold_flow_tap/test_keymap.c new file mode 100644 index 0000000000..8a6a2c59b0 --- /dev/null +++ b/tests/tap_hold_configurations/chordal_hold/permissive_hold_flow_tap/test_keymap.c @@ -0,0 +1,22 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "quantum.h" + +const char chordal_hold_layout[MATRIX_ROWS][MATRIX_COLS] PROGMEM = { + {'L', 'L', 'L', 'L', 'L', 'R', 'R', 'R', 'R', 'R'}, + {'L', 'L', 'L', 'L', 'L', 'R', 'R', 'R', 'R', 'R'}, + {'*', 'L', 'L', 'L', 'L', 'R', 'R', 'R', 'R', 'R'}, + {'L', 'L', 'L', 'L', 'L', 'R', 'R', 'R', 'R', 'R'}, +}; diff --git a/tests/tap_hold_configurations/chordal_hold/permissive_hold_flow_tap/test_one_shot_keys.cpp b/tests/tap_hold_configurations/chordal_hold/permissive_hold_flow_tap/test_one_shot_keys.cpp new file mode 100644 index 0000000000..e48cba73e2 --- /dev/null +++ b/tests/tap_hold_configurations/chordal_hold/permissive_hold_flow_tap/test_one_shot_keys.cpp @@ -0,0 +1,174 @@ +/* Copyright 2021 Stefan Kerkmann + * Copyright 2024 Google LLC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "action_util.h" +#include "keyboard_report_util.hpp" +#include "test_common.hpp" + +using testing::_; +using testing::InSequence; + +class OneShot : public TestFixture {}; +class OneShotParametrizedTestFixture : public ::testing::WithParamInterface>, public OneShot {}; + +TEST_P(OneShotParametrizedTestFixture, OSMWithAdditionalKeypress) { + TestDriver driver; + KeymapKey osm_key = GetParam().first; + KeymapKey regular_key = GetParam().second; + + set_keymap({osm_key, regular_key}); + + // Press and release OSM. + EXPECT_NO_REPORT(driver); + tap_key(osm_key); + VERIFY_AND_CLEAR(driver); + + // Press regular key. + EXPECT_REPORT(driver, (osm_key.report_code, regular_key.report_code)); + regular_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release regular key. + EXPECT_EMPTY_REPORT(driver); + regular_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_P(OneShotParametrizedTestFixture, OSMAsRegularModifierWithAdditionalKeypress) { + TestDriver driver; + KeymapKey osm_key = GetParam().first; + KeymapKey regular_key = GetParam().second; + + set_keymap({osm_key, regular_key}); + + // Press OSM. + EXPECT_NO_REPORT(driver); + osm_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Press regular key. + EXPECT_NO_REPORT(driver); + regular_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release regular key. + EXPECT_REPORT(driver, (osm_key.report_code)).Times(2); + EXPECT_REPORT(driver, (regular_key.report_code, osm_key.report_code)); + regular_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release OSM. + EXPECT_EMPTY_REPORT(driver); + osm_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +// clang-format off + +INSTANTIATE_TEST_CASE_P( + OneShotModifierTests, + OneShotParametrizedTestFixture, + ::testing::Values( + // First is osm key, second is regular key. + std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_LSFT), KC_LSFT}, KeymapKey{0, 1, 1, KC_A}), + std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_LCTL), KC_LCTL}, KeymapKey{0, 1, 1, KC_A}), + std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_LALT), KC_LALT}, KeymapKey{0, 1, 1, KC_A}), + std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_LGUI), KC_LGUI}, KeymapKey{0, 1, 1, KC_A}), + std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_RCTL), KC_RCTL}, KeymapKey{0, 1, 1, KC_A}), + std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_RSFT), KC_RSFT}, KeymapKey{0, 1, 1, KC_A}), + std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_RALT), KC_RALT}, KeymapKey{0, 1, 1, KC_A}), + std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_RGUI), KC_RGUI}, KeymapKey{0, 1, 1, KC_A}) + )); +// clang-format on + +TEST_F(OneShot, OSLWithAdditionalKeypress) { + TestDriver driver; + InSequence s; + KeymapKey osl_key = KeymapKey{0, 0, 0, OSL(1)}; + KeymapKey osl_key1 = KeymapKey{1, 0, 0, KC_X}; + KeymapKey regular_key0 = KeymapKey{0, 1, 0, KC_Y}; + KeymapKey regular_key1 = KeymapKey{1, 1, 0, KC_A}; + + set_keymap({osl_key, osl_key1, regular_key0, regular_key1}); + + // Press OSL key. + EXPECT_NO_REPORT(driver); + osl_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release OSL key. + EXPECT_NO_REPORT(driver); + osl_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Press regular key. + EXPECT_REPORT(driver, (regular_key1.report_code)); + EXPECT_EMPTY_REPORT(driver); + regular_key1.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release regular key. + EXPECT_NO_REPORT(driver); + regular_key1.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(OneShot, OSLWithOsmAndAdditionalKeypress) { + TestDriver driver; + InSequence s; + KeymapKey osl_key = KeymapKey{0, 0, 0, OSL(1)}; + KeymapKey osm_key = KeymapKey{1, 1, 0, OSM(MOD_LSFT), KC_LSFT}; + KeymapKey regular_key = KeymapKey{1, 1, 1, KC_A}; + KeymapKey blank_key = KeymapKey{1, 0, 0, KC_NO}; + + set_keymap({osl_key, osm_key, regular_key, blank_key}); + + // Press OSL key. + EXPECT_NO_REPORT(driver); + osl_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release OSL key. + EXPECT_NO_REPORT(driver); + osl_key.release(); + run_one_scan_loop(); + EXPECT_TRUE(layer_state_is(1)); + VERIFY_AND_CLEAR(driver); + + // Press and release OSM. + EXPECT_NO_REPORT(driver); + tap_key(osm_key); + EXPECT_TRUE(layer_state_is(1)); + VERIFY_AND_CLEAR(driver); + + // Tap regular key. + EXPECT_REPORT(driver, (osm_key.report_code, regular_key.report_code)); + EXPECT_EMPTY_REPORT(driver); + tap_key(regular_key); + VERIFY_AND_CLEAR(driver); +} diff --git a/tests/tap_hold_configurations/chordal_hold/permissive_hold_flow_tap/test_tap_hold.cpp b/tests/tap_hold_configurations/chordal_hold/permissive_hold_flow_tap/test_tap_hold.cpp new file mode 100644 index 0000000000..05acb6f416 --- /dev/null +++ b/tests/tap_hold_configurations/chordal_hold/permissive_hold_flow_tap/test_tap_hold.cpp @@ -0,0 +1,911 @@ +// Copyright 2024-2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "keyboard_report_util.hpp" +#include "keycode.h" +#include "test_common.hpp" +#include "action_tapping.h" +#include "test_fixture.hpp" +#include "test_keymap_key.hpp" + +using testing::_; +using testing::InSequence; + +class ChordalHoldPermissiveHoldFlowTap : public TestFixture {}; + +TEST_F(ChordalHoldPermissiveHoldFlowTap, chordal_hold_handedness) { + EXPECT_EQ(chordal_hold_handedness({.col = 0, .row = 0}), 'L'); + EXPECT_EQ(chordal_hold_handedness({.col = MATRIX_COLS - 1, .row = 0}), 'R'); + EXPECT_EQ(chordal_hold_handedness({.col = 0, .row = 2}), '*'); +} + +TEST_F(ChordalHoldPermissiveHoldFlowTap, get_chordal_hold_default) { + auto make_record = [](uint8_t row, uint8_t col, keyevent_type_t type = KEY_EVENT) { + return keyrecord_t{ + .event = + { + .key = {.col = col, .row = row}, + .type = type, + .pressed = true, + }, + }; + }; + // Create two records on the left hand. + keyrecord_t record_l0 = make_record(0, 0); + keyrecord_t record_l1 = make_record(1, 0); + // Create a record on the right hand. + keyrecord_t record_r = make_record(0, MATRIX_COLS - 1); + + // Function should return true when records are on opposite hands. + EXPECT_TRUE(get_chordal_hold_default(&record_l0, &record_r)); + EXPECT_TRUE(get_chordal_hold_default(&record_r, &record_l0)); + // ... and false when on the same hand. + EXPECT_FALSE(get_chordal_hold_default(&record_l0, &record_l1)); + EXPECT_FALSE(get_chordal_hold_default(&record_l1, &record_l0)); + // But (2, 0) has handedness '*', for which true is returned for chords + // with either hand. + keyrecord_t record_l2 = make_record(2, 0); + EXPECT_TRUE(get_chordal_hold_default(&record_l2, &record_l0)); + EXPECT_TRUE(get_chordal_hold_default(&record_l2, &record_r)); + + // Create a record resulting from a combo. + keyrecord_t record_combo = make_record(0, 0, COMBO_EVENT); + // Function returns true in all cases. + EXPECT_TRUE(get_chordal_hold_default(&record_l0, &record_combo)); + EXPECT_TRUE(get_chordal_hold_default(&record_r, &record_combo)); + EXPECT_TRUE(get_chordal_hold_default(&record_combo, &record_l0)); + EXPECT_TRUE(get_chordal_hold_default(&record_combo, &record_r)); +} + +TEST_F(ChordalHoldPermissiveHoldFlowTap, chord_nested_press_settled_as_hold) { + TestDriver driver; + InSequence s; + // Mod-tap key on the left hand. + auto mod_tap_key = KeymapKey(0, 1, 0, SFT_T(KC_P)); + // Regular key on the right hand. + auto regular_key = KeymapKey(0, MATRIX_COLS - 1, 0, KC_A); + + set_keymap({mod_tap_key, regular_key}); + + // Press mod-tap key. + EXPECT_NO_REPORT(driver); + mod_tap_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Tap regular key. + EXPECT_REPORT(driver, (KC_LEFT_SHIFT)); + EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_A)); + EXPECT_REPORT(driver, (KC_LEFT_SHIFT)); + tap_key(regular_key); + VERIFY_AND_CLEAR(driver); + + // Release mod-tap key. + EXPECT_EMPTY_REPORT(driver); + mod_tap_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(ChordalHoldPermissiveHoldFlowTap, chord_rolled_press_settled_as_tap) { + TestDriver driver; + InSequence s; + // Mod-tap key on the left hand. + auto mod_tap_key = KeymapKey(0, 1, 0, SFT_T(KC_P)); + // Regular key on the right hand. + auto regular_key = KeymapKey(0, MATRIX_COLS - 1, 0, KC_A); + + set_keymap({mod_tap_key, regular_key}); + + // Press mod-tap key and regular key. + EXPECT_NO_REPORT(driver); + mod_tap_key.press(); + run_one_scan_loop(); + regular_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release mod-tap key. + EXPECT_REPORT(driver, (KC_P)); + EXPECT_REPORT(driver, (KC_P, KC_A)); + EXPECT_REPORT(driver, (KC_A)); + mod_tap_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release regular key. + EXPECT_EMPTY_REPORT(driver); + regular_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(ChordalHoldPermissiveHoldFlowTap, non_chord_with_mod_tap_settled_as_tap) { + TestDriver driver; + InSequence s; + // Mod-tap key and regular key both on the left hand. + auto mod_tap_key = KeymapKey(0, 1, 0, SFT_T(KC_P)); + auto regular_key = KeymapKey(0, 2, 0, KC_A); + + set_keymap({mod_tap_key, regular_key}); + + // Press mod-tap-hold key. + EXPECT_NO_REPORT(driver); + mod_tap_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Press regular key. + EXPECT_REPORT(driver, (KC_P)); + EXPECT_REPORT(driver, (KC_P, KC_A)); + regular_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release regular key. + EXPECT_REPORT(driver, (KC_P)); + regular_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release mod-tap-hold key. + EXPECT_EMPTY_REPORT(driver); + mod_tap_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(ChordalHoldPermissiveHoldFlowTap, tap_mod_tap_key) { + TestDriver driver; + InSequence s; + auto mod_tap_key = KeymapKey(0, 1, 0, SFT_T(KC_P)); + + set_keymap({mod_tap_key}); + + EXPECT_NO_REPORT(driver); + mod_tap_key.press(); + idle_for(TAPPING_TERM - 1); + VERIFY_AND_CLEAR(driver); + + EXPECT_REPORT(driver, (KC_P)); + EXPECT_EMPTY_REPORT(driver); + mod_tap_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(ChordalHoldPermissiveHoldFlowTap, hold_mod_tap_key) { + TestDriver driver; + InSequence s; + auto mod_tap_key = KeymapKey(0, 1, 0, SFT_T(KC_P)); + + set_keymap({mod_tap_key}); + + EXPECT_REPORT(driver, (KC_LEFT_SHIFT)); + mod_tap_key.press(); + idle_for(TAPPING_TERM + 1); + VERIFY_AND_CLEAR(driver); + + EXPECT_EMPTY_REPORT(driver); + mod_tap_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(ChordalHoldPermissiveHoldFlowTap, two_mod_taps_same_hand_hold_til_timeout) { + TestDriver driver; + InSequence s; + auto mod_tap_key1 = KeymapKey(0, MATRIX_COLS - 2, 0, RCTL_T(KC_A)); + auto mod_tap_key2 = KeymapKey(0, MATRIX_COLS - 1, 0, RSFT_T(KC_B)); + + set_keymap({mod_tap_key1, mod_tap_key2}); + + // Press mod-tap keys. + EXPECT_NO_REPORT(driver); + mod_tap_key1.press(); + run_one_scan_loop(); + mod_tap_key2.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Continue holding til the tapping term. + EXPECT_REPORT(driver, (KC_RIGHT_CTRL)); + EXPECT_REPORT(driver, (KC_RIGHT_CTRL, KC_RIGHT_SHIFT)); + idle_for(TAPPING_TERM); + VERIFY_AND_CLEAR(driver); + + // Release mod-tap keys. + EXPECT_REPORT(driver, (KC_RIGHT_SHIFT)); + mod_tap_key1.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_EMPTY_REPORT(driver); + mod_tap_key2.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(ChordalHoldPermissiveHoldFlowTap, two_mod_taps_nested_press_opposite_hands) { + TestDriver driver; + InSequence s; + auto mod_tap_key1 = KeymapKey(0, 1, 0, SFT_T(KC_A)); + auto mod_tap_key2 = KeymapKey(0, MATRIX_COLS - 1, 0, RSFT_T(KC_B)); + + set_keymap({mod_tap_key1, mod_tap_key2}); + + // Press mod-tap keys. + EXPECT_NO_REPORT(driver); + mod_tap_key1.press(); + run_one_scan_loop(); + mod_tap_key2.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release mod-tap keys. + EXPECT_REPORT(driver, (KC_LEFT_SHIFT)); + EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_B)); + EXPECT_REPORT(driver, (KC_LEFT_SHIFT)); + mod_tap_key2.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_EMPTY_REPORT(driver); + mod_tap_key1.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(ChordalHoldPermissiveHoldFlowTap, two_mod_taps_nested_press_same_hand) { + TestDriver driver; + InSequence s; + auto mod_tap_key1 = KeymapKey(0, 1, 0, SFT_T(KC_A)); + auto mod_tap_key2 = KeymapKey(0, 2, 0, RSFT_T(KC_B)); + + set_keymap({mod_tap_key1, mod_tap_key2}); + + // Press mod-tap keys. + EXPECT_NO_REPORT(driver); + mod_tap_key1.press(); + run_one_scan_loop(); + mod_tap_key2.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release mod-tap keys. + EXPECT_REPORT(driver, (KC_A)); + EXPECT_REPORT(driver, (KC_A, KC_B)); + EXPECT_REPORT(driver, (KC_A)); + mod_tap_key2.release(); + run_one_scan_loop(); + + EXPECT_EMPTY_REPORT(driver); + mod_tap_key1.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(ChordalHoldPermissiveHoldFlowTap, three_mod_taps_same_hand_streak_roll) { + TestDriver driver; + InSequence s; + auto mod_tap_key1 = KeymapKey(0, 1, 0, SFT_T(KC_A)); + auto mod_tap_key2 = KeymapKey(0, 2, 0, CTL_T(KC_B)); + auto mod_tap_key3 = KeymapKey(0, 3, 0, RSFT_T(KC_C)); + + set_keymap({mod_tap_key1, mod_tap_key2, mod_tap_key3}); + + // Press mod-tap keys. + EXPECT_NO_REPORT(driver); + mod_tap_key1.press(); + run_one_scan_loop(); + mod_tap_key2.press(); + run_one_scan_loop(); + mod_tap_key3.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release keys 1, 2, 3. + EXPECT_REPORT(driver, (KC_A)); + EXPECT_REPORT(driver, (KC_A, KC_B)); + EXPECT_REPORT(driver, (KC_A, KC_B, KC_C)); + EXPECT_REPORT(driver, (KC_B, KC_C)); + EXPECT_REPORT(driver, (KC_C)); + EXPECT_EMPTY_REPORT(driver); + mod_tap_key1.release(); + run_one_scan_loop(); + mod_tap_key2.release(); + run_one_scan_loop(); + mod_tap_key3.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(ChordalHoldPermissiveHoldFlowTap, three_mod_taps_same_hand_streak_orders) { + TestDriver driver; + InSequence s; + auto mod_tap_key1 = KeymapKey(0, 1, 0, SFT_T(KC_A)); + auto mod_tap_key2 = KeymapKey(0, 2, 0, CTL_T(KC_B)); + auto mod_tap_key3 = KeymapKey(0, 3, 0, RSFT_T(KC_C)); + + set_keymap({mod_tap_key1, mod_tap_key2, mod_tap_key3}); + + // Press mod-tap keys. + EXPECT_NO_REPORT(driver); + mod_tap_key1.press(); + run_one_scan_loop(); + mod_tap_key2.press(); + run_one_scan_loop(); + mod_tap_key3.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release keys 3, 2, 1. + EXPECT_REPORT(driver, (KC_A)); + EXPECT_REPORT(driver, (KC_A, KC_B)); + EXPECT_REPORT(driver, (KC_A, KC_B, KC_C)); + EXPECT_REPORT(driver, (KC_A, KC_B)); + mod_tap_key3.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_REPORT(driver, (KC_A)); + mod_tap_key2.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_EMPTY_REPORT(driver); + mod_tap_key1.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Press mod-tap keys. + EXPECT_NO_REPORT(driver); + idle_for(TAPPING_TERM); + mod_tap_key1.press(); + run_one_scan_loop(); + mod_tap_key2.press(); + run_one_scan_loop(); + mod_tap_key3.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release keys 3, 1, 2. + EXPECT_REPORT(driver, (KC_A)); + EXPECT_REPORT(driver, (KC_A, KC_B)); + EXPECT_REPORT(driver, (KC_A, KC_B, KC_C)); + EXPECT_REPORT(driver, (KC_A, KC_B)); + mod_tap_key3.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_REPORT(driver, (KC_B)); + mod_tap_key1.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_EMPTY_REPORT(driver); + mod_tap_key2.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Press mod-tap keys. + EXPECT_NO_REPORT(driver); + idle_for(TAPPING_TERM); + mod_tap_key1.press(); + run_one_scan_loop(); + mod_tap_key2.press(); + run_one_scan_loop(); + mod_tap_key3.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release keys 2, 3, 1. + EXPECT_REPORT(driver, (KC_A)); + EXPECT_REPORT(driver, (KC_A, KC_B)); + EXPECT_REPORT(driver, (KC_A, KC_B, KC_C)); + EXPECT_REPORT(driver, (KC_A, KC_C)); + EXPECT_REPORT(driver, (KC_A)); + EXPECT_EMPTY_REPORT(driver); + mod_tap_key2.release(); + run_one_scan_loop(); + mod_tap_key3.release(); + run_one_scan_loop(); + mod_tap_key1.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_NO_REPORT(driver); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(ChordalHoldPermissiveHoldFlowTap, three_mod_taps_opposite_hands_roll) { + TestDriver driver; + InSequence s; + auto mod_tap_key1 = KeymapKey(0, 1, 0, SFT_T(KC_A)); + auto mod_tap_key2 = KeymapKey(0, 2, 0, CTL_T(KC_B)); + auto mod_tap_key3 = KeymapKey(0, MATRIX_COLS - 1, 0, RSFT_T(KC_C)); + + set_keymap({mod_tap_key1, mod_tap_key2, mod_tap_key3}); + + // Press mod-tap keys. + EXPECT_NO_REPORT(driver); + mod_tap_key1.press(); + run_one_scan_loop(); + mod_tap_key2.press(); + run_one_scan_loop(); + mod_tap_key3.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release keys 1, 2, 3. + EXPECT_REPORT(driver, (KC_A)); + EXPECT_REPORT(driver, (KC_A, KC_B)); + EXPECT_REPORT(driver, (KC_A, KC_B, KC_C)); + EXPECT_REPORT(driver, (KC_B, KC_C)); + EXPECT_REPORT(driver, (KC_C)); + EXPECT_EMPTY_REPORT(driver); + mod_tap_key1.release(); + run_one_scan_loop(); + mod_tap_key2.release(); + run_one_scan_loop(); + mod_tap_key3.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(ChordalHoldPermissiveHoldFlowTap, three_mod_taps_two_left_one_right) { + TestDriver driver; + InSequence s; + auto mod_tap_key1 = KeymapKey(0, 1, 0, SFT_T(KC_A)); + auto mod_tap_key2 = KeymapKey(0, 2, 0, CTL_T(KC_B)); + auto mod_tap_key3 = KeymapKey(0, MATRIX_COLS - 1, 0, RSFT_T(KC_C)); + + set_keymap({mod_tap_key1, mod_tap_key2, mod_tap_key3}); + + // Press mod-tap keys. + EXPECT_NO_REPORT(driver); + mod_tap_key1.press(); + run_one_scan_loop(); + mod_tap_key2.press(); + run_one_scan_loop(); + mod_tap_key3.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release key 3. + EXPECT_REPORT(driver, (KC_LEFT_SHIFT)); + EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_LEFT_CTRL)); + EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_LEFT_CTRL, KC_C)); + EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_LEFT_CTRL)); + mod_tap_key3.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release key 2, then key 1. + EXPECT_REPORT(driver, (KC_LEFT_SHIFT)); + mod_tap_key2.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_EMPTY_REPORT(driver); + mod_tap_key1.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Press mod-tap keys. + EXPECT_NO_REPORT(driver); + idle_for(TAPPING_TERM); + mod_tap_key1.press(); + run_one_scan_loop(); + mod_tap_key2.press(); + run_one_scan_loop(); + mod_tap_key3.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release key 3. + EXPECT_REPORT(driver, (KC_LEFT_SHIFT)); + EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_LEFT_CTRL)); + EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_LEFT_CTRL, KC_C)); + EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_LEFT_CTRL)); + mod_tap_key3.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release key 1, then key 2. + EXPECT_REPORT(driver, (KC_LEFT_CTRL)); + mod_tap_key1.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_EMPTY_REPORT(driver); + mod_tap_key2.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(ChordalHoldPermissiveHoldFlowTap, three_mod_taps_one_held_two_tapped) { + TestDriver driver; + InSequence s; + auto mod_tap_key1 = KeymapKey(0, 1, 0, SFT_T(KC_A)); + auto mod_tap_key2 = KeymapKey(0, MATRIX_COLS - 2, 0, CTL_T(KC_B)); + auto mod_tap_key3 = KeymapKey(0, MATRIX_COLS - 1, 0, RSFT_T(KC_C)); + + set_keymap({mod_tap_key1, mod_tap_key2, mod_tap_key3}); + + // Press mod-tap keys. + EXPECT_NO_REPORT(driver); + mod_tap_key1.press(); + run_one_scan_loop(); + mod_tap_key2.press(); + run_one_scan_loop(); + mod_tap_key3.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release keys 3, 2, 1. + EXPECT_REPORT(driver, (KC_LEFT_SHIFT)); + EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_B)); + EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_B, KC_C)); + EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_B)); + mod_tap_key3.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_REPORT(driver, (KC_LEFT_SHIFT)); + mod_tap_key2.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_EMPTY_REPORT(driver); + mod_tap_key1.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Press mod-tap keys. + EXPECT_NO_REPORT(driver); + idle_for(TAPPING_TERM); + mod_tap_key1.press(); + run_one_scan_loop(); + mod_tap_key2.press(); + run_one_scan_loop(); + mod_tap_key3.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release keys 3, 1, 2. + EXPECT_REPORT(driver, (KC_LEFT_SHIFT)); + EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_B)); + EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_B, KC_C)); + EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_B)); + mod_tap_key3.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_REPORT(driver, (KC_B)); + mod_tap_key1.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_EMPTY_REPORT(driver); + mod_tap_key2.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(ChordalHoldPermissiveHoldFlowTap, two_mod_taps_one_regular_key) { + TestDriver driver; + InSequence s; + auto mod_tap_key1 = KeymapKey(0, 1, 0, SFT_T(KC_A)); + auto mod_tap_key2 = KeymapKey(0, MATRIX_COLS - 2, 0, CTL_T(KC_B)); + auto regular_key = KeymapKey(0, MATRIX_COLS - 1, 0, KC_C); + + set_keymap({mod_tap_key1, mod_tap_key2, regular_key}); + + // Press keys. + EXPECT_NO_REPORT(driver); + mod_tap_key1.press(); + run_one_scan_loop(); + mod_tap_key2.press(); + run_one_scan_loop(); + regular_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release keys. + EXPECT_REPORT(driver, (KC_LEFT_SHIFT)); + EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_B)); + EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_B, KC_C)); + EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_C)); + mod_tap_key2.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_REPORT(driver, (KC_LEFT_SHIFT)); + regular_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_EMPTY_REPORT(driver); + mod_tap_key1.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Press mod-tap keys. + EXPECT_NO_REPORT(driver); + idle_for(TAPPING_TERM); + mod_tap_key1.press(); + run_one_scan_loop(); + mod_tap_key2.press(); + run_one_scan_loop(); + regular_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release keys. + EXPECT_REPORT(driver, (KC_LEFT_SHIFT)); + EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_B)); + EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_B, KC_C)); + EXPECT_REPORT(driver, (KC_LEFT_SHIFT, KC_B)); + regular_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_REPORT(driver, (KC_B)); + mod_tap_key1.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_EMPTY_REPORT(driver); + mod_tap_key2.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(ChordalHoldPermissiveHoldFlowTap, tap_regular_key_while_layer_tap_key_is_held) { + TestDriver driver; + InSequence s; + auto layer_tap_hold_key = KeymapKey(0, 1, 0, LT(1, KC_P)); + auto regular_key = KeymapKey(0, MATRIX_COLS - 1, 0, KC_A); + auto no_key = KeymapKey(1, 1, 0, XXXXXXX); + auto layer_key = KeymapKey(1, MATRIX_COLS - 1, 0, KC_B); + + set_keymap({layer_tap_hold_key, regular_key, no_key, layer_key}); + + // Press layer-tap-hold key. + EXPECT_NO_REPORT(driver); + layer_tap_hold_key.press(); + run_one_scan_loop(); + // Press regular key. + regular_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release regular key. + EXPECT_REPORT(driver, (KC_B)); + EXPECT_EMPTY_REPORT(driver); + regular_key.release(); + run_one_scan_loop(); + EXPECT_EQ(layer_state, 2); + VERIFY_AND_CLEAR(driver); + + // Release layer-tap-hold key. + EXPECT_NO_REPORT(driver); + layer_tap_hold_key.release(); + run_one_scan_loop(); + EXPECT_EQ(layer_state, 0); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(ChordalHoldPermissiveHoldFlowTap, nested_tap_of_layer_0_layer_tap_keys) { + TestDriver driver; + InSequence s; + // The keys are layer-taps on layer 2 but regular keys on layer 1. + auto first_layer_tap_key = KeymapKey(0, 1, 0, LT(1, KC_A)); + auto second_layer_tap_key = KeymapKey(0, MATRIX_COLS - 1, 0, LT(1, KC_P)); + auto first_key_on_layer = KeymapKey(1, 1, 0, KC_B); + auto second_key_on_layer = KeymapKey(1, MATRIX_COLS - 1, 0, KC_Q); + + set_keymap({first_layer_tap_key, second_layer_tap_key, first_key_on_layer, second_key_on_layer}); + + // Press first layer-tap key. + EXPECT_NO_REPORT(driver); + first_layer_tap_key.press(); + run_one_scan_loop(); + // Press second layer-tap key. + second_layer_tap_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release second layer-tap key. + EXPECT_REPORT(driver, (KC_Q)); + EXPECT_EMPTY_REPORT(driver); + second_layer_tap_key.release(); + run_one_scan_loop(); + EXPECT_EQ(layer_state, 2); + VERIFY_AND_CLEAR(driver); + + // Release first layer-tap key. + EXPECT_NO_REPORT(driver); + first_layer_tap_key.release(); + run_one_scan_loop(); + EXPECT_EQ(layer_state, 0); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(ChordalHoldPermissiveHoldFlowTap, lt_mt_one_regular_key) { + TestDriver driver; + InSequence s; + auto lt_key = KeymapKey(0, 1, 0, LT(1, KC_A)); + auto mt_key0 = KeymapKey(0, 2, 0, SFT_T(KC_B)); + auto mt_key1 = KeymapKey(1, 2, 0, CTL_T(KC_C)); + auto regular_key = KeymapKey(1, MATRIX_COLS - 1, 0, KC_X); + auto no_key0 = KeymapKey(0, MATRIX_COLS - 1, 0, XXXXXXX); + auto no_key1 = KeymapKey(1, 1, 0, XXXXXXX); + + set_keymap({lt_key, mt_key0, mt_key1, regular_key, no_key0, no_key1}); + + // Press LT, MT, and regular key. + EXPECT_NO_REPORT(driver); + lt_key.press(); + run_one_scan_loop(); + mt_key1.press(); + run_one_scan_loop(); + regular_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release the regular key. + EXPECT_REPORT(driver, (KC_LCTL)); + EXPECT_REPORT(driver, (KC_LCTL, KC_X)); + EXPECT_REPORT(driver, (KC_LCTL)); + regular_key.release(); + run_one_scan_loop(); + EXPECT_EQ(get_mods(), MOD_BIT_LCTRL); + EXPECT_EQ(layer_state, 2); + VERIFY_AND_CLEAR(driver); + + // Release MT key. + EXPECT_EMPTY_REPORT(driver); + mt_key1.release(); + run_one_scan_loop(); + EXPECT_EQ(get_mods(), 0); + VERIFY_AND_CLEAR(driver); + + // Release LT key. + EXPECT_NO_REPORT(driver); + lt_key.release(); + run_one_scan_loop(); + EXPECT_EQ(layer_state, 0); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(ChordalHoldPermissiveHoldFlowTap, nested_tap_of_layer_tap_keys) { + TestDriver driver; + InSequence s; + // The keys are layer-taps on all layers. + auto first_key_layer_0 = KeymapKey(0, 1, 0, LT(1, KC_A)); + auto second_key_layer_0 = KeymapKey(0, MATRIX_COLS - 1, 0, LT(1, KC_P)); + auto first_key_layer_1 = KeymapKey(1, 1, 0, LT(2, KC_B)); + auto second_key_layer_1 = KeymapKey(1, MATRIX_COLS - 1, 0, LT(2, KC_Q)); + auto first_key_layer_2 = KeymapKey(2, 1, 0, KC_TRNS); + auto second_key_layer_2 = KeymapKey(2, MATRIX_COLS - 1, 0, KC_TRNS); + + set_keymap({first_key_layer_0, second_key_layer_0, first_key_layer_1, second_key_layer_1, first_key_layer_2, second_key_layer_2}); + + // Press first layer-tap key. + EXPECT_NO_REPORT(driver); + first_key_layer_0.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Press second layer-tap key. + EXPECT_NO_REPORT(driver); + second_key_layer_0.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release second layer-tap key. + EXPECT_REPORT(driver, (KC_Q)); + EXPECT_EMPTY_REPORT(driver); + second_key_layer_0.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release first layer-tap key. + EXPECT_NO_REPORT(driver); + first_key_layer_0.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(ChordalHoldPermissiveHoldFlowTap, roll_layer_tap_key_with_regular_key) { + TestDriver driver; + InSequence s; + + auto layer_tap_hold_key = KeymapKey(0, 1, 0, LT(1, KC_P)); + auto regular_key = KeymapKey(0, MATRIX_COLS - 1, 0, KC_A); + auto layer_key = KeymapKey(1, MATRIX_COLS - 1, 0, KC_B); + + set_keymap({layer_tap_hold_key, regular_key, layer_key}); + + // Press layer-tap-hold key. + EXPECT_NO_REPORT(driver); + layer_tap_hold_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Press regular key. + EXPECT_NO_REPORT(driver); + regular_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release layer-tap-hold key. + EXPECT_REPORT(driver, (KC_P)); + EXPECT_REPORT(driver, (KC_P, KC_A)); + EXPECT_REPORT(driver, (KC_A)); + layer_tap_hold_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release regular key. + EXPECT_EMPTY_REPORT(driver); + regular_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(ChordalHoldPermissiveHoldFlowTap, two_mod_tap_keys_stuttered_press) { + TestDriver driver; + InSequence s; + + auto mod_tap_key1 = KeymapKey(0, 1, 0, LSFT_T(KC_A)); + auto mod_tap_key2 = KeymapKey(0, 2, 0, LCTL_T(KC_B)); + + set_keymap({mod_tap_key1, mod_tap_key2}); + + // Hold first mod-tap key until the tapping term. + EXPECT_REPORT(driver, (KC_LSFT)); + mod_tap_key1.press(); + idle_for(TAPPING_TERM + 1); + VERIFY_AND_CLEAR(driver); + + // Press the second mod-tap key, then quickly release and press the first. + EXPECT_NO_REPORT(driver); + mod_tap_key2.press(); + run_one_scan_loop(); + mod_tap_key1.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_REPORT(driver, (KC_LSFT, KC_B)); + EXPECT_REPORT(driver, (KC_B)); + EXPECT_REPORT(driver, (KC_B, KC_A)); + mod_tap_key1.press(); + run_one_scan_loop(); + EXPECT_EQ(get_mods(), 0); // Verify that Shift was released. + VERIFY_AND_CLEAR(driver); + + // Release both keys. + EXPECT_REPORT(driver, (KC_A)); + mod_tap_key2.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_EMPTY_REPORT(driver); + mod_tap_key1.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} diff --git a/tests/tap_hold_configurations/flow_tap/config.h b/tests/tap_hold_configurations/flow_tap/config.h new file mode 100644 index 0000000000..d6f385d8d4 --- /dev/null +++ b/tests/tap_hold_configurations/flow_tap/config.h @@ -0,0 +1,23 @@ +/* Copyright 2022 Vladislav Kucheriavykh + * Copyright 2025 Google LLC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include "test_common.h" + +#define FLOW_TAP_TERM 150 +#define PERMISSIVE_HOLD diff --git a/tests/tap_hold_configurations/flow_tap/test.mk b/tests/tap_hold_configurations/flow_tap/test.mk new file mode 100644 index 0000000000..81ba8da66d --- /dev/null +++ b/tests/tap_hold_configurations/flow_tap/test.mk @@ -0,0 +1,18 @@ +# Copyright 2022 Vladislav Kucheriavykh +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +COMBO_ENABLE = yes + +INTROSPECTION_KEYMAP_C = test_keymap.c diff --git a/tests/tap_hold_configurations/flow_tap/test_keymap.c b/tests/tap_hold_configurations/flow_tap/test_keymap.c new file mode 100644 index 0000000000..4dfe5e4cb6 --- /dev/null +++ b/tests/tap_hold_configurations/flow_tap/test_keymap.c @@ -0,0 +1,23 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "quantum.h" + +uint16_t const mt_lt_combo[] = {SFT_T(KC_X), LT(1, KC_Y), COMBO_END}; + +// clang-format off +combo_t key_combos[] = { + COMBO(mt_lt_combo, KC_Z), +}; +// clang-format on diff --git a/tests/tap_hold_configurations/flow_tap/test_tap_hold.cpp b/tests/tap_hold_configurations/flow_tap/test_tap_hold.cpp new file mode 100644 index 0000000000..d419a3b313 --- /dev/null +++ b/tests/tap_hold_configurations/flow_tap/test_tap_hold.cpp @@ -0,0 +1,844 @@ +// Copyright 2025 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "keyboard_report_util.hpp" +#include "keycode.h" +#include "test_common.hpp" +#include "action_tapping.h" +#include "test_fixture.hpp" +#include "test_keymap_key.hpp" + +using testing::_; +using testing::AnyNumber; +using testing::InSequence; + +class FlowTapTest : public TestFixture {}; + +// Test an input of quick distinct taps. All should be settled as tapped. +TEST_F(FlowTapTest, distinct_taps) { + TestDriver driver; + InSequence s; + auto regular_key = KeymapKey(0, 0, 0, KC_A); + auto mod_tap_key1 = KeymapKey(0, 1, 0, SFT_T(KC_B)); + auto mod_tap_key2 = KeymapKey(0, 2, 0, CTL_T(KC_C)); + auto mod_tap_key3 = KeymapKey(0, 3, 0, ALT_T(KC_D)); + + set_keymap({regular_key, mod_tap_key1, mod_tap_key2, mod_tap_key3}); + + // Tap regular key. + EXPECT_REPORT(driver, (KC_A)); + EXPECT_EMPTY_REPORT(driver); + tap_key(regular_key, FLOW_TAP_TERM + 1); + VERIFY_AND_CLEAR(driver); + + // Tap mod-tap 1. + EXPECT_REPORT(driver, (KC_B)); + mod_tap_key1.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_EMPTY_REPORT(driver); + idle_for(FLOW_TAP_TERM + 1); + mod_tap_key1.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Tap mod-tap 2. + EXPECT_REPORT(driver, (KC_C)); + mod_tap_key2.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_EMPTY_REPORT(driver); + idle_for(FLOW_TAP_TERM + 1); + mod_tap_key2.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Tap mod-tap 3. + EXPECT_REPORT(driver, (KC_D)); + mod_tap_key3.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_EMPTY_REPORT(driver); + idle_for(FLOW_TAP_TERM + 1); + mod_tap_key3.release(); + idle_for(FLOW_TAP_TERM + 1); // Pause between taps. + VERIFY_AND_CLEAR(driver); + + // Tap mod-tap 1. + EXPECT_NO_REPORT(driver); + mod_tap_key1.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_REPORT(driver, (KC_B)); + EXPECT_EMPTY_REPORT(driver); + idle_for(FLOW_TAP_TERM + 1); + mod_tap_key1.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Tap mod-tap 2. + EXPECT_REPORT(driver, (KC_C)); + mod_tap_key2.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_EMPTY_REPORT(driver); + idle_for(TAPPING_TERM + 1); + mod_tap_key2.release(); + idle_for(FLOW_TAP_TERM + 1); + VERIFY_AND_CLEAR(driver); +} + +// By default, Flow Tap is disabled when mods other than Shift and AltGr are on. +TEST_F(FlowTapTest, hotkey_taps) { + TestDriver driver; + InSequence s; + auto ctrl_key = KeymapKey(0, 0, 0, KC_LCTL); + auto shft_key = KeymapKey(0, 1, 0, KC_LSFT); + auto alt_key = KeymapKey(0, 2, 0, KC_LALT); + auto gui_key = KeymapKey(0, 3, 0, KC_LGUI); + auto regular_key = KeymapKey(0, 4, 0, KC_A); + auto mod_tap_key = KeymapKey(0, 5, 0, RCTL_T(KC_B)); + + set_keymap({ctrl_key, shft_key, alt_key, gui_key, regular_key, mod_tap_key}); + + for (KeymapKey* mod_key : {&ctrl_key, &alt_key, &gui_key}) { + // Hold mod key. + EXPECT_REPORT(driver, (mod_key->code)); + mod_key->press(); + run_one_scan_loop(); + + // Tap regular key. + EXPECT_REPORT(driver, (mod_key->code, KC_A)); + regular_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_REPORT(driver, (mod_key->code)); + regular_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Press mod-tap, where Flow Tap is disabled due to the held mod. + EXPECT_REPORT(driver, (mod_key->code, KC_RCTL)); + mod_tap_key.press(); + idle_for(TAPPING_TERM + 1); + VERIFY_AND_CLEAR(driver); + + // Release mod-tap. + EXPECT_REPORT(driver, (mod_key->code)); + mod_tap_key.release(); + run_one_scan_loop(); + + // Release mod key. + EXPECT_EMPTY_REPORT(driver); + mod_key->release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + } + + // Hold Shift key. + EXPECT_REPORT(driver, (KC_LSFT)); + shft_key.press(); + run_one_scan_loop(); + + // Tap regular key. + EXPECT_REPORT(driver, (KC_LSFT, KC_A)); + regular_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_REPORT(driver, (KC_LSFT)); + regular_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Press mod-tap, where Flow Tap applies to settle as tapped. + EXPECT_REPORT(driver, (KC_LSFT, KC_B)); + mod_tap_key.press(); + idle_for(TAPPING_TERM + 1); + VERIFY_AND_CLEAR(driver); + + // Release mod-tap. + EXPECT_REPORT(driver, (KC_LSFT)); + mod_tap_key.release(); + run_one_scan_loop(); + + // Release Shift key. + EXPECT_EMPTY_REPORT(driver); + shft_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +// Test input with two mod-taps in a rolled press quickly after a regular key. +TEST_F(FlowTapTest, rolled_press) { + TestDriver driver; + InSequence s; + auto regular_key = KeymapKey(0, 0, 0, KC_A); + auto mod_tap_key1 = KeymapKey(0, 1, 0, SFT_T(KC_B)); + auto mod_tap_key2 = KeymapKey(0, 2, 0, CTL_T(KC_C)); + + set_keymap({regular_key, mod_tap_key1, mod_tap_key2}); + + // Tap regular key. + EXPECT_REPORT(driver, (KC_A)); + EXPECT_EMPTY_REPORT(driver); + tap_key(regular_key); + VERIFY_AND_CLEAR(driver); + + // Press mod-tap key 1 quickly after regular key. The mod-tap should settle + // immediately as tapped, sending `KC_B`. + EXPECT_REPORT(driver, (KC_B)); + mod_tap_key1.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Press mod-tap key 2 quickly. + EXPECT_REPORT(driver, (KC_B, KC_C)); + mod_tap_key2.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Hold for longer than the tapping term. + EXPECT_NO_REPORT(driver); + idle_for(TAPPING_TERM + 1); + VERIFY_AND_CLEAR(driver); + + // Release mod-tap keys. + EXPECT_REPORT(driver, (KC_C)); + EXPECT_EMPTY_REPORT(driver); + mod_tap_key1.release(); + run_one_scan_loop(); + mod_tap_key2.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(FlowTapTest, long_flow_tap_settled_as_held) { + TestDriver driver; + InSequence s; + auto regular_key = KeymapKey(0, 0, 0, KC_A); + auto mod_tap_key = KeymapKey(0, 1, 0, SFT_T(KC_B)); + + set_keymap({regular_key, mod_tap_key}); + + // Tap regular key. + EXPECT_REPORT(driver, (KC_A)); + EXPECT_EMPTY_REPORT(driver); + tap_key(regular_key); + VERIFY_AND_CLEAR(driver); + + EXPECT_NO_REPORT(driver); + idle_for(FLOW_TAP_TERM + 1); + VERIFY_AND_CLEAR(driver); + + // Press mod-tap key. + EXPECT_NO_REPORT(driver); + mod_tap_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Hold for the tapping term. + EXPECT_REPORT(driver, (KC_LSFT)); + idle_for(TAPPING_TERM); + VERIFY_AND_CLEAR(driver); + + // Release mod-tap key. + EXPECT_EMPTY_REPORT(driver); + mod_tap_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(FlowTapTest, holding_multiple_mod_taps) { + TestDriver driver; + InSequence s; + auto regular_key = KeymapKey(0, 0, 0, KC_A); + auto mod_tap_key1 = KeymapKey(0, 1, 0, SFT_T(KC_B)); + auto mod_tap_key2 = KeymapKey(0, 2, 0, CTL_T(KC_C)); + + set_keymap({regular_key, mod_tap_key1, mod_tap_key2}); + + // Tap regular key. + EXPECT_REPORT(driver, (KC_A)); + EXPECT_EMPTY_REPORT(driver); + tap_key(regular_key); + VERIFY_AND_CLEAR(driver); + + EXPECT_NO_REPORT(driver); + idle_for(FLOW_TAP_TERM + 1); + VERIFY_AND_CLEAR(driver); + + // Press mod-tap keys. + EXPECT_NO_REPORT(driver); + mod_tap_key1.press(); + run_one_scan_loop(); + mod_tap_key2.press(); + idle_for(TAPPING_TERM - 5); // Hold almost until tapping term. + VERIFY_AND_CLEAR(driver); + + // Press regular key. + EXPECT_REPORT(driver, (KC_LSFT)); + EXPECT_REPORT(driver, (KC_LSFT, KC_LCTL)); + EXPECT_REPORT(driver, (KC_LSFT, KC_LCTL, KC_A)); + regular_key.press(); + idle_for(10); + VERIFY_AND_CLEAR(driver); + + // Release keys. + EXPECT_REPORT(driver, (KC_LSFT, KC_LCTL)); + EXPECT_REPORT(driver, (KC_LCTL)); + EXPECT_EMPTY_REPORT(driver); + regular_key.release(); + run_one_scan_loop(); + mod_tap_key1.release(); + run_one_scan_loop(); + mod_tap_key2.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(FlowTapTest, holding_mod_tap_with_regular_mod) { + TestDriver driver; + InSequence s; + auto regular_key = KeymapKey(0, 0, 0, KC_A); + auto mod_key = KeymapKey(0, 1, 0, KC_LSFT); + auto mod_tap_key = KeymapKey(0, 2, 0, CTL_T(KC_C)); + + set_keymap({regular_key, mod_key, mod_tap_key}); + + // Tap regular key. + EXPECT_REPORT(driver, (KC_A)); + EXPECT_EMPTY_REPORT(driver); + tap_key(regular_key); + VERIFY_AND_CLEAR(driver); + + EXPECT_NO_REPORT(driver); + idle_for(FLOW_TAP_TERM + 1); + VERIFY_AND_CLEAR(driver); + + // Press mod and mod-tap keys. + EXPECT_REPORT(driver, (KC_LSFT)); + mod_key.press(); + run_one_scan_loop(); + mod_tap_key.press(); + idle_for(TAPPING_TERM - 5); // Hold almost until tapping term. + VERIFY_AND_CLEAR(driver); + + // Press regular key. + EXPECT_REPORT(driver, (KC_LSFT, KC_LCTL)); + EXPECT_REPORT(driver, (KC_LSFT, KC_LCTL, KC_A)); + regular_key.press(); + idle_for(10); + VERIFY_AND_CLEAR(driver); + + // Release keys. + EXPECT_REPORT(driver, (KC_LSFT, KC_LCTL)); + EXPECT_REPORT(driver, (KC_LCTL)); + EXPECT_EMPTY_REPORT(driver); + regular_key.release(); + run_one_scan_loop(); + mod_key.release(); + run_one_scan_loop(); + mod_tap_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(FlowTapTest, layer_tap_key) { + TestDriver driver; + InSequence s; + auto regular_key = KeymapKey(0, 0, 0, KC_A); + auto layer_tap_key = KeymapKey(0, 1, 0, LT(1, KC_B)); + auto regular_key2 = KeymapKey(1, 0, 0, KC_C); + + set_keymap({regular_key, layer_tap_key, regular_key2}); + + // Tap regular key. + EXPECT_REPORT(driver, (KC_A)); + EXPECT_EMPTY_REPORT(driver); + tap_key(regular_key); + VERIFY_AND_CLEAR(driver); + + // Press layer-tap key, quickly after the regular key. + EXPECT_REPORT(driver, (KC_B)); + layer_tap_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_NO_REPORT(driver); + idle_for(TAPPING_TERM + 1); + VERIFY_AND_CLEAR(driver); + + // Release layer-tap key. + EXPECT_EMPTY_REPORT(driver); + layer_tap_key.release(); + run_one_scan_loop(); + + // Tap regular key. + EXPECT_REPORT(driver, (KC_A)); + EXPECT_EMPTY_REPORT(driver); + tap_key(regular_key); + VERIFY_AND_CLEAR(driver); + + EXPECT_NO_REPORT(driver); + idle_for(FLOW_TAP_TERM + 1); + VERIFY_AND_CLEAR(driver); + + // Press layer-tap key, slowly after the regular key. + EXPECT_NO_REPORT(driver); + layer_tap_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_NO_REPORT(driver); + idle_for(TAPPING_TERM + 1); + EXPECT_EQ(layer_state, 1 << 1); + VERIFY_AND_CLEAR(driver); + + // Tap regular key2. + EXPECT_REPORT(driver, (KC_C)); + EXPECT_EMPTY_REPORT(driver); + tap_key(regular_key); + VERIFY_AND_CLEAR(driver); + + // Release layer-tap key. + EXPECT_NO_REPORT(driver); + layer_tap_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(FlowTapTest, layer_tap_ignored_with_disabled_key) { + TestDriver driver; + InSequence s; + auto no_key = KeymapKey(0, 0, 0, KC_NO); + auto regular_key = KeymapKey(1, 0, 0, KC_ESC); + auto layer_tap_key = KeymapKey(0, 1, 0, LT(1, KC_A)); + auto mod_tap_key = KeymapKey(0, 2, 0, CTL_T(KC_B)); + + set_keymap({no_key, regular_key, layer_tap_key, mod_tap_key}); + + EXPECT_REPORT(driver, (KC_ESC)); + EXPECT_EMPTY_REPORT(driver); + layer_tap_key.press(); + idle_for(TAPPING_TERM + 1); + tap_key(regular_key); + layer_tap_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_REPORT(driver, (KC_LCTL)); + mod_tap_key.press(); + idle_for(TAPPING_TERM + 1); + VERIFY_AND_CLEAR(driver); + + EXPECT_EMPTY_REPORT(driver); + mod_tap_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(FlowTapTest, layer_tap_ignored_with_disabled_key_complex) { + TestDriver driver; + InSequence s; + auto regular_key1 = KeymapKey(0, 0, 0, KC_Q); + auto layer_tap_key = KeymapKey(0, 1, 0, LT(1, KC_SPC)); + auto mod_tap_key1 = KeymapKey(0, 2, 0, CTL_T(KC_T)); + // Place RALT_T(KC_I), where Flow Tap is enabled, in the same position on + // layer 0 as KC_RGHT, where Flow Tap is disabled. This tests that Flow Tap + // tracks the keycode from the correct layer. + auto mod_tap_key2 = KeymapKey(0, 3, 0, RALT_T(KC_I)); + auto regular_key2 = KeymapKey(1, 3, 0, KC_RGHT); + + set_keymap({regular_key1, layer_tap_key, mod_tap_key1, mod_tap_key2, regular_key2}); + + // Tap regular key 1. + EXPECT_REPORT(driver, (KC_Q)); + EXPECT_EMPTY_REPORT(driver); + tap_key(regular_key1); + idle_for(FLOW_TAP_TERM + 1); + VERIFY_AND_CLEAR(driver); + + // Hold layer-tap key. + EXPECT_NO_REPORT(driver); + layer_tap_key.press(); + run_one_scan_loop(); + // idle_for(TAPPING_TERM + 1); + VERIFY_AND_CLEAR(driver); + + // Tap regular key 2. + EXPECT_REPORT(driver, (KC_RGHT)); + EXPECT_EMPTY_REPORT(driver); + tap_key(regular_key2); + VERIFY_AND_CLEAR(driver); + + // Release layer-tap key. + EXPECT_NO_REPORT(driver); + layer_tap_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Quickly hold mod-tap key 1. + EXPECT_NO_REPORT(driver); + mod_tap_key1.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_REPORT(driver, (KC_LCTL)); + EXPECT_REPORT(driver, (KC_LCTL, KC_Q)); + EXPECT_REPORT(driver, (KC_LCTL)); + tap_key(regular_key1); + VERIFY_AND_CLEAR(driver); + + EXPECT_EMPTY_REPORT(driver); + mod_tap_key1.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(FlowTapTest, layer_tap_ignored_with_enabled_key) { + TestDriver driver; + InSequence s; + auto no_key = KeymapKey(0, 0, 0, KC_NO); + auto regular_key = KeymapKey(1, 0, 0, KC_C); + auto layer_tap_key = KeymapKey(0, 1, 0, LT(1, KC_A)); + auto mod_tap_key = KeymapKey(0, 2, 0, CTL_T(KC_B)); + + set_keymap({no_key, regular_key, layer_tap_key, mod_tap_key}); + + EXPECT_REPORT(driver, (KC_C)); + EXPECT_EMPTY_REPORT(driver); + layer_tap_key.press(); + idle_for(TAPPING_TERM + 1); + tap_key(regular_key); + layer_tap_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_REPORT(driver, (KC_B)); + mod_tap_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_EMPTY_REPORT(driver); + idle_for(TAPPING_TERM + 1); + mod_tap_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(FlowTapTest, combo_key) { + TestDriver driver; + InSequence s; + auto regular_key = KeymapKey(0, 0, 0, KC_A); + auto mod_tap_key = KeymapKey(0, 1, 0, SFT_T(KC_X)); + auto layer_tap_key = KeymapKey(0, 2, 0, LT(1, KC_Y)); + + set_keymap({regular_key, mod_tap_key, layer_tap_key}); + + // Tap regular key. + EXPECT_REPORT(driver, (KC_A)); + EXPECT_EMPTY_REPORT(driver); + tap_key(regular_key); + VERIFY_AND_CLEAR(driver); + + // Press combo keys quickly after regular key. + EXPECT_REPORT(driver, (KC_Z)); + EXPECT_EMPTY_REPORT(driver); + tap_combo({mod_tap_key, layer_tap_key}); + VERIFY_AND_CLEAR(driver); + + // Press mod-tap key quickly. + EXPECT_REPORT(driver, (KC_X)); + mod_tap_key.press(); + idle_for(TAPPING_TERM + 1); + VERIFY_AND_CLEAR(driver); + + // Release mod-tap key. + EXPECT_EMPTY_REPORT(driver); + mod_tap_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(FlowTapTest, oneshot_mod_key) { + TestDriver driver; + InSequence s; + auto regular_key = KeymapKey(0, 0, 0, KC_A); + auto osm_key = KeymapKey(0, 1, 0, OSM(MOD_LSFT)); + + set_keymap({regular_key, osm_key}); + + // Tap regular key. + EXPECT_REPORT(driver, (KC_A)); + EXPECT_EMPTY_REPORT(driver); + tap_key(regular_key); + VERIFY_AND_CLEAR(driver); + + // Tap OSM, tap regular key. + EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).Times(AnyNumber()); + EXPECT_REPORT(driver, (KC_LSFT, KC_A)); + EXPECT_EMPTY_REPORT(driver); + tap_key(osm_key); + tap_key(regular_key); + VERIFY_AND_CLEAR(driver); + + // Nested press of OSM and regular keys. + EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).Times(AnyNumber()); + EXPECT_REPORT(driver, (KC_LSFT, KC_A)); + EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT))).Times(AnyNumber()); + EXPECT_EMPTY_REPORT(driver); + osm_key.press(); + run_one_scan_loop(); + tap_key(regular_key); + osm_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(FlowTapTest, quick_tap) { + TestDriver driver; + InSequence s; + auto mod_tap_key = KeymapKey(0, 1, 0, SFT_T(KC_A)); + + set_keymap({mod_tap_key}); + + EXPECT_REPORT(driver, (KC_A)); + EXPECT_EMPTY_REPORT(driver); + tap_key(mod_tap_key); + VERIFY_AND_CLEAR(driver); + + EXPECT_REPORT(driver, (KC_A)); + mod_tap_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_NO_REPORT(driver); + idle_for(TAPPING_TERM + 1); + VERIFY_AND_CLEAR(driver); + + // Release mod-tap key. + EXPECT_EMPTY_REPORT(driver); + mod_tap_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(FlowTapTest, rolling_mt_mt) { + TestDriver driver; + InSequence s; + auto mod_tap_key1 = KeymapKey(0, 1, 0, SFT_T(KC_A)); + auto mod_tap_key2 = KeymapKey(0, 2, 0, CTL_T(KC_B)); + + set_keymap({mod_tap_key1, mod_tap_key2}); + + EXPECT_NO_REPORT(driver); + idle_for(FLOW_TAP_TERM + 1); + mod_tap_key1.press(); + run_one_scan_loop(); + mod_tap_key2.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_REPORT(driver, (KC_A)); + EXPECT_REPORT(driver, (KC_A, KC_B)); + EXPECT_REPORT(driver, (KC_B)); + mod_tap_key1.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Hold for longer than the tapping term. + EXPECT_NO_REPORT(driver); + idle_for(TAPPING_TERM + 1); + VERIFY_AND_CLEAR(driver); + + // Release mod-tap keys. + EXPECT_EMPTY_REPORT(driver); + mod_tap_key2.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(FlowTapTest, rolling_lt_mt_regular) { + TestDriver driver; + InSequence s; + auto layer_tap_key = KeymapKey(0, 0, 0, LT(1, KC_A)); + auto mod_tap_key = KeymapKey(0, 1, 0, CTL_T(KC_B)); + auto regular_key = KeymapKey(0, 2, 0, KC_C); + + set_keymap({layer_tap_key, mod_tap_key, regular_key}); + + EXPECT_NO_REPORT(driver); + idle_for(FLOW_TAP_TERM + 1); + layer_tap_key.press(); + run_one_scan_loop(); + mod_tap_key.press(); + run_one_scan_loop(); + regular_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_REPORT(driver, (KC_A)); + EXPECT_REPORT(driver, (KC_A, KC_B)); + EXPECT_REPORT(driver, (KC_A, KC_B, KC_C)); + EXPECT_REPORT(driver, (KC_B, KC_C)); + layer_tap_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Hold for longer than the tapping term. + EXPECT_NO_REPORT(driver); + idle_for(TAPPING_TERM + 1); + VERIFY_AND_CLEAR(driver); + + // Release mod-tap keys. + EXPECT_REPORT(driver, (KC_C)); + EXPECT_EMPTY_REPORT(driver); + mod_tap_key.release(); + run_one_scan_loop(); + regular_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(FlowTapTest, rolling_lt_regular_mt) { + TestDriver driver; + InSequence s; + auto layer_tap_key = KeymapKey(0, 0, 0, LT(1, KC_A)); + auto regular_key = KeymapKey(0, 1, 0, KC_B); + auto mod_tap_key = KeymapKey(0, 2, 0, CTL_T(KC_C)); + + set_keymap({layer_tap_key, regular_key, mod_tap_key}); + + EXPECT_NO_REPORT(driver); + idle_for(FLOW_TAP_TERM + 1); + layer_tap_key.press(); + run_one_scan_loop(); + regular_key.press(); + run_one_scan_loop(); + mod_tap_key.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + EXPECT_REPORT(driver, (KC_A)); + EXPECT_REPORT(driver, (KC_A, KC_B)); + EXPECT_REPORT(driver, (KC_A, KC_B, KC_C)); + EXPECT_REPORT(driver, (KC_B, KC_C)); + layer_tap_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Hold for longer than the tapping term. + EXPECT_NO_REPORT(driver); + idle_for(TAPPING_TERM + 1); + VERIFY_AND_CLEAR(driver); + + // Release mod-tap keys. + EXPECT_REPORT(driver, (KC_C)); + EXPECT_EMPTY_REPORT(driver); + regular_key.release(); + run_one_scan_loop(); + mod_tap_key.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(FlowTapTest, rolling_mt_mt_mt) { + TestDriver driver; + InSequence s; + auto mod_tap_key1 = KeymapKey(0, 0, 0, CTL_T(KC_A)); + auto mod_tap_key2 = KeymapKey(0, 1, 0, GUI_T(KC_B)); + auto mod_tap_key3 = KeymapKey(0, 2, 0, ALT_T(KC_C)); + + set_keymap({mod_tap_key1, mod_tap_key2, mod_tap_key3}); + + // Press mod-tap keys. + EXPECT_NO_REPORT(driver); + idle_for(FLOW_TAP_TERM + 1); + mod_tap_key1.press(); + run_one_scan_loop(); + mod_tap_key2.press(); + run_one_scan_loop(); + mod_tap_key3.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release first mod-tap key. + EXPECT_REPORT(driver, (KC_A)); + EXPECT_REPORT(driver, (KC_A, KC_B)); + EXPECT_REPORT(driver, (KC_A, KC_B, KC_C)); + EXPECT_REPORT(driver, (KC_B, KC_C)); + mod_tap_key1.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Hold for longer than the tapping term. + EXPECT_NO_REPORT(driver); + idle_for(TAPPING_TERM + 1); + VERIFY_AND_CLEAR(driver); + + // Release other mod-tap keys. + EXPECT_REPORT(driver, (KC_C)); + EXPECT_EMPTY_REPORT(driver); + mod_tap_key2.release(); + run_one_scan_loop(); + mod_tap_key3.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} + +TEST_F(FlowTapTest, roll_release_132) { + TestDriver driver; + InSequence s; + auto mod_tap_key1 = KeymapKey(0, 0, 0, CTL_T(KC_A)); + auto mod_tap_key2 = KeymapKey(0, 1, 0, GUI_T(KC_B)); + auto mod_tap_key3 = KeymapKey(0, 2, 0, ALT_T(KC_C)); + + set_keymap({mod_tap_key1, mod_tap_key2, mod_tap_key3}); + + // Press mod-tap keys. + EXPECT_NO_REPORT(driver); + idle_for(FLOW_TAP_TERM + 1); + mod_tap_key1.press(); + run_one_scan_loop(); + mod_tap_key2.press(); + idle_for(FLOW_TAP_TERM + 1); + mod_tap_key3.press(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release first mod-tap key. + EXPECT_REPORT(driver, (KC_A)); + EXPECT_REPORT(driver, (KC_A, KC_B)); + EXPECT_REPORT(driver, (KC_B)); + mod_tap_key1.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); + + // Release other mod-tap keys. + EXPECT_REPORT(driver, (KC_B, KC_C)); + EXPECT_REPORT(driver, (KC_B)); + EXPECT_EMPTY_REPORT(driver); + mod_tap_key3.release(); + run_one_scan_loop(); + mod_tap_key2.release(); + run_one_scan_loop(); + VERIFY_AND_CLEAR(driver); +} diff --git a/tests/test_common/build.mk b/tests/test_common/build.mk index d7423bc78a..385da7adf9 100644 --- a/tests/test_common/build.mk +++ b/tests/test_common/build.mk @@ -14,3 +14,4 @@ # along with this program. If not, see . CUSTOM_MATRIX=yes +KEYCODE_STRING_ENABLE = yes diff --git a/tests/test_common/keyboard_report_util.cpp b/tests/test_common/keyboard_report_util.cpp index 18e0574277..5e40323669 100644 --- a/tests/test_common/keyboard_report_util.cpp +++ b/tests/test_common/keyboard_report_util.cpp @@ -19,6 +19,10 @@ #include #include +extern "C" { +#include "keycode_string.h" +} + using namespace testing; extern std::map KEYCODE_ID_TABLE; @@ -72,7 +76,7 @@ std::ostream& operator<<(std::ostream& os, const report_keyboard_t& report) { os << "("; for (auto key = keys.cbegin(); key != keys.cend();) { - os << KEYCODE_ID_TABLE.at(*key); + os << get_keycode_string(*key); key++; if (key != keys.cend()) { os << ", "; @@ -82,7 +86,7 @@ std::ostream& operator<<(std::ostream& os, const report_keyboard_t& report) { os << ") ["; for (auto mod = mods.cbegin(); mod != mods.cend();) { - os << KEYCODE_ID_TABLE.at(*mod); + os << get_keycode_string(*mod); mod++; if (mod != mods.cend()) { os << ", "; diff --git a/tests/test_common/keycode_table.cpp b/tests/test_common/keycode_table.cpp deleted file mode 100644 index 26d0919619..0000000000 --- a/tests/test_common/keycode_table.cpp +++ /dev/null @@ -1,767 +0,0 @@ -// Copyright 2025 QMK -// SPDX-License-Identifier: GPL-2.0-or-later - -/******************************************************************************* - 88888888888 888 d8b .d888 d8b 888 d8b - 888 888 Y8P d88P" Y8P 888 Y8P - 888 888 888 888 - 888 88888b. 888 .d8888b 888888 888 888 .d88b. 888 .d8888b - 888 888 "88b 888 88K 888 888 888 d8P Y8b 888 88K - 888 888 888 888 "Y8888b. 888 888 888 88888888 888 "Y8888b. - 888 888 888 888 X88 888 888 888 Y8b. 888 X88 - 888 888 888 888 88888P' 888 888 888 "Y8888 888 88888P' - 888 888 - 888 888 - 888 888 - .d88b. .d88b. 88888b. .d88b. 888d888 8888b. 888888 .d88b. .d88888 - d88P"88b d8P Y8b 888 "88b d8P Y8b 888P" "88b 888 d8P Y8b d88" 888 - 888 888 88888888 888 888 88888888 888 .d888888 888 88888888 888 888 - Y88b 888 Y8b. 888 888 Y8b. 888 888 888 Y88b. Y8b. Y88b 888 - "Y88888 "Y8888 888 888 "Y8888 888 "Y888888 "Y888 "Y8888 "Y88888 - 888 - Y8b d88P - "Y88P" -*******************************************************************************/ - -// clang-format off -extern "C" { -#include -} -#include -#include -#include - -std::map KEYCODE_ID_TABLE = { - {KC_NO, "KC_NO"}, - {KC_TRANSPARENT, "KC_TRANSPARENT"}, - {KC_A, "KC_A"}, - {KC_B, "KC_B"}, - {KC_C, "KC_C"}, - {KC_D, "KC_D"}, - {KC_E, "KC_E"}, - {KC_F, "KC_F"}, - {KC_G, "KC_G"}, - {KC_H, "KC_H"}, - {KC_I, "KC_I"}, - {KC_J, "KC_J"}, - {KC_K, "KC_K"}, - {KC_L, "KC_L"}, - {KC_M, "KC_M"}, - {KC_N, "KC_N"}, - {KC_O, "KC_O"}, - {KC_P, "KC_P"}, - {KC_Q, "KC_Q"}, - {KC_R, "KC_R"}, - {KC_S, "KC_S"}, - {KC_T, "KC_T"}, - {KC_U, "KC_U"}, - {KC_V, "KC_V"}, - {KC_W, "KC_W"}, - {KC_X, "KC_X"}, - {KC_Y, "KC_Y"}, - {KC_Z, "KC_Z"}, - {KC_1, "KC_1"}, - {KC_2, "KC_2"}, - {KC_3, "KC_3"}, - {KC_4, "KC_4"}, - {KC_5, "KC_5"}, - {KC_6, "KC_6"}, - {KC_7, "KC_7"}, - {KC_8, "KC_8"}, - {KC_9, "KC_9"}, - {KC_0, "KC_0"}, - {KC_ENTER, "KC_ENTER"}, - {KC_ESCAPE, "KC_ESCAPE"}, - {KC_BACKSPACE, "KC_BACKSPACE"}, - {KC_TAB, "KC_TAB"}, - {KC_SPACE, "KC_SPACE"}, - {KC_MINUS, "KC_MINUS"}, - {KC_EQUAL, "KC_EQUAL"}, - {KC_LEFT_BRACKET, "KC_LEFT_BRACKET"}, - {KC_RIGHT_BRACKET, "KC_RIGHT_BRACKET"}, - {KC_BACKSLASH, "KC_BACKSLASH"}, - {KC_NONUS_HASH, "KC_NONUS_HASH"}, - {KC_SEMICOLON, "KC_SEMICOLON"}, - {KC_QUOTE, "KC_QUOTE"}, - {KC_GRAVE, "KC_GRAVE"}, - {KC_COMMA, "KC_COMMA"}, - {KC_DOT, "KC_DOT"}, - {KC_SLASH, "KC_SLASH"}, - {KC_CAPS_LOCK, "KC_CAPS_LOCK"}, - {KC_F1, "KC_F1"}, - {KC_F2, "KC_F2"}, - {KC_F3, "KC_F3"}, - {KC_F4, "KC_F4"}, - {KC_F5, "KC_F5"}, - {KC_F6, "KC_F6"}, - {KC_F7, "KC_F7"}, - {KC_F8, "KC_F8"}, - {KC_F9, "KC_F9"}, - {KC_F10, "KC_F10"}, - {KC_F11, "KC_F11"}, - {KC_F12, "KC_F12"}, - {KC_PRINT_SCREEN, "KC_PRINT_SCREEN"}, - {KC_SCROLL_LOCK, "KC_SCROLL_LOCK"}, - {KC_PAUSE, "KC_PAUSE"}, - {KC_INSERT, "KC_INSERT"}, - {KC_HOME, "KC_HOME"}, - {KC_PAGE_UP, "KC_PAGE_UP"}, - {KC_DELETE, "KC_DELETE"}, - {KC_END, "KC_END"}, - {KC_PAGE_DOWN, "KC_PAGE_DOWN"}, - {KC_RIGHT, "KC_RIGHT"}, - {KC_LEFT, "KC_LEFT"}, - {KC_DOWN, "KC_DOWN"}, - {KC_UP, "KC_UP"}, - {KC_NUM_LOCK, "KC_NUM_LOCK"}, - {KC_KP_SLASH, "KC_KP_SLASH"}, - {KC_KP_ASTERISK, "KC_KP_ASTERISK"}, - {KC_KP_MINUS, "KC_KP_MINUS"}, - {KC_KP_PLUS, "KC_KP_PLUS"}, - {KC_KP_ENTER, "KC_KP_ENTER"}, - {KC_KP_1, "KC_KP_1"}, - {KC_KP_2, "KC_KP_2"}, - {KC_KP_3, "KC_KP_3"}, - {KC_KP_4, "KC_KP_4"}, - {KC_KP_5, "KC_KP_5"}, - {KC_KP_6, "KC_KP_6"}, - {KC_KP_7, "KC_KP_7"}, - {KC_KP_8, "KC_KP_8"}, - {KC_KP_9, "KC_KP_9"}, - {KC_KP_0, "KC_KP_0"}, - {KC_KP_DOT, "KC_KP_DOT"}, - {KC_NONUS_BACKSLASH, "KC_NONUS_BACKSLASH"}, - {KC_APPLICATION, "KC_APPLICATION"}, - {KC_KB_POWER, "KC_KB_POWER"}, - {KC_KP_EQUAL, "KC_KP_EQUAL"}, - {KC_F13, "KC_F13"}, - {KC_F14, "KC_F14"}, - {KC_F15, "KC_F15"}, - {KC_F16, "KC_F16"}, - {KC_F17, "KC_F17"}, - {KC_F18, "KC_F18"}, - {KC_F19, "KC_F19"}, - {KC_F20, "KC_F20"}, - {KC_F21, "KC_F21"}, - {KC_F22, "KC_F22"}, - {KC_F23, "KC_F23"}, - {KC_F24, "KC_F24"}, - {KC_EXECUTE, "KC_EXECUTE"}, - {KC_HELP, "KC_HELP"}, - {KC_MENU, "KC_MENU"}, - {KC_SELECT, "KC_SELECT"}, - {KC_STOP, "KC_STOP"}, - {KC_AGAIN, "KC_AGAIN"}, - {KC_UNDO, "KC_UNDO"}, - {KC_CUT, "KC_CUT"}, - {KC_COPY, "KC_COPY"}, - {KC_PASTE, "KC_PASTE"}, - {KC_FIND, "KC_FIND"}, - {KC_KB_MUTE, "KC_KB_MUTE"}, - {KC_KB_VOLUME_UP, "KC_KB_VOLUME_UP"}, - {KC_KB_VOLUME_DOWN, "KC_KB_VOLUME_DOWN"}, - {KC_LOCKING_CAPS_LOCK, "KC_LOCKING_CAPS_LOCK"}, - {KC_LOCKING_NUM_LOCK, "KC_LOCKING_NUM_LOCK"}, - {KC_LOCKING_SCROLL_LOCK, "KC_LOCKING_SCROLL_LOCK"}, - {KC_KP_COMMA, "KC_KP_COMMA"}, - {KC_KP_EQUAL_AS400, "KC_KP_EQUAL_AS400"}, - {KC_INTERNATIONAL_1, "KC_INTERNATIONAL_1"}, - {KC_INTERNATIONAL_2, "KC_INTERNATIONAL_2"}, - {KC_INTERNATIONAL_3, "KC_INTERNATIONAL_3"}, - {KC_INTERNATIONAL_4, "KC_INTERNATIONAL_4"}, - {KC_INTERNATIONAL_5, "KC_INTERNATIONAL_5"}, - {KC_INTERNATIONAL_6, "KC_INTERNATIONAL_6"}, - {KC_INTERNATIONAL_7, "KC_INTERNATIONAL_7"}, - {KC_INTERNATIONAL_8, "KC_INTERNATIONAL_8"}, - {KC_INTERNATIONAL_9, "KC_INTERNATIONAL_9"}, - {KC_LANGUAGE_1, "KC_LANGUAGE_1"}, - {KC_LANGUAGE_2, "KC_LANGUAGE_2"}, - {KC_LANGUAGE_3, "KC_LANGUAGE_3"}, - {KC_LANGUAGE_4, "KC_LANGUAGE_4"}, - {KC_LANGUAGE_5, "KC_LANGUAGE_5"}, - {KC_LANGUAGE_6, "KC_LANGUAGE_6"}, - {KC_LANGUAGE_7, "KC_LANGUAGE_7"}, - {KC_LANGUAGE_8, "KC_LANGUAGE_8"}, - {KC_LANGUAGE_9, "KC_LANGUAGE_9"}, - {KC_ALTERNATE_ERASE, "KC_ALTERNATE_ERASE"}, - {KC_SYSTEM_REQUEST, "KC_SYSTEM_REQUEST"}, - {KC_CANCEL, "KC_CANCEL"}, - {KC_CLEAR, "KC_CLEAR"}, - {KC_PRIOR, "KC_PRIOR"}, - {KC_RETURN, "KC_RETURN"}, - {KC_SEPARATOR, "KC_SEPARATOR"}, - {KC_OUT, "KC_OUT"}, - {KC_OPER, "KC_OPER"}, - {KC_CLEAR_AGAIN, "KC_CLEAR_AGAIN"}, - {KC_CRSEL, "KC_CRSEL"}, - {KC_EXSEL, "KC_EXSEL"}, - {KC_SYSTEM_POWER, "KC_SYSTEM_POWER"}, - {KC_SYSTEM_SLEEP, "KC_SYSTEM_SLEEP"}, - {KC_SYSTEM_WAKE, "KC_SYSTEM_WAKE"}, - {KC_AUDIO_MUTE, "KC_AUDIO_MUTE"}, - {KC_AUDIO_VOL_UP, "KC_AUDIO_VOL_UP"}, - {KC_AUDIO_VOL_DOWN, "KC_AUDIO_VOL_DOWN"}, - {KC_MEDIA_NEXT_TRACK, "KC_MEDIA_NEXT_TRACK"}, - {KC_MEDIA_PREV_TRACK, "KC_MEDIA_PREV_TRACK"}, - {KC_MEDIA_STOP, "KC_MEDIA_STOP"}, - {KC_MEDIA_PLAY_PAUSE, "KC_MEDIA_PLAY_PAUSE"}, - {KC_MEDIA_SELECT, "KC_MEDIA_SELECT"}, - {KC_MEDIA_EJECT, "KC_MEDIA_EJECT"}, - {KC_MAIL, "KC_MAIL"}, - {KC_CALCULATOR, "KC_CALCULATOR"}, - {KC_MY_COMPUTER, "KC_MY_COMPUTER"}, - {KC_WWW_SEARCH, "KC_WWW_SEARCH"}, - {KC_WWW_HOME, "KC_WWW_HOME"}, - {KC_WWW_BACK, "KC_WWW_BACK"}, - {KC_WWW_FORWARD, "KC_WWW_FORWARD"}, - {KC_WWW_STOP, "KC_WWW_STOP"}, - {KC_WWW_REFRESH, "KC_WWW_REFRESH"}, - {KC_WWW_FAVORITES, "KC_WWW_FAVORITES"}, - {KC_MEDIA_FAST_FORWARD, "KC_MEDIA_FAST_FORWARD"}, - {KC_MEDIA_REWIND, "KC_MEDIA_REWIND"}, - {KC_BRIGHTNESS_UP, "KC_BRIGHTNESS_UP"}, - {KC_BRIGHTNESS_DOWN, "KC_BRIGHTNESS_DOWN"}, - {KC_CONTROL_PANEL, "KC_CONTROL_PANEL"}, - {KC_ASSISTANT, "KC_ASSISTANT"}, - {KC_MISSION_CONTROL, "KC_MISSION_CONTROL"}, - {KC_LAUNCHPAD, "KC_LAUNCHPAD"}, - {QK_MOUSE_CURSOR_UP, "QK_MOUSE_CURSOR_UP"}, - {QK_MOUSE_CURSOR_DOWN, "QK_MOUSE_CURSOR_DOWN"}, - {QK_MOUSE_CURSOR_LEFT, "QK_MOUSE_CURSOR_LEFT"}, - {QK_MOUSE_CURSOR_RIGHT, "QK_MOUSE_CURSOR_RIGHT"}, - {QK_MOUSE_BUTTON_1, "QK_MOUSE_BUTTON_1"}, - {QK_MOUSE_BUTTON_2, "QK_MOUSE_BUTTON_2"}, - {QK_MOUSE_BUTTON_3, "QK_MOUSE_BUTTON_3"}, - {QK_MOUSE_BUTTON_4, "QK_MOUSE_BUTTON_4"}, - {QK_MOUSE_BUTTON_5, "QK_MOUSE_BUTTON_5"}, - {QK_MOUSE_BUTTON_6, "QK_MOUSE_BUTTON_6"}, - {QK_MOUSE_BUTTON_7, "QK_MOUSE_BUTTON_7"}, - {QK_MOUSE_BUTTON_8, "QK_MOUSE_BUTTON_8"}, - {QK_MOUSE_WHEEL_UP, "QK_MOUSE_WHEEL_UP"}, - {QK_MOUSE_WHEEL_DOWN, "QK_MOUSE_WHEEL_DOWN"}, - {QK_MOUSE_WHEEL_LEFT, "QK_MOUSE_WHEEL_LEFT"}, - {QK_MOUSE_WHEEL_RIGHT, "QK_MOUSE_WHEEL_RIGHT"}, - {QK_MOUSE_ACCELERATION_0, "QK_MOUSE_ACCELERATION_0"}, - {QK_MOUSE_ACCELERATION_1, "QK_MOUSE_ACCELERATION_1"}, - {QK_MOUSE_ACCELERATION_2, "QK_MOUSE_ACCELERATION_2"}, - {KC_LEFT_CTRL, "KC_LEFT_CTRL"}, - {KC_LEFT_SHIFT, "KC_LEFT_SHIFT"}, - {KC_LEFT_ALT, "KC_LEFT_ALT"}, - {KC_LEFT_GUI, "KC_LEFT_GUI"}, - {KC_RIGHT_CTRL, "KC_RIGHT_CTRL"}, - {KC_RIGHT_SHIFT, "KC_RIGHT_SHIFT"}, - {KC_RIGHT_ALT, "KC_RIGHT_ALT"}, - {KC_RIGHT_GUI, "KC_RIGHT_GUI"}, - {QK_SWAP_HANDS_TOGGLE, "QK_SWAP_HANDS_TOGGLE"}, - {QK_SWAP_HANDS_TAP_TOGGLE, "QK_SWAP_HANDS_TAP_TOGGLE"}, - {QK_SWAP_HANDS_MOMENTARY_ON, "QK_SWAP_HANDS_MOMENTARY_ON"}, - {QK_SWAP_HANDS_MOMENTARY_OFF, "QK_SWAP_HANDS_MOMENTARY_OFF"}, - {QK_SWAP_HANDS_OFF, "QK_SWAP_HANDS_OFF"}, - {QK_SWAP_HANDS_ON, "QK_SWAP_HANDS_ON"}, - {QK_SWAP_HANDS_ONE_SHOT, "QK_SWAP_HANDS_ONE_SHOT"}, - {QK_MAGIC_SWAP_CONTROL_CAPS_LOCK, "QK_MAGIC_SWAP_CONTROL_CAPS_LOCK"}, - {QK_MAGIC_UNSWAP_CONTROL_CAPS_LOCK, "QK_MAGIC_UNSWAP_CONTROL_CAPS_LOCK"}, - {QK_MAGIC_TOGGLE_CONTROL_CAPS_LOCK, "QK_MAGIC_TOGGLE_CONTROL_CAPS_LOCK"}, - {QK_MAGIC_CAPS_LOCK_AS_CONTROL_OFF, "QK_MAGIC_CAPS_LOCK_AS_CONTROL_OFF"}, - {QK_MAGIC_CAPS_LOCK_AS_CONTROL_ON, "QK_MAGIC_CAPS_LOCK_AS_CONTROL_ON"}, - {QK_MAGIC_SWAP_LALT_LGUI, "QK_MAGIC_SWAP_LALT_LGUI"}, - {QK_MAGIC_UNSWAP_LALT_LGUI, "QK_MAGIC_UNSWAP_LALT_LGUI"}, - {QK_MAGIC_SWAP_RALT_RGUI, "QK_MAGIC_SWAP_RALT_RGUI"}, - {QK_MAGIC_UNSWAP_RALT_RGUI, "QK_MAGIC_UNSWAP_RALT_RGUI"}, - {QK_MAGIC_GUI_ON, "QK_MAGIC_GUI_ON"}, - {QK_MAGIC_GUI_OFF, "QK_MAGIC_GUI_OFF"}, - {QK_MAGIC_TOGGLE_GUI, "QK_MAGIC_TOGGLE_GUI"}, - {QK_MAGIC_SWAP_GRAVE_ESC, "QK_MAGIC_SWAP_GRAVE_ESC"}, - {QK_MAGIC_UNSWAP_GRAVE_ESC, "QK_MAGIC_UNSWAP_GRAVE_ESC"}, - {QK_MAGIC_SWAP_BACKSLASH_BACKSPACE, "QK_MAGIC_SWAP_BACKSLASH_BACKSPACE"}, - {QK_MAGIC_UNSWAP_BACKSLASH_BACKSPACE, "QK_MAGIC_UNSWAP_BACKSLASH_BACKSPACE"}, - {QK_MAGIC_TOGGLE_BACKSLASH_BACKSPACE, "QK_MAGIC_TOGGLE_BACKSLASH_BACKSPACE"}, - {QK_MAGIC_NKRO_ON, "QK_MAGIC_NKRO_ON"}, - {QK_MAGIC_NKRO_OFF, "QK_MAGIC_NKRO_OFF"}, - {QK_MAGIC_TOGGLE_NKRO, "QK_MAGIC_TOGGLE_NKRO"}, - {QK_MAGIC_SWAP_ALT_GUI, "QK_MAGIC_SWAP_ALT_GUI"}, - {QK_MAGIC_UNSWAP_ALT_GUI, "QK_MAGIC_UNSWAP_ALT_GUI"}, - {QK_MAGIC_TOGGLE_ALT_GUI, "QK_MAGIC_TOGGLE_ALT_GUI"}, - {QK_MAGIC_SWAP_LCTL_LGUI, "QK_MAGIC_SWAP_LCTL_LGUI"}, - {QK_MAGIC_UNSWAP_LCTL_LGUI, "QK_MAGIC_UNSWAP_LCTL_LGUI"}, - {QK_MAGIC_SWAP_RCTL_RGUI, "QK_MAGIC_SWAP_RCTL_RGUI"}, - {QK_MAGIC_UNSWAP_RCTL_RGUI, "QK_MAGIC_UNSWAP_RCTL_RGUI"}, - {QK_MAGIC_SWAP_CTL_GUI, "QK_MAGIC_SWAP_CTL_GUI"}, - {QK_MAGIC_UNSWAP_CTL_GUI, "QK_MAGIC_UNSWAP_CTL_GUI"}, - {QK_MAGIC_TOGGLE_CTL_GUI, "QK_MAGIC_TOGGLE_CTL_GUI"}, - {QK_MAGIC_EE_HANDS_LEFT, "QK_MAGIC_EE_HANDS_LEFT"}, - {QK_MAGIC_EE_HANDS_RIGHT, "QK_MAGIC_EE_HANDS_RIGHT"}, - {QK_MAGIC_SWAP_ESCAPE_CAPS_LOCK, "QK_MAGIC_SWAP_ESCAPE_CAPS_LOCK"}, - {QK_MAGIC_UNSWAP_ESCAPE_CAPS_LOCK, "QK_MAGIC_UNSWAP_ESCAPE_CAPS_LOCK"}, - {QK_MAGIC_TOGGLE_ESCAPE_CAPS_LOCK, "QK_MAGIC_TOGGLE_ESCAPE_CAPS_LOCK"}, - {QK_MIDI_ON, "QK_MIDI_ON"}, - {QK_MIDI_OFF, "QK_MIDI_OFF"}, - {QK_MIDI_TOGGLE, "QK_MIDI_TOGGLE"}, - {QK_MIDI_NOTE_C_0, "QK_MIDI_NOTE_C_0"}, - {QK_MIDI_NOTE_C_SHARP_0, "QK_MIDI_NOTE_C_SHARP_0"}, - {QK_MIDI_NOTE_D_0, "QK_MIDI_NOTE_D_0"}, - {QK_MIDI_NOTE_D_SHARP_0, "QK_MIDI_NOTE_D_SHARP_0"}, - {QK_MIDI_NOTE_E_0, "QK_MIDI_NOTE_E_0"}, - {QK_MIDI_NOTE_F_0, "QK_MIDI_NOTE_F_0"}, - {QK_MIDI_NOTE_F_SHARP_0, "QK_MIDI_NOTE_F_SHARP_0"}, - {QK_MIDI_NOTE_G_0, "QK_MIDI_NOTE_G_0"}, - {QK_MIDI_NOTE_G_SHARP_0, "QK_MIDI_NOTE_G_SHARP_0"}, - {QK_MIDI_NOTE_A_0, "QK_MIDI_NOTE_A_0"}, - {QK_MIDI_NOTE_A_SHARP_0, "QK_MIDI_NOTE_A_SHARP_0"}, - {QK_MIDI_NOTE_B_0, "QK_MIDI_NOTE_B_0"}, - {QK_MIDI_NOTE_C_1, "QK_MIDI_NOTE_C_1"}, - {QK_MIDI_NOTE_C_SHARP_1, "QK_MIDI_NOTE_C_SHARP_1"}, - {QK_MIDI_NOTE_D_1, "QK_MIDI_NOTE_D_1"}, - {QK_MIDI_NOTE_D_SHARP_1, "QK_MIDI_NOTE_D_SHARP_1"}, - {QK_MIDI_NOTE_E_1, "QK_MIDI_NOTE_E_1"}, - {QK_MIDI_NOTE_F_1, "QK_MIDI_NOTE_F_1"}, - {QK_MIDI_NOTE_F_SHARP_1, "QK_MIDI_NOTE_F_SHARP_1"}, - {QK_MIDI_NOTE_G_1, "QK_MIDI_NOTE_G_1"}, - {QK_MIDI_NOTE_G_SHARP_1, "QK_MIDI_NOTE_G_SHARP_1"}, - {QK_MIDI_NOTE_A_1, "QK_MIDI_NOTE_A_1"}, - {QK_MIDI_NOTE_A_SHARP_1, "QK_MIDI_NOTE_A_SHARP_1"}, - {QK_MIDI_NOTE_B_1, "QK_MIDI_NOTE_B_1"}, - {QK_MIDI_NOTE_C_2, "QK_MIDI_NOTE_C_2"}, - {QK_MIDI_NOTE_C_SHARP_2, "QK_MIDI_NOTE_C_SHARP_2"}, - {QK_MIDI_NOTE_D_2, "QK_MIDI_NOTE_D_2"}, - {QK_MIDI_NOTE_D_SHARP_2, "QK_MIDI_NOTE_D_SHARP_2"}, - {QK_MIDI_NOTE_E_2, "QK_MIDI_NOTE_E_2"}, - {QK_MIDI_NOTE_F_2, "QK_MIDI_NOTE_F_2"}, - {QK_MIDI_NOTE_F_SHARP_2, "QK_MIDI_NOTE_F_SHARP_2"}, - {QK_MIDI_NOTE_G_2, "QK_MIDI_NOTE_G_2"}, - {QK_MIDI_NOTE_G_SHARP_2, "QK_MIDI_NOTE_G_SHARP_2"}, - {QK_MIDI_NOTE_A_2, "QK_MIDI_NOTE_A_2"}, - {QK_MIDI_NOTE_A_SHARP_2, "QK_MIDI_NOTE_A_SHARP_2"}, - {QK_MIDI_NOTE_B_2, "QK_MIDI_NOTE_B_2"}, - {QK_MIDI_NOTE_C_3, "QK_MIDI_NOTE_C_3"}, - {QK_MIDI_NOTE_C_SHARP_3, "QK_MIDI_NOTE_C_SHARP_3"}, - {QK_MIDI_NOTE_D_3, "QK_MIDI_NOTE_D_3"}, - {QK_MIDI_NOTE_D_SHARP_3, "QK_MIDI_NOTE_D_SHARP_3"}, - {QK_MIDI_NOTE_E_3, "QK_MIDI_NOTE_E_3"}, - {QK_MIDI_NOTE_F_3, "QK_MIDI_NOTE_F_3"}, - {QK_MIDI_NOTE_F_SHARP_3, "QK_MIDI_NOTE_F_SHARP_3"}, - {QK_MIDI_NOTE_G_3, "QK_MIDI_NOTE_G_3"}, - {QK_MIDI_NOTE_G_SHARP_3, "QK_MIDI_NOTE_G_SHARP_3"}, - {QK_MIDI_NOTE_A_3, "QK_MIDI_NOTE_A_3"}, - {QK_MIDI_NOTE_A_SHARP_3, "QK_MIDI_NOTE_A_SHARP_3"}, - {QK_MIDI_NOTE_B_3, "QK_MIDI_NOTE_B_3"}, - {QK_MIDI_NOTE_C_4, "QK_MIDI_NOTE_C_4"}, - {QK_MIDI_NOTE_C_SHARP_4, "QK_MIDI_NOTE_C_SHARP_4"}, - {QK_MIDI_NOTE_D_4, "QK_MIDI_NOTE_D_4"}, - {QK_MIDI_NOTE_D_SHARP_4, "QK_MIDI_NOTE_D_SHARP_4"}, - {QK_MIDI_NOTE_E_4, "QK_MIDI_NOTE_E_4"}, - {QK_MIDI_NOTE_F_4, "QK_MIDI_NOTE_F_4"}, - {QK_MIDI_NOTE_F_SHARP_4, "QK_MIDI_NOTE_F_SHARP_4"}, - {QK_MIDI_NOTE_G_4, "QK_MIDI_NOTE_G_4"}, - {QK_MIDI_NOTE_G_SHARP_4, "QK_MIDI_NOTE_G_SHARP_4"}, - {QK_MIDI_NOTE_A_4, "QK_MIDI_NOTE_A_4"}, - {QK_MIDI_NOTE_A_SHARP_4, "QK_MIDI_NOTE_A_SHARP_4"}, - {QK_MIDI_NOTE_B_4, "QK_MIDI_NOTE_B_4"}, - {QK_MIDI_NOTE_C_5, "QK_MIDI_NOTE_C_5"}, - {QK_MIDI_NOTE_C_SHARP_5, "QK_MIDI_NOTE_C_SHARP_5"}, - {QK_MIDI_NOTE_D_5, "QK_MIDI_NOTE_D_5"}, - {QK_MIDI_NOTE_D_SHARP_5, "QK_MIDI_NOTE_D_SHARP_5"}, - {QK_MIDI_NOTE_E_5, "QK_MIDI_NOTE_E_5"}, - {QK_MIDI_NOTE_F_5, "QK_MIDI_NOTE_F_5"}, - {QK_MIDI_NOTE_F_SHARP_5, "QK_MIDI_NOTE_F_SHARP_5"}, - {QK_MIDI_NOTE_G_5, "QK_MIDI_NOTE_G_5"}, - {QK_MIDI_NOTE_G_SHARP_5, "QK_MIDI_NOTE_G_SHARP_5"}, - {QK_MIDI_NOTE_A_5, "QK_MIDI_NOTE_A_5"}, - {QK_MIDI_NOTE_A_SHARP_5, "QK_MIDI_NOTE_A_SHARP_5"}, - {QK_MIDI_NOTE_B_5, "QK_MIDI_NOTE_B_5"}, - {QK_MIDI_OCTAVE_N2, "QK_MIDI_OCTAVE_N2"}, - {QK_MIDI_OCTAVE_N1, "QK_MIDI_OCTAVE_N1"}, - {QK_MIDI_OCTAVE_0, "QK_MIDI_OCTAVE_0"}, - {QK_MIDI_OCTAVE_1, "QK_MIDI_OCTAVE_1"}, - {QK_MIDI_OCTAVE_2, "QK_MIDI_OCTAVE_2"}, - {QK_MIDI_OCTAVE_3, "QK_MIDI_OCTAVE_3"}, - {QK_MIDI_OCTAVE_4, "QK_MIDI_OCTAVE_4"}, - {QK_MIDI_OCTAVE_5, "QK_MIDI_OCTAVE_5"}, - {QK_MIDI_OCTAVE_6, "QK_MIDI_OCTAVE_6"}, - {QK_MIDI_OCTAVE_7, "QK_MIDI_OCTAVE_7"}, - {QK_MIDI_OCTAVE_DOWN, "QK_MIDI_OCTAVE_DOWN"}, - {QK_MIDI_OCTAVE_UP, "QK_MIDI_OCTAVE_UP"}, - {QK_MIDI_TRANSPOSE_N6, "QK_MIDI_TRANSPOSE_N6"}, - {QK_MIDI_TRANSPOSE_N5, "QK_MIDI_TRANSPOSE_N5"}, - {QK_MIDI_TRANSPOSE_N4, "QK_MIDI_TRANSPOSE_N4"}, - {QK_MIDI_TRANSPOSE_N3, "QK_MIDI_TRANSPOSE_N3"}, - {QK_MIDI_TRANSPOSE_N2, "QK_MIDI_TRANSPOSE_N2"}, - {QK_MIDI_TRANSPOSE_N1, "QK_MIDI_TRANSPOSE_N1"}, - {QK_MIDI_TRANSPOSE_0, "QK_MIDI_TRANSPOSE_0"}, - {QK_MIDI_TRANSPOSE_1, "QK_MIDI_TRANSPOSE_1"}, - {QK_MIDI_TRANSPOSE_2, "QK_MIDI_TRANSPOSE_2"}, - {QK_MIDI_TRANSPOSE_3, "QK_MIDI_TRANSPOSE_3"}, - {QK_MIDI_TRANSPOSE_4, "QK_MIDI_TRANSPOSE_4"}, - {QK_MIDI_TRANSPOSE_5, "QK_MIDI_TRANSPOSE_5"}, - {QK_MIDI_TRANSPOSE_6, "QK_MIDI_TRANSPOSE_6"}, - {QK_MIDI_TRANSPOSE_DOWN, "QK_MIDI_TRANSPOSE_DOWN"}, - {QK_MIDI_TRANSPOSE_UP, "QK_MIDI_TRANSPOSE_UP"}, - {QK_MIDI_VELOCITY_0, "QK_MIDI_VELOCITY_0"}, - {QK_MIDI_VELOCITY_1, "QK_MIDI_VELOCITY_1"}, - {QK_MIDI_VELOCITY_2, "QK_MIDI_VELOCITY_2"}, - {QK_MIDI_VELOCITY_3, "QK_MIDI_VELOCITY_3"}, - {QK_MIDI_VELOCITY_4, "QK_MIDI_VELOCITY_4"}, - {QK_MIDI_VELOCITY_5, "QK_MIDI_VELOCITY_5"}, - {QK_MIDI_VELOCITY_6, "QK_MIDI_VELOCITY_6"}, - {QK_MIDI_VELOCITY_7, "QK_MIDI_VELOCITY_7"}, - {QK_MIDI_VELOCITY_8, "QK_MIDI_VELOCITY_8"}, - {QK_MIDI_VELOCITY_9, "QK_MIDI_VELOCITY_9"}, - {QK_MIDI_VELOCITY_10, "QK_MIDI_VELOCITY_10"}, - {QK_MIDI_VELOCITY_DOWN, "QK_MIDI_VELOCITY_DOWN"}, - {QK_MIDI_VELOCITY_UP, "QK_MIDI_VELOCITY_UP"}, - {QK_MIDI_CHANNEL_1, "QK_MIDI_CHANNEL_1"}, - {QK_MIDI_CHANNEL_2, "QK_MIDI_CHANNEL_2"}, - {QK_MIDI_CHANNEL_3, "QK_MIDI_CHANNEL_3"}, - {QK_MIDI_CHANNEL_4, "QK_MIDI_CHANNEL_4"}, - {QK_MIDI_CHANNEL_5, "QK_MIDI_CHANNEL_5"}, - {QK_MIDI_CHANNEL_6, "QK_MIDI_CHANNEL_6"}, - {QK_MIDI_CHANNEL_7, "QK_MIDI_CHANNEL_7"}, - {QK_MIDI_CHANNEL_8, "QK_MIDI_CHANNEL_8"}, - {QK_MIDI_CHANNEL_9, "QK_MIDI_CHANNEL_9"}, - {QK_MIDI_CHANNEL_10, "QK_MIDI_CHANNEL_10"}, - {QK_MIDI_CHANNEL_11, "QK_MIDI_CHANNEL_11"}, - {QK_MIDI_CHANNEL_12, "QK_MIDI_CHANNEL_12"}, - {QK_MIDI_CHANNEL_13, "QK_MIDI_CHANNEL_13"}, - {QK_MIDI_CHANNEL_14, "QK_MIDI_CHANNEL_14"}, - {QK_MIDI_CHANNEL_15, "QK_MIDI_CHANNEL_15"}, - {QK_MIDI_CHANNEL_16, "QK_MIDI_CHANNEL_16"}, - {QK_MIDI_CHANNEL_DOWN, "QK_MIDI_CHANNEL_DOWN"}, - {QK_MIDI_CHANNEL_UP, "QK_MIDI_CHANNEL_UP"}, - {QK_MIDI_ALL_NOTES_OFF, "QK_MIDI_ALL_NOTES_OFF"}, - {QK_MIDI_SUSTAIN, "QK_MIDI_SUSTAIN"}, - {QK_MIDI_PORTAMENTO, "QK_MIDI_PORTAMENTO"}, - {QK_MIDI_SOSTENUTO, "QK_MIDI_SOSTENUTO"}, - {QK_MIDI_SOFT, "QK_MIDI_SOFT"}, - {QK_MIDI_LEGATO, "QK_MIDI_LEGATO"}, - {QK_MIDI_MODULATION, "QK_MIDI_MODULATION"}, - {QK_MIDI_MODULATION_SPEED_DOWN, "QK_MIDI_MODULATION_SPEED_DOWN"}, - {QK_MIDI_MODULATION_SPEED_UP, "QK_MIDI_MODULATION_SPEED_UP"}, - {QK_MIDI_PITCH_BEND_DOWN, "QK_MIDI_PITCH_BEND_DOWN"}, - {QK_MIDI_PITCH_BEND_UP, "QK_MIDI_PITCH_BEND_UP"}, - {QK_SEQUENCER_ON, "QK_SEQUENCER_ON"}, - {QK_SEQUENCER_OFF, "QK_SEQUENCER_OFF"}, - {QK_SEQUENCER_TOGGLE, "QK_SEQUENCER_TOGGLE"}, - {QK_SEQUENCER_TEMPO_DOWN, "QK_SEQUENCER_TEMPO_DOWN"}, - {QK_SEQUENCER_TEMPO_UP, "QK_SEQUENCER_TEMPO_UP"}, - {QK_SEQUENCER_RESOLUTION_DOWN, "QK_SEQUENCER_RESOLUTION_DOWN"}, - {QK_SEQUENCER_RESOLUTION_UP, "QK_SEQUENCER_RESOLUTION_UP"}, - {QK_SEQUENCER_STEPS_ALL, "QK_SEQUENCER_STEPS_ALL"}, - {QK_SEQUENCER_STEPS_CLEAR, "QK_SEQUENCER_STEPS_CLEAR"}, - {QK_JOYSTICK_BUTTON_0, "QK_JOYSTICK_BUTTON_0"}, - {QK_JOYSTICK_BUTTON_1, "QK_JOYSTICK_BUTTON_1"}, - {QK_JOYSTICK_BUTTON_2, "QK_JOYSTICK_BUTTON_2"}, - {QK_JOYSTICK_BUTTON_3, "QK_JOYSTICK_BUTTON_3"}, - {QK_JOYSTICK_BUTTON_4, "QK_JOYSTICK_BUTTON_4"}, - {QK_JOYSTICK_BUTTON_5, "QK_JOYSTICK_BUTTON_5"}, - {QK_JOYSTICK_BUTTON_6, "QK_JOYSTICK_BUTTON_6"}, - {QK_JOYSTICK_BUTTON_7, "QK_JOYSTICK_BUTTON_7"}, - {QK_JOYSTICK_BUTTON_8, "QK_JOYSTICK_BUTTON_8"}, - {QK_JOYSTICK_BUTTON_9, "QK_JOYSTICK_BUTTON_9"}, - {QK_JOYSTICK_BUTTON_10, "QK_JOYSTICK_BUTTON_10"}, - {QK_JOYSTICK_BUTTON_11, "QK_JOYSTICK_BUTTON_11"}, - {QK_JOYSTICK_BUTTON_12, "QK_JOYSTICK_BUTTON_12"}, - {QK_JOYSTICK_BUTTON_13, "QK_JOYSTICK_BUTTON_13"}, - {QK_JOYSTICK_BUTTON_14, "QK_JOYSTICK_BUTTON_14"}, - {QK_JOYSTICK_BUTTON_15, "QK_JOYSTICK_BUTTON_15"}, - {QK_JOYSTICK_BUTTON_16, "QK_JOYSTICK_BUTTON_16"}, - {QK_JOYSTICK_BUTTON_17, "QK_JOYSTICK_BUTTON_17"}, - {QK_JOYSTICK_BUTTON_18, "QK_JOYSTICK_BUTTON_18"}, - {QK_JOYSTICK_BUTTON_19, "QK_JOYSTICK_BUTTON_19"}, - {QK_JOYSTICK_BUTTON_20, "QK_JOYSTICK_BUTTON_20"}, - {QK_JOYSTICK_BUTTON_21, "QK_JOYSTICK_BUTTON_21"}, - {QK_JOYSTICK_BUTTON_22, "QK_JOYSTICK_BUTTON_22"}, - {QK_JOYSTICK_BUTTON_23, "QK_JOYSTICK_BUTTON_23"}, - {QK_JOYSTICK_BUTTON_24, "QK_JOYSTICK_BUTTON_24"}, - {QK_JOYSTICK_BUTTON_25, "QK_JOYSTICK_BUTTON_25"}, - {QK_JOYSTICK_BUTTON_26, "QK_JOYSTICK_BUTTON_26"}, - {QK_JOYSTICK_BUTTON_27, "QK_JOYSTICK_BUTTON_27"}, - {QK_JOYSTICK_BUTTON_28, "QK_JOYSTICK_BUTTON_28"}, - {QK_JOYSTICK_BUTTON_29, "QK_JOYSTICK_BUTTON_29"}, - {QK_JOYSTICK_BUTTON_30, "QK_JOYSTICK_BUTTON_30"}, - {QK_JOYSTICK_BUTTON_31, "QK_JOYSTICK_BUTTON_31"}, - {QK_PROGRAMMABLE_BUTTON_1, "QK_PROGRAMMABLE_BUTTON_1"}, - {QK_PROGRAMMABLE_BUTTON_2, "QK_PROGRAMMABLE_BUTTON_2"}, - {QK_PROGRAMMABLE_BUTTON_3, "QK_PROGRAMMABLE_BUTTON_3"}, - {QK_PROGRAMMABLE_BUTTON_4, "QK_PROGRAMMABLE_BUTTON_4"}, - {QK_PROGRAMMABLE_BUTTON_5, "QK_PROGRAMMABLE_BUTTON_5"}, - {QK_PROGRAMMABLE_BUTTON_6, "QK_PROGRAMMABLE_BUTTON_6"}, - {QK_PROGRAMMABLE_BUTTON_7, "QK_PROGRAMMABLE_BUTTON_7"}, - {QK_PROGRAMMABLE_BUTTON_8, "QK_PROGRAMMABLE_BUTTON_8"}, - {QK_PROGRAMMABLE_BUTTON_9, "QK_PROGRAMMABLE_BUTTON_9"}, - {QK_PROGRAMMABLE_BUTTON_10, "QK_PROGRAMMABLE_BUTTON_10"}, - {QK_PROGRAMMABLE_BUTTON_11, "QK_PROGRAMMABLE_BUTTON_11"}, - {QK_PROGRAMMABLE_BUTTON_12, "QK_PROGRAMMABLE_BUTTON_12"}, - {QK_PROGRAMMABLE_BUTTON_13, "QK_PROGRAMMABLE_BUTTON_13"}, - {QK_PROGRAMMABLE_BUTTON_14, "QK_PROGRAMMABLE_BUTTON_14"}, - {QK_PROGRAMMABLE_BUTTON_15, "QK_PROGRAMMABLE_BUTTON_15"}, - {QK_PROGRAMMABLE_BUTTON_16, "QK_PROGRAMMABLE_BUTTON_16"}, - {QK_PROGRAMMABLE_BUTTON_17, "QK_PROGRAMMABLE_BUTTON_17"}, - {QK_PROGRAMMABLE_BUTTON_18, "QK_PROGRAMMABLE_BUTTON_18"}, - {QK_PROGRAMMABLE_BUTTON_19, "QK_PROGRAMMABLE_BUTTON_19"}, - {QK_PROGRAMMABLE_BUTTON_20, "QK_PROGRAMMABLE_BUTTON_20"}, - {QK_PROGRAMMABLE_BUTTON_21, "QK_PROGRAMMABLE_BUTTON_21"}, - {QK_PROGRAMMABLE_BUTTON_22, "QK_PROGRAMMABLE_BUTTON_22"}, - {QK_PROGRAMMABLE_BUTTON_23, "QK_PROGRAMMABLE_BUTTON_23"}, - {QK_PROGRAMMABLE_BUTTON_24, "QK_PROGRAMMABLE_BUTTON_24"}, - {QK_PROGRAMMABLE_BUTTON_25, "QK_PROGRAMMABLE_BUTTON_25"}, - {QK_PROGRAMMABLE_BUTTON_26, "QK_PROGRAMMABLE_BUTTON_26"}, - {QK_PROGRAMMABLE_BUTTON_27, "QK_PROGRAMMABLE_BUTTON_27"}, - {QK_PROGRAMMABLE_BUTTON_28, "QK_PROGRAMMABLE_BUTTON_28"}, - {QK_PROGRAMMABLE_BUTTON_29, "QK_PROGRAMMABLE_BUTTON_29"}, - {QK_PROGRAMMABLE_BUTTON_30, "QK_PROGRAMMABLE_BUTTON_30"}, - {QK_PROGRAMMABLE_BUTTON_31, "QK_PROGRAMMABLE_BUTTON_31"}, - {QK_PROGRAMMABLE_BUTTON_32, "QK_PROGRAMMABLE_BUTTON_32"}, - {QK_AUDIO_ON, "QK_AUDIO_ON"}, - {QK_AUDIO_OFF, "QK_AUDIO_OFF"}, - {QK_AUDIO_TOGGLE, "QK_AUDIO_TOGGLE"}, - {QK_AUDIO_CLICKY_TOGGLE, "QK_AUDIO_CLICKY_TOGGLE"}, - {QK_AUDIO_CLICKY_ON, "QK_AUDIO_CLICKY_ON"}, - {QK_AUDIO_CLICKY_OFF, "QK_AUDIO_CLICKY_OFF"}, - {QK_AUDIO_CLICKY_UP, "QK_AUDIO_CLICKY_UP"}, - {QK_AUDIO_CLICKY_DOWN, "QK_AUDIO_CLICKY_DOWN"}, - {QK_AUDIO_CLICKY_RESET, "QK_AUDIO_CLICKY_RESET"}, - {QK_MUSIC_ON, "QK_MUSIC_ON"}, - {QK_MUSIC_OFF, "QK_MUSIC_OFF"}, - {QK_MUSIC_TOGGLE, "QK_MUSIC_TOGGLE"}, - {QK_MUSIC_MODE_NEXT, "QK_MUSIC_MODE_NEXT"}, - {QK_AUDIO_VOICE_NEXT, "QK_AUDIO_VOICE_NEXT"}, - {QK_AUDIO_VOICE_PREVIOUS, "QK_AUDIO_VOICE_PREVIOUS"}, - {QK_STENO_BOLT, "QK_STENO_BOLT"}, - {QK_STENO_GEMINI, "QK_STENO_GEMINI"}, - {QK_STENO_COMB, "QK_STENO_COMB"}, - {QK_STENO_COMB_MAX, "QK_STENO_COMB_MAX"}, - {QK_MACRO_0, "QK_MACRO_0"}, - {QK_MACRO_1, "QK_MACRO_1"}, - {QK_MACRO_2, "QK_MACRO_2"}, - {QK_MACRO_3, "QK_MACRO_3"}, - {QK_MACRO_4, "QK_MACRO_4"}, - {QK_MACRO_5, "QK_MACRO_5"}, - {QK_MACRO_6, "QK_MACRO_6"}, - {QK_MACRO_7, "QK_MACRO_7"}, - {QK_MACRO_8, "QK_MACRO_8"}, - {QK_MACRO_9, "QK_MACRO_9"}, - {QK_MACRO_10, "QK_MACRO_10"}, - {QK_MACRO_11, "QK_MACRO_11"}, - {QK_MACRO_12, "QK_MACRO_12"}, - {QK_MACRO_13, "QK_MACRO_13"}, - {QK_MACRO_14, "QK_MACRO_14"}, - {QK_MACRO_15, "QK_MACRO_15"}, - {QK_MACRO_16, "QK_MACRO_16"}, - {QK_MACRO_17, "QK_MACRO_17"}, - {QK_MACRO_18, "QK_MACRO_18"}, - {QK_MACRO_19, "QK_MACRO_19"}, - {QK_MACRO_20, "QK_MACRO_20"}, - {QK_MACRO_21, "QK_MACRO_21"}, - {QK_MACRO_22, "QK_MACRO_22"}, - {QK_MACRO_23, "QK_MACRO_23"}, - {QK_MACRO_24, "QK_MACRO_24"}, - {QK_MACRO_25, "QK_MACRO_25"}, - {QK_MACRO_26, "QK_MACRO_26"}, - {QK_MACRO_27, "QK_MACRO_27"}, - {QK_MACRO_28, "QK_MACRO_28"}, - {QK_MACRO_29, "QK_MACRO_29"}, - {QK_MACRO_30, "QK_MACRO_30"}, - {QK_MACRO_31, "QK_MACRO_31"}, - {QK_OUTPUT_AUTO, "QK_OUTPUT_AUTO"}, - {QK_OUTPUT_NEXT, "QK_OUTPUT_NEXT"}, - {QK_OUTPUT_PREV, "QK_OUTPUT_PREV"}, - {QK_OUTPUT_NONE, "QK_OUTPUT_NONE"}, - {QK_OUTPUT_USB, "QK_OUTPUT_USB"}, - {QK_OUTPUT_2P4GHZ, "QK_OUTPUT_2P4GHZ"}, - {QK_OUTPUT_BLUETOOTH, "QK_OUTPUT_BLUETOOTH"}, - {QK_BLUETOOTH_PROFILE_NEXT, "QK_BLUETOOTH_PROFILE_NEXT"}, - {QK_BLUETOOTH_PROFILE_PREV, "QK_BLUETOOTH_PROFILE_PREV"}, - {QK_BLUETOOTH_UNPAIR, "QK_BLUETOOTH_UNPAIR"}, - {QK_BLUETOOTH_PROFILE1, "QK_BLUETOOTH_PROFILE1"}, - {QK_BLUETOOTH_PROFILE2, "QK_BLUETOOTH_PROFILE2"}, - {QK_BLUETOOTH_PROFILE3, "QK_BLUETOOTH_PROFILE3"}, - {QK_BLUETOOTH_PROFILE4, "QK_BLUETOOTH_PROFILE4"}, - {QK_BLUETOOTH_PROFILE5, "QK_BLUETOOTH_PROFILE5"}, - {QK_BACKLIGHT_ON, "QK_BACKLIGHT_ON"}, - {QK_BACKLIGHT_OFF, "QK_BACKLIGHT_OFF"}, - {QK_BACKLIGHT_TOGGLE, "QK_BACKLIGHT_TOGGLE"}, - {QK_BACKLIGHT_DOWN, "QK_BACKLIGHT_DOWN"}, - {QK_BACKLIGHT_UP, "QK_BACKLIGHT_UP"}, - {QK_BACKLIGHT_STEP, "QK_BACKLIGHT_STEP"}, - {QK_BACKLIGHT_TOGGLE_BREATHING, "QK_BACKLIGHT_TOGGLE_BREATHING"}, - {QK_LED_MATRIX_ON, "QK_LED_MATRIX_ON"}, - {QK_LED_MATRIX_OFF, "QK_LED_MATRIX_OFF"}, - {QK_LED_MATRIX_TOGGLE, "QK_LED_MATRIX_TOGGLE"}, - {QK_LED_MATRIX_MODE_NEXT, "QK_LED_MATRIX_MODE_NEXT"}, - {QK_LED_MATRIX_MODE_PREVIOUS, "QK_LED_MATRIX_MODE_PREVIOUS"}, - {QK_LED_MATRIX_BRIGHTNESS_UP, "QK_LED_MATRIX_BRIGHTNESS_UP"}, - {QK_LED_MATRIX_BRIGHTNESS_DOWN, "QK_LED_MATRIX_BRIGHTNESS_DOWN"}, - {QK_LED_MATRIX_SPEED_UP, "QK_LED_MATRIX_SPEED_UP"}, - {QK_LED_MATRIX_SPEED_DOWN, "QK_LED_MATRIX_SPEED_DOWN"}, - {QK_UNDERGLOW_TOGGLE, "QK_UNDERGLOW_TOGGLE"}, - {QK_UNDERGLOW_MODE_NEXT, "QK_UNDERGLOW_MODE_NEXT"}, - {QK_UNDERGLOW_MODE_PREVIOUS, "QK_UNDERGLOW_MODE_PREVIOUS"}, - {QK_UNDERGLOW_HUE_UP, "QK_UNDERGLOW_HUE_UP"}, - {QK_UNDERGLOW_HUE_DOWN, "QK_UNDERGLOW_HUE_DOWN"}, - {QK_UNDERGLOW_SATURATION_UP, "QK_UNDERGLOW_SATURATION_UP"}, - {QK_UNDERGLOW_SATURATION_DOWN, "QK_UNDERGLOW_SATURATION_DOWN"}, - {QK_UNDERGLOW_VALUE_UP, "QK_UNDERGLOW_VALUE_UP"}, - {QK_UNDERGLOW_VALUE_DOWN, "QK_UNDERGLOW_VALUE_DOWN"}, - {QK_UNDERGLOW_SPEED_UP, "QK_UNDERGLOW_SPEED_UP"}, - {QK_UNDERGLOW_SPEED_DOWN, "QK_UNDERGLOW_SPEED_DOWN"}, - {RGB_MODE_PLAIN, "RGB_MODE_PLAIN"}, - {RGB_MODE_BREATHE, "RGB_MODE_BREATHE"}, - {RGB_MODE_RAINBOW, "RGB_MODE_RAINBOW"}, - {RGB_MODE_SWIRL, "RGB_MODE_SWIRL"}, - {RGB_MODE_SNAKE, "RGB_MODE_SNAKE"}, - {RGB_MODE_KNIGHT, "RGB_MODE_KNIGHT"}, - {RGB_MODE_XMAS, "RGB_MODE_XMAS"}, - {RGB_MODE_GRADIENT, "RGB_MODE_GRADIENT"}, - {RGB_MODE_RGBTEST, "RGB_MODE_RGBTEST"}, - {RGB_MODE_TWINKLE, "RGB_MODE_TWINKLE"}, - {QK_RGB_MATRIX_ON, "QK_RGB_MATRIX_ON"}, - {QK_RGB_MATRIX_OFF, "QK_RGB_MATRIX_OFF"}, - {QK_RGB_MATRIX_TOGGLE, "QK_RGB_MATRIX_TOGGLE"}, - {QK_RGB_MATRIX_MODE_NEXT, "QK_RGB_MATRIX_MODE_NEXT"}, - {QK_RGB_MATRIX_MODE_PREVIOUS, "QK_RGB_MATRIX_MODE_PREVIOUS"}, - {QK_RGB_MATRIX_HUE_UP, "QK_RGB_MATRIX_HUE_UP"}, - {QK_RGB_MATRIX_HUE_DOWN, "QK_RGB_MATRIX_HUE_DOWN"}, - {QK_RGB_MATRIX_SATURATION_UP, "QK_RGB_MATRIX_SATURATION_UP"}, - {QK_RGB_MATRIX_SATURATION_DOWN, "QK_RGB_MATRIX_SATURATION_DOWN"}, - {QK_RGB_MATRIX_VALUE_UP, "QK_RGB_MATRIX_VALUE_UP"}, - {QK_RGB_MATRIX_VALUE_DOWN, "QK_RGB_MATRIX_VALUE_DOWN"}, - {QK_RGB_MATRIX_SPEED_UP, "QK_RGB_MATRIX_SPEED_UP"}, - {QK_RGB_MATRIX_SPEED_DOWN, "QK_RGB_MATRIX_SPEED_DOWN"}, - {QK_BOOTLOADER, "QK_BOOTLOADER"}, - {QK_REBOOT, "QK_REBOOT"}, - {QK_DEBUG_TOGGLE, "QK_DEBUG_TOGGLE"}, - {QK_CLEAR_EEPROM, "QK_CLEAR_EEPROM"}, - {QK_MAKE, "QK_MAKE"}, - {QK_AUTO_SHIFT_DOWN, "QK_AUTO_SHIFT_DOWN"}, - {QK_AUTO_SHIFT_UP, "QK_AUTO_SHIFT_UP"}, - {QK_AUTO_SHIFT_REPORT, "QK_AUTO_SHIFT_REPORT"}, - {QK_AUTO_SHIFT_ON, "QK_AUTO_SHIFT_ON"}, - {QK_AUTO_SHIFT_OFF, "QK_AUTO_SHIFT_OFF"}, - {QK_AUTO_SHIFT_TOGGLE, "QK_AUTO_SHIFT_TOGGLE"}, - {QK_GRAVE_ESCAPE, "QK_GRAVE_ESCAPE"}, - {QK_VELOCIKEY_TOGGLE, "QK_VELOCIKEY_TOGGLE"}, - {QK_SPACE_CADET_LEFT_CTRL_PARENTHESIS_OPEN, "QK_SPACE_CADET_LEFT_CTRL_PARENTHESIS_OPEN"}, - {QK_SPACE_CADET_RIGHT_CTRL_PARENTHESIS_CLOSE, "QK_SPACE_CADET_RIGHT_CTRL_PARENTHESIS_CLOSE"}, - {QK_SPACE_CADET_LEFT_SHIFT_PARENTHESIS_OPEN, "QK_SPACE_CADET_LEFT_SHIFT_PARENTHESIS_OPEN"}, - {QK_SPACE_CADET_RIGHT_SHIFT_PARENTHESIS_CLOSE, "QK_SPACE_CADET_RIGHT_SHIFT_PARENTHESIS_CLOSE"}, - {QK_SPACE_CADET_LEFT_ALT_PARENTHESIS_OPEN, "QK_SPACE_CADET_LEFT_ALT_PARENTHESIS_OPEN"}, - {QK_SPACE_CADET_RIGHT_ALT_PARENTHESIS_CLOSE, "QK_SPACE_CADET_RIGHT_ALT_PARENTHESIS_CLOSE"}, - {QK_SPACE_CADET_RIGHT_SHIFT_ENTER, "QK_SPACE_CADET_RIGHT_SHIFT_ENTER"}, - {QK_UNICODE_MODE_NEXT, "QK_UNICODE_MODE_NEXT"}, - {QK_UNICODE_MODE_PREVIOUS, "QK_UNICODE_MODE_PREVIOUS"}, - {QK_UNICODE_MODE_MACOS, "QK_UNICODE_MODE_MACOS"}, - {QK_UNICODE_MODE_LINUX, "QK_UNICODE_MODE_LINUX"}, - {QK_UNICODE_MODE_WINDOWS, "QK_UNICODE_MODE_WINDOWS"}, - {QK_UNICODE_MODE_BSD, "QK_UNICODE_MODE_BSD"}, - {QK_UNICODE_MODE_WINCOMPOSE, "QK_UNICODE_MODE_WINCOMPOSE"}, - {QK_UNICODE_MODE_EMACS, "QK_UNICODE_MODE_EMACS"}, - {QK_HAPTIC_ON, "QK_HAPTIC_ON"}, - {QK_HAPTIC_OFF, "QK_HAPTIC_OFF"}, - {QK_HAPTIC_TOGGLE, "QK_HAPTIC_TOGGLE"}, - {QK_HAPTIC_RESET, "QK_HAPTIC_RESET"}, - {QK_HAPTIC_FEEDBACK_TOGGLE, "QK_HAPTIC_FEEDBACK_TOGGLE"}, - {QK_HAPTIC_BUZZ_TOGGLE, "QK_HAPTIC_BUZZ_TOGGLE"}, - {QK_HAPTIC_MODE_NEXT, "QK_HAPTIC_MODE_NEXT"}, - {QK_HAPTIC_MODE_PREVIOUS, "QK_HAPTIC_MODE_PREVIOUS"}, - {QK_HAPTIC_CONTINUOUS_TOGGLE, "QK_HAPTIC_CONTINUOUS_TOGGLE"}, - {QK_HAPTIC_CONTINUOUS_UP, "QK_HAPTIC_CONTINUOUS_UP"}, - {QK_HAPTIC_CONTINUOUS_DOWN, "QK_HAPTIC_CONTINUOUS_DOWN"}, - {QK_HAPTIC_DWELL_UP, "QK_HAPTIC_DWELL_UP"}, - {QK_HAPTIC_DWELL_DOWN, "QK_HAPTIC_DWELL_DOWN"}, - {QK_COMBO_ON, "QK_COMBO_ON"}, - {QK_COMBO_OFF, "QK_COMBO_OFF"}, - {QK_COMBO_TOGGLE, "QK_COMBO_TOGGLE"}, - {QK_DYNAMIC_MACRO_RECORD_START_1, "QK_DYNAMIC_MACRO_RECORD_START_1"}, - {QK_DYNAMIC_MACRO_RECORD_START_2, "QK_DYNAMIC_MACRO_RECORD_START_2"}, - {QK_DYNAMIC_MACRO_RECORD_STOP, "QK_DYNAMIC_MACRO_RECORD_STOP"}, - {QK_DYNAMIC_MACRO_PLAY_1, "QK_DYNAMIC_MACRO_PLAY_1"}, - {QK_DYNAMIC_MACRO_PLAY_2, "QK_DYNAMIC_MACRO_PLAY_2"}, - {QK_LEADER, "QK_LEADER"}, - {QK_LOCK, "QK_LOCK"}, - {QK_ONE_SHOT_ON, "QK_ONE_SHOT_ON"}, - {QK_ONE_SHOT_OFF, "QK_ONE_SHOT_OFF"}, - {QK_ONE_SHOT_TOGGLE, "QK_ONE_SHOT_TOGGLE"}, - {QK_KEY_OVERRIDE_TOGGLE, "QK_KEY_OVERRIDE_TOGGLE"}, - {QK_KEY_OVERRIDE_ON, "QK_KEY_OVERRIDE_ON"}, - {QK_KEY_OVERRIDE_OFF, "QK_KEY_OVERRIDE_OFF"}, - {QK_SECURE_LOCK, "QK_SECURE_LOCK"}, - {QK_SECURE_UNLOCK, "QK_SECURE_UNLOCK"}, - {QK_SECURE_TOGGLE, "QK_SECURE_TOGGLE"}, - {QK_SECURE_REQUEST, "QK_SECURE_REQUEST"}, - {QK_DYNAMIC_TAPPING_TERM_PRINT, "QK_DYNAMIC_TAPPING_TERM_PRINT"}, - {QK_DYNAMIC_TAPPING_TERM_UP, "QK_DYNAMIC_TAPPING_TERM_UP"}, - {QK_DYNAMIC_TAPPING_TERM_DOWN, "QK_DYNAMIC_TAPPING_TERM_DOWN"}, - {QK_CAPS_WORD_TOGGLE, "QK_CAPS_WORD_TOGGLE"}, - {QK_AUTOCORRECT_ON, "QK_AUTOCORRECT_ON"}, - {QK_AUTOCORRECT_OFF, "QK_AUTOCORRECT_OFF"}, - {QK_AUTOCORRECT_TOGGLE, "QK_AUTOCORRECT_TOGGLE"}, - {QK_TRI_LAYER_LOWER, "QK_TRI_LAYER_LOWER"}, - {QK_TRI_LAYER_UPPER, "QK_TRI_LAYER_UPPER"}, - {QK_REPEAT_KEY, "QK_REPEAT_KEY"}, - {QK_ALT_REPEAT_KEY, "QK_ALT_REPEAT_KEY"}, - {QK_LAYER_LOCK, "QK_LAYER_LOCK"}, - {QK_KB_0, "QK_KB_0"}, - {QK_KB_1, "QK_KB_1"}, - {QK_KB_2, "QK_KB_2"}, - {QK_KB_3, "QK_KB_3"}, - {QK_KB_4, "QK_KB_4"}, - {QK_KB_5, "QK_KB_5"}, - {QK_KB_6, "QK_KB_6"}, - {QK_KB_7, "QK_KB_7"}, - {QK_KB_8, "QK_KB_8"}, - {QK_KB_9, "QK_KB_9"}, - {QK_KB_10, "QK_KB_10"}, - {QK_KB_11, "QK_KB_11"}, - {QK_KB_12, "QK_KB_12"}, - {QK_KB_13, "QK_KB_13"}, - {QK_KB_14, "QK_KB_14"}, - {QK_KB_15, "QK_KB_15"}, - {QK_KB_16, "QK_KB_16"}, - {QK_KB_17, "QK_KB_17"}, - {QK_KB_18, "QK_KB_18"}, - {QK_KB_19, "QK_KB_19"}, - {QK_KB_20, "QK_KB_20"}, - {QK_KB_21, "QK_KB_21"}, - {QK_KB_22, "QK_KB_22"}, - {QK_KB_23, "QK_KB_23"}, - {QK_KB_24, "QK_KB_24"}, - {QK_KB_25, "QK_KB_25"}, - {QK_KB_26, "QK_KB_26"}, - {QK_KB_27, "QK_KB_27"}, - {QK_KB_28, "QK_KB_28"}, - {QK_KB_29, "QK_KB_29"}, - {QK_KB_30, "QK_KB_30"}, - {QK_KB_31, "QK_KB_31"}, - {QK_USER_0, "QK_USER_0"}, - {QK_USER_1, "QK_USER_1"}, - {QK_USER_2, "QK_USER_2"}, - {QK_USER_3, "QK_USER_3"}, - {QK_USER_4, "QK_USER_4"}, - {QK_USER_5, "QK_USER_5"}, - {QK_USER_6, "QK_USER_6"}, - {QK_USER_7, "QK_USER_7"}, - {QK_USER_8, "QK_USER_8"}, - {QK_USER_9, "QK_USER_9"}, - {QK_USER_10, "QK_USER_10"}, - {QK_USER_11, "QK_USER_11"}, - {QK_USER_12, "QK_USER_12"}, - {QK_USER_13, "QK_USER_13"}, - {QK_USER_14, "QK_USER_14"}, - {QK_USER_15, "QK_USER_15"}, - {QK_USER_16, "QK_USER_16"}, - {QK_USER_17, "QK_USER_17"}, - {QK_USER_18, "QK_USER_18"}, - {QK_USER_19, "QK_USER_19"}, - {QK_USER_20, "QK_USER_20"}, - {QK_USER_21, "QK_USER_21"}, - {QK_USER_22, "QK_USER_22"}, - {QK_USER_23, "QK_USER_23"}, - {QK_USER_24, "QK_USER_24"}, - {QK_USER_25, "QK_USER_25"}, - {QK_USER_26, "QK_USER_26"}, - {QK_USER_27, "QK_USER_27"}, - {QK_USER_28, "QK_USER_28"}, - {QK_USER_29, "QK_USER_29"}, - {QK_USER_30, "QK_USER_30"}, - {QK_USER_31, "QK_USER_31"}, -}; diff --git a/tests/test_common/keycode_util.cpp b/tests/test_common/keycode_util.cpp deleted file mode 100644 index 539cab819a..0000000000 --- a/tests/test_common/keycode_util.cpp +++ /dev/null @@ -1,130 +0,0 @@ -#include "keycode_util.hpp" -#include -extern "C" { -#include "action_code.h" -#include "keycode.h" -#include "quantum_keycodes.h" -#include "util.h" -} -#include -#include -#include - -extern std::map KEYCODE_ID_TABLE; - -std::string get_mods(uint8_t mods) { - std::stringstream s; - if ((mods & MOD_RCTL) == MOD_RCTL) { - s << XSTR(MOD_RCTL) << " | "; - } else if ((mods & MOD_LCTL) == MOD_LCTL) { - s << XSTR(MOD_LCTL) << " | "; - } - - if ((mods & MOD_RSFT) == MOD_RSFT) { - s << XSTR(MOD_RSFT) << " | "; - } else if ((mods & MOD_LSFT) == MOD_LSFT) { - s << XSTR(MOD_LSFT) << " | "; - } - - if ((mods & MOD_RALT) == MOD_RALT) { - s << XSTR(MOD_RALT) << " | "; - } else if ((mods & MOD_LALT) == MOD_LALT) { - s << XSTR(MOD_LALT) << " | "; - } - - if ((mods & MOD_RGUI) == MOD_RGUI) { - s << XSTR(MOD_RGUI) << " | "; - } else if ((mods & MOD_LGUI) == MOD_LGUI) { - s << XSTR(MOD_LGUI) << " | "; - } - - auto _mods = s.str(); - - if (_mods.size()) { - _mods.resize(_mods.size() - 3); - } - - return std::string(_mods); -} - -std::string get_qk_mods(uint16_t keycode) { - std::stringstream s; - if ((keycode & QK_RCTL) == QK_RCTL) { - s << XSTR(QK_RCTL) << " | "; - } else if ((keycode & QK_LCTL) == QK_LCTL) { - s << XSTR(QK_LCTL) << " | "; - } - - if ((keycode & QK_RSFT) == QK_RSFT) { - s << XSTR(QK_RSFT) << " | "; - } else if ((keycode & QK_LSFT) == QK_LSFT) { - s << XSTR(QK_LSFT) << " | "; - } - - if ((keycode & QK_RALT) == QK_RALT) { - s << XSTR(QK_RALT) << " | "; - } else if ((keycode & QK_LALT) == QK_LALT) { - s << XSTR(QK_LALT) << " | "; - } - - if ((keycode & QK_RGUI) == QK_RGUI) { - s << XSTR(QK_RGUI) << " | "; - } else if ((keycode & QK_LGUI) == QK_LGUI) { - s << XSTR(QK_LGUI) << " | "; - } - - auto _mods = s.str(); - - if (_mods.size()) { - _mods.resize(_mods.size() - 3); - } - - return std::string(_mods); -} - -std::string generate_identifier(uint16_t kc) { - std::stringstream s; - if (IS_QK_MOD_TAP(kc)) { - s << "MT(" << get_mods(QK_MOD_TAP_GET_MODS(kc)) << ", " << KEYCODE_ID_TABLE.at(kc & 0xFF) << ")"; - } else if (IS_QK_LAYER_TAP(kc)) { - s << "LT(" << +QK_LAYER_TAP_GET_LAYER(kc) << ", " << KEYCODE_ID_TABLE.at(kc & 0xFF) << ")"; - } else if (IS_QK_TO(kc)) { - s << "TO(" << +QK_TO_GET_LAYER(kc) << ")"; - } else if (IS_QK_MOMENTARY(kc)) { - s << "MO(" << +QK_MOMENTARY_GET_LAYER(kc) << ")"; - } else if (IS_QK_DEF_LAYER(kc)) { - s << "DF(" << +QK_DEF_LAYER_GET_LAYER(kc) << ")"; - } else if (IS_QK_PERSISTENT_DEF_LAYER(kc)) { - s << "PDF(" << +QK_PERSISTENT_DEF_LAYER_GET_LAYER(kc) << ")"; - } else if (IS_QK_TOGGLE_LAYER(kc)) { - s << "TG(" << +QK_TOGGLE_LAYER_GET_LAYER(kc) << ")"; - } else if (IS_QK_LAYER_TAP_TOGGLE(kc)) { - s << "TT(" << +QK_LAYER_TAP_TOGGLE_GET_LAYER(kc) << ")"; - } else if (IS_QK_ONE_SHOT_LAYER(kc)) { - s << "OSL(" << +QK_ONE_SHOT_LAYER_GET_LAYER(kc) << ")"; - } else if (IS_QK_LAYER_MOD(kc)) { - s << "LM(" << +QK_LAYER_MOD_GET_LAYER(kc) << ", " << get_mods(QK_LAYER_MOD_GET_MODS(kc)) << ")"; - } else if (IS_QK_ONE_SHOT_MOD(kc)) { - s << "OSM(" << get_mods(QK_ONE_SHOT_MOD_GET_MODS(kc)) << ")"; - } else if (IS_QK_MODS(kc)) { - s << "QK_MODS(" << KEYCODE_ID_TABLE.at(QK_MODS_GET_BASIC_KEYCODE(kc)) << ", " << get_qk_mods(kc) << ")"; - } else if (IS_QK_TAP_DANCE(kc)) { - s << "TD(" << +(kc & 0xFF) << ")"; - } else { - // Fallback - we didn't found any matching keycode, generate the hex representation. - s << "unknown keycode: 0x" << std::hex << kc << ". Add conversion to " << XSTR(generate_identifier); - } - - return std::string(s.str()); -} - -std::string get_keycode_identifier_or_default(uint16_t keycode) { - auto identifier = KEYCODE_ID_TABLE.find(keycode); - if (identifier != KEYCODE_ID_TABLE.end()) { - return identifier->second; - } - - KEYCODE_ID_TABLE[keycode] = generate_identifier(keycode); - - return KEYCODE_ID_TABLE[keycode]; -} diff --git a/tests/test_common/keycode_util.hpp b/tests/test_common/keycode_util.hpp deleted file mode 100644 index 3143ab364e..0000000000 --- a/tests/test_common/keycode_util.hpp +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once - -#include -#include - -std::string get_keycode_identifier_or_default(uint16_t keycode); diff --git a/tests/test_common/test_driver.hpp b/tests/test_common/test_driver.hpp index fea8225953..5c36c80dfc 100644 --- a/tests/test_common/test_driver.hpp +++ b/tests/test_common/test_driver.hpp @@ -20,7 +20,9 @@ #include #include "host.h" #include "keyboard_report_util.hpp" -#include "keycode_util.hpp" +extern "C" { +#include "keycode_string.h" +} #include "test_logger.hpp" class TestDriver { @@ -146,11 +148,11 @@ class TestDriver { /** @brief Tests whether keycode `actual` is equal to `expected`. */ #define EXPECT_KEYCODE_EQ(actual, expected) EXPECT_THAT((actual), KeycodeEq((expected))) -MATCHER_P(KeycodeEq, expected_keycode, "is equal to " + testing::PrintToString(expected_keycode) + ", keycode " + get_keycode_identifier_or_default(expected_keycode)) { +MATCHER_P(KeycodeEq, expected_keycode, "is equal to " + testing::PrintToString(expected_keycode) + ", keycode " + get_keycode_string(expected_keycode)) { if (arg == expected_keycode) { return true; } - *result_listener << "keycode " << get_keycode_identifier_or_default(arg); + *result_listener << "keycode " << get_keycode_string(arg); return false; } diff --git a/tests/test_common/test_fixture.cpp b/tests/test_common/test_fixture.cpp index 81806b0e6d..00084721d6 100644 --- a/tests/test_common/test_fixture.cpp +++ b/tests/test_common/test_fixture.cpp @@ -46,7 +46,7 @@ void TestFixture::SetUpTestCase() { // The following is enough to bootstrap the values set in main eeconfig_init_quantum(); - eeconfig_update_debug(debug_config.raw); + eeconfig_update_debug(&debug_config); TestDriver driver; keyboard_init(); diff --git a/tests/test_common/test_keymap_key.hpp b/tests/test_common/test_keymap_key.hpp index 37b4c827e4..ba2c2912e3 100644 --- a/tests/test_common/test_keymap_key.hpp +++ b/tests/test_common/test_keymap_key.hpp @@ -18,10 +18,10 @@ #include #include -#include "keycode_util.hpp" extern "C" { #include "keyboard.h" #include "test_matrix.h" +#include "keycode_string.h" } #include @@ -29,11 +29,11 @@ extern "C" { typedef uint8_t layer_t; struct KeymapKey { - KeymapKey(layer_t layer, uint8_t col, uint8_t row, uint16_t keycode) : layer(layer), position({.col = col, .row = row}), code(keycode), report_code(keycode), name(get_keycode_identifier_or_default(keycode)) { + KeymapKey(layer_t layer, uint8_t col, uint8_t row, uint16_t keycode) : layer(layer), position({.col = col, .row = row}), code(keycode), report_code(keycode), name(get_keycode_string(keycode)) { validate(); } - KeymapKey(layer_t layer, uint8_t col, uint8_t row, uint16_t keycode, uint16_t report_code) : layer(layer), position({.col = col, .row = row}), code(keycode), report_code(report_code), name{get_keycode_identifier_or_default(keycode)} { + KeymapKey(layer_t layer, uint8_t col, uint8_t row, uint16_t keycode, uint16_t report_code) : layer(layer), position({.col = col, .row = row}), code(keycode), report_code(report_code), name{get_keycode_string(keycode)} { validate(); } diff --git a/tmk_core/protocol.mk b/tmk_core/protocol.mk index 8f01976548..81520c1bc8 100644 --- a/tmk_core/protocol.mk +++ b/tmk_core/protocol.mk @@ -33,10 +33,6 @@ ifeq ($(strip $(PROGRAMMABLE_BUTTON_ENABLE)), yes) SHARED_EP_ENABLE = yes endif -ifeq ($(strip $(RAW_ENABLE)), yes) - OPT_DEFS += -DRAW_ENABLE -endif - ifeq ($(strip $(CONSOLE_ENABLE)), yes) OPT_DEFS += -DCONSOLE_ENABLE else @@ -46,12 +42,8 @@ else endif ifeq ($(strip $(NKRO_ENABLE)), yes) - ifeq ($(strip $(BLUETOOTH_ENABLE)), yes) - $(info NKRO is not currently supported with Bluetooth, and has been disabled.) - else - OPT_DEFS += -DNKRO_ENABLE - SHARED_EP_ENABLE = yes - endif + OPT_DEFS += -DNKRO_ENABLE + SHARED_EP_ENABLE = yes endif ifeq ($(strip $(NO_SUSPEND_POWER_DOWN)), yes) diff --git a/tmk_core/protocol/chibios/chibios.c b/tmk_core/protocol/chibios/chibios.c index cf948154f9..19d8121e34 100644 --- a/tmk_core/protocol/chibios/chibios.c +++ b/tmk_core/protocol/chibios/chibios.c @@ -66,9 +66,19 @@ void send_keyboard(report_keyboard_t *report); void send_nkro(report_nkro_t *report); void send_mouse(report_mouse_t *report); void send_extra(report_extra_t *report); +void send_raw_hid(uint8_t *data, uint8_t length); /* host struct */ -host_driver_t chibios_driver = {.keyboard_leds = usb_device_state_get_leds, .send_keyboard = send_keyboard, .send_nkro = send_nkro, .send_mouse = send_mouse, .send_extra = send_extra}; +host_driver_t chibios_driver = { + .keyboard_leds = usb_device_state_get_leds, + .send_keyboard = send_keyboard, + .send_nkro = send_nkro, + .send_mouse = send_mouse, + .send_extra = send_extra, +#ifdef RAW_ENABLE + .send_raw_hid = send_raw_hid, +#endif +}; #ifdef VIRTSER_ENABLE void virtser_task(void); @@ -134,8 +144,6 @@ void protocol_setup(void) { // chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL); } -static host_driver_t *driver = NULL; - void protocol_pre_init(void) { /* Init USB */ usb_event_queue_init(); @@ -146,18 +154,11 @@ void protocol_pre_init(void) { #endif /* Wait until USB is active */ - while (true) { -#if defined(USB_WAIT_FOR_ENUMERATION) - if (USB_DRIVER.state == USB_ACTIVE) { - driver = &chibios_driver; - break; - } -#else - driver = &chibios_driver; - break; -#endif +#ifdef USB_WAIT_FOR_ENUMERATION + while (USB_DRIVER.state != USB_ACTIVE) { wait_ms(50); } +#endif /* Do need to wait here! * Otherwise the next print might start a transfer on console EP @@ -170,7 +171,7 @@ void protocol_pre_init(void) { } void protocol_post_init(void) { - host_set_driver(driver); + host_set_driver(&chibios_driver); } void protocol_pre_task(void) { diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index 5a5354416f..f9d7f5c4d6 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -32,6 +32,10 @@ #include "usb_driver.h" #include "usb_types.h" +#ifdef RAW_ENABLE +# include "raw_hid.h" +#endif + #ifdef NKRO_ENABLE # include "keycode_config.h" @@ -515,19 +519,13 @@ void console_task(void) { #endif /* CONSOLE_ENABLE */ #ifdef RAW_ENABLE -void raw_hid_send(uint8_t *data, uint8_t length) { +void send_raw_hid(uint8_t *data, uint8_t length) { if (length != RAW_EPSIZE) { return; } send_report(USB_ENDPOINT_IN_RAW, data, length); } -__attribute__((weak)) void raw_hid_receive(uint8_t *data, uint8_t length) { - // Users should #include "raw_hid.h" in their own code - // and implement this function there. Leave this as weak linkage - // so users can opt to not handle data coming in. -} - void raw_hid_task(void) { uint8_t buffer[RAW_EPSIZE]; while (receive_report(USB_ENDPOINT_OUT_RAW, buffer, sizeof(buffer))) { diff --git a/tmk_core/protocol/host.c b/tmk_core/protocol/host.c index df805c827c..4874d7c1d3 100644 --- a/tmk_core/protocol/host.c +++ b/tmk_core/protocol/host.c @@ -21,6 +21,7 @@ along with this program. If not, see . #include "host.h" #include "util.h" #include "debug.h" +#include "usb_device_state.h" #ifdef DIGITIZER_ENABLE # include "digitizer.h" @@ -30,9 +31,34 @@ along with this program. If not, see . # include "joystick.h" #endif +#ifdef CONNECTION_ENABLE +# include "connection.h" +#endif + #ifdef BLUETOOTH_ENABLE # include "bluetooth.h" -# include "outputselect.h" + +static void bluetooth_send_extra(report_extra_t *report) { + switch (report->report_id) { + case REPORT_ID_SYSTEM: + bluetooth_send_system(report->usage); + return; + case REPORT_ID_CONSUMER: + bluetooth_send_consumer(report->usage); + return; + } +} + +host_driver_t bt_driver = { + .keyboard_leds = bluetooth_keyboard_leds, + .send_keyboard = bluetooth_send_keyboard, + .send_nkro = bluetooth_send_nkro, + .send_mouse = bluetooth_send_mouse, + .send_extra = bluetooth_send_extra, +# ifdef RAW_ENABLE + .send_raw_hid = bluetooth_send_raw_hid, +# endif +}; #endif #ifdef NKRO_ENABLE @@ -52,6 +78,39 @@ host_driver_t *host_get_driver(void) { return driver; } +static host_driver_t *host_get_active_driver(void) { +#ifdef CONNECTION_ENABLE + switch (connection_get_host()) { +# ifdef BLUETOOTH_ENABLE + case CONNECTION_HOST_BLUETOOTH: + return &bt_driver; +# endif + case CONNECTION_HOST_NONE: + return NULL; + default: + break; + } +#endif + return driver; +} + +bool host_can_send_nkro(void) { +#ifdef CONNECTION_ENABLE + switch (connection_get_host()) { +# ifdef BLUETOOTH_ENABLE + case CONNECTION_HOST_BLUETOOTH: + return bluetooth_can_send_nkro(); +# endif + case CONNECTION_HOST_NONE: + return false; + default: + break; + } +#endif + + return usb_device_state_get_protocol() == USB_PROTOCOL_REPORT; +} + #ifdef SPLIT_KEYBOARD uint8_t split_led_state = 0; void set_split_host_keyboard_leds(uint8_t led_state) { @@ -63,7 +122,10 @@ uint8_t host_keyboard_leds(void) { #ifdef SPLIT_KEYBOARD if (!is_keyboard_master()) return split_led_state; #endif - if (!driver) return 0; + + host_driver_t *driver = host_get_active_driver(); + if (!driver || !driver->keyboard_leds) return 0; + return (*driver->keyboard_leds)(); } @@ -73,14 +135,9 @@ led_t host_keyboard_led_state(void) { /* send report */ void host_keyboard_send(report_keyboard_t *report) { -#ifdef BLUETOOTH_ENABLE - if (where_to_send() == OUTPUT_BLUETOOTH) { - bluetooth_send_keyboard(report); - return; - } -#endif + host_driver_t *driver = host_get_active_driver(); + if (!driver || !driver->send_keyboard) return; - if (!driver) return; #ifdef KEYBOARD_SHARED_EP report->report_id = REPORT_ID_KEYBOARD; #endif @@ -96,7 +153,9 @@ void host_keyboard_send(report_keyboard_t *report) { } void host_nkro_send(report_nkro_t *report) { - if (!driver) return; + host_driver_t *driver = host_get_active_driver(); + if (!driver || !driver->send_nkro) return; + report->report_id = REPORT_ID_NKRO; (*driver->send_nkro)(report); @@ -110,14 +169,9 @@ void host_nkro_send(report_nkro_t *report) { } void host_mouse_send(report_mouse_t *report) { -#ifdef BLUETOOTH_ENABLE - if (where_to_send() == OUTPUT_BLUETOOTH) { - bluetooth_send_mouse(report); - return; - } -#endif + host_driver_t *driver = host_get_active_driver(); + if (!driver || !driver->send_mouse) return; - if (!driver) return; #ifdef MOUSE_SHARED_EP report->report_id = REPORT_ID_MOUSE; #endif @@ -133,7 +187,8 @@ void host_system_send(uint16_t usage) { if (usage == last_system_usage) return; last_system_usage = usage; - if (!driver) return; + host_driver_t *driver = host_get_active_driver(); + if (!driver || !driver->send_extra) return; report_extra_t report = { .report_id = REPORT_ID_SYSTEM, @@ -146,14 +201,8 @@ void host_consumer_send(uint16_t usage) { if (usage == last_consumer_usage) return; last_consumer_usage = usage; -#ifdef BLUETOOTH_ENABLE - if (where_to_send() == OUTPUT_BLUETOOTH) { - bluetooth_send_consumer(usage); - return; - } -#endif - - if (!driver) return; + host_driver_t *driver = host_get_active_driver(); + if (!driver || !driver->send_extra) return; report_extra_t report = { .report_id = REPORT_ID_CONSUMER, @@ -253,6 +302,15 @@ void host_programmable_button_send(uint32_t data) { __attribute__((weak)) void send_programmable_button(report_programmable_button_t *report) {} +#ifdef RAW_ENABLE +void host_raw_hid_send(uint8_t *data, uint8_t length) { + host_driver_t *driver = host_get_active_driver(); + if (!driver || !driver->send_raw_hid) return; + + (*driver->send_raw_hid)(data, length); +} +#endif + uint16_t host_last_system_usage(void) { return last_system_usage; } diff --git a/tmk_core/protocol/host.h b/tmk_core/protocol/host.h index d824fca077..a0b1e73dcc 100644 --- a/tmk_core/protocol/host.h +++ b/tmk_core/protocol/host.h @@ -32,6 +32,7 @@ void host_set_driver(host_driver_t *driver); host_driver_t *host_get_driver(void); /* host driver interface */ +bool host_can_send_nkro(void); uint8_t host_keyboard_leds(void); led_t host_keyboard_led_state(void); void host_keyboard_send(report_keyboard_t *report); @@ -40,6 +41,7 @@ void host_mouse_send(report_mouse_t *report); void host_system_send(uint16_t usage); void host_consumer_send(uint16_t usage); void host_programmable_button_send(uint32_t data); +void host_raw_hid_send(uint8_t *data, uint8_t length); uint16_t host_last_system_usage(void); uint16_t host_last_consumer_usage(void); diff --git a/tmk_core/protocol/host_driver.h b/tmk_core/protocol/host_driver.h index 8aa38b6dee..c2835aaa99 100644 --- a/tmk_core/protocol/host_driver.h +++ b/tmk_core/protocol/host_driver.h @@ -29,6 +29,9 @@ typedef struct { void (*send_nkro)(report_nkro_t *); void (*send_mouse)(report_mouse_t *); void (*send_extra)(report_extra_t *); +#ifdef RAW_ENABLE + void (*send_raw_hid)(uint8_t *, uint8_t); +#endif } host_driver_t; void send_joystick(report_joystick_t *report); diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index 311d743d05..a87bd13aba 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c @@ -75,11 +75,24 @@ static report_keyboard_t keyboard_report_sent; /* Host driver */ -static void send_keyboard(report_keyboard_t *report); -static void send_nkro(report_nkro_t *report); -static void send_mouse(report_mouse_t *report); -static void send_extra(report_extra_t *report); -host_driver_t lufa_driver = {.keyboard_leds = usb_device_state_get_leds, .send_keyboard = send_keyboard, .send_nkro = send_nkro, .send_mouse = send_mouse, .send_extra = send_extra}; +static void send_keyboard(report_keyboard_t *report); +static void send_nkro(report_nkro_t *report); +static void send_mouse(report_mouse_t *report); +static void send_extra(report_extra_t *report); +#ifdef RAW_ENABLE +static void send_raw_hid(uint8_t *data, uint8_t length); +#endif + +host_driver_t lufa_driver = { + .keyboard_leds = usb_device_state_get_leds, + .send_keyboard = send_keyboard, + .send_nkro = send_nkro, + .send_mouse = send_mouse, + .send_extra = send_extra, +#ifdef RAW_ENABLE + .send_raw_hid = send_raw_hid, +#endif +}; bool send_report(uint8_t endpoint, void *report, size_t size) { uint8_t timeout = 255; @@ -132,21 +145,11 @@ USB_ClassInfo_CDC_Device_t cdc_device = { * * FIXME: Needs doc */ -void raw_hid_send(uint8_t *data, uint8_t length) { +static void send_raw_hid(uint8_t *data, uint8_t length) { if (length != RAW_EPSIZE) return; send_report(RAW_IN_EPNUM, data, RAW_EPSIZE); } -/** \brief Raw HID Receive - * - * FIXME: Needs doc - */ -__attribute__((weak)) void raw_hid_receive(uint8_t *data, uint8_t length) { - // Users should #include "raw_hid.h" in their own code - // and implement this function there. Leave this as weak linkage - // so users can opt to not handle data coming in. -} - /** \brief Raw HID Task * * FIXME: Needs doc diff --git a/tmk_core/protocol/report.c b/tmk_core/protocol/report.c index 6203a3116b..f68334adeb 100644 --- a/tmk_core/protocol/report.c +++ b/tmk_core/protocol/report.c @@ -32,7 +32,7 @@ uint8_t has_anykey(void) { uint8_t* p = keyboard_report->keys; uint8_t lp = sizeof(keyboard_report->keys); #ifdef NKRO_ENABLE - if (usb_device_state_get_protocol() == USB_PROTOCOL_REPORT && keymap_config.nkro) { + if (host_can_send_nkro() && keymap_config.nkro) { p = nkro_report->bits; lp = sizeof(nkro_report->bits); } @@ -49,7 +49,7 @@ uint8_t has_anykey(void) { */ uint8_t get_first_key(void) { #ifdef NKRO_ENABLE - if (usb_device_state_get_protocol() == USB_PROTOCOL_REPORT && keymap_config.nkro) { + if (host_can_send_nkro() && keymap_config.nkro) { uint8_t i = 0; for (; i < NKRO_REPORT_BITS && !nkro_report->bits[i]; i++) ; @@ -69,7 +69,7 @@ bool is_key_pressed(uint8_t key) { return false; } #ifdef NKRO_ENABLE - if (usb_device_state_get_protocol() == USB_PROTOCOL_REPORT && keymap_config.nkro) { + if (host_can_send_nkro() && keymap_config.nkro) { if ((key >> 3) < NKRO_REPORT_BITS) { return nkro_report->bits[key >> 3] & 1 << (key & 7); } else { @@ -151,7 +151,7 @@ void del_key_bit(report_nkro_t* nkro_report, uint8_t code) { */ void add_key_to_report(uint8_t key) { #ifdef NKRO_ENABLE - if (usb_device_state_get_protocol() == USB_PROTOCOL_REPORT && keymap_config.nkro) { + if (host_can_send_nkro() && keymap_config.nkro) { add_key_bit(nkro_report, key); return; } @@ -165,7 +165,7 @@ void add_key_to_report(uint8_t key) { */ void del_key_from_report(uint8_t key) { #ifdef NKRO_ENABLE - if (usb_device_state_get_protocol() == USB_PROTOCOL_REPORT && keymap_config.nkro) { + if (host_can_send_nkro() && keymap_config.nkro) { del_key_bit(nkro_report, key); return; } @@ -180,7 +180,7 @@ void del_key_from_report(uint8_t key) { void clear_keys_from_report(void) { // not clear mods #ifdef NKRO_ENABLE - if (usb_device_state_get_protocol() == USB_PROTOCOL_REPORT && keymap_config.nkro) { + if (host_can_send_nkro() && keymap_config.nkro) { memset(nkro_report->bits, 0, sizeof(nkro_report->bits)); return; } diff --git a/tmk_core/protocol/report.h b/tmk_core/protocol/report.h index d854f51d5c..9053b0bb3f 100644 --- a/tmk_core/protocol/report.h +++ b/tmk_core/protocol/report.h @@ -194,14 +194,22 @@ typedef struct { } PACKED report_programmable_button_t; #ifdef MOUSE_EXTENDED_REPORT +# define MOUSE_REPORT_XY_MIN INT16_MIN +# define MOUSE_REPORT_XY_MAX INT16_MAX typedef int16_t mouse_xy_report_t; #else +# define MOUSE_REPORT_XY_MIN INT8_MIN +# define MOUSE_REPORT_XY_MAX INT8_MAX typedef int8_t mouse_xy_report_t; #endif #ifdef WHEEL_EXTENDED_REPORT +# define MOUSE_REPORT_HV_MIN INT16_MIN +# define MOUSE_REPORT_HV_MAX INT16_MAX typedef int16_t mouse_hv_report_t; #else +# define MOUSE_REPORT_HV_MIN INT8_MIN +# define MOUSE_REPORT_HV_MAX INT8_MAX typedef int8_t mouse_hv_report_t; #endif diff --git a/tmk_core/protocol/usb_descriptor.c b/tmk_core/protocol/usb_descriptor.c index c7fb660b65..ceab9eef9a 100644 --- a/tmk_core/protocol/usb_descriptor.c +++ b/tmk_core/protocol/usb_descriptor.c @@ -165,6 +165,24 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = { # endif HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), +# ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE + HID_RI_COLLECTION(8, 0x02), + // Feature report and padding (1 byte) + HID_RI_USAGE(8, 0x48), // Resolution Multiplier + HID_RI_REPORT_COUNT(8, 0x01), + HID_RI_REPORT_SIZE(8, 0x02), + HID_RI_LOGICAL_MINIMUM(8, 0x00), + HID_RI_LOGICAL_MAXIMUM(8, 0x01), + HID_RI_PHYSICAL_MINIMUM(8, 1), + HID_RI_PHYSICAL_MAXIMUM(8, POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER), + HID_RI_UNIT_EXPONENT(8, POINTING_DEVICE_HIRES_SCROLL_EXPONENT), + HID_RI_FEATURE(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), + HID_RI_PHYSICAL_MINIMUM(8, 0x00), + HID_RI_PHYSICAL_MAXIMUM(8, 0x00), + HID_RI_REPORT_SIZE(8, 0x06), + HID_RI_FEATURE(8, HID_IOF_CONSTANT), +# endif + // Vertical wheel (1 or 2 bytes) HID_RI_USAGE(8, 0x38), // Wheel # ifndef WHEEL_EXTENDED_REPORT @@ -179,6 +197,7 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = { HID_RI_REPORT_SIZE(8, 0x10), # endif HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), + // Horizontal wheel (1 or 2 bytes) HID_RI_USAGE_PAGE(8, 0x0C),// Consumer HID_RI_USAGE(16, 0x0238), // AC Pan @@ -194,6 +213,11 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM SharedReport[] = { HID_RI_REPORT_SIZE(8, 0x10), # endif HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), + +# ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE + HID_RI_END_COLLECTION(0), +# endif + HID_RI_END_COLLECTION(0), HID_RI_END_COLLECTION(0), # ifndef MOUSE_SHARED_EP diff --git a/tmk_core/protocol/usb_descriptor_common.h b/tmk_core/protocol/usb_descriptor_common.h index 909c230a99..f782d83fbc 100644 --- a/tmk_core/protocol/usb_descriptor_common.h +++ b/tmk_core/protocol/usb_descriptor_common.h @@ -32,3 +32,23 @@ #ifndef RAW_USAGE_ID # define RAW_USAGE_ID 0x61 #endif + +///////////////////// +// Hires Scroll Defaults + +#ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE +# ifdef POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER +# if POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER > 127 || POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER < 1 +# error "POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER must be between 1 and 127, inclusive!" +# endif +# else +# define POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER 120 +# endif +# ifdef POINTING_DEVICE_HIRES_SCROLL_EXPONENT +# if POINTING_DEVICE_HIRES_SCROLL_EXPONENT > 127 || POINTING_DEVICE_HIRES_SCROLL_EXPONENT < 0 +# error "POINTING_DEVICE_HIRES_SCROLL_EXPONENT must be between 0 and 127, inclusive!" +# endif +# else +# define POINTING_DEVICE_HIRES_SCROLL_EXPONENT 0 +# endif +#endif \ No newline at end of file diff --git a/tmk_core/protocol/vusb/vusb.c b/tmk_core/protocol/vusb/vusb.c index fdbfcc17dc..1f0f82664b 100644 --- a/tmk_core/protocol/vusb/vusb.c +++ b/tmk_core/protocol/vusb/vusb.c @@ -21,6 +21,7 @@ along with this program. If not, see . #include +#include "compiler_support.h" #include "usbconfig.h" #include "host.h" #include "report.h" @@ -80,7 +81,7 @@ enum usb_interfaces { #define MAX_INTERFACES 3 -_Static_assert(TOTAL_INTERFACES <= MAX_INTERFACES, "There are not enough available interfaces to support all functions. Please disable one or more of the following: Mouse Keys, Extra Keys, Raw HID, Console."); +STATIC_ASSERT(TOTAL_INTERFACES <= MAX_INTERFACES, "There are not enough available interfaces to support all functions. Please disable one or more of the following: Mouse Keys, Extra Keys, Raw HID, Console."); #if (defined(MOUSE_ENABLE) || defined(EXTRAKEY_ENABLE)) && CONSOLE_ENABLE # error Mouse/Extra Keys share an endpoint with Console. Please disable one of the two. @@ -144,7 +145,7 @@ static void send_report(uint8_t endpoint, void *report, size_t size) { static uint8_t raw_output_buffer[RAW_BUFFER_SIZE]; static uint8_t raw_output_received_bytes = 0; -void raw_hid_send(uint8_t *data, uint8_t length) { +static void send_raw_hid(uint8_t *data, uint8_t length) { if (length != RAW_BUFFER_SIZE) { return; } @@ -152,12 +153,6 @@ void raw_hid_send(uint8_t *data, uint8_t length) { send_report(4, data, 32); } -__attribute__((weak)) void raw_hid_receive(uint8_t *data, uint8_t length) { - // Users should #include "raw_hid.h" in their own code - // and implement this function there. Leave this as weak linkage - // so users can opt to not handle data coming in. -} - void raw_hid_task(void) { usbPoll(); @@ -213,8 +208,20 @@ static void send_keyboard(report_keyboard_t *report); static void send_nkro(report_nkro_t *report); static void send_mouse(report_mouse_t *report); static void send_extra(report_extra_t *report); +#ifdef RAW_ENABLE +static void send_raw_hid(uint8_t *data, uint8_t length); +#endif -static host_driver_t driver = {.keyboard_leds = usb_device_state_get_leds, .send_keyboard = send_keyboard, .send_nkro = send_nkro, .send_mouse = send_mouse, .send_extra = send_extra}; +static host_driver_t driver = { + .keyboard_leds = usb_device_state_get_leds, + .send_keyboard = send_keyboard, + .send_nkro = send_nkro, + .send_mouse = send_mouse, + .send_extra = send_extra, +#ifdef RAW_ENABLE + .send_raw_hid = send_raw_hid, +#endif +}; host_driver_t *vusb_driver(void) { return &driver; @@ -520,6 +527,24 @@ const PROGMEM uchar shared_hid_report[] = { # endif 0x81, 0x06, // Input (Data, Variable, Relative) +# ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE + // Feature report and padding (1 byte) + 0xA1, 0x02, // Collection (Logical) + 0x09, 0x48, // Usage (Resolution Multiplier) + 0x95, 0x01, // Report Count (1) + 0x75, 0x02, // Report Size (2) + 0x15, 0x00, // Logical Minimum (0) + 0x25, 0x01, // Logical Maximum (1) + 0x35, 0x01, // Physical Minimum (1) + 0x45, POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER, // Physical Maximum (POINTING_DEVICE_HIRES_SCROLL_MULTIPLIER) + 0x55, POINTING_DEVICE_HIRES_SCROLL_EXPONENT, // Unit Exponent (POINTING_DEVICE_HIRES_SCROLL_EXPONENT) + 0xB1, 0x02, // Feature (Data, Variable, Absolute) + 0x35, 0x00, // Physical Minimum (0) + 0x45, 0x00, // Physical Maximum (0) + 0x75, 0x06, // Report Size (6) + 0xB1, 0x03, // Feature (Constant) +# endif + // Vertical wheel (1 or 2 bytes) 0x09, 0x38, // Usage (Wheel) # ifndef WHEEL_EXTENDED_REPORT @@ -534,6 +559,7 @@ const PROGMEM uchar shared_hid_report[] = { 0x75, 0x10, // Report Size (16) # endif 0x81, 0x06, // Input (Data, Variable, Relative) + // Horizontal wheel (1 or 2 bytes) 0x05, 0x0C, // Usage Page (Consumer) 0x0A, 0x38, 0x02, // Usage (AC Pan) @@ -549,8 +575,13 @@ const PROGMEM uchar shared_hid_report[] = { 0x75, 0x10, // Report Size (16) # endif 0x81, 0x06, // Input (Data, Variable, Relative) - 0xC0, // End Collection - 0xC0, // End Collection + +# ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE + 0xC0, // End Collection +# endif + + 0xC0, // End Collection + 0xC0, // End Collection #endif #ifdef EXTRAKEY_ENABLE diff --git a/util/nix/poetry.lock b/util/nix/poetry.lock deleted file mode 100644 index e9ac914702..0000000000 --- a/util/nix/poetry.lock +++ /dev/null @@ -1,671 +0,0 @@ -# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. - -[[package]] -name = "appdirs" -version = "1.4.4" -description = "A small Python module for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." -optional = false -python-versions = "*" -files = [ - {file = "appdirs-1.4.4-py2.py3-none-any.whl", hash = "sha256:a841dacd6b99318a741b166adb07e19ee71a274450e68237b4650ca1055ab128"}, - {file = "appdirs-1.4.4.tar.gz", hash = "sha256:7d5d0167b2b1ba821647616af46a749d1c653740dd0d2415100fe26e27afdf41"}, -] - -[[package]] -name = "argcomplete" -version = "3.2.2" -description = "Bash tab completion for argparse" -optional = false -python-versions = ">=3.8" -files = [ - {file = "argcomplete-3.2.2-py3-none-any.whl", hash = "sha256:e44f4e7985883ab3e73a103ef0acd27299dbfe2dfed00142c35d4ddd3005901d"}, - {file = "argcomplete-3.2.2.tar.gz", hash = "sha256:f3e49e8ea59b4026ee29548e24488af46e30c9de57d48638e24f54a1ea1000a2"}, -] - -[package.extras] -test = ["coverage", "mypy", "pexpect", "ruff", "wheel"] - -[[package]] -name = "attrs" -version = "23.2.0" -description = "Classes Without Boilerplate" -optional = false -python-versions = ">=3.7" -files = [ - {file = "attrs-23.2.0-py3-none-any.whl", hash = "sha256:99b87a485a5820b23b879f04c2305b44b951b502fd64be915879d77a7e8fc6f1"}, - {file = "attrs-23.2.0.tar.gz", hash = "sha256:935dc3b529c262f6cf76e50877d35a4bd3c1de194fd41f47a2b7ae8f19971f30"}, -] - -[package.extras] -cov = ["attrs[tests]", "coverage[toml] (>=5.3)"] -dev = ["attrs[tests]", "pre-commit"] -docs = ["furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier", "zope-interface"] -tests = ["attrs[tests-no-zope]", "zope-interface"] -tests-mypy = ["mypy (>=1.6)", "pytest-mypy-plugins"] -tests-no-zope = ["attrs[tests-mypy]", "cloudpickle", "hypothesis", "pympler", "pytest (>=4.3.0)", "pytest-xdist[psutil]"] - -[[package]] -name = "colorama" -version = "0.4.6" -description = "Cross-platform colored terminal text." -optional = false -python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" -files = [ - {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, - {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, -] - -[[package]] -name = "dotty-dict" -version = "1.3.1" -description = "Dictionary wrapper for quick access to deeply nested keys." -optional = false -python-versions = ">=3.5,<4.0" -files = [ - {file = "dotty_dict-1.3.1-py3-none-any.whl", hash = "sha256:5022d234d9922f13aa711b4950372a06a6d64cb6d6db9ba43d0ba133ebfce31f"}, - {file = "dotty_dict-1.3.1.tar.gz", hash = "sha256:4b016e03b8ae265539757a53eba24b9bfda506fb94fbce0bee843c6f05541a15"}, -] - -[[package]] -name = "flake8" -version = "7.0.0" -description = "the modular source code checker: pep8 pyflakes and co" -optional = false -python-versions = ">=3.8.1" -files = [ - {file = "flake8-7.0.0-py2.py3-none-any.whl", hash = "sha256:a6dfbb75e03252917f2473ea9653f7cd799c3064e54d4c8140044c5c065f53c3"}, - {file = "flake8-7.0.0.tar.gz", hash = "sha256:33f96621059e65eec474169085dc92bf26e7b2d47366b70be2f67ab80dc25132"}, -] - -[package.dependencies] -mccabe = ">=0.7.0,<0.8.0" -pycodestyle = ">=2.11.0,<2.12.0" -pyflakes = ">=3.2.0,<3.3.0" - -[[package]] -name = "halo" -version = "0.0.31" -description = "Beautiful terminal spinners in Python" -optional = false -python-versions = ">=3.4" -files = [ - {file = "halo-0.0.31-py2-none-any.whl", hash = "sha256:5350488fb7d2aa7c31a1344120cee67a872901ce8858f60da7946cef96c208ab"}, - {file = "halo-0.0.31.tar.gz", hash = "sha256:7b67a3521ee91d53b7152d4ee3452811e1d2a6321975137762eb3d70063cc9d6"}, -] - -[package.dependencies] -colorama = ">=0.3.9" -log-symbols = ">=0.0.14" -six = ">=1.12.0" -spinners = ">=0.0.24" -termcolor = ">=1.1.0" - -[package.extras] -ipython = ["IPython (==5.7.0)", "ipywidgets (==7.1.0)"] - -[[package]] -name = "hid" -version = "1.0.6" -description = "ctypes bindings for hidapi" -optional = false -python-versions = "*" -files = [ - {file = "hid-1.0.6-py3-none-any.whl", hash = "sha256:60446054aec54a767d9a4e97920761f41809a055c6d51c54879e37a706dcb588"}, - {file = "hid-1.0.6.tar.gz", hash = "sha256:48d764d7ae9746ba123b96dbf457893ca80268b7791c4b1d2e051310eeb83860"}, -] - -[[package]] -name = "hjson" -version = "3.1.0" -description = "Hjson, a user interface for JSON." -optional = false -python-versions = "*" -files = [ - {file = "hjson-3.1.0-py3-none-any.whl", hash = "sha256:65713cdcf13214fb554eb8b4ef803419733f4f5e551047c9b711098ab7186b89"}, - {file = "hjson-3.1.0.tar.gz", hash = "sha256:55af475a27cf83a7969c808399d7bccdec8fb836a07ddbd574587593b9cdcf75"}, -] - -[[package]] -name = "importlib-metadata" -version = "7.0.1" -description = "Read metadata from Python packages" -optional = false -python-versions = ">=3.8" -files = [ - {file = "importlib_metadata-7.0.1-py3-none-any.whl", hash = "sha256:4805911c3a4ec7c3966410053e9ec6a1fecd629117df5adee56dfc9432a1081e"}, - {file = "importlib_metadata-7.0.1.tar.gz", hash = "sha256:f238736bb06590ae52ac1fab06a3a9ef1d8dce2b7a35b5ab329371d6c8f5d2cc"}, -] - -[package.dependencies] -zipp = ">=0.5" - -[package.extras] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] -perf = ["ipython"] -testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy (>=0.9.1)", "pytest-perf (>=0.9.2)", "pytest-ruff"] - -[[package]] -name = "jsonschema" -version = "4.21.1" -description = "An implementation of JSON Schema validation for Python" -optional = false -python-versions = ">=3.8" -files = [ - {file = "jsonschema-4.21.1-py3-none-any.whl", hash = "sha256:7996507afae316306f9e2290407761157c6f78002dcf7419acb99822143d1c6f"}, - {file = "jsonschema-4.21.1.tar.gz", hash = "sha256:85727c00279f5fa6bedbe6238d2aa6403bedd8b4864ab11207d07df3cc1b2ee5"}, -] - -[package.dependencies] -attrs = ">=22.2.0" -jsonschema-specifications = ">=2023.03.6" -referencing = ">=0.28.4" -rpds-py = ">=0.7.1" - -[package.extras] -format = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339-validator", "rfc3987", "uri-template", "webcolors (>=1.11)"] -format-nongpl = ["fqdn", "idna", "isoduration", "jsonpointer (>1.13)", "rfc3339-validator", "rfc3986-validator (>0.1.0)", "uri-template", "webcolors (>=1.11)"] - -[[package]] -name = "jsonschema-specifications" -version = "2023.12.1" -description = "The JSON Schema meta-schemas and vocabularies, exposed as a Registry" -optional = false -python-versions = ">=3.8" -files = [ - {file = "jsonschema_specifications-2023.12.1-py3-none-any.whl", hash = "sha256:87e4fdf3a94858b8a2ba2778d9ba57d8a9cafca7c7489c46ba0d30a8bc6a9c3c"}, - {file = "jsonschema_specifications-2023.12.1.tar.gz", hash = "sha256:48a76787b3e70f5ed53f1160d2b81f586e4ca6d1548c5de7085d1682674764cc"}, -] - -[package.dependencies] -referencing = ">=0.31.0" - -[[package]] -name = "log-symbols" -version = "0.0.14" -description = "Colored symbols for various log levels for Python" -optional = false -python-versions = "*" -files = [ - {file = "log_symbols-0.0.14-py3-none-any.whl", hash = "sha256:4952106ff8b605ab7d5081dd2c7e6ca7374584eff7086f499c06edd1ce56dcca"}, - {file = "log_symbols-0.0.14.tar.gz", hash = "sha256:cf0bbc6fe1a8e53f0d174a716bc625c4f87043cc21eb55dd8a740cfe22680556"}, -] - -[package.dependencies] -colorama = ">=0.3.9" - -[[package]] -name = "mccabe" -version = "0.7.0" -description = "McCabe checker, plugin for flake8" -optional = false -python-versions = ">=3.6" -files = [ - {file = "mccabe-0.7.0-py2.py3-none-any.whl", hash = "sha256:6c2d30ab6be0e4a46919781807b4f0d834ebdd6c6e3dca0bda5a15f863427b6e"}, - {file = "mccabe-0.7.0.tar.gz", hash = "sha256:348e0240c33b60bbdf4e523192ef919f28cb2c3d7d5c7794f74009290f236325"}, -] - -[[package]] -name = "milc" -version = "1.8.0" -description = "Opinionated Batteries-Included Python 3 CLI Framework." -optional = false -python-versions = ">=3.7" -files = [ - {file = "milc-1.8.0-py2.py3-none-any.whl", hash = "sha256:faee16fe92ce13eb1b0b4e24ac5b5003d7234880a8d21e4210016d70512bc921"}, - {file = "milc-1.8.0.tar.gz", hash = "sha256:cabe658de07ab97f937c7672b8a604cc825174c28d66d3afd047a9b4b2770bbe"}, -] - -[package.dependencies] -appdirs = "*" -argcomplete = "*" -colorama = "*" -halo = "*" -spinners = "*" -types-colorama = "*" - -[[package]] -name = "nose2" -version = "0.14.1" -description = "unittest with plugins" -optional = false -python-versions = ">=3.8" -files = [ - {file = "nose2-0.14.1-py3-none-any.whl", hash = "sha256:dfbf0d90c98b8d7bbf47d7721c7554ffcca86828ec074c985bb6ecc83c445a4e"}, - {file = "nose2-0.14.1.tar.gz", hash = "sha256:7f8f03a21c9de2c33015933afcef72bf8e4a2d5dfec3b40092287de6e41b093a"}, -] - -[package.extras] -coverage-plugin = ["coverage"] -dev = ["Sphinx", "sphinx-issues", "sphinx-rtd-theme"] - -[[package]] -name = "pep8-naming" -version = "0.13.3" -description = "Check PEP-8 naming conventions, plugin for flake8" -optional = false -python-versions = ">=3.7" -files = [ - {file = "pep8-naming-0.13.3.tar.gz", hash = "sha256:1705f046dfcd851378aac3be1cd1551c7c1e5ff363bacad707d43007877fa971"}, - {file = "pep8_naming-0.13.3-py3-none-any.whl", hash = "sha256:1a86b8c71a03337c97181917e2b472f0f5e4ccb06844a0d6f0a33522549e7a80"}, -] - -[package.dependencies] -flake8 = ">=5.0.0" - -[[package]] -name = "pillow" -version = "10.2.0" -description = "Python Imaging Library (Fork)" -optional = false -python-versions = ">=3.8" -files = [ - {file = "pillow-10.2.0-cp310-cp310-macosx_10_10_x86_64.whl", hash = "sha256:7823bdd049099efa16e4246bdf15e5a13dbb18a51b68fa06d6c1d4d8b99a796e"}, - {file = "pillow-10.2.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:83b2021f2ade7d1ed556bc50a399127d7fb245e725aa0113ebd05cfe88aaf588"}, - {file = "pillow-10.2.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6fad5ff2f13d69b7e74ce5b4ecd12cc0ec530fcee76356cac6742785ff71c452"}, - {file = "pillow-10.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:da2b52b37dad6d9ec64e653637a096905b258d2fc2b984c41ae7d08b938a67e4"}, - {file = "pillow-10.2.0-cp310-cp310-manylinux_2_28_aarch64.whl", hash = "sha256:47c0995fc4e7f79b5cfcab1fc437ff2890b770440f7696a3ba065ee0fd496563"}, - {file = "pillow-10.2.0-cp310-cp310-manylinux_2_28_x86_64.whl", hash = "sha256:322bdf3c9b556e9ffb18f93462e5f749d3444ce081290352c6070d014c93feb2"}, - {file = "pillow-10.2.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:51f1a1bffc50e2e9492e87d8e09a17c5eea8409cda8d3f277eb6edc82813c17c"}, - {file = "pillow-10.2.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:69ffdd6120a4737710a9eee73e1d2e37db89b620f702754b8f6e62594471dee0"}, - {file = "pillow-10.2.0-cp310-cp310-win32.whl", hash = "sha256:c6dafac9e0f2b3c78df97e79af707cdc5ef8e88208d686a4847bab8266870023"}, - {file = "pillow-10.2.0-cp310-cp310-win_amd64.whl", hash = "sha256:aebb6044806f2e16ecc07b2a2637ee1ef67a11840a66752751714a0d924adf72"}, - {file = "pillow-10.2.0-cp310-cp310-win_arm64.whl", hash = "sha256:7049e301399273a0136ff39b84c3678e314f2158f50f517bc50285fb5ec847ad"}, - {file = "pillow-10.2.0-cp311-cp311-macosx_10_10_x86_64.whl", hash = "sha256:35bb52c37f256f662abdfa49d2dfa6ce5d93281d323a9af377a120e89a9eafb5"}, - {file = "pillow-10.2.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:9c23f307202661071d94b5e384e1e1dc7dfb972a28a2310e4ee16103e66ddb67"}, - {file = "pillow-10.2.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:773efe0603db30c281521a7c0214cad7836c03b8ccff897beae9b47c0b657d61"}, - {file = "pillow-10.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:11fa2e5984b949b0dd6d7a94d967743d87c577ff0b83392f17cb3990d0d2fd6e"}, - {file = "pillow-10.2.0-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:716d30ed977be8b37d3ef185fecb9e5a1d62d110dfbdcd1e2a122ab46fddb03f"}, - {file = "pillow-10.2.0-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:a086c2af425c5f62a65e12fbf385f7c9fcb8f107d0849dba5839461a129cf311"}, - {file = "pillow-10.2.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:c8de2789052ed501dd829e9cae8d3dcce7acb4777ea4a479c14521c942d395b1"}, - {file = "pillow-10.2.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:609448742444d9290fd687940ac0b57fb35e6fd92bdb65386e08e99af60bf757"}, - {file = "pillow-10.2.0-cp311-cp311-win32.whl", hash = "sha256:823ef7a27cf86df6597fa0671066c1b596f69eba53efa3d1e1cb8b30f3533068"}, - {file = "pillow-10.2.0-cp311-cp311-win_amd64.whl", hash = "sha256:1da3b2703afd040cf65ec97efea81cfba59cdbed9c11d8efc5ab09df9509fc56"}, - {file = "pillow-10.2.0-cp311-cp311-win_arm64.whl", hash = "sha256:edca80cbfb2b68d7b56930b84a0e45ae1694aeba0541f798e908a49d66b837f1"}, - {file = "pillow-10.2.0-cp312-cp312-macosx_10_10_x86_64.whl", hash = "sha256:1b5e1b74d1bd1b78bc3477528919414874748dd363e6272efd5abf7654e68bef"}, - {file = "pillow-10.2.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:0eae2073305f451d8ecacb5474997c08569fb4eb4ac231ffa4ad7d342fdc25ac"}, - {file = "pillow-10.2.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b7c2286c23cd350b80d2fc9d424fc797575fb16f854b831d16fd47ceec078f2c"}, - {file = "pillow-10.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1e23412b5c41e58cec602f1135c57dfcf15482013ce6e5f093a86db69646a5aa"}, - {file = "pillow-10.2.0-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:52a50aa3fb3acb9cf7213573ef55d31d6eca37f5709c69e6858fe3bc04a5c2a2"}, - {file = "pillow-10.2.0-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:127cee571038f252a552760076407f9cff79761c3d436a12af6000cd182a9d04"}, - {file = "pillow-10.2.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:8d12251f02d69d8310b046e82572ed486685c38f02176bd08baf216746eb947f"}, - {file = "pillow-10.2.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:54f1852cd531aa981bc0965b7d609f5f6cc8ce8c41b1139f6ed6b3c54ab82bfb"}, - {file = "pillow-10.2.0-cp312-cp312-win32.whl", hash = "sha256:257d8788df5ca62c980314053197f4d46eefedf4e6175bc9412f14412ec4ea2f"}, - {file = "pillow-10.2.0-cp312-cp312-win_amd64.whl", hash = "sha256:154e939c5f0053a383de4fd3d3da48d9427a7e985f58af8e94d0b3c9fcfcf4f9"}, - {file = "pillow-10.2.0-cp312-cp312-win_arm64.whl", hash = "sha256:f379abd2f1e3dddb2b61bc67977a6b5a0a3f7485538bcc6f39ec76163891ee48"}, - {file = "pillow-10.2.0-cp38-cp38-macosx_10_10_x86_64.whl", hash = "sha256:8373c6c251f7ef8bda6675dd6d2b3a0fcc31edf1201266b5cf608b62a37407f9"}, - {file = "pillow-10.2.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:870ea1ada0899fd0b79643990809323b389d4d1d46c192f97342eeb6ee0b8483"}, - {file = "pillow-10.2.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:b4b6b1e20608493548b1f32bce8cca185bf0480983890403d3b8753e44077129"}, - {file = "pillow-10.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3031709084b6e7852d00479fd1d310b07d0ba82765f973b543c8af5061cf990e"}, - {file = "pillow-10.2.0-cp38-cp38-manylinux_2_28_aarch64.whl", hash = "sha256:3ff074fc97dd4e80543a3e91f69d58889baf2002b6be64347ea8cf5533188213"}, - {file = "pillow-10.2.0-cp38-cp38-manylinux_2_28_x86_64.whl", hash = "sha256:cb4c38abeef13c61d6916f264d4845fab99d7b711be96c326b84df9e3e0ff62d"}, - {file = "pillow-10.2.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:b1b3020d90c2d8e1dae29cf3ce54f8094f7938460fb5ce8bc5c01450b01fbaf6"}, - {file = "pillow-10.2.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:170aeb00224ab3dc54230c797f8404507240dd868cf52066f66a41b33169bdbe"}, - {file = "pillow-10.2.0-cp38-cp38-win32.whl", hash = "sha256:c4225f5220f46b2fde568c74fca27ae9771536c2e29d7c04f4fb62c83275ac4e"}, - {file = "pillow-10.2.0-cp38-cp38-win_amd64.whl", hash = "sha256:0689b5a8c5288bc0504d9fcee48f61a6a586b9b98514d7d29b840143d6734f39"}, - {file = "pillow-10.2.0-cp39-cp39-macosx_10_10_x86_64.whl", hash = "sha256:b792a349405fbc0163190fde0dc7b3fef3c9268292586cf5645598b48e63dc67"}, - {file = "pillow-10.2.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:c570f24be1e468e3f0ce7ef56a89a60f0e05b30a3669a459e419c6eac2c35364"}, - {file = "pillow-10.2.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d8ecd059fdaf60c1963c58ceb8997b32e9dc1b911f5da5307aab614f1ce5c2fb"}, - {file = "pillow-10.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c365fd1703040de1ec284b176d6af5abe21b427cb3a5ff68e0759e1e313a5e7e"}, - {file = "pillow-10.2.0-cp39-cp39-manylinux_2_28_aarch64.whl", hash = "sha256:70c61d4c475835a19b3a5aa42492409878bbca7438554a1f89d20d58a7c75c01"}, - {file = "pillow-10.2.0-cp39-cp39-manylinux_2_28_x86_64.whl", hash = "sha256:b6f491cdf80ae540738859d9766783e3b3c8e5bd37f5dfa0b76abdecc5081f13"}, - {file = "pillow-10.2.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:9d189550615b4948f45252d7f005e53c2040cea1af5b60d6f79491a6e147eef7"}, - {file = "pillow-10.2.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:49d9ba1ed0ef3e061088cd1e7538a0759aab559e2e0a80a36f9fd9d8c0c21591"}, - {file = "pillow-10.2.0-cp39-cp39-win32.whl", hash = "sha256:babf5acfede515f176833ed6028754cbcd0d206f7f614ea3447d67c33be12516"}, - {file = "pillow-10.2.0-cp39-cp39-win_amd64.whl", hash = "sha256:0304004f8067386b477d20a518b50f3fa658a28d44e4116970abfcd94fac34a8"}, - {file = "pillow-10.2.0-cp39-cp39-win_arm64.whl", hash = "sha256:0fb3e7fc88a14eacd303e90481ad983fd5b69c761e9e6ef94c983f91025da869"}, - {file = "pillow-10.2.0-pp310-pypy310_pp73-macosx_10_10_x86_64.whl", hash = "sha256:322209c642aabdd6207517e9739c704dc9f9db943015535783239022002f054a"}, - {file = "pillow-10.2.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3eedd52442c0a5ff4f887fab0c1c0bb164d8635b32c894bc1faf4c618dd89df2"}, - {file = "pillow-10.2.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cb28c753fd5eb3dd859b4ee95de66cc62af91bcff5db5f2571d32a520baf1f04"}, - {file = "pillow-10.2.0-pp310-pypy310_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:33870dc4653c5017bf4c8873e5488d8f8d5f8935e2f1fb9a2208c47cdd66efd2"}, - {file = "pillow-10.2.0-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:3c31822339516fb3c82d03f30e22b1d038da87ef27b6a78c9549888f8ceda39a"}, - {file = "pillow-10.2.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:a2b56ba36e05f973d450582fb015594aaa78834fefe8dfb8fcd79b93e64ba4c6"}, - {file = "pillow-10.2.0-pp38-pypy38_pp73-win_amd64.whl", hash = "sha256:d8e6aeb9201e655354b3ad049cb77d19813ad4ece0df1249d3c793de3774f8c7"}, - {file = "pillow-10.2.0-pp39-pypy39_pp73-macosx_10_10_x86_64.whl", hash = "sha256:2247178effb34a77c11c0e8ac355c7a741ceca0a732b27bf11e747bbc950722f"}, - {file = "pillow-10.2.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:15587643b9e5eb26c48e49a7b33659790d28f190fc514a322d55da2fb5c2950e"}, - {file = "pillow-10.2.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:753cd8f2086b2b80180d9b3010dd4ed147efc167c90d3bf593fe2af21265e5a5"}, - {file = "pillow-10.2.0-pp39-pypy39_pp73-manylinux_2_28_aarch64.whl", hash = "sha256:7c8f97e8e7a9009bcacbe3766a36175056c12f9a44e6e6f2d5caad06dcfbf03b"}, - {file = "pillow-10.2.0-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:d1b35bcd6c5543b9cb547dee3150c93008f8dd0f1fef78fc0cd2b141c5baf58a"}, - {file = "pillow-10.2.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:fe4c15f6c9285dc54ce6553a3ce908ed37c8f3825b5a51a15c91442bb955b868"}, - {file = "pillow-10.2.0.tar.gz", hash = "sha256:e87f0b2c78157e12d7686b27d63c070fd65d994e8ddae6f328e0dcf4a0cd007e"}, -] - -[package.extras] -docs = ["furo", "olefile", "sphinx (>=2.4)", "sphinx-copybutton", "sphinx-inline-tabs", "sphinx-removed-in", "sphinxext-opengraph"] -fpx = ["olefile"] -mic = ["olefile"] -tests = ["check-manifest", "coverage", "defusedxml", "markdown2", "olefile", "packaging", "pyroma", "pytest", "pytest-cov", "pytest-timeout"] -typing = ["typing-extensions"] -xmp = ["defusedxml"] - -[[package]] -name = "platformdirs" -version = "4.2.0" -description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." -optional = false -python-versions = ">=3.8" -files = [ - {file = "platformdirs-4.2.0-py3-none-any.whl", hash = "sha256:0614df2a2f37e1a662acbd8e2b25b92ccf8632929bc6d43467e17fe89c75e068"}, - {file = "platformdirs-4.2.0.tar.gz", hash = "sha256:ef0cc731df711022c174543cb70a9b5bd22e5a9337c8624ef2c2ceb8ddad8768"}, -] - -[package.extras] -docs = ["furo (>=2023.9.10)", "proselint (>=0.13)", "sphinx (>=7.2.6)", "sphinx-autodoc-typehints (>=1.25.2)"] -test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.12)"] - -[[package]] -name = "pycodestyle" -version = "2.11.1" -description = "Python style guide checker" -optional = false -python-versions = ">=3.8" -files = [ - {file = "pycodestyle-2.11.1-py2.py3-none-any.whl", hash = "sha256:44fe31000b2d866f2e41841b18528a505fbd7fef9017b04eff4e2648a0fadc67"}, - {file = "pycodestyle-2.11.1.tar.gz", hash = "sha256:41ba0e7afc9752dfb53ced5489e89f8186be00e599e712660695b7a75ff2663f"}, -] - -[[package]] -name = "pyflakes" -version = "3.2.0" -description = "passive checker of Python programs" -optional = false -python-versions = ">=3.8" -files = [ - {file = "pyflakes-3.2.0-py2.py3-none-any.whl", hash = "sha256:84b5be138a2dfbb40689ca07e2152deb896a65c3a3e24c251c5c62489568074a"}, - {file = "pyflakes-3.2.0.tar.gz", hash = "sha256:1c61603ff154621fb2a9172037d84dca3500def8c8b630657d1701f026f8af3f"}, -] - -[[package]] -name = "pygments" -version = "2.17.2" -description = "Pygments is a syntax highlighting package written in Python." -optional = false -python-versions = ">=3.7" -files = [ - {file = "pygments-2.17.2-py3-none-any.whl", hash = "sha256:b27c2826c47d0f3219f29554824c30c5e8945175d888647acd804ddd04af846c"}, - {file = "pygments-2.17.2.tar.gz", hash = "sha256:da46cec9fd2de5be3a8a784f434e4c4ab670b4ff54d605c4c2717e9d49c4c367"}, -] - -[package.extras] -plugins = ["importlib-metadata"] -windows-terminal = ["colorama (>=0.4.6)"] - -[[package]] -name = "pyserial" -version = "3.5" -description = "Python Serial Port Extension" -optional = false -python-versions = "*" -files = [ - {file = "pyserial-3.5-py2.py3-none-any.whl", hash = "sha256:c4451db6ba391ca6ca299fb3ec7bae67a5c55dde170964c7a14ceefec02f2cf0"}, - {file = "pyserial-3.5.tar.gz", hash = "sha256:3c77e014170dfffbd816e6ffc205e9842efb10be9f58ec16d3e8675b4925cddb"}, -] - -[package.extras] -cp2110 = ["hidapi"] - -[[package]] -name = "pyusb" -version = "1.2.1" -description = "Python USB access module" -optional = false -python-versions = ">=3.6.0" -files = [ - {file = "pyusb-1.2.1-py3-none-any.whl", hash = "sha256:2b4c7cb86dbadf044dfb9d3a4ff69fd217013dbe78a792177a3feb172449ea36"}, - {file = "pyusb-1.2.1.tar.gz", hash = "sha256:a4cc7404a203144754164b8b40994e2849fde1cfff06b08492f12fff9d9de7b9"}, -] - -[[package]] -name = "qmk" -version = "1.1.5" -description = "A program to help users work with QMK Firmware." -optional = false -python-versions = ">=3.7" -files = [ - {file = "qmk-1.1.5-py2.py3-none-any.whl", hash = "sha256:9c16fa2ad9b279ce9cc121a5462f02637611c6f54c49f9f2cac8ba2898f35b94"}, - {file = "qmk-1.1.5.tar.gz", hash = "sha256:2efe3c752230c6ba24b8719c3b6e85a5644bf8f7d0dd237757eda9b7b7e60b11"}, -] - -[package.dependencies] -dotty-dict = "*" -hid = "*" -hjson = "*" -jsonschema = ">=4" -milc = ">=1.6.8" -pillow = "*" -pygments = "*" -pyserial = "*" -pyusb = "*" -setuptools = ">=45" - -[[package]] -name = "referencing" -version = "0.33.0" -description = "JSON Referencing + Python" -optional = false -python-versions = ">=3.8" -files = [ - {file = "referencing-0.33.0-py3-none-any.whl", hash = "sha256:39240f2ecc770258f28b642dd47fd74bc8b02484de54e1882b74b35ebd779bd5"}, - {file = "referencing-0.33.0.tar.gz", hash = "sha256:c775fedf74bc0f9189c2a3be1c12fd03e8c23f4d371dce795df44e06c5b412f7"}, -] - -[package.dependencies] -attrs = ">=22.2.0" -rpds-py = ">=0.7.0" - -[[package]] -name = "rpds-py" -version = "0.18.0" -description = "Python bindings to Rust's persistent data structures (rpds)" -optional = false -python-versions = ">=3.8" -files = [ - {file = "rpds_py-0.18.0-cp310-cp310-macosx_10_12_x86_64.whl", hash = "sha256:5b4e7d8d6c9b2e8ee2d55c90b59c707ca59bc30058269b3db7b1f8df5763557e"}, - {file = "rpds_py-0.18.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:c463ed05f9dfb9baebef68048aed8dcdc94411e4bf3d33a39ba97e271624f8f7"}, - {file = "rpds_py-0.18.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:01e36a39af54a30f28b73096dd39b6802eddd04c90dbe161c1b8dbe22353189f"}, - {file = "rpds_py-0.18.0-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:d62dec4976954a23d7f91f2f4530852b0c7608116c257833922a896101336c51"}, - {file = "rpds_py-0.18.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:dd18772815d5f008fa03d2b9a681ae38d5ae9f0e599f7dda233c439fcaa00d40"}, - {file = "rpds_py-0.18.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:923d39efa3cfb7279a0327e337a7958bff00cc447fd07a25cddb0a1cc9a6d2da"}, - {file = "rpds_py-0.18.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:39514da80f971362f9267c600b6d459bfbbc549cffc2cef8e47474fddc9b45b1"}, - {file = "rpds_py-0.18.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:a34d557a42aa28bd5c48a023c570219ba2593bcbbb8dc1b98d8cf5d529ab1434"}, - {file = "rpds_py-0.18.0-cp310-cp310-musllinux_1_2_aarch64.whl", hash = "sha256:93df1de2f7f7239dc9cc5a4a12408ee1598725036bd2dedadc14d94525192fc3"}, - {file = "rpds_py-0.18.0-cp310-cp310-musllinux_1_2_i686.whl", hash = "sha256:34b18ba135c687f4dac449aa5157d36e2cbb7c03cbea4ddbd88604e076aa836e"}, - {file = "rpds_py-0.18.0-cp310-cp310-musllinux_1_2_x86_64.whl", hash = "sha256:c0b5dcf9193625afd8ecc92312d6ed78781c46ecbf39af9ad4681fc9f464af88"}, - {file = "rpds_py-0.18.0-cp310-none-win32.whl", hash = "sha256:c4325ff0442a12113a6379af66978c3fe562f846763287ef66bdc1d57925d337"}, - {file = "rpds_py-0.18.0-cp310-none-win_amd64.whl", hash = "sha256:7223a2a5fe0d217e60a60cdae28d6949140dde9c3bcc714063c5b463065e3d66"}, - {file = "rpds_py-0.18.0-cp311-cp311-macosx_10_12_x86_64.whl", hash = "sha256:3a96e0c6a41dcdba3a0a581bbf6c44bb863f27c541547fb4b9711fd8cf0ffad4"}, - {file = "rpds_py-0.18.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:30f43887bbae0d49113cbaab729a112251a940e9b274536613097ab8b4899cf6"}, - {file = "rpds_py-0.18.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fcb25daa9219b4cf3a0ab24b0eb9a5cc8949ed4dc72acb8fa16b7e1681aa3c58"}, - {file = "rpds_py-0.18.0-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:d68c93e381010662ab873fea609bf6c0f428b6d0bb00f2c6939782e0818d37bf"}, - {file = "rpds_py-0.18.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b34b7aa8b261c1dbf7720b5d6f01f38243e9b9daf7e6b8bc1fd4657000062f2c"}, - {file = "rpds_py-0.18.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2e6d75ab12b0bbab7215e5d40f1e5b738aa539598db27ef83b2ec46747df90e1"}, - {file = "rpds_py-0.18.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0b8612cd233543a3781bc659c731b9d607de65890085098986dfd573fc2befe5"}, - {file = "rpds_py-0.18.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:aec493917dd45e3c69d00a8874e7cbed844efd935595ef78a0f25f14312e33c6"}, - {file = "rpds_py-0.18.0-cp311-cp311-musllinux_1_2_aarch64.whl", hash = "sha256:661d25cbffaf8cc42e971dd570d87cb29a665f49f4abe1f9e76be9a5182c4688"}, - {file = "rpds_py-0.18.0-cp311-cp311-musllinux_1_2_i686.whl", hash = "sha256:1df3659d26f539ac74fb3b0c481cdf9d725386e3552c6fa2974f4d33d78e544b"}, - {file = "rpds_py-0.18.0-cp311-cp311-musllinux_1_2_x86_64.whl", hash = "sha256:a1ce3ba137ed54f83e56fb983a5859a27d43a40188ba798993812fed73c70836"}, - {file = "rpds_py-0.18.0-cp311-none-win32.whl", hash = "sha256:69e64831e22a6b377772e7fb337533c365085b31619005802a79242fee620bc1"}, - {file = "rpds_py-0.18.0-cp311-none-win_amd64.whl", hash = "sha256:998e33ad22dc7ec7e030b3df701c43630b5bc0d8fbc2267653577e3fec279afa"}, - {file = "rpds_py-0.18.0-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:7f2facbd386dd60cbbf1a794181e6aa0bd429bd78bfdf775436020172e2a23f0"}, - {file = "rpds_py-0.18.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:1d9a5be316c15ffb2b3c405c4ff14448c36b4435be062a7f578ccd8b01f0c4d8"}, - {file = "rpds_py-0.18.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:cd5bf1af8efe569654bbef5a3e0a56eca45f87cfcffab31dd8dde70da5982475"}, - {file = "rpds_py-0.18.0-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:5417558f6887e9b6b65b4527232553c139b57ec42c64570569b155262ac0754f"}, - {file = "rpds_py-0.18.0-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:56a737287efecafc16f6d067c2ea0117abadcd078d58721f967952db329a3e5c"}, - {file = "rpds_py-0.18.0-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8f03bccbd8586e9dd37219bce4d4e0d3ab492e6b3b533e973fa08a112cb2ffc9"}, - {file = "rpds_py-0.18.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:4457a94da0d5c53dc4b3e4de1158bdab077db23c53232f37a3cb7afdb053a4e3"}, - {file = "rpds_py-0.18.0-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:0ab39c1ba9023914297dd88ec3b3b3c3f33671baeb6acf82ad7ce883f6e8e157"}, - {file = "rpds_py-0.18.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:9d54553c1136b50fd12cc17e5b11ad07374c316df307e4cfd6441bea5fb68496"}, - {file = "rpds_py-0.18.0-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:0af039631b6de0397ab2ba16eaf2872e9f8fca391b44d3d8cac317860a700a3f"}, - {file = "rpds_py-0.18.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:84ffab12db93b5f6bad84c712c92060a2d321b35c3c9960b43d08d0f639d60d7"}, - {file = "rpds_py-0.18.0-cp312-none-win32.whl", hash = "sha256:685537e07897f173abcf67258bee3c05c374fa6fff89d4c7e42fb391b0605e98"}, - {file = "rpds_py-0.18.0-cp312-none-win_amd64.whl", hash = "sha256:e003b002ec72c8d5a3e3da2989c7d6065b47d9eaa70cd8808b5384fbb970f4ec"}, - {file = "rpds_py-0.18.0-cp38-cp38-macosx_10_12_x86_64.whl", hash = "sha256:08f9ad53c3f31dfb4baa00da22f1e862900f45908383c062c27628754af2e88e"}, - {file = "rpds_py-0.18.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:c0013fe6b46aa496a6749c77e00a3eb07952832ad6166bd481c74bda0dcb6d58"}, - {file = "rpds_py-0.18.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e32a92116d4f2a80b629778280103d2a510a5b3f6314ceccd6e38006b5e92dcb"}, - {file = "rpds_py-0.18.0-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e541ec6f2ec456934fd279a3120f856cd0aedd209fc3852eca563f81738f6861"}, - {file = "rpds_py-0.18.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:bed88b9a458e354014d662d47e7a5baafd7ff81c780fd91584a10d6ec842cb73"}, - {file = "rpds_py-0.18.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:2644e47de560eb7bd55c20fc59f6daa04682655c58d08185a9b95c1970fa1e07"}, - {file = "rpds_py-0.18.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:8e8916ae4c720529e18afa0b879473049e95949bf97042e938530e072fde061d"}, - {file = "rpds_py-0.18.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:465a3eb5659338cf2a9243e50ad9b2296fa15061736d6e26240e713522b6235c"}, - {file = "rpds_py-0.18.0-cp38-cp38-musllinux_1_2_aarch64.whl", hash = "sha256:ea7d4a99f3b38c37eac212dbd6ec42b7a5ec51e2c74b5d3223e43c811609e65f"}, - {file = "rpds_py-0.18.0-cp38-cp38-musllinux_1_2_i686.whl", hash = "sha256:67071a6171e92b6da534b8ae326505f7c18022c6f19072a81dcf40db2638767c"}, - {file = "rpds_py-0.18.0-cp38-cp38-musllinux_1_2_x86_64.whl", hash = "sha256:41ef53e7c58aa4ef281da975f62c258950f54b76ec8e45941e93a3d1d8580594"}, - {file = "rpds_py-0.18.0-cp38-none-win32.whl", hash = "sha256:fdea4952db2793c4ad0bdccd27c1d8fdd1423a92f04598bc39425bcc2b8ee46e"}, - {file = "rpds_py-0.18.0-cp38-none-win_amd64.whl", hash = "sha256:7cd863afe7336c62ec78d7d1349a2f34c007a3cc6c2369d667c65aeec412a5b1"}, - {file = "rpds_py-0.18.0-cp39-cp39-macosx_10_12_x86_64.whl", hash = "sha256:5307def11a35f5ae4581a0b658b0af8178c65c530e94893345bebf41cc139d33"}, - {file = "rpds_py-0.18.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:77f195baa60a54ef9d2de16fbbfd3ff8b04edc0c0140a761b56c267ac11aa467"}, - {file = "rpds_py-0.18.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:39f5441553f1c2aed4de4377178ad8ff8f9d733723d6c66d983d75341de265ab"}, - {file = "rpds_py-0.18.0-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:9a00312dea9310d4cb7dbd7787e722d2e86a95c2db92fbd7d0155f97127bcb40"}, - {file = "rpds_py-0.18.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8f2fc11e8fe034ee3c34d316d0ad8808f45bc3b9ce5857ff29d513f3ff2923a1"}, - {file = "rpds_py-0.18.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:586f8204935b9ec884500498ccc91aa869fc652c40c093bd9e1471fbcc25c022"}, - {file = "rpds_py-0.18.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:ddc2f4dfd396c7bfa18e6ce371cba60e4cf9d2e5cdb71376aa2da264605b60b9"}, - {file = "rpds_py-0.18.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:5ddcba87675b6d509139d1b521e0c8250e967e63b5909a7e8f8944d0f90ff36f"}, - {file = "rpds_py-0.18.0-cp39-cp39-musllinux_1_2_aarch64.whl", hash = "sha256:7bd339195d84439cbe5771546fe8a4e8a7a045417d8f9de9a368c434e42a721e"}, - {file = "rpds_py-0.18.0-cp39-cp39-musllinux_1_2_i686.whl", hash = "sha256:d7c36232a90d4755b720fbd76739d8891732b18cf240a9c645d75f00639a9024"}, - {file = "rpds_py-0.18.0-cp39-cp39-musllinux_1_2_x86_64.whl", hash = "sha256:6b0817e34942b2ca527b0e9298373e7cc75f429e8da2055607f4931fded23e20"}, - {file = "rpds_py-0.18.0-cp39-none-win32.whl", hash = "sha256:99f70b740dc04d09e6b2699b675874367885217a2e9f782bdf5395632ac663b7"}, - {file = "rpds_py-0.18.0-cp39-none-win_amd64.whl", hash = "sha256:6ef687afab047554a2d366e112dd187b62d261d49eb79b77e386f94644363294"}, - {file = "rpds_py-0.18.0-pp310-pypy310_pp73-macosx_10_12_x86_64.whl", hash = "sha256:ad36cfb355e24f1bd37cac88c112cd7730873f20fb0bdaf8ba59eedf8216079f"}, - {file = "rpds_py-0.18.0-pp310-pypy310_pp73-macosx_11_0_arm64.whl", hash = "sha256:36b3ee798c58ace201289024b52788161e1ea133e4ac93fba7d49da5fec0ef9e"}, - {file = "rpds_py-0.18.0-pp310-pypy310_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:f8a2f084546cc59ea99fda8e070be2fd140c3092dc11524a71aa8f0f3d5a55ca"}, - {file = "rpds_py-0.18.0-pp310-pypy310_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e4461d0f003a0aa9be2bdd1b798a041f177189c1a0f7619fe8c95ad08d9a45d7"}, - {file = "rpds_py-0.18.0-pp310-pypy310_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:8db715ebe3bb7d86d77ac1826f7d67ec11a70dbd2376b7cc214199360517b641"}, - {file = "rpds_py-0.18.0-pp310-pypy310_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:793968759cd0d96cac1e367afd70c235867831983f876a53389ad869b043c948"}, - {file = "rpds_py-0.18.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:66e6a3af5a75363d2c9a48b07cb27c4ea542938b1a2e93b15a503cdfa8490795"}, - {file = "rpds_py-0.18.0-pp310-pypy310_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:6ef0befbb5d79cf32d0266f5cff01545602344eda89480e1dd88aca964260b18"}, - {file = "rpds_py-0.18.0-pp310-pypy310_pp73-musllinux_1_2_aarch64.whl", hash = "sha256:1d4acf42190d449d5e89654d5c1ed3a4f17925eec71f05e2a41414689cda02d1"}, - {file = "rpds_py-0.18.0-pp310-pypy310_pp73-musllinux_1_2_i686.whl", hash = "sha256:a5f446dd5055667aabaee78487f2b5ab72e244f9bc0b2ffebfeec79051679984"}, - {file = "rpds_py-0.18.0-pp310-pypy310_pp73-musllinux_1_2_x86_64.whl", hash = "sha256:9dbbeb27f4e70bfd9eec1be5477517365afe05a9b2c441a0b21929ee61048124"}, - {file = "rpds_py-0.18.0-pp38-pypy38_pp73-macosx_10_12_x86_64.whl", hash = "sha256:22806714311a69fd0af9b35b7be97c18a0fc2826e6827dbb3a8c94eac6cf7eeb"}, - {file = "rpds_py-0.18.0-pp38-pypy38_pp73-macosx_11_0_arm64.whl", hash = "sha256:b34ae4636dfc4e76a438ab826a0d1eed2589ca7d9a1b2d5bb546978ac6485461"}, - {file = "rpds_py-0.18.0-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:8c8370641f1a7f0e0669ddccca22f1da893cef7628396431eb445d46d893e5cd"}, - {file = "rpds_py-0.18.0-pp38-pypy38_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:c8362467a0fdeccd47935f22c256bec5e6abe543bf0d66e3d3d57a8fb5731863"}, - {file = "rpds_py-0.18.0-pp38-pypy38_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:11a8c85ef4a07a7638180bf04fe189d12757c696eb41f310d2426895356dcf05"}, - {file = "rpds_py-0.18.0-pp38-pypy38_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:b316144e85316da2723f9d8dc75bada12fa58489a527091fa1d5a612643d1a0e"}, - {file = "rpds_py-0.18.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:cf1ea2e34868f6fbf070e1af291c8180480310173de0b0c43fc38a02929fc0e3"}, - {file = "rpds_py-0.18.0-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:e546e768d08ad55b20b11dbb78a745151acbd938f8f00d0cfbabe8b0199b9880"}, - {file = "rpds_py-0.18.0-pp38-pypy38_pp73-musllinux_1_2_aarch64.whl", hash = "sha256:4901165d170a5fde6f589acb90a6b33629ad1ec976d4529e769c6f3d885e3e80"}, - {file = "rpds_py-0.18.0-pp38-pypy38_pp73-musllinux_1_2_i686.whl", hash = "sha256:618a3d6cae6ef8ec88bb76dd80b83cfe415ad4f1d942ca2a903bf6b6ff97a2da"}, - {file = "rpds_py-0.18.0-pp38-pypy38_pp73-musllinux_1_2_x86_64.whl", hash = "sha256:ed4eb745efbff0a8e9587d22a84be94a5eb7d2d99c02dacf7bd0911713ed14dd"}, - {file = "rpds_py-0.18.0-pp39-pypy39_pp73-macosx_10_12_x86_64.whl", hash = "sha256:6c81e5f372cd0dc5dc4809553d34f832f60a46034a5f187756d9b90586c2c307"}, - {file = "rpds_py-0.18.0-pp39-pypy39_pp73-macosx_11_0_arm64.whl", hash = "sha256:43fbac5f22e25bee1d482c97474f930a353542855f05c1161fd804c9dc74a09d"}, - {file = "rpds_py-0.18.0-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:6d7faa6f14017c0b1e69f5e2c357b998731ea75a442ab3841c0dbbbfe902d2c4"}, - {file = "rpds_py-0.18.0-pp39-pypy39_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:08231ac30a842bd04daabc4d71fddd7e6d26189406d5a69535638e4dcb88fe76"}, - {file = "rpds_py-0.18.0-pp39-pypy39_pp73-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:044a3e61a7c2dafacae99d1e722cc2d4c05280790ec5a05031b3876809d89a5c"}, - {file = "rpds_py-0.18.0-pp39-pypy39_pp73-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:3f26b5bd1079acdb0c7a5645e350fe54d16b17bfc5e71f371c449383d3342e17"}, - {file = "rpds_py-0.18.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:482103aed1dfe2f3b71a58eff35ba105289b8d862551ea576bd15479aba01f66"}, - {file = "rpds_py-0.18.0-pp39-pypy39_pp73-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:1374f4129f9bcca53a1bba0bb86bf78325a0374577cf7e9e4cd046b1e6f20e24"}, - {file = "rpds_py-0.18.0-pp39-pypy39_pp73-musllinux_1_2_aarch64.whl", hash = "sha256:635dc434ff724b178cb192c70016cc0ad25a275228f749ee0daf0eddbc8183b1"}, - {file = "rpds_py-0.18.0-pp39-pypy39_pp73-musllinux_1_2_i686.whl", hash = "sha256:bc362ee4e314870a70f4ae88772d72d877246537d9f8cb8f7eacf10884862432"}, - {file = "rpds_py-0.18.0-pp39-pypy39_pp73-musllinux_1_2_x86_64.whl", hash = "sha256:4832d7d380477521a8c1644bbab6588dfedea5e30a7d967b5fb75977c45fd77f"}, - {file = "rpds_py-0.18.0.tar.gz", hash = "sha256:42821446ee7a76f5d9f71f9e33a4fb2ffd724bb3e7f93386150b61a43115788d"}, -] - -[[package]] -name = "setuptools" -version = "69.1.1" -description = "Easily download, build, install, upgrade, and uninstall Python packages" -optional = false -python-versions = ">=3.8" -files = [ - {file = "setuptools-69.1.1-py3-none-any.whl", hash = "sha256:02fa291a0471b3a18b2b2481ed902af520c69e8ae0919c13da936542754b4c56"}, - {file = "setuptools-69.1.1.tar.gz", hash = "sha256:5c0806c7d9af348e6dd3777b4f4dbb42c7ad85b190104837488eab9a7c945cf8"}, -] - -[package.extras] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-inline-tabs", "sphinx-lint", "sphinx-notfound-page (>=1,<2)", "sphinx-reredirects", "sphinxcontrib-towncrier"] -testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.develop (>=7.21)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "packaging (>=23.2)", "pip (>=19.1)", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-home (>=0.5)", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-ruff (>=0.2.1)", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"] -testing-integration = ["build[virtualenv] (>=1.0.3)", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "packaging (>=23.2)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"] - -[[package]] -name = "six" -version = "1.16.0" -description = "Python 2 and 3 compatibility utilities" -optional = false -python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" -files = [ - {file = "six-1.16.0-py2.py3-none-any.whl", hash = "sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"}, - {file = "six-1.16.0.tar.gz", hash = "sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"}, -] - -[[package]] -name = "spinners" -version = "0.0.24" -description = "Spinners for terminals" -optional = false -python-versions = "*" -files = [ - {file = "spinners-0.0.24-py3-none-any.whl", hash = "sha256:2fa30d0b72c9650ad12bbe031c9943b8d441e41b4f5602b0ec977a19f3290e98"}, - {file = "spinners-0.0.24.tar.gz", hash = "sha256:1eb6aeb4781d72ab42ed8a01dcf20f3002bf50740d7154d12fb8c9769bf9e27f"}, -] - -[[package]] -name = "termcolor" -version = "2.4.0" -description = "ANSI color formatting for output in terminal" -optional = false -python-versions = ">=3.8" -files = [ - {file = "termcolor-2.4.0-py3-none-any.whl", hash = "sha256:9297c0df9c99445c2412e832e882a7884038a25617c60cea2ad69488d4040d63"}, - {file = "termcolor-2.4.0.tar.gz", hash = "sha256:aab9e56047c8ac41ed798fa36d892a37aca6b3e9159f3e0c24bc64a9b3ac7b7a"}, -] - -[package.extras] -tests = ["pytest", "pytest-cov"] - -[[package]] -name = "tomli" -version = "2.0.1" -description = "A lil' TOML parser" -optional = false -python-versions = ">=3.7" -files = [ - {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, - {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, -] - -[[package]] -name = "types-colorama" -version = "0.4.15.20240205" -description = "Typing stubs for colorama" -optional = false -python-versions = ">=3.8" -files = [ - {file = "types-colorama-0.4.15.20240205.tar.gz", hash = "sha256:7ae4f58d407d387f4f98b24d81e1b7657ec754ea1dc4619ae5bd27f0c367637e"}, - {file = "types_colorama-0.4.15.20240205-py3-none-any.whl", hash = "sha256:3ab26dcd76d2f13b1b795ed5c87a1a1a29331ea64cf614bb6ae958a3cebc3a53"}, -] - -[[package]] -name = "yapf" -version = "0.40.2" -description = "A formatter for Python code" -optional = false -python-versions = ">=3.7" -files = [ - {file = "yapf-0.40.2-py3-none-any.whl", hash = "sha256:adc8b5dd02c0143108878c499284205adb258aad6db6634e5b869e7ee2bd548b"}, - {file = "yapf-0.40.2.tar.gz", hash = "sha256:4dab8a5ed7134e26d57c1647c7483afb3f136878b579062b786c9ba16b94637b"}, -] - -[package.dependencies] -importlib-metadata = ">=6.6.0" -platformdirs = ">=3.5.1" -tomli = ">=2.0.1" - -[[package]] -name = "zipp" -version = "3.17.0" -description = "Backport of pathlib-compatible object wrapper for zip files" -optional = false -python-versions = ">=3.8" -files = [ - {file = "zipp-3.17.0-py3-none-any.whl", hash = "sha256:0e923e726174922dce09c53c59ad483ff7bbb8e572e00c7f7c46b88556409f31"}, - {file = "zipp-3.17.0.tar.gz", hash = "sha256:84e64a1c28cf7e91ed2078bb8cc8c259cb19b76942096c8d7b84947690cabaf0"}, -] - -[package.extras] -docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (<7.2.5)", "sphinx (>=3.5)", "sphinx-lint"] -testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-ignore-flaky", "pytest-mypy (>=0.9.1)", "pytest-ruff"] - -[metadata] -lock-version = "2.0" -python-versions = "^3.11" -content-hash = "6146ea1571def62c4f7ff33173e0144bcfd206c178936365bff8b4e1669b90ff" diff --git a/util/nix/pyproject.toml b/util/nix/pyproject.toml deleted file mode 100644 index fa62eb96c0..0000000000 --- a/util/nix/pyproject.toml +++ /dev/null @@ -1,39 +0,0 @@ -# This file should be kept in sync with requirements.txt and requirements-dev.txt -# It is particularly required by the Nix environment (see shell.nix). To update versions, -# normally one would run "poetry update --lock" -[tool.poetry] -name = "qmk_firmware" -version = "0.1.0" -description = "" -authors = [] - -[tool.poetry.dependencies] -python = "^3.11" -appdirs = "*" -argcomplete = "*" -colorama = "*" -dotty-dict = "*" -hid = "*" -hjson = "*" -jsonschema = ">=4" -milc = ">=1.4.2" -Pygments = "*" -pyserial = "*" -pyusb = "*" -pillow = "*" - -# This dependency is not mentioned in requirements.txt (QMK CLI is not a -# library package that is required by the Python code in qmk_firmware), but is -# required to build a proper nix-shell environment. -qmk = "*" - -[tool.poetry.dev-dependencies] -nose2 = "*" -flake8 = "*" -pep8-naming = "*" -pyflakes = "*" -yapf = "*" - -[build-system] -requires = ["poetry-core>=1.0.0"] -build-backend = "poetry.core.masonry.api" diff --git a/util/nix/sources.json b/util/nix/sources.json deleted file mode 100644 index 3985f75e03..0000000000 --- a/util/nix/sources.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "niv": { - "branch": "master", - "description": "Easy dependency management for Nix projects", - "homepage": "https://github.com/nmattia/niv", - "owner": "nmattia", - "repo": "niv", - "rev": "af958e8057f345ee1aca714c1247ef3ba1c15f5e", - "sha256": "1qjavxabbrsh73yck5dcq8jggvh3r2jkbr6b5nlz5d9yrqm9255n", - "type": "tarball", - "url": "https://github.com/nmattia/niv/archive/af958e8057f345ee1aca714c1247ef3ba1c15f5e.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "nixpkgs": { - "branch": "nixpkgs-unstable", - "description": "Nix Packages collection", - "homepage": "", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "98b00b6947a9214381112bdb6f89c25498db4959", - "sha256": "1m6dm144mbm56n9293m26f46bjrklknyr4q4kzvxkiv036ijma98", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/98b00b6947a9214381112bdb6f89c25498db4959.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - }, - "poetry2nix": { - "branch": "master", - "description": "Convert poetry projects to nix automagically [maintainer=@adisbladis] ", - "homepage": "", - "owner": "nix-community", - "repo": "poetry2nix", - "rev": "3c92540611f42d3fb2d0d084a6c694cd6544b609", - "sha256": "1jfrangw0xb5b8sdkimc550p3m98zhpb1fayahnr7crg74as4qyq", - "type": "tarball", - "url": "https://github.com/nix-community/poetry2nix/archive/3c92540611f42d3fb2d0d084a6c694cd6544b609.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - } -} diff --git a/util/nix/sources.nix b/util/nix/sources.nix deleted file mode 100644 index fe3dadf7eb..0000000000 --- a/util/nix/sources.nix +++ /dev/null @@ -1,198 +0,0 @@ -# This file has been generated by Niv. - -let - - # - # The fetchers. fetch_ fetches specs of type . - # - - fetch_file = pkgs: name: spec: - let - name' = sanitizeName name + "-src"; - in - if spec.builtin or true then - builtins_fetchurl { inherit (spec) url sha256; name = name'; } - else - pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; - - fetch_tarball = pkgs: name: spec: - let - name' = sanitizeName name + "-src"; - in - if spec.builtin or true then - builtins_fetchTarball { name = name'; inherit (spec) url sha256; } - else - pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; - - fetch_git = name: spec: - let - ref = - spec.ref or ( - if spec ? branch then "refs/heads/${spec.branch}" else - if spec ? tag then "refs/tags/${spec.tag}" else - abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!" - ); - submodules = spec.submodules or false; - submoduleArg = - let - nixSupportsSubmodules = builtins.compareVersions builtins.nixVersion "2.4" >= 0; - emptyArgWithWarning = - if submodules - then - builtins.trace - ( - "The niv input \"${name}\" uses submodules " - + "but your nix's (${builtins.nixVersion}) builtins.fetchGit " - + "does not support them" - ) - { } - else { }; - in - if nixSupportsSubmodules - then { inherit submodules; } - else emptyArgWithWarning; - in - builtins.fetchGit - ({ url = spec.repo; inherit (spec) rev; inherit ref; } // submoduleArg); - - fetch_local = spec: spec.path; - - fetch_builtin-tarball = name: throw - ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`. - $ niv modify ${name} -a type=tarball -a builtin=true''; - - fetch_builtin-url = name: throw - ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`. - $ niv modify ${name} -a type=file -a builtin=true''; - - # - # Various helpers - # - - # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695 - sanitizeName = name: - ( - concatMapStrings (s: if builtins.isList s then "-" else s) - ( - builtins.split "[^[:alnum:]+._?=-]+" - ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) - ) - ); - - # The set of packages used when specs are fetched using non-builtins. - mkPkgs = sources: system: - let - sourcesNixpkgs = - import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; }; - hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; - hasThisAsNixpkgsPath = == ./.; - in - if builtins.hasAttr "nixpkgs" sources - then sourcesNixpkgs - else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then - import { } - else - abort - '' - Please specify either (through -I or NIX_PATH=nixpkgs=...) or - add a package called "nixpkgs" to your sources.json. - ''; - - # The actual fetching function. - fetch = pkgs: name: spec: - - if ! builtins.hasAttr "type" spec then - abort "ERROR: niv spec ${name} does not have a 'type' attribute" - else if spec.type == "file" then fetch_file pkgs name spec - else if spec.type == "tarball" then fetch_tarball pkgs name spec - else if spec.type == "git" then fetch_git name spec - else if spec.type == "local" then fetch_local spec - else if spec.type == "builtin-tarball" then fetch_builtin-tarball name - else if spec.type == "builtin-url" then fetch_builtin-url name - else - abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; - - # If the environment variable NIV_OVERRIDE_${name} is set, then use - # the path directly as opposed to the fetched source. - replace = name: drv: - let - saneName = stringAsChars (c: if (builtins.match "[a-zA-Z0-9]" c) == null then "_" else c) name; - ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; - in - if ersatz == "" then drv else - # this turns the string into an actual Nix path (for both absolute and - # relative paths) - if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}"; - - # Ports of functions for older nix versions - - # a Nix version of mapAttrs if the built-in doesn't exist - mapAttrs = builtins.mapAttrs or ( - f: set: with builtins; - listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)) - ); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 - range = first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L257 - stringToCharacters = s: map (p: builtins.substring p 1 s) (range 0 (builtins.stringLength s - 1)); - - # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/strings.nix#L269 - stringAsChars = f: s: concatStrings (map f (stringToCharacters s)); - concatMapStrings = f: list: concatStrings (map f list); - concatStrings = builtins.concatStringsSep ""; - - # https://github.com/NixOS/nixpkgs/blob/8a9f58a375c401b96da862d969f66429def1d118/lib/attrsets.nix#L331 - optionalAttrs = cond: as: if cond then as else { }; - - # fetchTarball version that is compatible between all the versions of Nix - builtins_fetchTarball = { url, name ? null, sha256 }@attrs: - let - inherit (builtins) lessThan nixVersion fetchTarball; - in - if lessThan nixVersion "1.12" then - fetchTarball ({ inherit url; } // (optionalAttrs (name != null) { inherit name; })) - else - fetchTarball attrs; - - # fetchurl version that is compatible between all the versions of Nix - builtins_fetchurl = { url, name ? null, sha256 }@attrs: - let - inherit (builtins) lessThan nixVersion fetchurl; - in - if lessThan nixVersion "1.12" then - fetchurl ({ inherit url; } // (optionalAttrs (name != null) { inherit name; })) - else - fetchurl attrs; - - # Create the final "sources" from the config - mkSources = config: - mapAttrs - ( - name: spec: - if builtins.hasAttr "outPath" spec - then - abort - "The values in sources.json should not have an 'outPath' attribute" - else - spec // { outPath = replace name (fetch config.pkgs name spec); } - ) - config.sources; - - # The "config" used by the fetchers - mkConfig = - { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null - , sources ? if sourcesFile == null then { } else builtins.fromJSON (builtins.readFile sourcesFile) - , system ? builtins.currentSystem - , pkgs ? mkPkgs sources system - }: rec { - # The sources, i.e. the attribute set of spec name to spec - inherit sources; - - # The "pkgs" (evaluated nixpkgs) to use for e.g. non-builtin fetchers - inherit pkgs; - }; - -in -mkSources (mkConfig { }) // { __functor = _: settings: mkSources (mkConfig settings); } diff --git a/util/regen.sh b/util/regen.sh index ab03018893..df40444f80 100755 --- a/util/regen.sh +++ b/util/regen.sh @@ -3,7 +3,6 @@ set -e qmk generate-rgb-breathe-table -o quantum/rgblight/rgblight_breathe_table.h qmk generate-keycodes --version latest -o quantum/keycodes.h -qmk generate-keycodes-tests --version latest -o tests/test_common/keycode_table.cpp for lang in $(find data/constants/keycodes/extras/ -type f -exec basename '{}' \; | sed "s/keycodes_\(.*\)_[0-9].*/\1/"); do qmk generate-keycode-extras --version latest --lang $lang -o quantum/keymap_extras/keymap_$lang.h diff --git a/util/usb_detach/usb_detach.c b/util/usb_detach/usb_detach.c index 786ab5e674..8047c37ba3 100644 --- a/util/usb_detach/usb_detach.c +++ b/util/usb_detach/usb_detach.c @@ -31,4 +31,4 @@ int main(int argc, char**argv) printf ("usage: %s /dev/bus/usb/BUS/DEVICE\n",argv[0]); printf("Release all interfaces of this usb device for usage in virtualisation\n"); } -} \ No newline at end of file +}