[Keyboard] Gboards common - TOGG()/inject.h (#9236)
This commit is contained in:
		
							parent
							
								
									d03bc3a9c1
								
							
						
					
					
						commit
						7a75af8342
					
				
					 1 changed files with 20 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -11,14 +11,21 @@
 | 
			
		|||
    case name:                            \
 | 
			
		||||
        if (pressed) SEND_STRING(string); \
 | 
			
		||||
        break;
 | 
			
		||||
#define BLANK(...)
 | 
			
		||||
 | 
			
		||||
#define A_TOGG(name, layer, ...)          \
 | 
			
		||||
    case name:                            \
 | 
			
		||||
        if (pressed) layer_invert(layer); \
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
#define BLANK(...)
 | 
			
		||||
// Generate data needed for combos/actions
 | 
			
		||||
// Create Enum
 | 
			
		||||
#undef COMB
 | 
			
		||||
#undef SUBS
 | 
			
		||||
#undef TOGG
 | 
			
		||||
#define COMB K_ENUM
 | 
			
		||||
#define SUBS A_ENUM
 | 
			
		||||
#define TOGG A_ENUM
 | 
			
		||||
enum combos {
 | 
			
		||||
#include "combos.def"
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -26,20 +33,25 @@ enum combos {
 | 
			
		|||
// Bake combos into mem
 | 
			
		||||
#undef COMB
 | 
			
		||||
#undef SUBS
 | 
			
		||||
#undef TOGG
 | 
			
		||||
#define COMB K_DATA
 | 
			
		||||
#define SUBS A_DATA
 | 
			
		||||
#define TOGG A_DATA
 | 
			
		||||
#include "combos.def"
 | 
			
		||||
#undef COMB
 | 
			
		||||
#undef SUBS
 | 
			
		||||
#undef TOGG
 | 
			
		||||
 | 
			
		||||
// Fill combo array
 | 
			
		||||
#define COMB K_COMB
 | 
			
		||||
#define SUBS A_COMB
 | 
			
		||||
#define TOGG A_COMB
 | 
			
		||||
combo_t key_combos[] = {
 | 
			
		||||
#include "combos.def"
 | 
			
		||||
};
 | 
			
		||||
#undef COMB
 | 
			
		||||
#undef SUBS
 | 
			
		||||
#undef TOGG
 | 
			
		||||
 | 
			
		||||
// Export length to combo module
 | 
			
		||||
int COMBO_LEN = sizeof(key_combos) / sizeof(key_combos[0]);
 | 
			
		||||
| 
						 | 
				
			
			@ -47,10 +59,17 @@ int COMBO_LEN = sizeof(key_combos) / sizeof(key_combos[0]);
 | 
			
		|||
// Fill QMK hook
 | 
			
		||||
#define COMB BLANK
 | 
			
		||||
#define SUBS A_ACTI
 | 
			
		||||
#define TOGG A_TOGG
 | 
			
		||||
void process_combo_event(uint8_t combo_index, bool pressed) {
 | 
			
		||||
    switch (combo_index) {
 | 
			
		||||
#include "combos.def"
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Allow user overrides per keymap
 | 
			
		||||
#if __has_include("inject.h") 
 | 
			
		||||
# include "inject.h"
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
#undef COMB
 | 
			
		||||
#undef SUBS
 | 
			
		||||
#undef TOGG
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue