Closed jpetermans closed 5 years ago
I wouldn't mind setting up a framework for more hooks like this, or even renaming some of the existing ones. I wasn't aware of the hooks TMK added - this might have happened after we forked.
The matrixinit and matrixscan functions seem to cover most scenarios. matrix_init worked fine for the tmk backlight code I'm working on from whitefox. It was using hook_init_early. Although, additional hooks may be less processor intensive in some cases where you don't need to run something every keyboard loop, just on a few discrete events.
This would be nice to have. I've been using matrix_scan_user
for changing backlight color when the current layer changes, but TMK-style hooks would be a bit cleaner.
In case you're curious, tmk/tmk_keyboard@53bd4a01be5c4327462e6c6620ea7670eddca6f2 was the commit that introduced hooks to TMK. There's more to that commit than just setting up hooks I believe, but the code for hooks looks pretty clean and fairly simple to move to QMK.
This is partially done, now, actually. https://docs.qmk.fm/#/custom_quantum_functions?id=keyboard-idlingwake-code
And #3113
I think the only thing that is left is bootmagic, actually. And we have bootmagic lite
which is user configurable, though not as fully featured.
And I'm not sure we really need the bootmagic hook. That can be done as part of the init functions. Right now, bootmagic lite does this during matrix_init.
@jpetermans would you say that this could be closed?
I haven't looked over everything in any detail, but there is no need for me to that. A quick review looks like it's all covered as you noted. Closing this issue. Thanks for the building in these additional options!
I'm in the process of trying to port over matt3o's whitefox backlight code from TMK and converting for infinity60. In another issue I opened, #1179, fredizzimo commented that he is working on a software solution for the ergodox that could be ported over. In the meantime, I thought I'd take a stab at porting over the hardward approach from the whitefox tmk code.
matt3o's led_controller code uses functions from tmk_core/common/hook.c which qmk does not have. I'm trying to translate to equivalent the kb / user level functions from qmk and want to make sure the timing of the calls is similar. My attempt is below. Bolded calls are used in led_controller.c from tmk. Do these look correct? My primary concern is matching the hook_early_init timing.
(unused in whitefox led_controller code)
(edit) Full list of hooks to convert:
suspend_power_down_*
handles this, as of #3112)