qmk_firmware/users/muppetjones/features/dancelayers.c

99 lines
2.9 KiB
C
Raw Normal View History

Userspace: muppetjones (#1) (#13461) * Userspace: muppetjones (#1) Add and update lily58 to work with userspace Add and update kyria keymap to work with userspace Add and update planck keymap with userspace Add etchamouse code and docs to userpace Add userspace Update mouse encoder for smoother movement. Encoder + mouse Added casemodes by andrewjrae * Rollback lily58 state reader and add missing GPL * Apply suggestions from code review Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Joel Challis <git@zvecr.com> * fix lily58 keymap * Updates to user and lily for muppetjones. Updated parameters for etchamouse for smoother mouse movement. Updated lily keymap and userspace to actually work together. * Update keyboards/lily58/keymaps/muppetjones/config.h Co-authored-by: Drashna Jaelre <drashna@live.com> * Updated keymaps and userspace * Little more cleanup. * Update keyboards/lily58/keymaps/muppetjones/rules.mk Co-authored-by: Ryan <fauxpark@gmail.com> * Rollback accidental libchibios update * Apply suggestions from code review Co-authored-by: Drashna Jaelre <drashna@live.com> * Update kyria keymap * Move kyria keymap to splitkb/kyria * Update planck keymap * Remove all changes to keyboards/lily58/lib/layer_state_reader.c * Update lily58 keymap * Recommended change * Update keymap readme * Update kyria keymap and userspace * Apply suggestions from code review Co-authored-by: Drashna Jaelre <drashna@live.com> * Renamed users/muppetjones/README.md to lc * Update keyboards/lily58/keymaps/muppetjones/config.h Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Joel Challis <git@zvecr.com> Co-authored-by: Ryan <fauxpark@gmail.com>
2022-08-03 17:23:17 +00:00
/* Copyright 2020 Stephen J. Bush
*
* 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/>.
*/
#ifdef TAP_DANCE_ENABLE
# include QMK_KEYBOARD_H
# include "muppetjones.h"
# include "dancelayers.h"
// Initialize tap structure associated with example tap dance key
static td_tap_t lyr_tap_state = {.is_press_action = true, .state = TD_NONE};
/* @brief Determine the current tap dance state
* @param A tap dance state struct.
* @return A struct.
*/
td_state_t cur_dance(qk_tap_dance_state_t *state) {
switch (state->count) {
case 1:
if (!state->pressed)
return TD_1X_TAP;
else
return TD_1X_HOLD;
case 2:
return TD_2X_TAP;
break;
case 3:
return TD_3X_TAP;
break;
case 4:
return TD_4X_TAP;
break;
default:
return TD_UNKNOWN;
}
}
// Functions that control what our tap dance key does
__attribute__((weak)) void td_layer_finished(qk_tap_dance_state_t *state, void *user_data) {
lyr_tap_state.state = cur_dance(state);
switch (lyr_tap_state.state) {
case TD_1X_TAP:
if (layer_state_is(_MOUSE))
layer_off(_MOUSE);
else
layer_on(_MOUSE);
break;
case TD_1X_HOLD:
layer_on(_ADJUST);
break;
case TD_2X_TAP:
// Toggle lower layer
if (layer_state_is(_LOWER))
layer_off(_LOWER);
else
layer_on(_LOWER);
break;
case TD_3X_TAP:
// Toggle lower layer
if (layer_state_is(_RAISE))
layer_off(_RAISE);
else
layer_on(_RAISE);
break;
case TD_4X_TAP:
// Toggle lower layer
if (layer_state_is(_ADJUST))
layer_off(_ADJUST);
else
layer_on(_ADJUST);
break;
default:
break;
}
}
__attribute__((weak)) void td_layer_reset(qk_tap_dance_state_t *state, void *user_data) {
// If the key was held down and now is released then switch off the layer
if (lyr_tap_state.state == TD_1X_HOLD) {
layer_off(_ADJUST);
}
lyr_tap_state.state = TD_NONE;
}
#endif