QMK/keyboards/betalupi_ergodox/features/leader/beta_leader.h

39 lines
2.6 KiB
C
Raw Normal View History

2023-12-19 08:34:06 -08:00
#pragma once
#ifdef ENABLE_BETA_LEADER
#include "quantum.h"
bool beta_process_leader(uint16_t keycode, keyrecord_t *record);
void beta_leader_start(void);
void beta_leader_end(void);
bool beta_leader_check(void);
void beta_qk_leader_check(void);
void beta_qk_leader_start(void);
#define BETA_LEADER_EXTERNS() \
extern bool beta_leading; \
extern uint16_t beta_leader_time; \
extern uint16_t beta_leader_sequence[5]; \
extern uint8_t beta_leader_sequence_size
// Normal sequence
// These do the same thing as SEQ_X_KEYS from qmk.
#define BETA_SEQ_1_LONG(key) if (beta_leader_sequence[0] == (key) && beta_leader_sequence[1] == 0 && beta_leader_sequence[2] == 0 && beta_leader_sequence[3] == 0 && beta_leader_sequence[4] == 0 && timer_elapsed(beta_leader_time) > LEADER_TIMEOUT)
#define BETA_SEQ_2_LONG(key1, key2) if (beta_leader_sequence[0] == (key1) && beta_leader_sequence[1] == (key2) && beta_leader_sequence[2] == 0 && beta_leader_sequence[3] == 0 && beta_leader_sequence[4] == 0 && timer_elapsed(beta_leader_time) > LEADER_TIMEOUT)
#define BETA_SEQ_3_LONG(key1, key2, key3) if (beta_leader_sequence[0] == (key1) && beta_leader_sequence[1] == (key2) && beta_leader_sequence[2] == (key3) && beta_leader_sequence[3] == 0 && beta_leader_sequence[4] == 0 && timer_elapsed(beta_leader_time) > LEADER_TIMEOUT)
#define BETA_SEQ_4_LONG(key1, key2, key3, key4) if (beta_leader_sequence[0] == (key1) && beta_leader_sequence[1] == (key2) && beta_leader_sequence[2] == (key3) && beta_leader_sequence[3] == (key4) && beta_leader_sequence[4] == 0 && timer_elapsed(beta_leader_time) > LEADER_TIMEOUT)
#define BETA_SEQ_5_LONG(key1, key2, key3, key4, key5) if (leader_sequence[0] == (key1) && beta_leader_sequence[1] == (key2) && beta_leader_sequence[2] == (key3) && beta_leader_sequence[3] == (key4) && beta_leader_sequence[4] == (key5) && timer_elapsed(beta_leader_time) > LEADER_TIMEOUT)
// Short-circuit sequence
// These match as soon as a matching sequence is seen,
// not waiting for the leader timeout. They thus register
// immediately, but cannot be used in longer sequences.
#define BETA_SEQ_1_SHORT(key) if (beta_leader_sequence[0] == (key))
#define BETA_SEQ_2_SHORT(key1, key2) if (beta_leader_sequence[0] == (key1) && beta_leader_sequence[1] == (key2))
#define BETA_SEQ_3_SHORT(key1, key2, key3) if (beta_leader_sequence[0] == (key1) && beta_leader_sequence[1] == (key2))
#define BETA_SEQ_4_SHORT(key1, key2, key3, key4) if (beta_leader_sequence[0] == (key1) && beta_leader_sequence[1] == (key2))
#define BETA_SEQ_5_SHORT(key1, key2, key3, key4, key5) if (beta_leader_sequence[0] == (key1) && beta_leader_sequence[1] == (key2))
#endif