Repository navigation
Add string macro advanced key support - #22
Conversation
|
Oh I thought we want to implement the single linked list in case we want to support full macro in the future? |
|
Yes you are right this was simpler for me to write 😢 |
|
By full macro, I meant macro system where we support setting delay for each action, and possibly pointing the event to the next one to create a loop etc. I don't really have the full picture of how it will look like, but I imagine either the web configurator or the firmware to walk through the macro and compact/garbage collect the linked list buffer if it is full. Each node can have a key, delay in matrix cycle/milliseconds (potentially 0 so we can press a character and shift and the same time), and the next node. For the first simple version, I think maybe we can start with just a linked list of characters to support sending string for now, and keep the UI you proposed for hmkconf since the UI for the full macro system probably requires a lot of thought. For the garbage collection, I meant something like:
Might be too complex but I'm open for suggestions. Sorry for the back and forth, but it's kinda sad that if one day, we implement this macro system then its functionality will overlap with this PR. |
|
No issues I love the conversation! The proposed cleanup is quite sophisticated but also very bulletproof! |
|
Hello! I added another 2 bytes per "step" as a pointer to the next item in the list. BTW I dont think we need garbage collection neceserily. One disadvantage is that now with 512 byte space we only get around 100 total macro "steps" were before we were at 170. But this does make our list much more scalable. Let me know what you think.
Cheers! |
|
Thanks for making the changes. I'm sick right now, so not sure if you can review this soon though. |
|
Hey Pep! |
peppapighs
left a comment
There was a problem hiding this comment.
I left some comments from my first glance at the code. Let me know your thought and thank you for writing this PR!
As for your questions:
- I agree with keeping the firmware clean. It probably doesn't matter in practice anyway whether we do it in the same cycle or not.
- I think let's leave that aside for now. I still don't have a good picture of how the UI/UX would be like if we support repeating/looping. I suppose the implementation should not be too difficult since we are essentially implementing a tiny state machine. Open for some ideas though.
| break; | ||
|
|
||
| case STRING_MACRO_ACTION_TAP: | ||
| layout_register(state->key, node->keycode); |
There was a problem hiding this comment.
Not sure if I'm missing something but maybe we can use deferred action here for tapping, so that the tick rate config is in effect for this too.
There was a problem hiding this comment.
I tested this and I dont think we can use deferred tap here.
Mainly because the macro needs to run in order. In the situation where we have "PRESS shift, TAP a, RELEASE shift"
The release shift might happen (due to the tick of the macro) before the deferred tap has finished.
If you really prefer using deferred tap I suggest we do either:
A) hard wire a wait after macro TAP based on the tick time of deferred macro before moving to the next item in the list.
B) Add a callback from the deferred macro function to know that it has finished before moving to the next item on the list.
In both this situations the disadvantage is that the taps of macros will not be as fast as possible (currently next matrix scan cycle) but this might be acceptable. Let me know your thoughts on this.
There was a problem hiding this comment.
I'm generally ok with A) to keep it consistent with tap-hold and DKS. I acknowledge the disadvantage here, but it's probably doesn't matter in practice.
There was a problem hiding this comment.
Sorry I have been out of the country I aim to fix this in a few days.
I think B) is better structure so I will try that and if to complex fall back on A).
There was a problem hiding this comment.
I would prefer A) over B) though since I think deferred action should just be on its own, not needed to know about macros. Anyway, please take your time.
There was a problem hiding this comment.
Yes agreed I was thinking of making the "deferred action" function call you back or reply to you once the deferred action is done, so its reusable.
There was a problem hiding this comment.
@peppapighs Hey ya! ok its now done with option A)
I tried option B) but keeping a queue of each deferred action and then getting a callback was a but too much for this.
This way you get a small delay between issuing every deferred action which to work nicely.
|
Done except the last point which I would like to discuss a bit more. I have some UI ideas about making loops etc but maybe we can leave that for later indeed! |
|
Hey Pep just pinging in case you missed it. lmk if i can help with anything else now:) |
|
Hi, sorry it was a busy week for me. I'll try to review it tomorrow. |
|
@yiancar could you allow me to push some commit to your pull request? have some refactor I want to push. mostly just some refactoring, but I kinda regret saying that we should use deferred actions for tap macro, so I've made some changes to have macro maintain its own simple tap action. sorry for the back and forth. |
|
Yep no problem please feel free :) @peppapighs I think github already allows you to push ontop of this right? |
|
Hmmm I have trouble pushing the commit. Can you help me apply this diff instead? Thanks! |
|
I am making a change because as is your patch would infinitely run the macro while the key is help where i think the behaviour should be only once? Also AI spotted some unguarded behaviour: High: macro taps can leave a key stuck pressed. I am pushing some changes on this lmk if you are happy or I can roll back? |
Would that only happen if the macro linked list contains a loop? My thought is that it is correct for macro to run infinitely in that case, so we can support a feature like keep repeating keys indefinitely while held. What do you think? Also, thanks for the bug fix. AIs are so good at catching bugs these days 😄 |
|
I think if we then make it a loop it should run infinitely. But that would be because the list point back to the origin for example and not by nature. A lot of people use this simple macros to write their address quickly etc. I have also asked ai to update my hmkconfig to match ur changes. That needs a bit more code review as I dont know how to write svelte 😆 |
|
Sorry, I still don't get why we need the visited nodes. Like if you want the macro to run once, would it not be sufficient to set the last node to point to MACRO_NODE_NONE? |
|
Sorry you are right... I was a bit hasty with pushing |
|
Thank you for the PR! |
|
Thank you! could you also please look at the matching hmkconfig pr too? |
As discussed here is a first draft for the string macro:)
I used AI to help make a UI for testing but it looks quite smart:
peppapighs/hmkconf#7