logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

keymap_combo.h (2422B)


  1. #pragma once
  2. // Keymap helpers
  3. // define reference layers per layer.
  4. #define REF_LAYER_FOR_LAYER(LAYER, REF_LAYER) \
  5. case LAYER: return REF_LAYER;
  6. #define DEF_REF_LAYER(LAYER) \
  7. default: return LAYER;
  8. #define K_ENUM(name, key, ...) name,
  9. #define K_DATA(name, key, ...) const uint16_t PROGMEM cmb_##name[] = {__VA_ARGS__, COMBO_END};
  10. #define K_COMB(name, key, ...) [name] = COMBO(cmb_##name, key),
  11. #define A_ENUM(name, string, ...) name,
  12. #define A_DATA(name, string, ...) const uint16_t PROGMEM cmb_##name[] = {__VA_ARGS__, COMBO_END};
  13. #define A_COMB(name, string, ...) [name] = COMBO_ACTION(cmb_##name),
  14. #define A_ACTI(name, string, ...) \
  15. case name: \
  16. if (pressed) SEND_STRING(string); \
  17. break;
  18. #define A_TOGG(name, layer, ...) \
  19. case name: \
  20. if (pressed) layer_invert(layer); \
  21. break;
  22. #define BLANK(...)
  23. #undef COMBO_REF_LAYER
  24. #undef DEFAULT_REF_LAYER
  25. #define COMBO_REF_LAYER BLANK
  26. #define DEFAULT_REF_LAYER BLANK
  27. // Generate data needed for combos/actions
  28. // Create Enum
  29. #undef COMB
  30. #undef SUBS
  31. #undef TOGG
  32. #define COMB K_ENUM
  33. #define SUBS A_ENUM
  34. #define TOGG A_ENUM
  35. enum combos {
  36. #include "combos.def"
  37. };
  38. // Bake combos into mem
  39. #undef COMB
  40. #undef SUBS
  41. #undef TOGG
  42. #define COMB K_DATA
  43. #define SUBS A_DATA
  44. #define TOGG A_DATA
  45. #include "combos.def"
  46. #undef COMB
  47. #undef SUBS
  48. #undef TOGG
  49. // Fill combo array
  50. #define COMB K_COMB
  51. #define SUBS A_COMB
  52. #define TOGG A_COMB
  53. combo_t key_combos[] = {
  54. #include "combos.def"
  55. };
  56. #undef COMB
  57. #undef SUBS
  58. #undef TOGG
  59. // Fill QMK hook
  60. #define COMB BLANK
  61. #define SUBS A_ACTI
  62. #define TOGG A_TOGG
  63. void process_combo_event(uint16_t combo_index, bool pressed) {
  64. switch (combo_index) {
  65. #include "combos.def"
  66. }
  67. // Allow user overrides per keymap
  68. #if __has_include("inject.h")
  69. # include "inject.h"
  70. #endif
  71. }
  72. #undef COMB
  73. #undef SUBS
  74. #undef TOGG
  75. // Allow reference layers per layer.
  76. #define COMB BLANK
  77. #define SUBS BLANK
  78. #define TOGG BLANK
  79. #undef DEFAULT_REF_LAYER
  80. #undef COMBO_REF_LAYER
  81. #define COMBO_REF_LAYER REF_LAYER_FOR_LAYER
  82. #define DEFAULT_REF_LAYER DEF_REF_LAYER
  83. uint8_t combo_ref_from_layer(uint8_t current_layer){
  84. switch (current_layer){
  85. #include "combos.def"
  86. }
  87. return current_layer;
  88. }
  89. #undef COMB
  90. #undef SUBS
  91. #undef TOGG
  92. #undef COMBO_REF_LAYER
  93. #undef DEFAULT_REF_LAYER