summaryrefslogtreecommitdiff
path: root/users/ibnuda/tapdance.c
diff options
context:
space:
mode:
authorIbnu Daru Aji <ibnuda@users.noreply.github.com>2020-03-04 04:46:11 +0700
committerGitHub <noreply@github.com>2020-03-03 13:46:11 -0800
commit910d603c657e4ad81a4e7a4c86a74e2e79aa1eaa (patch)
tree0f6261380999d09444ed5c4313e336ef9f534a58 /users/ibnuda/tapdance.c
parentad96e995afc6a8132a054ccab2b08e3501719159 (diff)
[Keymap] new userspace for ibnuda (#8221)
* to ease the maintenance for some boards ibnuda has. * followed ridingqwerty's suggestion on 8821. * folloing drashna's suggestion on qmk's 8221. * following drashn's suggestion on qmk's 8211
Diffstat (limited to 'users/ibnuda/tapdance.c')
-rw-r--r--users/ibnuda/tapdance.c83
1 files changed, 83 insertions, 0 deletions
diff --git a/users/ibnuda/tapdance.c b/users/ibnuda/tapdance.c
new file mode 100644
index 0000000000..c0d2192587
--- /dev/null
+++ b/users/ibnuda/tapdance.c
@@ -0,0 +1,83 @@
+#include "tapdance.h"
+
+static td_state_t td_state;
+
+void dance_dlt_finished(qk_tap_dance_state_t *state, void *user_data) {
+ if (state->count == 1) {
+ register_code16(KC_DELT);
+ } else {
+ register_code16(C(KC_DELT));
+ }
+}
+
+void dance_dlt_reset(qk_tap_dance_state_t *state, void *user_data) {
+ if (state->count == 1) {
+ unregister_code16(KC_DELT);
+ } else {
+ unregister_code16(C(KC_DELT));
+ }
+}
+
+void dance_cln_finished(qk_tap_dance_state_t *state, void *user_data) {
+ if (state->count == 1) {
+ register_code(KC_LSFT);
+ }
+ register_code(KC_SCLN);
+}
+
+void dance_cln_reset(qk_tap_dance_state_t *state, void *user_data) {
+ if (state->count == 1) {
+ unregister_code(KC_LSFT);
+ }
+ unregister_code(KC_SCLN);
+}
+
+int current_dance(qk_tap_dance_state_t *state) {
+ if (state->count == 1) {
+ if (state->interrupted || !state->pressed) {
+ return SINGLE_TAP;
+ } else {
+ return SINGLE_HOLD;
+ }
+ }
+ if (state->count == 2) {
+ return DOUBLE_TAP;
+ } else {
+ return 3;
+ }
+}
+
+void dance_tmb_finished(qk_tap_dance_state_t *state, void *user_data) {
+ td_state = current_dance(state);
+ switch (td_state) {
+ case SINGLE_TAP:
+ register_code16(KC_ESC);
+ break;
+ case SINGLE_HOLD:
+ register_mods(MOD_BIT(KC_LSFT));
+ break;
+ case DOUBLE_TAP:
+ register_code16(KC_DELT);
+ break;
+ }
+}
+
+void dance_tmb_reset(qk_tap_dance_state_t *state, void *user_data) {
+ switch (td_state) {
+ case SINGLE_TAP:
+ unregister_code16(KC_ESC);
+ break;
+ case SINGLE_HOLD:
+ unregister_mods(MOD_BIT(KC_LSFT));
+ break;
+ case DOUBLE_TAP:
+ unregister_code16(KC_DELT);
+ break;
+ }
+}
+
+qk_tap_dance_action_t tap_dance_actions[] = {
+ [TD_DLT_CTLDLT] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_dlt_finished, dance_dlt_reset),
+ [TD_SCLN_CLN] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_cln_finished, dance_cln_reset),
+ [TD_LEFT_THUMB] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, dance_tmb_finished, dance_tmb_reset),
+};