qmk / qmk_firmware

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

More than 2 dynamic macros #1544

Closed zealws closed 2 years ago

zealws commented 7 years ago

TLDR

How hard would it be to program more than 2 dynamic macros?

Background

One of the things I miss most from my pok3r was the ability to rebind keys on the fly. Usually I would rebind short macros of 2 or 3 characters that I had to type repeatedly for specific cases during whatever game I was playing. It was easy to pause the game, reprogram a macro, then resume and use the bound macro a few times, and then I could clear it again. It made repetitive tasks very easy.

More than 2 dynamic macros with QMK?

I'd like to do something similar with QMK, where I can bind several macros on the fly.

I know that's not possible out-of-the-box, but I'm wondering how difficult this would be to add, and how I could go about doing it.

I don't really need that many, but 2 is definitely not enough. I figure if it's limited to 128 keypresses, then splitting that into 8 macros would be 16 keypresses, which is a ton for what I want to do. Or 16 macros at 8 each would be suitable too.

I'm wondering how I might go about allowing this using QMK. Is this easy or hard? Where should I get started? Does something like this exist already?

jayliu50 commented 7 years ago

Would be great to have, for sure. From what I understood about the code, it's implemented by cutting a buffer in half and filling it up from the middle of the buffer; that is why there can only be two. Adding more is theoretically possible, but I think would be a more disruptive rewrite and have more complex logic. Perhaps someone who knows better could clarify or correct what I have said.

drashna commented 6 years ago

I believe that the issue here is that there is a limit on the RAM that many of the controllers have. As well as eeprom size.

So adding more may not be feasible for all boards.

@jackhumbert, @fredizzimo, or the like would have to confirm this, though.

fredizzimo commented 6 years ago

This would need a completely new implementation. It wouldn't be that hard to make, but still someone has to do it.

As @drashna mentioned, the EEPROM size is an issue, but still we could fit quite many small ones there. Currently a single configurble buffer, which defaults to 128 is used. But that could also be for example eight 16 byte buffers, or 16 eight byte buffers. At the moment eveything is stored in RAM, which is very limited, but if the storage is changed to EEPROM, then almost 1024 bytes should be available.

stash commented 4 years ago

I looked at the code recently and I can say it's definitely possible. The main constraint is that memory is allocated statically. There's also a bunch of code to change, but it's far from impossible, just a fair amount of work, IMO:

The alternative would be to dynamically allocate memory somehow for each slot, but I am not aware how viable that is in QMK. Maybe a linked list of recorded key events. What happens when memory can't be allocated during a recording?

github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had activity in the last 90 days. It will be closed in the next 30 days unless it is tagged properly or other activity occurs. For maintainers: Please label with bug, in progress, on hold, discussion or to do to prevent the issue from being re-flagged.

tzarc commented 2 years ago

Closing due to inactivity.