2023-03-23 23:21:37 +06:00
|
|
|
#pragma once
|
|
|
|
|
2020-05-04 22:49:47 +06:00
|
|
|
// Keymap helpers
|
2023-02-12 22:31:04 +06:00
|
|
|
// define reference layers per layer.
|
|
|
|
#define REF_LAYER_FOR_LAYER(LAYER, REF_LAYER) \
|
|
|
|
case LAYER: return REF_LAYER;
|
|
|
|
|
|
|
|
#define DEF_REF_LAYER(LAYER) \
|
|
|
|
default: return LAYER;
|
2020-05-04 22:49:47 +06:00
|
|
|
|
|
|
|
#define K_ENUM(name, key, ...) name,
|
|
|
|
#define K_DATA(name, key, ...) const uint16_t PROGMEM cmb_##name[] = {__VA_ARGS__, COMBO_END};
|
|
|
|
#define K_COMB(name, key, ...) [name] = COMBO(cmb_##name, key),
|
|
|
|
|
|
|
|
#define A_ENUM(name, string, ...) name,
|
|
|
|
#define A_DATA(name, string, ...) const uint16_t PROGMEM cmb_##name[] = {__VA_ARGS__, COMBO_END};
|
|
|
|
#define A_COMB(name, string, ...) [name] = COMBO_ACTION(cmb_##name),
|
2023-02-12 22:31:04 +06:00
|
|
|
#define A_ACTI(name, string, ...) \
|
|
|
|
case name: \
|
|
|
|
if (pressed) SEND_STRING(string); \
|
2020-05-04 22:49:47 +06:00
|
|
|
break;
|
|
|
|
|
2023-02-12 22:31:04 +06:00
|
|
|
#define A_TOGG(name, layer, ...) \
|
|
|
|
case name: \
|
|
|
|
if (pressed) layer_invert(layer); \
|
2020-06-05 15:06:58 +06:00
|
|
|
break;
|
|
|
|
|
|
|
|
#define BLANK(...)
|
2023-02-12 22:31:04 +06:00
|
|
|
#undef COMBO_REF_LAYER
|
|
|
|
#undef DEFAULT_REF_LAYER
|
|
|
|
#define COMBO_REF_LAYER BLANK
|
|
|
|
#define DEFAULT_REF_LAYER BLANK
|
|
|
|
|
2020-05-04 22:49:47 +06:00
|
|
|
// Generate data needed for combos/actions
|
|
|
|
// Create Enum
|
|
|
|
#undef COMB
|
|
|
|
#undef SUBS
|
2020-06-05 15:06:58 +06:00
|
|
|
#undef TOGG
|
2020-05-04 22:49:47 +06:00
|
|
|
#define COMB K_ENUM
|
|
|
|
#define SUBS A_ENUM
|
2020-06-05 15:06:58 +06:00
|
|
|
#define TOGG A_ENUM
|
2020-05-04 22:49:47 +06:00
|
|
|
enum combos {
|
|
|
|
#include "combos.def"
|
|
|
|
};
|
|
|
|
|
|
|
|
// Bake combos into mem
|
|
|
|
#undef COMB
|
|
|
|
#undef SUBS
|
2020-06-05 15:06:58 +06:00
|
|
|
#undef TOGG
|
2020-05-04 22:49:47 +06:00
|
|
|
#define COMB K_DATA
|
|
|
|
#define SUBS A_DATA
|
2020-06-05 15:06:58 +06:00
|
|
|
#define TOGG A_DATA
|
2020-05-04 22:49:47 +06:00
|
|
|
#include "combos.def"
|
|
|
|
#undef COMB
|
|
|
|
#undef SUBS
|
2020-06-05 15:06:58 +06:00
|
|
|
#undef TOGG
|
2020-05-04 22:49:47 +06:00
|
|
|
|
|
|
|
// Fill combo array
|
|
|
|
#define COMB K_COMB
|
|
|
|
#define SUBS A_COMB
|
2020-06-05 15:06:58 +06:00
|
|
|
#define TOGG A_COMB
|
2020-05-04 22:49:47 +06:00
|
|
|
combo_t key_combos[] = {
|
|
|
|
#include "combos.def"
|
|
|
|
};
|
|
|
|
#undef COMB
|
|
|
|
#undef SUBS
|
2020-06-05 15:06:58 +06:00
|
|
|
#undef TOGG
|
2020-05-04 22:49:47 +06:00
|
|
|
|
|
|
|
// Fill QMK hook
|
|
|
|
#define COMB BLANK
|
|
|
|
#define SUBS A_ACTI
|
2020-06-05 15:06:58 +06:00
|
|
|
#define TOGG A_TOGG
|
2020-07-16 18:39:01 +06:00
|
|
|
void process_combo_event(uint16_t combo_index, bool pressed) {
|
2020-05-04 22:49:47 +06:00
|
|
|
switch (combo_index) {
|
|
|
|
#include "combos.def"
|
|
|
|
}
|
2020-06-05 15:06:58 +06:00
|
|
|
|
|
|
|
// Allow user overrides per keymap
|
2023-02-12 22:31:04 +06:00
|
|
|
#if __has_include("inject.h")
|
2020-06-05 15:06:58 +06:00
|
|
|
# include "inject.h"
|
|
|
|
#endif
|
2020-05-04 22:49:47 +06:00
|
|
|
}
|
|
|
|
#undef COMB
|
|
|
|
#undef SUBS
|
2020-06-05 15:06:58 +06:00
|
|
|
#undef TOGG
|
2023-02-12 22:31:04 +06:00
|
|
|
|
|
|
|
// Allow reference layers per layer.
|
|
|
|
#define COMB BLANK
|
|
|
|
#define SUBS BLANK
|
|
|
|
#define TOGG BLANK
|
|
|
|
|
|
|
|
#undef DEFAULT_REF_LAYER
|
|
|
|
#undef COMBO_REF_LAYER
|
|
|
|
#define COMBO_REF_LAYER REF_LAYER_FOR_LAYER
|
|
|
|
#define DEFAULT_REF_LAYER DEF_REF_LAYER
|
|
|
|
|
|
|
|
uint8_t combo_ref_from_layer(uint8_t current_layer){
|
|
|
|
switch (current_layer){
|
|
|
|
#include "combos.def"
|
|
|
|
}
|
|
|
|
return current_layer;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef COMB
|
|
|
|
#undef SUBS
|
|
|
|
#undef TOGG
|
|
|
|
#undef COMBO_REF_LAYER
|
|
|
|
#undef DEFAULT_REF_LAYER
|