1 #include "process_combo.h"
4 // __attribute__ ((weak))
5 // combo_t key_combos[] = {
9 #define SEND_KEY(key) \
11 register_code16(key); \
12 send_keyboard_report(); \
13 unregister_code16(key); \
17 #define ALL_COMBO_KEYS_ARE_DOWN (((1<<count)-1) == combo->state)
18 static bool process_single_combo(combo_t *combo, uint16_t keycode, keyrecord_t *record)
21 bool is_combo_key = false;
22 // bool combo_key_released = false;
24 // Count the number of combo keys
25 for (const uint16_t *key = combo->keys; COMBO_END != pgm_read_word(key); ++key, ++count);
27 for (uint8_t i = 0; i < count; ++i) {
28 uint16_t key = pgm_read_word(&combo->keys[i]);
33 if (record->event.pressed) {
34 combo->state |= (1<<i);
35 } else { // Combo key released
37 // The combo was sent, no need to send released key
41 combo->state &= ~(1<<i);
47 if (ALL_COMBO_KEYS_ARE_DOWN) {
48 SEND_KEY(combo->action);
56 bool process_combo(uint16_t keycode, keyrecord_t *record)
58 bool is_combo_key = false;
60 for (int i = 0; i < NUM_ELEMS(key_combos); ++i) {
61 combo_t *combo = &key_combos[i];
62 is_combo_key |= process_single_combo(combo, keycode, record);