1 #include "tap_dances.h"
4 //define diablo macro timer variables
5 diablo_timer_t diablo_timer[4];
7 uint8_t diablo_times[] = { 0, 0, 1, 3, 5, 10, 30 };
9 // has the correct number of seconds elapsed (as defined by diablo_times)
10 bool check_dtimer(uint8_t dtimer) { return (timer_elapsed(diablo_timer[dtimer].key_time) < (diablo_timer[dtimer].timer * 1000)) ? false : true; };
12 // Cycle through the times for the macro, starting at 0, for disabled.
13 // Max of six values, so don't exceed
14 void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data) {
15 int index = (int)user_data;
16 if (state->count >= 7) {
17 diablo_timer[index].key_time = diablo_times[0];
18 reset_tap_dance(state);
20 diablo_timer[index].key_time = diablo_times[state->count];
24 // One funtion to rule them all!!
25 #define ACTION_TAP_DANCE_DIABLO(arg) { \
26 .fn = { NULL, (void *)diablo_tapdance_master, NULL }, \
27 .user_data = (void *)arg, \
30 //Tap Dance Definitions
31 qk_tap_dance_action_t tap_dance_actions[] = {
32 // tap once to disable, and more to enable timed micros
33 [TD_D3_1] = ACTION_TAP_DANCE_DIABLO(0),
34 [TD_D3_2] = ACTION_TAP_DANCE_DIABLO(1),
35 [TD_D3_3] = ACTION_TAP_DANCE_DIABLO(2),
36 [TD_D3_4] = ACTION_TAP_DANCE_DIABLO(3),
39 // Sends the key press to system, but only if on the Diablo layer
40 void send_diablo_keystroke(uint8_t diablo_key) {
41 if (IS_LAYER_ON(_DIABLO)) {
44 tap_code(KC_1); break;
46 tap_code(KC_2); break;
48 tap_code(KC_3); break;
50 tap_code(KC_4); break;
55 // Checks each of the 4 timers/keys to see if enough time has elapsed
56 // Runs the "send string" command if enough time has passed, and resets the timer.
57 void run_diablo_macro_check(void) {
59 for (dtime = 0; dtime < 4; dtime++) {
60 if (check_dtimer(dtime) && diablo_timer[dtime].key_time) {
61 diablo_timer[dtime].timer = timer_read();
62 send_diablo_keystroke(dtime);