From 1bf1feb9e273934e34249fbdc9dea4966993cfe6 Mon Sep 17 00:00:00 2001 From: Raphael Mor Date: Tue, 17 Jun 2025 18:02:07 +0200 Subject: [PATCH] Added many things... --- users/raphaelmor/README.md | 9 ++- users/raphaelmor/combos.c | 98 ++++++++++++++++++++++++++++++ users/raphaelmor/combos.h | 10 +++ users/raphaelmor/config.h | 4 ++ users/raphaelmor/layers.h | 43 +++++++++++++ users/raphaelmor/layers/CMK-defs.h | 14 +++-- users/raphaelmor/layers/HDG-defs.h | 14 ++++- users/raphaelmor/layers/HDP-defs.h | 84 +++++++++++++++++++++++++ users/raphaelmor/layers/NAV-defs.h | 2 +- users/raphaelmor/raphaelmor.c | 44 ++++---------- users/raphaelmor/raphaelmor.h | 29 +-------- users/raphaelmor/rules.mk | 6 +- users/raphaelmor/tap_dance.c | 17 ++++++ users/raphaelmor/tap_dance.h | 4 +- 14 files changed, 308 insertions(+), 70 deletions(-) create mode 100644 users/raphaelmor/combos.c create mode 100644 users/raphaelmor/combos.h create mode 100644 users/raphaelmor/layers.h create mode 100644 users/raphaelmor/layers/HDP-defs.h create mode 100644 users/raphaelmor/tap_dance.c diff --git a/users/raphaelmor/README.md b/users/raphaelmor/README.md index dfad101a..71a3f97b 100644 --- a/users/raphaelmor/README.md +++ b/users/raphaelmor/README.md @@ -4,10 +4,13 @@ - ~Alpha for Colemak~ - ~Alpha for Hands Down Gold~ +- ~Alpha for Hands Down Promethium~ - ~Other Layers~ - ~All extra (Boot, base layer, layer lock, etc...)~ - ~Check Miryoku code~ -- Find a solution for Space and 't' in HDG layout (switch space and enter, and add combo for tab ?) +- ~Find a solution for Space and 't' in HDG layout (switch space and enter, and add combo for tab ?)~ +- ~switch to split 3x6 ex2 version of the layout~ +- Combos + - ~z Combo~ + - ~Qu combo + linger~ - Adaptive keys -- Combo -- switch to split 3x6 ex2 version of the layout diff --git a/users/raphaelmor/combos.c b/users/raphaelmor/combos.c new file mode 100644 index 00000000..a52d334c --- /dev/null +++ b/users/raphaelmor/combos.c @@ -0,0 +1,98 @@ +// combos +#ifdef USE_HD_H_DIGRAPH_COMBO +const uint16_t PROGMEM HD_Th_combo[] = {HD_Th_keys, COMBO_END}; // TYPE "th" in hands down +#endif +const uint16_t PROGMEM HD_Q_combo[] = {HD_Q_keys, COMBO_END}; // TYPE "q" (Qu & Linger deletes u) +const uint16_t PROGMEM HD_Z_combo[] = {HD_Z_keys, COMBO_END}; // TYPE "z" +const uint16_t PROGMEM CMK_Th_combo[] = {CMK_Th_keys, COMBO_END}; // TYPE "th" in colemak + +combo_t key_combos[] = { + // Hands Down (Gold and Promethium) combos +#ifdef USE_HD_H_DIGRAPH_COMBO + [HD_COMBO_Th] = COMBO_ACTION(HD_Th_combo), + #endif + [HD_COMBO_Q] = COMBO_ACTION(HD_Q_combo), + [HD_COMBO_Z] = COMBO(HD_Z_combo, KC_Z), + // Colemak combos + [CMK_COMBO_Th] = COMBO_ACTION(CMK_Th_combo), +}; + +uint8_t current_combo = 0; // for combo actions to hold before triggering + +uint8_t ramo_process_combo_pressed(uint16_t combo_index); +void ramo_process_combo_released(uint16_t combo_index); + +void process_combo_event(uint16_t combo_index, bool pressed) { + if (pressed) { + current_combo = ramo_process_combo_pressed(combo_index); + if (current_combo != NO_COMBO) { + linger_timer = timer_read(); + } + } else { + ramo_process_combo_released(combo_index); + current_combo = NO_COMBO; + } +} + +// return the current combo, if it's a lingering combo +uint8_t ramo_process_combo_pressed(uint16_t combo_index) { + if (saved_modifiers & (MOD_MASK_ALT | MOD_MASK_GUI | MOD_MASK_CTRL)) { + // if alt, gui, or ctrl is pressed, don't handle combos + return 0; + } + + switch(combo_index) { +#ifdef USE_HD_H_DIGRAPH_COMBO + case HD_COMBO_Th: +#endif + case CMK_COMBO_Th: + if (is_caps_word_on()) { + tap_code16(S(KC_T)); // send "T" + tap_code16(S(KC_H)); // send "H" + } else { + tap_code(KC_T); // send "T" honoring caps + unregister_mods(MOD_MASK_SHIFT); + tap_code(KC_H); // send "h" honoring CAPSLK state + } + break; + case HD_COMBO_Q: + println("RAMO: Pressed N + H to type qu"); + if (is_caps_word_on()) { + tap_code16(S(KC_Q)); + tap_code16(S(KC_U)); + } else { + tap_code16(KC_Q); + unregister_mods(MOD_MASK_SHIFT); + tap_code16(KC_U); + } + return combo_index; // if held, delete the 'u' in matrix_scan_user_process_combo + } + return 0; +} + +void ramo_process_combo_released(uint16_t combo_index) { + switch(combo_index) { +#ifdef USE_HD_H_DIGRAPH_COMBO + case HD_COMBO_Th: +#endif + case CMK_COMBO_Th: + break; + case HD_COMBO_Q: + println("RAMO: Released N + H to type qu"); + } +} + +void matrix_scan_user(void) { + if ((timer_elapsed(linger_timer) > RAMO_COMBO_HOLD) && current_combo) { + println("RAMO: TRIGGERING COMBO_HOLD"); + uint16_t saved_mods = get_mods(); + clear_mods(); + switch (current_combo) { + case HD_COMBO_Q: + tap_code16(KC_BSPC); // held, so delete u + break; + } + current_combo = NO_COMBO; + set_mods(saved_mods); + } +} diff --git a/users/raphaelmor/combos.h b/users/raphaelmor/combos.h new file mode 100644 index 00000000..92fe13ba --- /dev/null +++ b/users/raphaelmor/combos.h @@ -0,0 +1,10 @@ + +enum ramo_combos { + NO_COMBO = 0, // Sentinel value (0) to signify no combo is currently pressed +#ifdef USE_HD_H_DIGRAPH_COMBO + HD_COMBO_Th, +#endif + HD_COMBO_Q, + HD_COMBO_Z, + CMK_COMBO_Th, +}; diff --git a/users/raphaelmor/config.h b/users/raphaelmor/config.h index a084a233..97a4ad1e 100644 --- a/users/raphaelmor/config.h +++ b/users/raphaelmor/config.h @@ -23,3 +23,7 @@ #define MOUSEKEY_MAX_SPEED 6 #undef MOUSEKEY_TIME_TO_MAX #define MOUSEKEY_TIME_TO_MAX 64 + + +// CUSTOM CONFIG +#define RAMO_COMBO_HOLD (TAPPING_TERM) // time to hold to trigger delayed combo diff --git a/users/raphaelmor/layers.h b/users/raphaelmor/layers.h new file mode 100644 index 00000000..27785373 --- /dev/null +++ b/users/raphaelmor/layers.h @@ -0,0 +1,43 @@ +#include "layers/CMK-defs.h" +#ifdef USE_HD_PROMETHIUM +#include "layers/HDP-defs.h" +#else +#include "layers/HDG-defs.h" +#endif +#include "layers/MED-defs.h" +#include "layers/NAV-defs.h" +#include "layers/MOS-defs.h" +#include "layers/NUM-defs.h" +#include "layers/SYM-defs.h" +#include "layers/FUN-defs.h" + + +#ifdef USE_HD_PROMETHIUM +#define RAMO_FOR_EACH_LAYER \ +RAMO_DO(COLEMAK, CMK) \ +RAMO_DO(HANDSDOWN, HDP) \ +RAMO_DO(NAV, NAV) \ +RAMO_DO(MOUSE, MOS) \ +RAMO_DO(MEDIA, MED) \ +RAMO_DO(NUM, NUM) \ +RAMO_DO(SYM, SYM) \ +RAMO_DO(FUN, FUN) +#else // use HD_GOLD +#define RAMO_FOR_EACH_LAYER \ +RAMO_DO(COLEMAK, CMK) \ +RAMO_DO(HANDSDOWN, HDG) \ +RAMO_DO(NAV, NAV) \ +RAMO_DO(MOUSE, MOS) \ +RAMO_DO(MEDIA, MED) \ +RAMO_DO(NUM, NUM) \ +RAMO_DO(SYM, SYM) \ +RAMO_DO(FUN, FUN) +#endif + + +enum ramo_layers { +#define RAMO_DO(LAYER, STRING) L_##LAYER, +RAMO_FOR_EACH_LAYER +#undef RAMO_DO +}; + diff --git a/users/raphaelmor/layers/CMK-defs.h b/users/raphaelmor/layers/CMK-defs.h index 8c92eb4a..38e60366 100644 --- a/users/raphaelmor/layers/CMK-defs.h +++ b/users/raphaelmor/layers/CMK-defs.h @@ -7,22 +7,22 @@ #define CMK_C KC_C #define CMK_D KC_D #define CMK_E RGUI_T(KC_E) -#define CMK_F KC_F +#define CMK_F HYPR_T(KC_F) #define CMK_G KC_G #define CMK_H KC_H #define CMK_I RALT_T(KC_I) #define CMK_J KC_J #define CMK_K KC_K -#define CMK_L KC_L +#define CMK_L MEH_T(KC_L) #define CMK_M KC_M #define CMK_N RSFT_T(KC_N) #define CMK_O RCTL_T(KC_O) -#define CMK_P KC_P +#define CMK_P MEH_T(KC_P) #define CMK_Q KC_Q #define CMK_R LALT_T(KC_R) #define CMK_S LGUI_T(KC_S) #define CMK_T LSFT_T(KC_T) -#define CMK_U KC_U +#define CMK_U HYPR_T(KC_U) #define CMK_V KC_V #define CMK_W KC_W #define CMK_X KC_X @@ -126,3 +126,9 @@ #define CMK_RH0 CMK_ENT #define CMK_RH1 CMK_BSPC #define CMK_RH2 CMK_DEL + + +// H digraph combos +// try to make these use the lead letter and a neighbor. +// +#define CMK_Th_keys CMK_LM2, CMK_LM1 // TYPE "st" to write "th" diff --git a/users/raphaelmor/layers/HDG-defs.h b/users/raphaelmor/layers/HDG-defs.h index 6229a1b9..9a090b3b 100644 --- a/users/raphaelmor/layers/HDG-defs.h +++ b/users/raphaelmor/layers/HDG-defs.h @@ -64,7 +64,7 @@ // │ ESC J G M P V │ │ ; . / " ' HYP │ // │ TAB R S N D B │ │ , A E I H MEH │ // │ Z X F L C W │ │ - U O Y K Q │ -// ╰───────────╮ ESC SPC T │ │ ENT BSP DEL ╭───────────╯ +// ╰───────────╮ ESC TAB T │ │ SPC ENT BSP ╭───────────╯ // ╰─────────────╯ ╰─────────────╯ // @@ -121,3 +121,15 @@ #define HDG_RH0 HDG_SPC #define HDG_RH1 HDG_ENT #define HDG_RH2 HDG_BSPC + + +// H digraph combos +// try to make these use the lead letter and a neighbor. +#define USE_HD_H_DIGRAPH_COMBO +#define HD_Th_keys HDG_LM2, HDG_LM1 // TYPE "nd" to write "th" + +// type g + p to type q +#define HD_Q_keys HDP_LT3, HDP_LT1 + +// type s + d to type z +#define HD_Z_keys HDP_LM3, HDP_LM1 diff --git a/users/raphaelmor/layers/HDP-defs.h b/users/raphaelmor/layers/HDP-defs.h new file mode 100644 index 00000000..f87ff78f --- /dev/null +++ b/users/raphaelmor/layers/HDP-defs.h @@ -0,0 +1,84 @@ +#pragma once + +// Let's place these HD keycodes on the keymap +// for variation independent spatial referencing by key position +// +// Key Position Names for a 42 key split form factor +// Should cover Corne v4.1 +// ╭───────────────────────────────╮ ╭───────────────────────────────╮ +// │ LT5 LT4 LT3 LT2 LT1 LT0 LTA │ │ RTA RT0 RT1 RT2 RT3 RT4 RT5 │ +// │ LM5 LM4 LM3 LM2 LM1 LM0 LMA │ │ RMA RM0 RM1 RM2 RM3 RM4 RM5 │ +// │ LB5 LB4 LB3 LB2 LB1 LB0 ╭─────╯ ╰─────╮ RB0 RB1 RB2 RB3 RB4 RB5 │ +// ╰───────────╮ LH2 LH1 LH0 │ │ RH0 RH1 RH2 ╭───────────╯ +// ╰─────────────╯ ╰─────────────╯ +// +// +// Base (alpha) Layer Hands Down Promethium (HRMs /+ thumb mods) +// ╭───────────────────────────────╮ ╭───────────────────────────────╮ +// │ ESC F P D L X LTA │ │ RTA ; U O Y B Z │ +// │ TAB S N T H K LMA │ │ RMA , A E I C Q │ +// │ \ V W G M J ╭─────╯ ╰─────╮ - . ' = / ENT │ +// ╰───────────╮ ESC TAB R │ │ SPC ENT BSP ╭───────────╯ +// ╰─────────────╯ ╰─────────────╯ +// + +#define HDP_LT5 KC_TAB +#define HDP_LT4 KC_F +#define HDP_LT3 KC_P +#define HDP_LT2 HYPR_T(KC_D) +#define HDP_LT1 MEH_T(KC_L) +#define HDP_LT0 KC_X +#define HDP_LTA KC_NO // TODO: should be a real key once a use is found + +#define HDP_RTA KC_NO // TODO: should be a real key once a use is found +#define HDP_RT0 KC_SCLN +#define HDP_RT1 MEH_T(KC_U) +#define HDP_RT2 HYPR_T(KC_O) +#define HDP_RT3 KC_Y +#define HDP_RT4 KC_B +#define HDP_RT5 KC_Z + +#define HDP_LM5 KC_TAB +#define HDP_LM4 LCTL_T(KC_S) +#define HDP_LM3 LALT_T(KC_N) +#define HDP_LM2 LGUI_T(KC_T) +#define HDP_LM1 LSFT_T(KC_H) +#define HDP_LM0 KC_K +#define HDP_LMA KC_NO // TODO: should be a real key once a use is found + +#define HDP_RMA KC_NO // TODO: should be a real key once a use is found +#define HDP_RM0 KC_COMM +#define HDP_RM1 RSFT_T(KC_A) +#define HDP_RM2 RGUI_T(KC_E) +#define HDP_RM3 RALT_T(KC_I) +#define HDP_RM4 RCTL_T(KC_C) +#define HDP_RM5 KC_Q + +#define HDP_LB5 KC_BSLS +#define HDP_LB4 KC_V +#define HDP_LB3 KC_W +#define HDP_LB2 KC_G +#define HDP_LB1 KC_M +#define HDP_LB0 KC_J + +#define HDP_RB0 KC_MINS +#define HDP_RB1 KC_DOT +#define HDP_RB2 KC_QUOT +#define HDP_RB3 KC_EQL +#define HDP_RB4 KC_SLSH +#define HDP_RB5 KC_ENT + +//Primary Thumbs 1-3 (others are unique to the board) +#define HDP_LH2 LT(L_MEDIA, KC_ESC) +#define HDP_LH1 LT(L_NAV, KC_TAB) +#define HDP_LH0 LT(L_MOUSE, KC_R) +#define HDP_RH0 LT(L_SYM, KC_SPC) +#define HDP_RH1 LT(L_NUM, KC_ENT) +#define HDP_RH2 LT(L_FUN, KC_BSPC) + +// type p + l to type q +#define HD_Q_keys HDP_LT3, HDP_LT1 + +// type n + h to type z +#define HD_Z_keys HDP_LM3, HDP_LM1 + diff --git a/users/raphaelmor/layers/NAV-defs.h b/users/raphaelmor/layers/NAV-defs.h index db6bcd75..9c88057a 100644 --- a/users/raphaelmor/layers/NAV-defs.h +++ b/users/raphaelmor/layers/NAV-defs.h @@ -21,7 +21,7 @@ #define NAV_LT4 NAV_NO #define NAV_LT3 NAV_NO #define NAV_LT2 TD(RAMO_TD_CMK) -#define NAV_LT1 TD(RAMO_TD_HDG) +#define NAV_LT1 TD(RAMO_TD_HD) #define NAV_LT0 NAV_NO #define NAV_LTA KC_NO // TODO: should be a real key once a use is found diff --git a/users/raphaelmor/raphaelmor.c b/users/raphaelmor/raphaelmor.c index 7c72ce4a..8f794e54 100644 --- a/users/raphaelmor/raphaelmor.c +++ b/users/raphaelmor/raphaelmor.c @@ -1,43 +1,25 @@ #include QMK_KEYBOARD_H #include "raphaelmor.h" - -void ramo_TD_make_colemak_default(tap_dance_state_t *state, void *user_data) { - if (state->count == 2) { - set_single_default_layer(L_COLEMAK); - } -}; -void ramo_TD_make_hd_gold_default(tap_dance_state_t *state, void *user_data) { - if (state->count == 2) { - set_single_default_layer(L_HANDSDOWN); - } -}; - -tap_dance_action_t tap_dance_actions[] = { - [RAMO_TD_CMK] = ACTION_TAP_DANCE_FN(ramo_TD_make_colemak_default), - [RAMO_TD_HDG] = ACTION_TAP_DANCE_FN(ramo_TD_make_hd_gold_default), -}; - - void keyboard_post_init_user(void) { // Customise these values to desired behaviour debug_enable=true; - debug_keyboard=true; - debug_mouse=true; + // debug_keyboard=true; + // debug_mouse=true; }; +// Info shared by subroutines (tap_dance, combos, etc..) +uint8_t saved_modifiers; +uint32_t linger_timer = 0; // time elapsed since combo was pressed // process - bool process_record_user(uint16_t keycode, keyrecord_t *record) { - bool return_state = true; - // uint8_t saved_mods; - // saved_mods = get_mods(); - - if (record->event.pressed == true) { - println("ramo: key pressed"); - } else { - println("ramo: key released"); - } - return return_state; + saved_modifiers = get_mods(); // share modifiers + return true; } + +// Include tap_dance processing code +#include "tap_dance.c" + +// Include combo processing code +#include "combos.c" diff --git a/users/raphaelmor/raphaelmor.h b/users/raphaelmor/raphaelmor.h index b85c9dc5..ea7dc748 100644 --- a/users/raphaelmor/raphaelmor.h +++ b/users/raphaelmor/raphaelmor.h @@ -1,30 +1,7 @@ #pragma once #include "tap_dance.h" +#include "combos.h" -#include "layers/CMK-defs.h" -#include "layers/HDG-defs.h" -#include "layers/MED-defs.h" -#include "layers/NAV-defs.h" -#include "layers/MOS-defs.h" -#include "layers/NUM-defs.h" -#include "layers/SYM-defs.h" -#include "layers/FUN-defs.h" - -#define RAMO_FOR_EACH_LAYER \ -RAMO_DO(COLEMAK, CMK) \ -RAMO_DO(HANDSDOWN, HDG) \ -RAMO_DO(NAV, NAV) \ -RAMO_DO(MOUSE, MOS) \ -RAMO_DO(MEDIA, MED) \ -RAMO_DO(NUM, NUM) \ -RAMO_DO(SYM, SYM) \ -RAMO_DO(FUN, FUN) - - -enum ramo_layers { -#define RAMO_DO(LAYER, STRING) L_##LAYER, -RAMO_FOR_EACH_LAYER -#undef RAMO_DO -}; - +#define USE_HD_PROMETHIUM // (Gold is the default) +#include "layers.h" diff --git a/users/raphaelmor/rules.mk b/users/raphaelmor/rules.mk index d10b2324..80e92cb3 100644 --- a/users/raphaelmor/rules.mk +++ b/users/raphaelmor/rules.mk @@ -1,8 +1,12 @@ TAP_DANCE_ENABLE = yes MOUSEKEY_ENABLE = yes -AUTO_SHIFT_ENABLE = yes +AUTO_SHIFT_ENABLE = no CAPS_WORD_ENABLE = yes CONSOLE_ENABLE = yes +COMBO_ENABLE = yes INTROSPECTION_KEYMAP_C += raphaelmor.c +RGBLIGHT_ENABLE = no +RGB_MATRIX_ENABLE = no + diff --git a/users/raphaelmor/tap_dance.c b/users/raphaelmor/tap_dance.c new file mode 100644 index 00000000..33f2ba06 --- /dev/null +++ b/users/raphaelmor/tap_dance.c @@ -0,0 +1,17 @@ +void ramo_TD_make_colemak_default(tap_dance_state_t *state, void *user_data) { + if (state->count == 2) { + set_single_default_layer(L_COLEMAK); + } +}; + +void ramo_TD_make_handsdown_default(tap_dance_state_t *state, void *user_data) { + if (state->count == 2) { + set_single_default_layer(L_HANDSDOWN); + } +}; + +tap_dance_action_t tap_dance_actions[] = { + [RAMO_TD_CMK] = ACTION_TAP_DANCE_FN(ramo_TD_make_colemak_default), + [RAMO_TD_HD] = ACTION_TAP_DANCE_FN(ramo_TD_make_handsdown_default), +}; + diff --git a/users/raphaelmor/tap_dance.h b/users/raphaelmor/tap_dance.h index 42d0b1f0..6d26f516 100644 --- a/users/raphaelmor/tap_dance.h +++ b/users/raphaelmor/tap_dance.h @@ -1,8 +1,6 @@ -#pragma once - // Tap Dance definitions enum { RAMO_TD_CMK, - RAMO_TD_HDG, + RAMO_TD_HD, };