Ejemplo n.º 1
0
bool process_tap_dance(uint16_t keycode, keyrecord_t *record) {
  uint16_t idx = keycode - QK_TAP_DANCE;
  qk_tap_dance_action_t *action;

  if (last_td && last_td != keycode) {
    (&tap_dance_actions[last_td - QK_TAP_DANCE])->state.interrupted = true;
  }

  switch(keycode) {
  case QK_TAP_DANCE ... QK_TAP_DANCE_MAX:
    if ((int16_t)idx > highest_td)
      highest_td = idx;
    action = &tap_dance_actions[idx];

    action->state.pressed = record->event.pressed;
    if (record->event.pressed) {
      action->state.keycode = keycode;
      action->state.count++;
      action->state.timer = timer_read();
      action->state.oneshot_mods = get_oneshot_mods();
      action->state.weak_mods = get_mods();
      action->state.weak_mods |= get_weak_mods();
      process_tap_dance_action_on_each_tap (action);

      if (last_td && last_td != keycode) {
        qk_tap_dance_action_t *paction = &tap_dance_actions[last_td - QK_TAP_DANCE];
        paction->state.interrupted = true;
        process_tap_dance_action_on_dance_finished (paction);
        reset_tap_dance (&paction->state);
      }

      last_td = keycode;
    }

    break;

  default:
    if (!record->event.pressed)
      return true;

    if (highest_td == -1)
      return true;

    for (int i = 0; i <= highest_td; i++) {
      action = &tap_dance_actions[i];
      if (action->state.count == 0)
        continue;
      action->state.interrupted = true;
      process_tap_dance_action_on_dance_finished (action);
      reset_tap_dance (&action->state);
    }
    break;
  }

  return true;
}
Ejemplo n.º 2
0
void matrix_scan_tap_dance () {
  if (qk_tap_dance_state.keycode && timer_elapsed (qk_tap_dance_state.timer) > TAPPING_TERM) {
    process_tap_dance_action (qk_tap_dance_state.keycode);

    reset_tap_dance (&qk_tap_dance_state);
  }
}
Ejemplo n.º 3
0
bool process_tap_dance(uint16_t keycode, keyrecord_t *record) {
  bool r = true;

  switch(keycode) {
  case QK_TAP_DANCE ... QK_TAP_DANCE_MAX:
    if (qk_tap_dance_state.keycode && qk_tap_dance_state.keycode != keycode) {
      process_tap_dance_action (qk_tap_dance_state.keycode);
    } else {
      r = false;
    }

    if (record->event.pressed) {
      qk_tap_dance_state.keycode = keycode;
      qk_tap_dance_state.timer = timer_read ();
      qk_tap_dance_state.count++;
    }
    break;

  default:
    if (qk_tap_dance_state.keycode) {
      process_tap_dance_action (qk_tap_dance_state.keycode);

      reset_tap_dance (&qk_tap_dance_state);
    }
    break;
  }

  return r;
}
Ejemplo n.º 4
0
// Cycle through the times for the macro, starting at 0, for disabled.
// Max of six values, so don't exceed
void diablo_tapdance_master (qk_tap_dance_state_t *state, void *user_data, uint8_t diablo_key) {
    if (state->count >= 7) {
        diablo_key_time[diablo_key] = diablo_times[0];
        reset_tap_dance(state);
    } else {
        diablo_key_time[diablo_key] = diablo_times[state->count - 1];
    }
}
Ejemplo n.º 5
0
// on the fourth tap, set the keyboard on flash state
// and set the underglow to red, because red == bad
void dance_flsh_finished(qk_tap_dance_state_t *state, void *user_data) {
    if (state->count >= 4) {
        rgblight_enable();
        rgblight_mode(1);
        rgblight_setrgb(0xff,0x00,0x00);
        reset_keyboard();
        reset_tap_dance(state);
    }
}
Ejemplo n.º 6
0
void belak_td_each(qk_tap_dance_state_t *state, void *user_data) {
    switch (state->count) {
    case 1:
        td_led_override = 1;
        break;
    case 2:
        td_led_override = 2;
        break;
    default:
        reset_tap_dance(state);
    }
}
Ejemplo n.º 7
0
void dance_cln (qk_tap_dance_state_t *state) {
  if (state->count == 1) {
    register_code (KC_RSFT);
    register_code (KC_SCLN);
    unregister_code (KC_SCLN);
    unregister_code (KC_RSFT);
  } else {
    register_code (KC_SCLN);
    unregister_code (KC_SCLN);
    reset_tap_dance (state);
  }
}
Ejemplo n.º 8
0
static void _process_tap_dance_action_pair (qk_tap_dance_state_t *state,
                                            uint16_t kc1, uint16_t kc2) {
  uint16_t kc;

  if (state->count == 0)
    return;

  kc = (state->count == 1) ? kc1 : kc2;

  register_code (kc);
  unregister_code (kc);

  if (state->count >= 2) {
    reset_tap_dance (state);
  }
}
Ejemplo n.º 9
0
// Tap dance functions
void mod_tap_fn(qk_tap_dance_state_t *state, void *user_data) {
    switch (state->count) {
        case 1:
            register_mods(MOD_BIT(tap_dance_keys[state->keycode - QK_TAP_DANCE]));
            send_keyboard_report();
            break;
        case 2:
            layer_on(_L2);
            break;
        case 3:
            layer_off(_L2);
            layer_on(_L1);
            break;
        default:
            reset_tap_dance(state);
    }
}
Ejemplo n.º 10
0
void findreplace(qk_tap_dance_state_t *state, void *user_data)
{
  if (state->count > 1)
  {
    register_code(KC_LCTL);
    register_code(KC_H);
    unregister_code(KC_H);
    unregister_code(KC_LCTL);
  }
  else
  {
    register_code(KC_LCTL);
    register_code(KC_F);
    unregister_code(KC_F);
    unregister_code(KC_LCTL);
  }
  reset_tap_dance(state);
}
Ejemplo n.º 11
0
void ccopy(qk_tap_dance_state_t *state, void *user_data)
{
  if (state->count > 1)
  {
    register_code(KC_LCTL);
    register_code(KC_X);
    unregister_code(KC_X);
    unregister_code(KC_LCTL);
  }
  else
  {
    register_code(KC_LCTL);
    register_code(KC_C);
    unregister_code(KC_C);
    unregister_code(KC_LCTL);
  }
  reset_tap_dance(state);
}
Ejemplo n.º 12
0
void matrix_scan_tap_dance () {
  if (highest_td == -1)
    return;
  uint16_t tap_user_defined;

for (uint8_t i = 0; i <= highest_td; i++) {
    qk_tap_dance_action_t *action = &tap_dance_actions[i];
    if(action->custom_tapping_term > 0 ) {
      tap_user_defined = action->custom_tapping_term;
    }
    else{
      tap_user_defined = TAPPING_TERM;
    }
    if (action->state.count && timer_elapsed (action->state.timer) > tap_user_defined) {
      process_tap_dance_action_on_dance_finished (action);
      reset_tap_dance (&action->state);
    }
  }
}
Ejemplo n.º 13
0
void flash_dance_finished(qk_tap_dance_state_t *state, void *user_data) {
  if (state->count >= 4) {
    reset_keyboard();
    reset_tap_dance(state);
  }
}
Ejemplo n.º 14
0
void dance_egg (qk_tap_dance_state_t *state) {
  if (state->count >= 100) {
    SEND_STRING ("Safety dance!");
    reset_tap_dance (state);
  }
}