summaryrefslogtreecommitdiffstats
path: root/users/drashna/tap_dances.c
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2018-06-01 07:11:06 +0200
committerJack Humbert <jack.humb@gmail.com>2018-06-01 07:11:06 +0200
commit3d1349b280d9c0a57e37b5347a405426de6dba10 (patch)
tree0b8c989d0c902115e2ce51c8bb9dc201b0e2eb0c /users/drashna/tap_dances.c
parent8eaf23ae8146766615cc1cec3fc8e04111e8ef49 (diff)
downloadqmk_firmware-3d1349b280d9c0a57e37b5347a405426de6dba10.tar.gz
qmk_firmware-3d1349b280d9c0a57e37b5347a405426de6dba10.tar.xz
Big overhaul to Drashna keymaps and userspace (#3097)
* Optimize secrets code * Orthodox tweaks * rules.mk features * Minor cleanup * Revert mod bits * Force Hold breaks One Shot Tap Toggle * Cleanup * Moke keymaps more consistent * minor ergodox tweak * More OSM for the Orthodox * Cleanup of userspace * Toggle Secrets * Add hidden process record for super secret macros * Make sure secret macros always compiles * finish up making them super secret * Add ColinTA's rgb twinkle as WIP * Optimize RGB Twinkling for typing Also, tweak RGB indicators. AND WTF, I HAVE NO IDEA WHY THE INDICATORS ONLY WORK AS IS. The logical method for getting them working doesn't ... and it's beyond bizarre * Make console logging more configurable * Indicator travisty * Clean up userspace rgb code * Optimize RGB Twinking to work on default layer only, and to base it's color on the curent hue * Eff it... rgblight_sethsv_at runs at every matrix scan * RGB Twinkle cleanup * Update Iris code for new board * Move RGB Indicator and RGB Twinkle into userspace * Move RGB Indicator code to rgb_stuff.c * Major cleanup of RGB Code in userspace * Additional cleanup of RGB code in userspace * Use noeeprom functions to save my boards! * Enable RGB Sleep on all boards now * Add old iris board * tapping tweak * Use byte 19 for eeprom to prepare for possible merge of eeconfig function pr * Add code to fix default layer after eeprom reset
Diffstat (limited to 'users/drashna/tap_dances.c')
-rw-r--r--users/drashna/tap_dances.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/users/drashna/tap_dances.c b/users/drashna/tap_dances.c
new file mode 100644
index 000000000..c9e4b1d0f
--- /dev/null
+++ b/users/drashna/tap_dances.c
@@ -0,0 +1,65 @@
+#include "drashna.h"
+#include "tap_dances.h"
+
+
+//define diablo macro timer variables
+uint16_t diablo_timer[4];
+uint8_t diablo_times[] = { 0, 1, 3, 5, 10, 30 };
+uint8_t diablo_key_time[4];
+
+// has the correct number of seconds elapsed (as defined by diablo_times)
+bool check_dtimer(uint8_t dtimer) { return (timer_elapsed(diablo_timer[dtimer]) < (diablo_key_time[dtimer] * 1000)) ? false : true; };
+
+// 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];
+ }
+}
+
+// Would rather have one function for all of this, but no idea how to do that...
+void diablo_tapdance1(qk_tap_dance_state_t *state, void *user_data) { diablo_tapdance_master(state, user_data, 0); }
+void diablo_tapdance2(qk_tap_dance_state_t *state, void *user_data) { diablo_tapdance_master(state, user_data, 1); }
+void diablo_tapdance3(qk_tap_dance_state_t *state, void *user_data) { diablo_tapdance_master(state, user_data, 2); }
+void diablo_tapdance4(qk_tap_dance_state_t *state, void *user_data) { diablo_tapdance_master(state, user_data, 3); }
+
+//Tap Dance Definitions
+qk_tap_dance_action_t tap_dance_actions[] = {
+ // tap once to disable, and more to enable timed micros
+ [TD_D3_1] = ACTION_TAP_DANCE_FN(diablo_tapdance1),
+ [TD_D3_2] = ACTION_TAP_DANCE_FN(diablo_tapdance2),
+ [TD_D3_3] = ACTION_TAP_DANCE_FN(diablo_tapdance3),
+ [TD_D3_4] = ACTION_TAP_DANCE_FN(diablo_tapdance4),
+};
+
+// Sends the key press to system, but only if on the Diablo layer
+void send_diablo_keystroke(uint8_t diablo_key) {
+ if (biton32(layer_state) == _DIABLO) {
+ switch (diablo_key) {
+ case 0:
+ tap(KC_1); break;
+ case 1:
+ tap(KC_2); break;
+ case 2:
+ tap(KC_3); break;
+ case 3:
+ tap(KC_4); break;
+ }
+ }
+}
+
+// Checks each of the 4 timers/keys to see if enough time has elapsed
+// Runs the "send string" command if enough time has passed, and resets the timer.
+void run_diablo_macro_check(void) {
+ uint8_t dtime;
+ for (dtime = 0; dtime < 4; dtime++) {
+ if (check_dtimer(dtime) && diablo_key_time[dtime]) {
+ diablo_timer[dtime] = timer_read();
+ send_diablo_keystroke(dtime);
+ }
+ }
+}