From 7ce5402417b0332569bf48cf2c51e412cd35a18a Mon Sep 17 00:00:00 2001 From: Joe Wasson Date: Fri, 6 Nov 2020 17:16:22 -0800 Subject: Updates to Talljoe's Keymaps (#10115) * Minor Tweak * Refactor spacebar defines. * Add TMO50 layout * Rename Atreus keymap. * Refactor Atreus for readability. * Eliminate tapdance quote and tweak maltroff. * Factor out tapdance. * Add some fancy combos and keys. * Remove combos for now because they cause pain. * WIP visualizer * Alternate method for reset * WIP2 visualizer * Layer text tweak. * Add made-up layout Nortron as a combination of Norman and Maltron. * Add backspace. * Add Talljoe keymap to Prime E. * Fix double-colon so it doesn't press enter if shift is released early. * Use new make command. * Bring some modern standards into code and add licenses. * Remove QMK_KEYBOARD_CONFIG_H and fixup QMK_KEYBOARD_H. * Move from `biton32` to `get_highest_layer`. * Remove PREVENT_STUCK_MODIFIERS * Update keyboards/thevankeyboards/minivan/keymaps/talljoe-minivan/config.h --- users/talljoe/tapdance/actions/td.function.c | 35 ++++++++++++++ users/talljoe/tapdance/actions/td.grave.c | 36 ++++++++++++++ users/talljoe/tapdance/actions/td.lock.c | 35 ++++++++++++++ users/talljoe/tapdance/actions/td.semicolon.c | 54 +++++++++++++++++++++ users/talljoe/tapdance/tapdance.h | 26 ++++++++++ users/talljoe/tapdance/tapdance_actions.c | 28 +++++++++++ users/talljoe/tapdance/td_setup.c | 70 +++++++++++++++++++++++++++ users/talljoe/tapdance/td_setup.h | 29 +++++++++++ 8 files changed, 313 insertions(+) create mode 100644 users/talljoe/tapdance/actions/td.function.c create mode 100644 users/talljoe/tapdance/actions/td.grave.c create mode 100644 users/talljoe/tapdance/actions/td.lock.c create mode 100644 users/talljoe/tapdance/actions/td.semicolon.c create mode 100644 users/talljoe/tapdance/tapdance.h create mode 100644 users/talljoe/tapdance/tapdance_actions.c create mode 100644 users/talljoe/tapdance/td_setup.c create mode 100644 users/talljoe/tapdance/td_setup.h (limited to 'users/talljoe/tapdance') diff --git a/users/talljoe/tapdance/actions/td.function.c b/users/talljoe/tapdance/actions/td.function.c new file mode 100644 index 0000000000..fffbf283dd --- /dev/null +++ b/users/talljoe/tapdance/actions/td.function.c @@ -0,0 +1,35 @@ +/* Copyright 2020 Joseph Wasson + * + * 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 . + */ + +static struct { + int state; +} function_state = {0}; + +// Send semi-colon + enter on two taps +void tap_dance_function_finished(qk_tap_dance_state_t *state, void *user_data) { + function_state.state = hold_cur_dance(state); + switch (function_state.state) { + case SINGLE_HOLD: layer_on(_ADJUST); break; + } +} + +void tap_dance_function_reset(qk_tap_dance_state_t *state, void *user_data) { + switch (function_state.state) { + case SPECIAL: reset_keyboard(); break; + case SINGLE_HOLD: layer_off(_ADJUST); break; + } + function_state.state = 0; +} diff --git a/users/talljoe/tapdance/actions/td.grave.c b/users/talljoe/tapdance/actions/td.grave.c new file mode 100644 index 0000000000..509b66dc35 --- /dev/null +++ b/users/talljoe/tapdance/actions/td.grave.c @@ -0,0 +1,36 @@ +/* Copyright 2020 Joseph Wasson + * + * 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 . + */ + +// Send `. ~. ``` +void tap_dance_grave_finished(qk_tap_dance_state_t *state, void *user_data) { + switch(state->count) { + case 1: + SEND_STRING("`"); + break; + case 2: + SEND_STRING("~"); + break; + } +} + +void tap_dance_grave_each(qk_tap_dance_state_t *state, void *user_data) { + if(state->count == 3) { + SEND_STRING("```"); + } else if (state->count > 3) { + SEND_STRING("`"); + } +} + diff --git a/users/talljoe/tapdance/actions/td.lock.c b/users/talljoe/tapdance/actions/td.lock.c new file mode 100644 index 0000000000..4422d9e252 --- /dev/null +++ b/users/talljoe/tapdance/actions/td.lock.c @@ -0,0 +1,35 @@ +/* Copyright 2020 Joseph Wasson + * + * 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 . + */ + +static struct { + int state; +} lock_state = {0}; + +// Send semi-colon + enter on two taps +void tap_dance_lock_finished(qk_tap_dance_state_t *state, void *user_data) { + lock_state.state = cur_dance(state); + switch (lock_state.state) { + case SINGLE_TAP: register_code(KC_ESC); break; + case SINGLE_HOLD: macro_lock(); break; + } +} + +void tap_dance_lock_reset(qk_tap_dance_state_t *state, void *user_data) { + switch (lock_state.state) { + case SINGLE_TAP: unregister_code(KC_ESC); break; + } + lock_state.state = 0; +} diff --git a/users/talljoe/tapdance/actions/td.semicolon.c b/users/talljoe/tapdance/actions/td.semicolon.c new file mode 100644 index 0000000000..45776492a4 --- /dev/null +++ b/users/talljoe/tapdance/actions/td.semicolon.c @@ -0,0 +1,54 @@ +/* Copyright 2020 Joseph Wasson + * + * 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 . + */ + +static struct { + int semicolon; + bool mods; +} tap_state = {0}; + +void tap_dance_semicolon_each(qk_tap_dance_state_t *state, void *user_data) { + tap_state.mods |= get_mods(); +} + +// Send semi-colon + enter on two taps +void tap_dance_semicolon_finished(qk_tap_dance_state_t *state, void *user_data) { + tap_state.semicolon = hold_cur_dance(state); + switch (tap_state.semicolon) { + case SINGLE_TAP: case DOUBLE_HOLD: register_code(KC_SCLN); break; + case SINGLE_HOLD: layer_on(_NUM); break; + } +} + +void tap_dance_semicolon_reset(qk_tap_dance_state_t *state, void *user_data) { + switch (tap_state.semicolon) { + case SINGLE_TAP: case DOUBLE_HOLD: unregister_code(KC_SCLN); break; + case DOUBLE_TAP: { + if (tap_state.mods) { + SEND_STRING(";;"); // send normal when mods are pressed + } + else { + SEND_STRING(";\n"); + } + break; + } + case TRIPLE_TAP: { + SEND_STRING(";\n\n"); + } + case SPECIAL: layer_invert(_NUM); break; + case SINGLE_HOLD: layer_off(_NUM); break; + } + tap_state.semicolon = 0; +} diff --git a/users/talljoe/tapdance/tapdance.h b/users/talljoe/tapdance/tapdance.h new file mode 100644 index 0000000000..532e978ca8 --- /dev/null +++ b/users/talljoe/tapdance/tapdance.h @@ -0,0 +1,26 @@ +/* Copyright 2020 Joseph Wasson + * + * 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 . + */ + +#include "quantum.h" +#include "td_setup.h" + +enum tap_dancers { + TD_SEMICOLON, + TD_GRAVE, + TD_LOCK, + TD_FUNCTION, +}; + diff --git a/users/talljoe/tapdance/tapdance_actions.c b/users/talljoe/tapdance/tapdance_actions.c new file mode 100644 index 0000000000..59a34b7b9e --- /dev/null +++ b/users/talljoe/tapdance/tapdance_actions.c @@ -0,0 +1,28 @@ +/* Copyright 2020 Joseph Wasson + * + * 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 . + */ + +#include "../talljoe.h" +#include "actions/td.grave.c" +#include "actions/td.lock.c" +#include "actions/td.semicolon.c" +#include "actions/td.function.c" + +qk_tap_dance_action_t tap_dance_actions[] = { + [TD_SEMICOLON] = ACTION_TAP_DANCE_FN_ADVANCED(tap_dance_semicolon_each, tap_dance_semicolon_finished, tap_dance_semicolon_reset), + [TD_LOCK] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, tap_dance_lock_finished, tap_dance_lock_reset), + [TD_GRAVE] = ACTION_TAP_DANCE_FN_ADVANCED(tap_dance_grave_each, tap_dance_grave_finished, NULL), + [TD_FUNCTION] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, tap_dance_function_finished, tap_dance_function_reset), +}; diff --git a/users/talljoe/tapdance/td_setup.c b/users/talljoe/tapdance/td_setup.c new file mode 100644 index 0000000000..d8464144ac --- /dev/null +++ b/users/talljoe/tapdance/td_setup.c @@ -0,0 +1,70 @@ +/* Copyright 2020 Joseph Wasson + * + * 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 . + */ + +#include "tapdance.h" + +int cur_dance (qk_tap_dance_state_t *state) { + if (state->count == 1) { + //If count = 1, and it has been interrupted - it doesn't matter if it is pressed or not: Send SINGLE_TAP + if (state->interrupted) { + // if (!state->pressed) return SINGLE_TAP; + //need "permissive hold" here. + // else return SINGLE_HOLD; + //If the interrupting key is released before the tap-dance key, then it is a single HOLD + //However, if the tap-dance key is released first, then it is a single TAP + //But how to get access to the state of the interrupting key???? + return SINGLE_TAP; + } + else { + if (!state->pressed) return SINGLE_TAP; + else return SINGLE_HOLD; + } + } + //If count = 2, and it has been interrupted - assume that user is trying to type the letter associated + //with single tap. + else if (state->count == 2) { + if (state->interrupted) return DOUBLE_SINGLE_TAP; + else if (state->pressed) return DOUBLE_HOLD; + else return DOUBLE_TAP; + } + else if ((state->count == 3) && ((state->interrupted) || (!state->pressed))) return TRIPLE_TAP; + else if (state->count == 3) return TRIPLE_HOLD; + else return SPECIAL; +} + +int hold_cur_dance (qk_tap_dance_state_t *state) { + if (state->count == 1) { + if (state->interrupted) { + if (!state->pressed) return SINGLE_TAP; + else return SINGLE_HOLD; + } + else { + if (!state->pressed) return SINGLE_TAP; + else return SINGLE_HOLD; + } + } + //If count = 2, and it has been interrupted - assume that user is trying to type the letter associated + //with single tap. + else if (state->count == 2) { + if (state->pressed) return DOUBLE_HOLD; + else return DOUBLE_TAP; + } + else if (state->count == 3) { + if (!state->pressed) return TRIPLE_TAP; + else return TRIPLE_HOLD; + } + else return SPECIAL; +} diff --git a/users/talljoe/tapdance/td_setup.h b/users/talljoe/tapdance/td_setup.h new file mode 100644 index 0000000000..85d45d944f --- /dev/null +++ b/users/talljoe/tapdance/td_setup.h @@ -0,0 +1,29 @@ +/* Copyright 2020 Joseph Wasson + * + * 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 . + */ + +enum { + SINGLE_TAP = 1, + SINGLE_HOLD = 2, + DOUBLE_TAP = 3, + DOUBLE_HOLD = 4, + DOUBLE_SINGLE_TAP = 5, //send two single taps + TRIPLE_TAP = 6, + TRIPLE_HOLD = 7, + SPECIAL = 8 +}; + +int cur_dance (qk_tap_dance_state_t *state); +int hold_cur_dance (qk_tap_dance_state_t *state); -- cgit v1.2.3