From d7e5932c87cf123a5b310431ebca3d16ca0d1050 Mon Sep 17 00:00:00 2001 From: hsuchil Date: Thu, 21 Apr 2022 08:59:53 -0700 Subject: [PATCH] Squashed commit of the following: commit c5ed8e7d33fe08bb224413546ea5c5f76c134be0 Author: hsuchil Date: Thu Apr 21 08:59:07 2022 -0700 Add more keymaps commit 3e30597ebc7d778faa4f4e07debfa8d9a5b20422 Author: hsuchil Date: Sun Apr 17 23:39:47 2022 -0700 Add mountain and layout Changes. Changes. --- .../mechwild/obe/keymaps/hsuchil/config.h | 3 + .../mechwild/obe/keymaps/hsuchil/rules.mk | 3 + keyboards/ydkb/mountain/config.h | 56 ++++++ .../ydkb/mountain/keymaps/default/keymap.c | 38 +++++ .../ydkb/mountain/keymaps/hsuchil/config.h | 24 +++ .../ydkb/mountain/keymaps/hsuchil/keymap.c | 55 ++++++ .../ydkb/mountain/keymaps/hsuchil/rules.mk | 1 + keyboards/ydkb/mountain/led.c | 36 ++++ keyboards/ydkb/mountain/matrix.c | 160 ++++++++++++++++++ keyboards/ydkb/mountain/mountain.h | 50 ++++++ keyboards/ydkb/mountain/rules.mk | 30 ++++ keyboards/ydkb/mountain/switch_board.h | 18 ++ users/hsuchil/custom_tapdance.c | 95 +++++++++++ users/hsuchil/hsuchil.c | 14 +- users/hsuchil/hsuchil.h | 10 ++ users/hsuchil/rules.mk | 6 +- 16 files changed, 591 insertions(+), 8 deletions(-) create mode 100644 keyboards/ydkb/mountain/config.h create mode 100644 keyboards/ydkb/mountain/keymaps/default/keymap.c create mode 100644 keyboards/ydkb/mountain/keymaps/hsuchil/config.h create mode 100644 keyboards/ydkb/mountain/keymaps/hsuchil/keymap.c create mode 100644 keyboards/ydkb/mountain/keymaps/hsuchil/rules.mk create mode 100644 keyboards/ydkb/mountain/led.c create mode 100644 keyboards/ydkb/mountain/matrix.c create mode 100644 keyboards/ydkb/mountain/mountain.h create mode 100644 keyboards/ydkb/mountain/rules.mk create mode 100644 keyboards/ydkb/mountain/switch_board.h create mode 100644 users/hsuchil/custom_tapdance.c diff --git a/keyboards/mechwild/obe/keymaps/hsuchil/config.h b/keyboards/mechwild/obe/keymaps/hsuchil/config.h index 7248c52fd8e..c02efa7b6d1 100644 --- a/keyboards/mechwild/obe/keymaps/hsuchil/config.h +++ b/keyboards/mechwild/obe/keymaps/hsuchil/config.h @@ -17,6 +17,9 @@ along with this program. If not, see . #pragma once +#define BOOTMAGIC_LITE_ROW 5 +#define BOOTMAGIC_LITE_COLUMN 4 + // Redefine number of LED #ifdef RGBLED_NUM # undef RGBLED_NUM diff --git a/keyboards/mechwild/obe/keymaps/hsuchil/rules.mk b/keyboards/mechwild/obe/keymaps/hsuchil/rules.mk index 76d3c49ffd6..ff247436816 100644 --- a/keyboards/mechwild/obe/keymaps/hsuchil/rules.mk +++ b/keyboards/mechwild/obe/keymaps/hsuchil/rules.mk @@ -1,2 +1,5 @@ RGBLIGHT_ENABLE = yes VIA_ENABLE = yes +ENCODER_ENABLE = yes +BOOTMAGIC_ENABLE = yes + diff --git a/keyboards/ydkb/mountain/config.h b/keyboards/ydkb/mountain/config.h new file mode 100644 index 00000000000..eb98020e072 --- /dev/null +++ b/keyboards/ydkb/mountain/config.h @@ -0,0 +1,56 @@ +/* Copyright 2020 + * + * 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 . + */ + +#pragma once + +#include "config_common.h" + +/* USB Device descriptor parameter */ +#define FW_VER QMK_DM3T +#define VENDOR_ID 0x9D5B +#define PRODUCT_ID 0x2163 +#define DEVICE_VER 0x0001 +#define MANUFACTURER YDKB +#define PRODUCT Mountain (FW_VER) + +/* key matrix size */ +#define MATRIX_ROWS 5 +#define MATRIX_COLS 16 + +#define MOUSEKEY_INTERVAL 20 +#define MOUSEKEY_DELAY 0 +#define MOUSEKEY_TIME_TO_MAX 60 +#define MOUSEKEY_MAX_SPEED 7 +#define MOUSEKEY_WHEEL_DELAY 0 + +#define TAPPING_TOGGLE 1 + +#define TAPPING_TERM 200 +#define IGNORE_MOD_TAP_INTERRUPT // this makes it possible to do rolling combos (zx) with keys that convert to other keys on hold (z becomes ctrl when you hold it, and when this option isn't enabled, z rapidly followed by x actually sends Ctrl-x. That's bad.) + + +/* key combination for command */ +#define IS_COMMAND() ( \ + get_mods() == (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) \ +) + +/* fix space cadet rollover issue */ +#define DISABLE_SPACE_CADET_ROLLOVER + +/* NKRO */ +#ifndef FORCE_NKRO + #define FORCE_NKRO // Depends on NKRO_ENABLE. +#endif diff --git a/keyboards/ydkb/mountain/keymaps/default/keymap.c b/keyboards/ydkb/mountain/keymaps/default/keymap.c new file mode 100644 index 00000000000..933ea84044b --- /dev/null +++ b/keyboards/ydkb/mountain/keymaps/default/keymap.c @@ -0,0 +1,38 @@ +/* +Copyright 2022 + +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 QMK_KEYBOARD_H + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + +[0] = LAYOUT_default( + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, + KC_LCTL, KC_LALT, KC_SPC, MO(1), KC_SPC, KC_RGUI, KC_LEFT, KC_DOWN, KC_RGHT +), + +[1] = LAYOUT_default( + KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, + _______, _______, _______, _______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______ +), + +}; diff --git a/keyboards/ydkb/mountain/keymaps/hsuchil/config.h b/keyboards/ydkb/mountain/keymaps/hsuchil/config.h new file mode 100644 index 00000000000..0572575b30d --- /dev/null +++ b/keyboards/ydkb/mountain/keymaps/hsuchil/config.h @@ -0,0 +1,24 @@ +/* +Copyright 2022 Hector Galindo + +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 . +*/ + +#pragma once + +#ifdef TAPPING_TERM +#undef TAPPING_TERM +#endif + +#define TAPPING_TERM 150 diff --git a/keyboards/ydkb/mountain/keymaps/hsuchil/keymap.c b/keyboards/ydkb/mountain/keymaps/hsuchil/keymap.c new file mode 100644 index 00000000000..214c49a1251 --- /dev/null +++ b/keyboards/ydkb/mountain/keymaps/hsuchil/keymap.c @@ -0,0 +1,55 @@ +/* +Copyright 2022 Hector Galindo + +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 QMK_KEYBOARD_H +#include "hsuchil.h" + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + +[_BSE] = LAYOUT_default( + KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, + RCT_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, L_BHGH, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, TD_RSFTUP, KC_HYPR, + KC_LCTL, KC_LALT, KC_SPC, L_LOW, KC_SPC, KC_RGUI, KC_LEFT, KC_DOWN, KC_RGHT +), + +[_LOW] = LAYOUT_default( + _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, + _______, _______, _______, _______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, + KC_CAPS, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, TOG_MAC, _______, _______, _______, KC_PGUP, _______, + _______, _______, KC_HYPR, _______, KC_MEH, _______, KC_HOME, KC_PGDN, KC_END +), + +[_HGH] = LAYOUT_default( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_VOLU, _______, + _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_MPLY +), + +[_FNC] = LAYOUT_default( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______ +), + +}; diff --git a/keyboards/ydkb/mountain/keymaps/hsuchil/rules.mk b/keyboards/ydkb/mountain/keymaps/hsuchil/rules.mk new file mode 100644 index 00000000000..1e5b99807cb --- /dev/null +++ b/keyboards/ydkb/mountain/keymaps/hsuchil/rules.mk @@ -0,0 +1 @@ +VIA_ENABLE = yes diff --git a/keyboards/ydkb/mountain/led.c b/keyboards/ydkb/mountain/led.c new file mode 100644 index 00000000000..d8eeeb1b77f --- /dev/null +++ b/keyboards/ydkb/mountain/led.c @@ -0,0 +1,36 @@ +/* +Copyright 2011 Jun Wako + +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 +#include "stdint.h" +#include "led.h" + + +void led_set_user(uint8_t usb_led) +{ + if (usb_led & (1< +#include +#include +#include "wait.h" +#include "action_layer.h" +#include "print.h" +#include "debug.h" +#include "util.h" +#include "timer.h" +#include "matrix.h" +#include "switch_board.h" + +#define DEBOUNCE_DN_MASK (uint8_t)(~(0x80 >> 5)) +#define DEBOUNCE_UP_MASK (uint8_t)(0x80 >> 5) + +static matrix_row_t matrix[MATRIX_ROWS] = {0}; + +static uint16_t matrix_scan_timestamp = 0; +static uint8_t matrix_debouncing[MATRIX_ROWS][MATRIX_COLS] = {0}; +static void select_next_key(uint8_t mode); +static uint8_t get_key(uint8_t col); + +static void init_cols(void); +__attribute__ ((weak)) +void matrix_scan_user(void) {} + +__attribute__ ((weak)) +void matrix_scan_kb(void) { + matrix_scan_user(); +} + +inline +uint8_t matrix_rows(void) +{ + return MATRIX_ROWS; +} + +inline +uint8_t matrix_cols(void) +{ + return MATRIX_COLS; +} + +static void get_key_ready(void) { + DDRB &= ~(1<<3); + PORTB |= (1<<3); + _delay_us(5); +} + +inline void select_key_ready(void) { + DDRB |= (1<<3); +} + + +void matrix_init(void) +{ + init_cols(); +} + +uint8_t matrix_scan(void) +{ + uint16_t time_check = timer_read(); + if (matrix_scan_timestamp == time_check) return 1; + matrix_scan_timestamp = time_check; + + select_next_key(0); + uint8_t *debounce = &matrix_debouncing[0][0]; + for (uint8_t row=0; row= 8) select_next_key(1); + *debounce = (*debounce >> 1) | key; + if ((*debounce > 0) && (*debounce < 255)) { + matrix_row_t *p_row = &matrix[row]; + matrix_row_t col_mask = ((matrix_row_t)1 << real_col); + if (*debounce >= DEBOUNCE_DN_MASK) { + *p_row |= col_mask; + } else if (*debounce <= DEBOUNCE_UP_MASK) { + *p_row &= ~col_mask; + } + } + + } + } + + matrix_scan_quantum(); + return 1; +} + + +inline +bool matrix_is_on(uint8_t row, uint8_t col) +{ + return (matrix[row] & ((matrix_row_t)1<. + */ + +#pragma once + +#define ___ KC_NO + +#include "quantum.h" + +#define LAYOUT_default( \ + K00, K01, K02, K03, K04, K05, K06, K49, K4A, K4B, K4C, K4D, K4E, K48, \ + K07, K10, K11, K12, K13, K14, K39, K3A, K3B, K3C, K3D, K3E, K3F, K38, \ + K17, K20, K21, K22, K16, K15, K29, K2A, K2B, K2C, K2D, K2E, K28, \ + K27, K31, K26, K25, K24, K23, K19, K1A, K1B, K1C, K1D, K1E, K1F, K18, \ + K37, K35, K34, K33, K0A, K0B, K0C, K0F, K08 \ +) { \ + { K00, K01, K02, K03, K04, K05, K06, K07, K08, ___, K0A, K0B, K0C, ___, ___, K0F }, \ + { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F }, \ + { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, ___ }, \ + { ___, K31, ___, K33, K34, K35, ___, K37, K38, K39, K3A, K3B, K3C, K3D, K3E, K3F }, \ + { ___, ___, ___, ___, ___, ___, ___, ___, K48, K49, K4A, K4B, K4C, K4D, K4E, ___ } \ +} + +#define LAYOUT_split_backspace( \ + K00, K01, K02, K03, K04, K05, K06, K49, K4A, K4B, K4C, K4D, K4E, K4F, K48, \ + K07, K10, K11, K12, K13, K14, K39, K3A, K3B, K3C, K3D, K3E, K3F, K38, \ + K17, K20, K21, K22, K16, K15, K29, K2A, K2B, K2C, K2D, K2E, K28, \ + K27, K31, K26, K25, K24, K23, K19, K1A, K1B, K1C, K1D, K1E, K1F, K18, \ + K37, K35, K34, K33, K0A, K0B, K0C, K0F, K08 \ +) { \ + { K00, K01, K02, K03, K04, K05, K06, K07, K08, ___, K0A, K0B, K0C, ___, ___, K0F }, \ + { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, K1E, K1F }, \ + { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, K2D, K2E, ___ }, \ + { ___, K31, ___, K33, K34, K35, ___, K37, K38, K39, K3A, K3B, K3C, K3D, K3E, K3F }, \ + { ___, ___, ___, ___, ___, ___, ___, ___, K48, K49, K4A, K4B, K4C, K4D, K4E, K4F } \ +} + diff --git a/keyboards/ydkb/mountain/rules.mk b/keyboards/ydkb/mountain/rules.mk new file mode 100644 index 00000000000..f19adf3e960 --- /dev/null +++ b/keyboards/ydkb/mountain/rules.mk @@ -0,0 +1,30 @@ +# MCU name +MCU = atmega32u4 + +# Processor frequency +F_CPU = 8000000 + +# Bootloader selection +BOOTLOADER = lufa-ms +BOOTLOADER_SIZE = 6144 + +# Build Options +# change yes to no to disable +# +CUSTOM_MATRIX = yes # Custom matrix file +UNICODE_ENABLE = yes # Unicode +BOOTMAGIC_ENABLE = yes # Enable Bootmagic Lite +MOUSEKEY_ENABLE = yes # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +CONSOLE_ENABLE = no # Console for debug +COMMAND_ENABLE = no # Commands for debug and configuration +NKRO_ENABLE = yes # Enable N-Key Rollover +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +SWAP_HANDS_ENABLE = no # Disable Onehand +RGBLIGHT_ENABLE = no + +# project specific files +SRC = \ + led.c \ + matrix.c \ + diff --git a/keyboards/ydkb/mountain/switch_board.h b/keyboards/ydkb/mountain/switch_board.h new file mode 100644 index 00000000000..7b4ec0b1716 --- /dev/null +++ b/keyboards/ydkb/mountain/switch_board.h @@ -0,0 +1,18 @@ +#ifndef SWITCH_BOARD_H +#define SWITCH_BOARD_H + +#include +#include +#include + +#define DS_PL_HI() (PORTB |= (1< + +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 QMK_KEYBOARD_H + +#include "process_tap_dance.h" + +#include "hsuchil.h" + +#define TD_FN(FN_NAME) void FN_NAME(qk_tap_dance_state_t *state, void *user_data) +#define TD_ON_EACH_TAP_FN_N(T) T##_on_each_tap +#define TD_ON_EACH_TAP_FN(T) TD_FN(TD_ON_EACH_TAP_FN_N(T)) +#define TD_ON_DANCE_FINISHED_FN_N(T) T##_on_dance_finished +#define TD_ON_DANCE_FINISHED_FN(T) TD_FN(TD_ON_DANCE_FINISHED_FN_N(T)) +#define TD_ON_DANCE_RESET_FN_N(T) T##_on_dance_reset +#define TD_ON_DANCE_RESET_FN(T) TD_FN(TD_ON_DANCE_RESET_FN_N(T)) + +#define ACTION_TD_DEF(T,E,F,R) [T] = ACTION_TAP_DANCE_FN_ADVANCED(E,F,R) +#define ACTION_TD_DEF_FULL(T) ACTION_TD_DEF(T, TD_ON_EACH_TAP_FN_N(T), TD_ON_DANCE_FINISHED_FN_N(T), TD_ON_DANCE_RESET_FN_N(T)) +#define ACTION_TD_DEF_NO_EACH(T) ACTION_TD_DEF(T, NULL, TD_ON_DANCE_FINISHED_FN_N(T), TD_ON_DANCE_RESET_FN_N(T)) +#define ACTION_TD_DEF_NO_FINISHED(T) ACTION_TD_DEF(T, TD_ON_EACH_TAP_FN_N(T), NULL, TD_ON_DANCE_RESET_FN_N(T)) +#define ACTION_TD_DEF_NO_RESET(T) ACTION_TD_DEF(T, TD_ON_EACH_TAP_FN_N(T), TD_ON_DANCE_FINISHED_FN_N(T), NULL) +#define ACTION_TD_DEF_ONLY_EACH(T) ACTION_TD_DEF(T, TD_ON_EACH_TAP_FN_N(T), NULL, NULL) +#define ACTION_TD_DEF_ONLY_FINISHED(T) ACTION_TD_DEF(T, NULL, TD_ON_DANCE_FINISHED_FN_N(T), NULL) +#define ACTION_TD_DEF_ONLY_RESET(T) ACTION_TD_DEF(T, NULL, NULL, TD_ON_DANCE_RESET_FN_N(T)) + +#define SIMPLE_DANCE_STATE cur_dance_simple(state) +#define DANCE_STATE cur_dance(state) + +typedef enum { + TD_NONE, + TD_UNKNOWN, + TD_TAP, + TD_HOLD, + TD_SINGLE_TAP, + TD_SINGLE_HOLD, + TD_DOUBLE_TAP, + TD_DOUBLE_HOLD +} td_state_t; + +td_state_t cur_dance_simple(qk_tap_dance_state_t *state) { + if (!state->pressed) return TD_TAP; + return TD_HOLD; +} + +td_state_t cur_dance(qk_tap_dance_state_t *state) { + if (state->count == 1) { + if (!state->pressed) return TD_SINGLE_TAP; + return TD_SINGLE_HOLD; + } + + if (state->count == 2) { + if (!state->pressed) return TD_DOUBLE_TAP; + return TD_DOUBLE_HOLD; + } + + return TD_UNKNOWN; +} + +static td_state_t rshift_up_state; + +TD_ON_DANCE_FINISHED_FN(_TD_RSHIFT_UP) { + rshift_up_state = SIMPLE_DANCE_STATE; + if (rshift_up_state == TD_HOLD) { + register_mods(MOD_BIT(KC_RSFT)); + } else { + register_code16(KC_UP); + } +} + +TD_ON_DANCE_RESET_FN(_TD_RSHIFT_UP) { + if (rshift_up_state == TD_HOLD) { + unregister_mods(MOD_BIT(KC_RSFT)); + } else { + unregister_code16(KC_UP); + } +} + +qk_tap_dance_action_t tap_dance_actions[] = { + ACTION_TD_DEF_NO_EACH(_TD_RSHIFT_UP), +}; diff --git a/users/hsuchil/hsuchil.c b/users/hsuchil/hsuchil.c index 3d91690b97e..7e824f349d0 100644 --- a/users/hsuchil/hsuchil.c +++ b/users/hsuchil/hsuchil.c @@ -44,23 +44,22 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } return false; - default: - return extra_process_record_user(keycode, record); - break; } - return true; + + return extra_process_record_user(keycode, record); } #ifdef ENCODER_ENABLE bool encoder_update_user(uint8_t index, bool clockwise) { if (index == 0) { if (clockwise) { - tap_code(KC_VOLD); - } else { tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); } } - return true; + + return false; } #endif @@ -125,3 +124,4 @@ void post_encoder_update_user(uint8_t index, bool clockwise) { extra_post_encoder_update_user(index, clockwise); } + diff --git a/users/hsuchil/hsuchil.h b/users/hsuchil/hsuchil.h index cc393ad0aa9..22ba9e22579 100644 --- a/users/hsuchil/hsuchil.h +++ b/users/hsuchil/hsuchil.h @@ -43,3 +43,13 @@ enum custom_user_keycodes { #define LCT_ESC LCTL_T(KC_ESC) // ESC if tapped, LCTL if held. #define RCT_ESC RCTL_T(KC_ESC) // ESC if tapped, RCTL if held. + +#define RSFT_UP RSFT_T(KC_UP) + +// Tap Dance + +enum tap_dance_keycodes { + _TD_RSHIFT_UP +}; + +#define TD_RSFTUP TD(_TD_RSHIFT_UP) diff --git a/users/hsuchil/rules.mk b/users/hsuchil/rules.mk index 49b58f34867..48c457d9f1c 100644 --- a/users/hsuchil/rules.mk +++ b/users/hsuchil/rules.mk @@ -1 +1,5 @@ -SRC += hsuchil.c +TAP_DANCE_ENABLE = yes + +SRC += \ + hsuchil.c \ + custom_tapdance.c