qmk / qmk_firmware

Open-source keyboard firmware for Atmel AVR and Arm USB families
https://qmk.fm
GNU General Public License v2.0
18.25k stars 39.33k forks source link

kb / user hooks - TMK vs QMK #1205

Closed jpetermans closed 5 years ago

jpetermans commented 7 years ago

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:

jackhumbert commented 7 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.

jpetermans commented 7 years ago

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.

luizribeiro commented 7 years ago

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.

drashna commented 6 years ago

This is partially done, now, actually. https://docs.qmk.fm/#/custom_quantum_functions?id=keyboard-idlingwake-code

And #3113

drashna commented 5 years ago

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?

jpetermans commented 5 years ago

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!