qmk / qmk_firmware

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

Macros and modifiers #519

Closed fredizzimo closed 4 years ago

fredizzimo commented 8 years ago

The issue #401 - "Inverting a key", got me thinking about macros and modifiers.

One of the huge drawbacks of the current modifier handling in QMK, is that we are really only able to remove modifiers from macros. Well, it's possible to directly modify the weak, macro, and real mods, but doing that could easily end up in a mess. In the TMK firmware they added support for that. Although that implementation is probably not ideal either, and not directly applicable to the QMK firmware, since macromods, have been added, in addition to the weak and real_ ones.

So, I think first, we need a design, what we want to be able to do from the macros. And remember that we don't necessarily need to support the old MACRO syntax for new features. The advanced macro form is probably much more flexible.

For mods, we probably have several different use cases that need to be taken care of, and different life times of the applied mods. So that requires careful planning.

The implementation would obviously be risky, so therefore I suggest that we first add well covered unit tests to the system(after the unit test framework is integrated, and then develop the required functionality.

I'm also aware that @eltang, had similar thoughts. in this pull reguest #277, and the following issue #272. However I don't believe doing risky changes like that is the way to go, first it needs to be planned properly, and then tested properly.

ezuk commented 8 years ago

I tend to start thinking about things like that from the interface, syntactic sugar angle. Like, what would a powerful and readable macro call look like? Do you have any thoughts on this?

One syntax I quite like is AutoHotkey Send command. I like what they do with the mods there -- using symbols, so ^s is Ctrl+S. I don't know if C lets us do that though.

iFreilicht commented 8 years ago

I don't know if C lets us do that though.

Nope, it doesn't, at least not easily. You can in theory write an additional module for the preprocessor (which would have to be separately developed and maintained), but if you wanted to use a symbol that's commonly used in C, you'd have to modify the compiler itself because that's the part the does the lexical analysis. So it's not really worth it.

The only people I know of doing something like that are Microsoft who implemented the ^ caret, which can be used like a * for pointers, but for special pointers in their environment.

drashna commented 5 years ago

Is this relevant anymore with SEND_STRING and the like?

stale[bot] commented 4 years ago

This issue has been automatically marked as resolved 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.

stale[bot] commented 4 years ago

This issue has been automatically closed because it has not had activity in the last 30 days. If this issue is still valid, re-open the issue and let us know.