diff options
author | Drashna Jaelre <drashna@live.com> | 2019-05-06 22:34:09 -0700 |
---|---|---|
committer | MechMerlin <30334081+mechmerlin@users.noreply.github.com> | 2019-05-06 22:34:09 -0700 |
commit | f3d5b1091d364468cd9f5510aef9e723d8542279 (patch) | |
tree | 762b8f562b1e96e42657f872fd4b04c8efaaa829 /users/drashna/tap_dances.c | |
parent | 7a751f114114bf3b78d5d8fc8bedf2b42b665dba (diff) |
[Keymap] RGB Changes for Drashna Keyboards (#5803)
* Disable a bunch of reactive modes
* Enable rgb matrix for Corne Keyboard
* Convert CRKBD to rgb matrix
* Add Gergo keyboard layout
* Make Diablo 3 tap dance better
* Add basic support for Planck EZ
* Fix RGB Matrix stuff
* Fix keycodes for Planck EZ
* Update CRKBD OLED stuff
* Fix typo for sleep on ergodox glow
* Improve my gergo layout
* Scrolling OLED key logger!
* Change gergo layout
* Hnadle unicode keycodes if unicode is disabled
* Disable COMMAND/CONSOLE for gergo
* Fix right side control
* Re-enable LTO for all platforms
Since I got updated arm gcc binaries that no longer error out on lto
* Update formatting to match newer community standards
Poor 2 space
* Re-alight startup animation to use new HUE range
* Streamline gitlab ci scripts
* Disabled Space Cadet
* Add support for breathing table
* Enable new LTO Option
And clean up defines that will now be repeatitive
* Remove vscode settings
* Additional formatting cleanup of config.h files
Diffstat (limited to 'users/drashna/tap_dances.c')
-rw-r--r-- | users/drashna/tap_dances.c | 77 |
1 files changed, 39 insertions, 38 deletions
diff --git a/users/drashna/tap_dances.c b/users/drashna/tap_dances.c index cbb3cf54ef..18ca96e187 100644 --- a/users/drashna/tap_dances.c +++ b/users/drashna/tap_dances.c @@ -2,63 +2,64 @@ //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]; +diablo_timer_t diablo_timer[4]; + +uint8_t diablo_times[] = { 0, 0, 1, 3, 5, 10, 30 }; // 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; }; +bool check_dtimer(uint8_t dtimer) { return (timer_elapsed(diablo_timer[dtimer].key_time) < (diablo_timer[dtimer].timer * 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]; - } +void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data) { + int index = (int)user_data; + if (state->count >= 7) { + diablo_timer[index].key_time = diablo_times[0]; + reset_tap_dance(state); + } else { + diablo_timer[index].key_time = diablo_times[state->count]; + } } -// 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); } +// One funtion to rule them all!! +#define ACTION_TAP_DANCE_DIABLO(arg) { \ + .fn = { NULL, (void *)diablo_tapdance_master, NULL }, \ + .user_data = (void *)arg, \ + } //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), + // tap once to disable, and more to enable timed micros + [TD_D3_1] = ACTION_TAP_DANCE_DIABLO(0), + [TD_D3_2] = ACTION_TAP_DANCE_DIABLO(1), + [TD_D3_3] = ACTION_TAP_DANCE_DIABLO(2), + [TD_D3_4] = ACTION_TAP_DANCE_DIABLO(3), }; // Sends the key press to system, but only if on the Diablo layer void send_diablo_keystroke(uint8_t diablo_key) { - if (IS_LAYER_ON(_DIABLO)) { - switch (diablo_key) { - case 0: - tap_code(KC_1); break; - case 1: - tap_code(KC_2); break; - case 2: - tap_code(KC_3); break; - case 3: - tap_code(KC_4); break; + if (IS_LAYER_ON(_DIABLO)) { + switch (diablo_key) { + case 0: + tap_code(KC_1); break; + case 1: + tap_code(KC_2); break; + case 2: + tap_code(KC_3); break; + case 3: + tap_code(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); + uint8_t dtime; + for (dtime = 0; dtime < 4; dtime++) { + if (check_dtimer(dtime) && diablo_timer[dtime].key_time) { + diablo_timer[dtime].timer = timer_read(); + send_diablo_keystroke(dtime); + } } - } } |