diff options
Diffstat (limited to 'users/talljoe/tapdance/td_setup.c')
| -rw-r--r-- | users/talljoe/tapdance/td_setup.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/users/talljoe/tapdance/td_setup.c b/users/talljoe/tapdance/td_setup.c new file mode 100644 index 000000000..d8464144a --- /dev/null +++ b/users/talljoe/tapdance/td_setup.c | |||
| @@ -0,0 +1,70 @@ | |||
| 1 | /* Copyright 2020 Joseph Wasson | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include "tapdance.h" | ||
| 18 | |||
| 19 | int cur_dance (qk_tap_dance_state_t *state) { | ||
| 20 | if (state->count == 1) { | ||
| 21 | //If count = 1, and it has been interrupted - it doesn't matter if it is pressed or not: Send SINGLE_TAP | ||
| 22 | if (state->interrupted) { | ||
| 23 | // if (!state->pressed) return SINGLE_TAP; | ||
| 24 | //need "permissive hold" here. | ||
| 25 | // else return SINGLE_HOLD; | ||
| 26 | //If the interrupting key is released before the tap-dance key, then it is a single HOLD | ||
| 27 | //However, if the tap-dance key is released first, then it is a single TAP | ||
| 28 | //But how to get access to the state of the interrupting key???? | ||
| 29 | return SINGLE_TAP; | ||
| 30 | } | ||
| 31 | else { | ||
| 32 | if (!state->pressed) return SINGLE_TAP; | ||
| 33 | else return SINGLE_HOLD; | ||
| 34 | } | ||
| 35 | } | ||
| 36 | //If count = 2, and it has been interrupted - assume that user is trying to type the letter associated | ||
| 37 | //with single tap. | ||
| 38 | else if (state->count == 2) { | ||
| 39 | if (state->interrupted) return DOUBLE_SINGLE_TAP; | ||
| 40 | else if (state->pressed) return DOUBLE_HOLD; | ||
| 41 | else return DOUBLE_TAP; | ||
| 42 | } | ||
| 43 | else if ((state->count == 3) && ((state->interrupted) || (!state->pressed))) return TRIPLE_TAP; | ||
| 44 | else if (state->count == 3) return TRIPLE_HOLD; | ||
| 45 | else return SPECIAL; | ||
| 46 | } | ||
| 47 | |||
| 48 | int hold_cur_dance (qk_tap_dance_state_t *state) { | ||
| 49 | if (state->count == 1) { | ||
| 50 | if (state->interrupted) { | ||
| 51 | if (!state->pressed) return SINGLE_TAP; | ||
| 52 | else return SINGLE_HOLD; | ||
| 53 | } | ||
| 54 | else { | ||
| 55 | if (!state->pressed) return SINGLE_TAP; | ||
| 56 | else return SINGLE_HOLD; | ||
| 57 | } | ||
| 58 | } | ||
| 59 | //If count = 2, and it has been interrupted - assume that user is trying to type the letter associated | ||
| 60 | //with single tap. | ||
| 61 | else if (state->count == 2) { | ||
| 62 | if (state->pressed) return DOUBLE_HOLD; | ||
| 63 | else return DOUBLE_TAP; | ||
| 64 | } | ||
| 65 | else if (state->count == 3) { | ||
| 66 | if (!state->pressed) return TRIPLE_TAP; | ||
| 67 | else return TRIPLE_HOLD; | ||
| 68 | } | ||
| 69 | else return SPECIAL; | ||
| 70 | } | ||
