summaryrefslogtreecommitdiffstats
path: root/users
diff options
context:
space:
mode:
authorQMK Bot <hello@qmk.fm>2021-07-20 16:41:40 +0000
committerQMK Bot <hello@qmk.fm>2021-07-20 16:41:40 +0000
commit6fa53023cb6a78a59fa940b56ae34531a765be90 (patch)
tree7e0272ee612cce05c4c1676e0cb51d26352d6c88 /users
parent154c7bc3e2bd328814823f5701273389a3f0f77f (diff)
parentec78f8bca2523a91a293d8ae4d61050d1e36b320 (diff)
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'users')
-rw-r--r--users/imchipwood/imchipwood.c141
-rw-r--r--users/imchipwood/imchipwood.h51
-rw-r--r--users/imchipwood/rules.mk2
3 files changed, 194 insertions, 0 deletions
diff --git a/users/imchipwood/imchipwood.c b/users/imchipwood/imchipwood.c
new file mode 100644
index 0000000000..e319c00ce7
--- /dev/null
+++ b/users/imchipwood/imchipwood.c
@@ -0,0 +1,141 @@
+/* Copyright 2021 imchipwood
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#include "imchipwood.h"
+
+static td_state_t td_state[3];
+
+// determine the tapdance state to return
+int cur_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;
+ } // any number higher than the maximum state value you return above
+}
+
+void altf2_finished(qk_tap_dance_state_t *state, void *user_data) {
+ td_state[0] = cur_dance(state);
+ switch (td_state[0]) {
+ case SINGLE_TAP:
+ register_code(KC_F2);
+ break;
+ case SINGLE_HOLD:
+ register_mods(MOD_BIT(KC_LALT));
+ break;
+ case DOUBLE_TAP:
+ register_mods(MOD_BIT(KC_LALT));
+ tap_code(KC_F2);
+ break;
+ }
+}
+
+void altf2_reset(qk_tap_dance_state_t *state, void *user_data) {
+ switch (td_state[0]) {
+ case SINGLE_TAP:
+ unregister_code(KC_F2);
+ break;
+ case SINGLE_HOLD:
+ unregister_mods(MOD_BIT(KC_LALT));
+ break;
+ case DOUBLE_TAP:
+ unregister_code(KC_F2);
+ unregister_mods(MOD_BIT(KC_LALT));
+ break;
+ }
+}
+
+
+void ctlf5_finished(qk_tap_dance_state_t *state, void *user_data) {
+ td_state[1] = cur_dance(state);
+ switch (td_state[1]) {
+ case SINGLE_TAP:
+ register_code(KC_F5);
+ break;
+ case SINGLE_HOLD:
+ register_mods(MOD_BIT(KC_LCTL));
+ break;
+ case DOUBLE_TAP:
+ register_mods(MOD_BIT(KC_LCTL));
+ tap_code(KC_F5);
+ break;
+ }
+}
+
+void ctlf5_reset(qk_tap_dance_state_t *state, void *user_data) {
+ switch (td_state[1]) {
+ case SINGLE_TAP:
+ unregister_code(KC_F5);
+ break;
+ case SINGLE_HOLD:
+ unregister_mods(MOD_BIT(KC_LCTL));
+ break;
+ case DOUBLE_TAP:
+ unregister_code(KC_F5);
+ unregister_mods(MOD_BIT(KC_LCTL));
+ break;
+ }
+}
+
+void altf7_finished(qk_tap_dance_state_t *state, void *user_data) {
+ td_state[2] = cur_dance(state);
+ switch (td_state[2]) {
+ case SINGLE_TAP:
+ register_code(KC_F7);
+ break;
+ case SINGLE_HOLD:
+ register_mods(MOD_BIT(KC_LALT));
+ break;
+ case DOUBLE_TAP:
+ register_mods(MOD_BIT(KC_LALT));
+ tap_code(KC_F7);
+ break;
+ }
+}
+
+void altf7_reset(qk_tap_dance_state_t *state, void *user_data) {
+ switch (td_state[2]) {
+ case SINGLE_TAP:
+ unregister_code(KC_F7);
+ break;
+ case SINGLE_HOLD:
+ unregister_mods(MOD_BIT(KC_LALT));
+ break;
+ case DOUBLE_TAP:
+ unregister_code(KC_F7);
+ unregister_mods(MOD_BIT(KC_LALT));
+ break;
+ }
+}
+
+qk_tap_dance_action_t tap_dance_actions[] = {
+ [ALT_F2] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, altf2_finished, altf2_reset),
+ [CTL_F5] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, ctlf5_finished, ctlf5_reset),
+ [ALT_F7] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, altf7_finished, altf7_reset),
+ [DEL_NLCK] = ACTION_TAP_DANCE_DOUBLE(KC_DEL, KC_NLCK),
+ // Double tap right -> END
+ [TD_REND] = ACTION_TAP_DANCE_DOUBLE(KC_RIGHT, KC_END),
+ // Double tap left -> HOME
+ [TD_LOME] = ACTION_TAP_DANCE_DOUBLE(KC_LEFT, KC_HOME),
+ // Double tap right shift -> CAPS LOCK
+ [TD_RSFT_CAPS] = ACTION_TAP_DANCE_DOUBLE(KC_RSFT, KC_CAPS),
+};
diff --git a/users/imchipwood/imchipwood.h b/users/imchipwood/imchipwood.h
new file mode 100644
index 0000000000..64726a862b
--- /dev/null
+++ b/users/imchipwood/imchipwood.h
@@ -0,0 +1,51 @@
+/* Copyright 2021 imchipwood
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#include "quantum.h"
+
+// change the tapping term to a little bit quicker
+#ifdef TAPPING_TERM
+ #undef TAPPING_TERM
+#endif
+#define TAPPING_TERM 175
+
+#ifdef TAPPING_TOGGLE
+ #undef TAPPING_TOGGLE
+#endif
+#define TAPPING_TOGGLE 2
+
+
+enum td_keycodes {
+ TD_REND = 0, // right when tapped, end when double tapped
+ TD_LOME, // left when tapped, home when double tapped
+ TD_RSFT_CAPS,
+ ALT_F2, // F2 when tapped, LALT when held, LALT+F2 when double tapped
+ CTL_F5, // F5 when tapped, LCTL when held, LCTL+F5 when double tapped
+ ALT_F7, // F7 when tapped, LALT when held, LALT+F7 when double tapped
+ DEL_NLCK, // DEL when tapped, NUMLOCK when double tapped
+};
+
+
+typedef enum { SINGLE_TAP, SINGLE_HOLD, DOUBLE_TAP } td_state_t;
+int cur_dance(qk_tap_dance_state_t *state);
+
+void altf2_finished(qk_tap_dance_state_t *state, void *user_data);
+void altf2_reset(qk_tap_dance_state_t *state, void *user_data);
+void ctlf5_finished(qk_tap_dance_state_t *state, void *user_data);
+void ctlf5_reset(qk_tap_dance_state_t *state, void *user_data);
+void altf7_finished(qk_tap_dance_state_t *state, void *user_data);
+void altf7_reset(qk_tap_dance_state_t *state, void *user_data);
diff --git a/users/imchipwood/rules.mk b/users/imchipwood/rules.mk
new file mode 100644
index 0000000000..87cca5b5e2
--- /dev/null
+++ b/users/imchipwood/rules.mk
@@ -0,0 +1,2 @@
+SRC += imchipwood.c
+TAP_DANCE_ENABLE=yes