Suggestion: Better typing macros (hopefully easily implementable)!
TMK suggestion: The MACRO function is often used to type hotstrings. Could this be implemented more smoothly?
String handling as such may well be overmuch and inflexible, but much could be gained by some hopefully simple additions:
- A T() macro function that can take a key sequence as input instead of just one key.
- Then, instead of T(H), T(E), T(L), T(L), T(O), you can use T(H, E, L, L, O) which is a lot nicer I think!
- A S() macro function that similarly shift-types one or several keys.
- That is, S(stringsequence) equals D(LSHIFT), T(stringsequence), U(LSHIFT)
To type 'Do NOT use!': S(D), T(O, SPC), S(N, O, T, SPC), T(U, S, E), S(1). To type a smiley: S(SCLN), T(MINS), S(0).
Could this be added, please? It'd be fully backwards compatible.
Thanks for the suggestion! i'll take into account when I redesign macros.
While we're talking Macro redesign, one little thing: Is the END mark necessary? Naïvely I'd think that when the MACRO function reaches its last argument the macro is finished, and there's no need to end a macro at any other point than this.
If you could remove the need for END, just ignoring it if it's found, that'd be backwards compatible – unless someone actually found the need to end a macro before the last argument which I doubt.
Rethinking the issue...:
What'd be even nicer than a S() function, would be syntax similar to AutoHotKey in the T() function! I don't know how hard that'd be to implement, but it should be like this: • +/^/!/# in front of key name means LShift/LCtrl/LAlt/LGui are pressed with the key • These mods can be combined sequentially (e.g., "^!ESC" means "LCtrl+LAlt+Esc")
The S() function suggested above wouldn't really be very practical since typing is usually in mixed case. To me at least, the AHK syntax is quite familiar and intuitive.
So now, my examples would be: "Do NOT use!" – T( +D, O, SPC, +N, +O, +T, SPC, U, S, E, +1 ) ":-)" – T( +SCLN, MINS, +0 ) "DreymaR" then Ctrl+Enter to send email – T( +D, R, E, Y, M, A, +R, ^ENT ) Alt+Tab – T( !TAB ) Ctrl+Alt+Del – T( ^!DEL )
It remains to be determined whether it's okay to keep pressing Shift up and down for upper case strings, but I suspect it'd be quite okay. If not, there's always D(LSFT), U(LSFT) to fall back on.
I think it'd be quite okay to use only the left-hand modifiers for this. Again, there's always the old syntax for other needs.
Again, backwards compatibility with T() macros would be kept.
On a side note: Maybe this idea could be carried to the ACTION_KEY() action as well, relieving the need for ACTION_MODS_KEY() or at least providing an alternative to it?
Another rethinking (given that the above suggestion may well be too hard to implement):
It'd be silly and clunky to have one T() and one S() function, after all. But could there simply be a few shortcuts for the T() function instead? • SFNX for "next character (only) is shifted" • SFDN/SFUP for "(left) shift down/up" (for longer shifted sequences) • If you do the above, I suppose it'd be handy with DN/UP for ALt/CTrl/WIn as well. Maybe NX too?
Then: "Do NOT use!" – T( SFNX, D, O, SPC, SFDN, N, O, T, SFUP, SPC, U, S, E, SFNX, 1) ":-)" – T( SFNX, SCLN, MINS, SFNX, 0) "DreymaR" then Ctrl+Enter – T( SFNX, D, R, E, Y, M, A, SFNX, R, CTNX, ENT) ALT+Tab – T(ALNX, TAB) Ctrl+Alt+Del – T( CTNX, ALNX, DEL) ... if you can; if not, T(CTDN, ALNX, DEL, CTUP)
Again, backwards compatible syntax. ;-)
Any chance of something like this happening soon? 👍
New thought: Could this be an easy-ish way of supporting glyph input? For Windows: "å" – T( ALDN, P0, P2, P2, P9, ALUP ) "Æ" – T( ALDN, P0, P1, P9, P8, ALUP ) etc
Actually... what if... what if... this ligature function could even skirt the whole Macro concept?!? So that one might map a key sequence directly into a keymap? (Maybe some other name than T() then, e.g., S() to not mess with Macro backwards compatibility?)
In which case, I'm not sure but maybe one could use keymap syntax in it which allows such handy tricks as s(
This would obviate the need for "keystring" macros altogether.
As for unicode input it would be useful to have dedicated method, like QMK or Kaleidoscope? Kaleidoscope gives us clear idea on this. https://github.com/keyboardio/Kaleidoscope-Unicode https://github.com/keyboardio/Kaleidoscope-HostOS
Maybe... but then again, if such a method is memory costly that's a consideration too! Unless we all migrate to the newest generation Teensy, memory is still limited.
So it might not be so bad to implement it per-platform, as a macro that may furthermore be aliased(?):
#define A(a, b, c, d) ( T( ALDN, Pa, Pb, Pc, Pd, ALUP ) )
But if someone needs their device to support multiple platforms with this input, that'd be trickier. I'd make two keymap layers then, say, one for Windows and one for Linux, with different macros. But then again, that'd cost memory so... heh.
As a quick solution for now, here's how shifted key presses could be implemented easily (I think?). Also, hopefully working, a quick-n-dirty Unicode entry MACRO hack.
In tmk_core/common/action_macro.h, line 97:
/* key type */
#define T(key) TYPE(KC_##key)
/* key type with shift */
#define ST(key) D(LSFT), T(key), U(LSFT)
/* Windows Unicode entry - use 4-digit decimal input */
#define UW(d1, d2, d3, d4) D(LALT), T(P##d1), T(P##d2), T(P##d3), T(P##d4), U(LALT)
/* MacOS Unicode entry - use hex input */
#define UM(d1, d2, d3, d4) D(LALT), T(d1), T(d2), T(d3), T(d4), U(LALT)
/* X.Org Unicode entry - use hex input */
#define UX(d1, d2, d3, d4) D(LCTL), ST(U), U(LCTL), T(d1), T(d2), T(d3), T(d4), T(ENT)
I have tested the above (only on Windows) and it works fine. Could this or a variant of your choice be added to tmk_core/common/action_macro.h please?
/* Macro definitions for typing modified keys more easily in TMK macros */
/* - Example: Ctrl+Alt+[Shift+]<key> can be entered with CTL_( ALT_( [S]T(key) )) */
/* - AGR_ is for RAlt/AltGr input, useful with international system layouts. */
#define ST(key) D(LSFT), T(key), U(LSFT)
#define SFT_(...) D(LSFT), __VA_ARGS__, U(LSFT)
#define CTL_(...) D(LCTL), __VA_ARGS__, U(LCTL)
#define ALT_(...) D(LALT), __VA_ARGS__, U(LALT)
#define AGR_(...) D(RALT), __VA_ARGS__, U(RALT)
/* Unicode macro for XOrg : #define UNI_(d1,d2,d3,d4) CTL_( ST(U) ), T(d1), T(d2), T(d3), T(d4), T(ENT) */
/* Unicode macro for MacOS: #define UNI_(d1,d2,d3,d4) ALT_( T(d1), T(d2), T(d3), T(d4) ) */
/* Unicode macro for Win : #define UNI_(d1,d2,d3,d4) ALT_( T(P##d1), T(P##d2), T(P##d3), T(P##d4) ) */
#define UNI_(d1,d2,d3,d4) ALT_( T(P##d1), T(P##d2), T(P##d3), T(P##d4) )
I don't know, you could make, say, UNIW_(), UNIM_() and UNIX_() :-p instead of just the one if you like.
NIce! Could you make pull request for this?