-
-
Notifications
You must be signed in to change notification settings - Fork 40.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Relocate RGB keycode processing #7508
Conversation
99dd3e0
to
fc295cc
Compare
I like this, a lot. Though, I don't like the remapping of the rgb matrix functions to rgb light functions, even if it's behind a preprocessor. In fact, this makes #5404 almost trival to implement, rather than the messy mess that it is right now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
* | ||
* noinline to optimise for firmware size not speed (not in hot path) | ||
*/ | ||
void __attribute__((noinline)) handleKeycodeRGB(const uint8_t is_shifted, const rgb_func_pointer inc_func, const rgb_func_pointer dec_func) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's change these to return boolean and return false. This will make the caller slightly cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So i gave the above suggestion a go, and it consumes about an extra 50 bytes with the return false
and return handleKeycodeRGB(
. While its about 0.17% of the available flash, we recent had the issue with trying to claw back 4 bytes. Do we want to focus on readability here? (its still a net saving)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While I'm all for regaining as much program space as possible... I think that readability (and maintainability) should be the priority.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the handleKeycodeRGB had more logic, i would agree, but if it just returns false i would say personally not any more readable. That being said, i don't mind either way.
In the case of the animations, you end up with
#ifdef RGBLIGHT_EFFECT_KNIGHT
return handleKeycodeRGBMode(RGBLIGHT_MODE_KNIGHT, RGBLIGHT_MODE_KNIGHT_end);
#else
return false;
#endif
or
#ifdef RGBLIGHT_EFFECT_KNIGHT
return handleKeycodeRGBMode(RGBLIGHT_MODE_KNIGHT, RGBLIGHT_MODE_KNIGHT_end);
#endif
return false;
with the dead double return that gets optimised out, which in both cases is less readable to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I deliberately didn't ask you to modify RGBMode because I didn't think it helped readability
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So i gave the above suggestion a go, and it consumes about an extra 50 bytes with the
return false
andreturn handleKeycodeRGB(
. While its about 0.17% of the available flash, we recent had the issue with trying to claw back 4 bytes. Do we want to focus on readability here? (its still a net saving)
I actually think that making this signature return something maybe useful in the long run, much like we had with led settings. Right now it only returns false, but there may be cases in the future where it's useful to return true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I read "these" as both the new function signatures.
As this is non user facing, would we not just defer to the point we implement the additional functionality?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's a fair point. I still think it's slightly more readable than having an explicit false, but it's also anticipating use cases we don't have, so just leave it as is for now.
1f21ae8
to
2237db2
Compare
Finally ironed out all the rebase issues, should be good to go again! |
* master: (99 commits) [Keymap] Added userspace for d4mation. Included their keymap for the Atreus62 (qmk#7483) [Keymap] Custom user keymap for Think6.5 with LED range control (qmk#7603) [Keymap] CRKBD Custom Keymap - KidBrazil (qmk#7630) [Keymap] Add pico 70 keys keymap (qmk#7654) Tidy up dztech default keymaps and info.json (qmk#7608) Heisenberg handwired keyboard added (qmk#7643) [Keyboard] Added Filco Majestouch TKL Pegasus Hoof ISO Layout (qmk#7647) Ported J80 to QMK (qmk#7488) [Keyboard] Magnavox Videowriter conversion with Pro Micro (qmk#7634) [Docs] add japanese translation (basic part) (qmk#7461) Tidy up dztech rules.mk Relocate RGB keycode processing (qmk#7508) Move kwerdenker's personal keymap from RGB (qmk#7645) Remove QMK_KEYBOARD_CONFIG_H from boards (qmk#7635) Disable usb on slave half to resolve random 'lockup' (qmk#7649) [Core] Optimize matrix processing (qmk#7621) [Keymap] boy_314's satisfaction75 layout (qmk#7638) [Keyboard] XD68 65% ATMega32U4 based (qmk#7395) [keyboard] Plain60 cleanups (qmk#7644) update default h88 keymap (qmk#7646) ...
* Move rgb keycode logic to process_keycode * Fixes for rgb matrix * Fixes for mxss * Fix inc/dec logic, add comments * Fix return RAINBOW_SWIRL logic * stop external use of rgb helper functions * merge fix * Fix 'defined but not used' when all animations are disabled
* Move rgb keycode logic to process_keycode * Fixes for rgb matrix * Fixes for mxss * Fix inc/dec logic, add comments * Fix return RAINBOW_SWIRL logic * stop external use of rgb helper functions * merge fix * Fix 'defined but not used' when all animations are disabled
* clean up quantum.c (qmk#7485) * idea * progress * more stuff * wip * wip * last couple of keycodes you can move safely * Update quantum/quantum.c Co-Authored-By: fauxpark <[email protected]> * Put back RGB_MODE_BREATHE * Compile out some keycode processing when features are disabled (qmk#7506) * Add shift-to-invert to remaining directional RGB_* keycode pairs (qmk#7484) * Add shift-to-invert to remaining directional RGB_* keycode pairs RGB_MODE_FORWARD / RGB_MODE_REVERSE invert their functions when shift is held. This change adds the same capabilities to the remaining directional RGB_* keycode pairs. This improves consistency and provides full RGB control in a keymap containing only one keycode from each pair. * remove redundant variable * fix typo * Fix more typos Flyspell is on now I swear! * Relocate magic keycode processing (qmk#7512) * Move magic keycode processing to own file * Save some bytes * Update comments * Update define to one thats not already used... * Fix audio * Fix breathing toggle when rgb is disabled (qmk#7550) * Ifdef MAGIC_EE_HANDS until #178 drops revert this commit once it does * Add short aliases for Magic keycodes (qmk#7541) * Add short alias for `MAGIC_TOGGLE_NKRO` * Add aliases for the other Bootmagic keycodes * Replace long form in default keymaps * Fix FORCE_NKRO handling (qmk#7601) * Add until #173 drops * Relocate RGB keycode processing (qmk#7508) * Move rgb keycode logic to process_keycode * Fixes for rgb matrix * Fixes for mxss * Fix inc/dec logic, add comments * Fix return RAINBOW_SWIRL logic * stop external use of rgb helper functions * merge fix * Fix 'defined but not used' when all animations are disabled Co-authored-by: Yan-Fa Li <[email protected]> Co-authored-by: Joel Challis <[email protected]> Co-authored-by: Manna Harbour <[email protected]> Co-authored-by: fauxpark <[email protected]> Co-authored-by: Florian Didron <[email protected]>
* clean up quantum.c (qmk#7485) * idea * progress * more stuff * wip * wip * last couple of keycodes you can move safely * Update quantum/quantum.c Co-Authored-By: fauxpark <[email protected]> * Put back RGB_MODE_BREATHE * Compile out some keycode processing when features are disabled (qmk#7506) * Add shift-to-invert to remaining directional RGB_* keycode pairs (qmk#7484) * Add shift-to-invert to remaining directional RGB_* keycode pairs RGB_MODE_FORWARD / RGB_MODE_REVERSE invert their functions when shift is held. This change adds the same capabilities to the remaining directional RGB_* keycode pairs. This improves consistency and provides full RGB control in a keymap containing only one keycode from each pair. * remove redundant variable * fix typo * Fix more typos Flyspell is on now I swear! * Relocate magic keycode processing (qmk#7512) * Move magic keycode processing to own file * Save some bytes * Update comments * Update define to one thats not already used... * Fix audio * Fix breathing toggle when rgb is disabled (qmk#7550) * Ifdef MAGIC_EE_HANDS until #178 drops revert this commit once it does * Add short aliases for Magic keycodes (qmk#7541) * Add short alias for `MAGIC_TOGGLE_NKRO` * Add aliases for the other Bootmagic keycodes * Replace long form in default keymaps * Fix FORCE_NKRO handling (qmk#7601) * Add until #173 drops * Relocate RGB keycode processing (qmk#7508) * Move rgb keycode logic to process_keycode * Fixes for rgb matrix * Fixes for mxss * Fix inc/dec logic, add comments * Fix return RAINBOW_SWIRL logic * stop external use of rgb helper functions * merge fix * Fix 'defined but not used' when all animations are disabled Co-authored-by: Yan-Fa Li <[email protected]> Co-authored-by: Joel Challis <[email protected]> Co-authored-by: Manna Harbour <[email protected]> Co-authored-by: fauxpark <[email protected]> Co-authored-by: Florian Didron <[email protected]>
* Move rgb keycode logic to process_keycode * Fixes for rgb matrix * Fixes for mxss * Fix inc/dec logic, add comments * Fix return RAINBOW_SWIRL logic * stop external use of rgb helper functions * merge fix * Fix 'defined but not used' when all animations are disabled
* Move rgb keycode logic to process_keycode * Fixes for rgb matrix * Fixes for mxss * Fix inc/dec logic, add comments * Fix return RAINBOW_SWIRL logic * stop external use of rgb helper functions * merge fix * Fix 'defined but not used' when all animations are disabled
* Move rgb keycode logic to process_keycode * Fixes for rgb matrix * Fixes for mxss * Fix inc/dec logic, add comments * Fix return RAINBOW_SWIRL logic * stop external use of rgb helper functions * merge fix * Fix 'defined but not used' when all animations are disabled
Description
This PR relocates a block of keycode handling to its own file for readability and also attempts to save some firmware bytes. Mimicking travis by running ./util/docker_build.sh helix/pico/back:default:
before
* The firmware size is approaching the maximum - 28482/28672 (99%, 190 bytes free)
after
* The firmware size is approaching the maximum - 28158/28672 (98%, 514 bytes free)
Types of Changes
Checklist