Trick to ensure used-defined keys (not in Ranges) don't collide?

I was wondering how MacrosOnTheFly defines the MacroRec and MacroPlay keys but they aren’t defined in Ranges and I find these lines:

#define MACROREC kaleidoscope::ranges::KALEIDOSCOPE_SAFE_START
#define MACROPLAY kaleidoscope::ranges::KALEIDOSCOPE_SAFE_START + 1
#define Key_MacroRec  (Key) {.raw = MACROREC}
#define Key_MacroPlay (Key) {.raw = MACROPLAY}

I’m not so sure how “safe” SAFE_START is because if more than one third-party plugin that wants to create synthetic keys not having official key codes allotted in Ranges starts using it, it isn’t “safe” any longer, because there is no guarantee that another third-party won’t use the same values!

I was thinking of maybe a registrar that would allot synthetic keycodes upon request, and that would avoid such plugin conflict, but since there isn’t any CTFE (compile time function evaluation, which I came across in D) in C++, I’m not sure how to get values on to the keymap which is marked PROGMEM at compile time!

I have to investigate whether the implementation-provided __COUNTER__ pre-processor macro can help here.

In the meanwhile, any thoughts?

The easiest approach would be to submit a PR against Kaleidoscope-Ranges :wink: