diff --git a/keyboards/crkbd/keymaps/sajenim/combos.def b/keyboards/crkbd/keymaps/sajenim/combos.def index 20acc34..0fa05e5 100644 --- a/keyboards/crkbd/keymaps/sajenim/combos.def +++ b/keyboards/crkbd/keymaps/sajenim/combos.def @@ -1,12 +1,18 @@ // clang-format off -// name result 1st chord key 2nd chord key -COMB(NE_ESC, KC_ESC, RCTL_T(KC_N), RSFT_T(KC_E)) -COMB(SE_CAP, CW_TOGG, LSFT_T(KC_S), RSFT_T(KC_E)) -COMB(THUMB_SLEEP, KC_SLEP, LT(NAV, KC_SPC), KC_ENT) -COMB(ST_MOD, TG(MOD), LSFT_T(KC_S), LCTL_T(KC_T)) -SUBS(YP_HOME, "~/", KC_Y, KC_P) -SUBS(FO_UPDIR, "../", KC_F, KC_O) +// name result 1st chord key 2nd chord key 3rd chord key +SUBS(LY_CD, "cd ", KC_L, KC_Y) +SUBS(YP_LS, "ls ", KC_Y, KC_P) +SUBS(FO_HOME, "~/", KC_F, KC_O) +SUBS(OU_UPDIR, "../", KC_O, KC_U) +COMB(RS_TAB, KC_TAB, LALT_T(KC_R), LSFT_T(KC_S)) +COMB(ST_BSPC, KC_BSPC, LSFT_T(KC_S), LCTL_T(KC_T)) +COMB(NE_ESC, KC_ESC, RCTL_T(KC_N), RSFT_T(KC_E)) +COMB(EI_ENT, KC_ENT, RSFT_T(KC_E), RALT_T(KC_I)) +SUBS(NEI_SAVE, SS_TAP(X_ESC)":w"SS_TAP(X_ENT), RCTL_T(KC_N), RSFT_T(KC_E), RALT_T(KC_I)) +SUBS(JV_COLN, ":", KC_J, KC_V) +SUBS(SLSDOT_SCLN, ";", KC_SLSH, KC_COMM) +COMB(SE_CAP, CW_TOGG, LSFT_T(KC_S), RSFT_T(KC_E)) /* vim: set filetype=c: */ diff --git a/keyboards/crkbd/keymaps/sajenim/features/achordion.c b/keyboards/crkbd/keymaps/sajenim/features/achordion.c deleted file mode 100644 index 3d62f6b..0000000 --- a/keyboards/crkbd/keymaps/sajenim/features/achordion.c +++ /dev/null @@ -1,283 +0,0 @@ -// Copyright 2022-2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file achordion.c - * @brief Achordion implementation - * - * For full documentation, see - * - */ - -#include "achordion.h" - -#if !defined(IS_QK_MOD_TAP) -// Attempt to detect out-of-date QMK installation, which would fail with -// implicit-function-declaration errors in the code below. -#error "achordion: QMK version is too old to build. Please update QMK." -#else - -// Copy of the `record` and `keycode` args for the current active tap-hold key. -static keyrecord_t tap_hold_record; -static uint16_t tap_hold_keycode = KC_NO; -// Timeout timer. When it expires, the key is considered held. -static uint16_t hold_timer = 0; -// Eagerly applied mods, if any. -static uint8_t eager_mods = 0; -// Flag to determine whether another key is pressed within the timeout. -static bool pressed_another_key_before_release = false; - -#ifdef ACHORDION_STREAK -// Timer for typing streak -static uint16_t streak_timer = 0; -#else -// When disabled, is_streak is never true -#define is_streak false -#endif - -// Achordion's current state. -enum { - // A tap-hold key is pressed, but hasn't yet been settled as tapped or held. - STATE_UNSETTLED, - // Achordion is inactive. - STATE_RELEASED, - // Active tap-hold key has been settled as tapped. - STATE_TAPPING, - // Active tap-hold key has been settled as held. - STATE_HOLDING, - // This state is set while calling `process_record()`, which will recursively - // call `process_achordion()`. This state is checked so that we don't process - // events generated by Achordion and potentially create an infinite loop. - STATE_RECURSING, -}; -static uint8_t achordion_state = STATE_RELEASED; - -// Calls `process_record()` with state set to RECURSING. -static void recursively_process_record(keyrecord_t* record, uint8_t state) { - achordion_state = STATE_RECURSING; - process_record(record); - achordion_state = state; -} - -// Clears eagerly-applied mods. -static void clear_eager_mods(void) { - unregister_mods(eager_mods); - eager_mods = 0; -} - -// Sends hold press event and settles the active tap-hold key as held. -static void settle_as_hold(void) { - clear_eager_mods(); - // Create hold press event. - recursively_process_record(&tap_hold_record, STATE_HOLDING); -} - -bool process_achordion(uint16_t keycode, keyrecord_t* record) { - // Don't process events that Achordion generated. - if (achordion_state == STATE_RECURSING) { - return true; - } - - // If this is a keypress and if the key is different than the tap-hold key, - // this information is saved to a flag to be processed later when the tap-hold - // key is released. - if (!pressed_another_key_before_release && record->event.pressed && - tap_hold_keycode != KC_NO && tap_hold_keycode != keycode) { - pressed_another_key_before_release = true; - } - - // Determine whether the current event is for a mod-tap or layer-tap key. - const bool is_mt = IS_QK_MOD_TAP(keycode); - const bool is_tap_hold = is_mt || IS_QK_LAYER_TAP(keycode); - // Check that this is a normal key event, don't act on combos. -#ifdef IS_KEYEVENT - const bool is_key_event = IS_KEYEVENT(record->event); -#else - const bool is_key_event = - (record->event.key.row < 254 && record->event.key.col < 254); -#endif - - if (achordion_state == STATE_RELEASED) { - if (is_tap_hold && record->tap.count == 0 && record->event.pressed && - is_key_event) { - // A tap-hold key is pressed and considered by QMK as "held". - const uint16_t timeout = achordion_timeout(keycode); - if (timeout > 0) { - achordion_state = STATE_UNSETTLED; - // Save info about this key. - tap_hold_keycode = keycode; - tap_hold_record = *record; - hold_timer = record->event.time + timeout; - - if (is_mt) { // Apply mods immediately if they are "eager." - uint8_t mod = mod_config(QK_MOD_TAP_GET_MODS(tap_hold_keycode)); - if (achordion_eager_mod(mod)) { - eager_mods = ((mod & 0x10) == 0) ? mod : (mod << 4); - register_mods(eager_mods); - } - } - - dprintf("Achordion: Key 0x%04X pressed.%s\n", keycode, - eager_mods ? " Set eager mods." : ""); - return false; // Skip default handling. - } - } - -#ifdef ACHORDION_STREAK - streak_timer = (timer_read() + achordion_streak_timeout(keycode)) | 1; -#endif - return true; // Otherwise, continue with default handling. - } - - if (keycode == tap_hold_keycode && !record->event.pressed) { - // The active tap-hold key is being released. - if (achordion_state == STATE_HOLDING) { - dprintln("Achordion: Key released. Plumbing hold release."); - tap_hold_record.event.pressed = false; - // Plumb hold release event. - recursively_process_record(&tap_hold_record, STATE_RELEASED); - } else if (!pressed_another_key_before_release) { - // No other key was pressed between the press and release of the tap-hold - // key, simulate a hold and then a release without waiting for Achordion - // timeout to end. - dprintln("Achordion: Key released. Simulating hold and release."); - settle_as_hold(); - tap_hold_record.event.pressed = false; - // Plumb hold release event. - recursively_process_record(&tap_hold_record, STATE_RELEASED); - } else { - dprintf("Achordion: Key released.%s\n", - eager_mods ? " Clearing eager mods." : ""); - if (is_mt) { - clear_eager_mods(); - } - } - - achordion_state = STATE_RELEASED; - // The tap-hold key is released, clear the related keycode and the flag. - tap_hold_keycode = KC_NO; - pressed_another_key_before_release = false; - return false; - } - - if (achordion_state == STATE_UNSETTLED && record->event.pressed) { -#ifdef ACHORDION_STREAK - const bool is_streak = (streak_timer != 0); - streak_timer = (timer_read() + achordion_streak_timeout(keycode)) | 1; -#endif - - // Press event occurred on a key other than the active tap-hold key. - - // If the other key is *also* a tap-hold key and considered by QMK to be - // held, then we settle the active key as held. This way, things like - // chording multiple home row modifiers will work, but let's our logic - // consider simply a single tap-hold key as "active" at a time. - // - // Otherwise, we call `achordion_chord()` to determine whether to settle the - // tap-hold key as tapped vs. held. We implement the tap or hold by plumbing - // events back into the handling pipeline so that QMK features and other - // user code can see them. This is done by calling `process_record()`, which - // in turn calls most handlers including `process_record_user()`. - if (!is_streak && (!is_key_event || (is_tap_hold && record->tap.count == 0) || - achordion_chord(tap_hold_keycode, &tap_hold_record, keycode, record))) { - dprintln("Achordion: Plumbing hold press."); - settle_as_hold(); - } else { - clear_eager_mods(); // Clear in case eager mods were set. - - dprintln("Achordion: Plumbing tap press."); - tap_hold_record.tap.count = 1; // Revise event as a tap. - tap_hold_record.tap.interrupted = true; - // Plumb tap press event. - recursively_process_record(&tap_hold_record, STATE_TAPPING); - - send_keyboard_report(); -#if TAP_CODE_DELAY > 0 - wait_ms(TAP_CODE_DELAY); -#endif // TAP_CODE_DELAY > 0 - - dprintln("Achordion: Plumbing tap release."); - tap_hold_record.event.pressed = false; - // Plumb tap release event. - recursively_process_record(&tap_hold_record, STATE_TAPPING); - } - - recursively_process_record(record, achordion_state); // Re-process event. - return false; // Block the original event. - } - -#ifdef ACHORDION_STREAK - // update idle timer on regular keys event - streak_timer = (timer_read() + achordion_streak_timeout(keycode)) | 1; -#endif - return true; -} - -void achordion_task(void) { - if (achordion_state == STATE_UNSETTLED && - timer_expired(timer_read(), hold_timer)) { - dprintln("Achordion: Timeout. Plumbing hold press."); - settle_as_hold(); // Timeout expired, settle the key as held. - } - -#ifdef ACHORDION_STREAK - if (streak_timer && timer_expired(timer_read(), streak_timer)) { - streak_timer = 0; // Expired. - } -#endif -} - -// Returns true if `pos` on the left hand of the keyboard, false if right. -static bool on_left_hand(keypos_t pos) { -#ifdef SPLIT_KEYBOARD - return pos.row < MATRIX_ROWS / 2; -#else - return (MATRIX_COLS > MATRIX_ROWS) ? pos.col < MATRIX_COLS / 2 - : pos.row < MATRIX_ROWS / 2; -#endif -} - -bool achordion_opposite_hands(const keyrecord_t* tap_hold_record, - const keyrecord_t* other_record) { - return on_left_hand(tap_hold_record->event.key) != - on_left_hand(other_record->event.key); -} - -// By default, use the BILATERAL_COMBINATIONS rule to consider the tap-hold key -// "held" only when it and the other key are on opposite hands. -__attribute__((weak)) bool achordion_chord(uint16_t tap_hold_keycode, - keyrecord_t* tap_hold_record, - uint16_t other_keycode, - keyrecord_t* other_record) { - return achordion_opposite_hands(tap_hold_record, other_record); -} - -// By default, the timeout is 1000 ms for all keys. -__attribute__((weak)) uint16_t achordion_timeout(uint16_t tap_hold_keycode) { - return 1000; -} - -// By default, Shift and Ctrl mods are eager, and Alt and GUI are not. -__attribute__((weak)) bool achordion_eager_mod(uint8_t mod) { - return (mod & (MOD_LALT | MOD_LGUI)) == 0; -} - -#ifdef ACHORDION_STREAK -__attribute__((weak)) uint16_t achordion_streak_timeout(uint16_t tap_hold_keycode) { - return 100; // Default of 100 ms. -} -#endif - -#endif // version check - diff --git a/keyboards/crkbd/keymaps/sajenim/features/achordion.h b/keyboards/crkbd/keymaps/sajenim/features/achordion.h deleted file mode 100644 index 470f132..0000000 --- a/keyboards/crkbd/keymaps/sajenim/features/achordion.h +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright 2022-2023 Google LLC -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/** - * @file achordion.h - * @brief Achordion: Customizing the tap-hold decision. - * - * Overview - * -------- - * - * This library customizes when tap-hold keys are considered held vs. tapped - * based on the next pressed key, like Manna Harbour's Bilateral Combinations or - * ZMK's positional hold. The library works on top of QMK's existing tap-hold - * implementation. You define mod-tap and layer-tap keys as usual and use - * Achordion to fine-tune the behavior. - * - * When QMK settles a tap-hold key as held, Achordion intercepts the event. - * Achordion then revises the event as a tap or passes it along as a hold: - * - * * Chord condition: On the next key press, a customizable `achordion_chord()` - * function is called, which takes the tap-hold key and the next key pressed - * as args. When the function returns true, the tap-hold key is settled as - * held, and otherwise as tapped. - * - * * Timeout: If no other key press occurs within a timeout, the tap-hold key - * is settled as held. This is customizable with `achordion_timeout()`. - * - * Achordion only changes the behavior when QMK considered the key held. It - * changes some would-be holds to taps, but no taps to holds. - * - * @note Some QMK features handle events before the point where Achordion can - * intercept them, particularly: Combos, Key Lock, and Dynamic Macros. It's - * still possible to use these features and Achordion in your keymap, but beware - * they might behave poorly when used simultaneously with tap-hold keys. - * - * - * For full documentation, see - * - */ - -#pragma once - -#include "quantum.h" - -/** - * Suppress tap-hold mods within a *typing streak* by defining - * ACHORDION_STREAK. This can help preventing accidental mod - * activation when performing a fast tapping sequence. - * This is inspired by https://sunaku.github.io/home-row-mods.html#typing-streaks - * - * Enable with: - * - * #define ACHORDION_STREAK - * - * Adjust the maximum time between key events before modifiers can be enabled - * by defining the following callback in your keymap.c: - * - * uint16_t achordion_streak_timeout(uint16_t tap_hold_keycode) { - * return 100; // Default of 100 ms. - * } - */ -#ifdef ACHORDION_STREAK -uint16_t achordion_streak_timeout(uint16_t tap_hold_keycode); -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * Handler function for Achordion. - * - * Call this function from `process_record_user()` as - * - * #include "features/achordion.h" - * - * bool process_record_user(uint16_t keycode, keyrecord_t* record) { - * if (!process_achordion(keycode, record)) { return false; } - * // Your macros... - * return true; - * } - */ -bool process_achordion(uint16_t keycode, keyrecord_t* record); - -/** - * Matrix task function for Achordion. - * - * Call this function from `matrix_scan_user()` as - * - * void matrix_scan_user(void) { - * achordion_task(); - * } - */ -void achordion_task(void); - -/** - * Optional callback to customize which key chords are considered "held". - * - * In your keymap.c, define the callback - * - * bool achordion_chord(uint16_t tap_hold_keycode, - * keyrecord_t* tap_hold_record, - * uint16_t other_keycode, - * keyrecord_t* other_record) { - * // Conditions... - * } - * - * This callback is called if while `tap_hold_keycode` is pressed, - * `other_keycode` is pressed. Return true if the tap-hold key should be - * considered held, or false to consider it tapped. - * - * @param tap_hold_keycode Keycode of the tap-hold key. - * @param tap_hold_record keyrecord_t from the tap-hold press event. - * @param other_keycode Keycode of the other key. - * @param other_record keyrecord_t from the other key's press event. - * @return True if the tap-hold key should be considered held. - */ -bool achordion_chord(uint16_t tap_hold_keycode, keyrecord_t* tap_hold_record, - uint16_t other_keycode, keyrecord_t* other_record); - -/** - * Optional callback to define a timeout duration per keycode. - * - * In your keymap.c, define the callback - * - * uint16_t achordion_timeout(uint16_t tap_hold_keycode) { - * // ... - * } - * - * The callback determines Achordion's timeout duration for `tap_hold_keycode` - * in units of milliseconds. The timeout be in the range 0 to 32767 ms (upper - * bound is due to 16-bit timer limitations). Use a timeout of 0 to bypass - * Achordion. - * - * @param tap_hold_keycode Keycode of the tap-hold key. - * @return Timeout duration in milliseconds in the range 0 to 32767. - */ -uint16_t achordion_timeout(uint16_t tap_hold_keycode); - -/** - * Optional callback defining which mods are "eagerly" applied. - * - * This callback defines which mods are "eagerly" applied while a mod-tap - * key is still being settled. This is helpful to reduce delay particularly when - * using mod-tap keys with an external mouse. - * - * Define this callback in your keymap.c. The default callback is eager for - * Shift and Ctrl, and not for Alt and GUI: - * - * bool achordion_eager_mod(uint8_t mod) { - * return (mod & (MOD_LALT | MOD_LGUI)) == 0; - * } - * - * @note `mod` should be compared with `MOD_` prefixed codes, not `KC_` codes, - * described at . - * - * @param mod Modifier `MOD_` code. - * @return True if the modifier should be eagerly applied. - */ -bool achordion_eager_mod(uint8_t mod); - -/** - * Returns true if the args come from keys on opposite hands. - * - * @param tap_hold_record keyrecord_t from the tap-hold key's event. - * @param other_record keyrecord_t from the other key's event. - * @return True if the keys are on opposite hands. - */ -bool achordion_opposite_hands(const keyrecord_t* tap_hold_record, - const keyrecord_t* other_record); - -#ifdef __cplusplus -} -#endif - diff --git a/keyboards/crkbd/keymaps/sajenim/keymap.c b/keyboards/crkbd/keymaps/sajenim/keymap.c index 6a6407b..b8f08a4 100644 --- a/keyboards/crkbd/keymaps/sajenim/keymap.c +++ b/keyboards/crkbd/keymaps/sajenim/keymap.c @@ -15,31 +15,44 @@ */ #include QMK_KEYBOARD_H -#include "features/achordion.h" enum layers { CANARY, NAV, NUM, SYM, - MOD, + FUN, }; #include "g/keymap_combo.h" // layer names must be defined before engine include +#define NAV_REP LT(NAV, QK_REP) +#define NUM_MAG LT(NUM, QK_AREP) + +enum custom_keycodes { + TRIPDOT = SAFE_RANGE, + + // Magic Keycodes + MG_OR, + MG_ON, + MG_ER, + MG_HA, + MG_BUT +}; + /* Home Row Mods: * https://precondition.github.io/home-row-mods */ -#define MT_C LGUI_T(KC_C) -#define MT_R LALT_T(KC_R) -#define MT_S LSFT_T(KC_S) -#define MT_T LCTL_T(KC_T) -#define MT_N RCTL_T(KC_N) -#define MT_E RSFT_T(KC_E) -#define MT_I RALT_T(KC_I) -#define MT_A RGUI_T(KC_A) -#define LT_D LT(SYM, KC_D) -#define LT_H LT(SYM, KC_H) +#define HRM_C LGUI_T(KC_C) +#define HRM_R LALT_T(KC_R) +#define HRM_S LSFT_T(KC_S) +#define HRM_T LCTL_T(KC_T) +#define HRM_N RCTL_T(KC_N) +#define HRM_E RSFT_T(KC_E) +#define HRM_I RALT_T(KC_I) +#define HRM_A RGUI_T(KC_A) +#define HRM_D LT(SYM, KC_D) +#define HRM_H LT(SYM, KC_H) /* One Shot Keys: * https://github.com/qmk/qmk_firmware/blob/master/docs/one_shot_keys.md */ @@ -53,12 +66,6 @@ enum layers { #define OS_RALT OSM(MOD_RALT) #define OS_RGUI OSM(MOD_RGUI) -/* Mod Tap: - * https://github.com/qmk/qmk_firmware/blob/master/docs/mod_tap.md */ - -#define SPC_NAV LT(NAV, KC_SPC) -#define BAK_NUM LT(NUM, KC_BSPC) - /* Shortcuts: * Some useful shortcuts such as copy paste */ @@ -75,53 +82,53 @@ enum layers { const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [CANARY] = LAYOUT_split_3x6_3( //,-----------------------------------------------------. ,-----------------------------------------------------. - KC_GRV, KC_W, KC_L, KC_Y, KC_P, KC_B, KC_Z, KC_F, KC_O, KC_U, KC_QUOT, DELWORD, + QK_GESC, KC_W, KC_L, KC_Y, KC_P, KC_B, KC_Z, KC_F, KC_O, KC_U, KC_QUOT, KC_BSPC, //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| - KC_TAB, MT_C, MT_R, MT_S, MT_T, KC_G, KC_M, MT_N, MT_E, MT_I, MT_A, KC_SCLN, + KC_TAB, HRM_C, HRM_R, HRM_S, HRM_T, KC_G, KC_M, HRM_N, HRM_E, HRM_I, HRM_A, KC_ENT, //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| - XXXXXXX, KC_Q, KC_J, KC_V, LT_D, KC_K, KC_X, LT_H, KC_SLSH, KC_COMM, KC_DOT, XXXXXXX, + OS_LSFT, KC_Q, KC_J, KC_V, HRM_D, KC_K, KC_X, HRM_H, KC_SLSH, KC_COMM, KC_DOT, OS_RSFT, //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| - QK_REP, BAK_NUM, SPC_NAV, KC_ENT, OS_LSFT, QK_AREP + XXXXXXX, NAV_REP, DELWORD, KC_SPC, NUM_MAG, XXXXXXX //`--------------------------' `--------------------------' ), [NAV] = LAYOUT_split_3x6_3( //,-----------------------------------------------------. ,-----------------------------------------------------. - XXXXXXX, KC_MPLY, KC_MSTP, KC_MPRV, KC_MNXT, KC_VOLU, WZ_CMOD, KC_HOME, KC_UP, KC_END, KC_PGUP, KC_DEL, + XXXXXXX, KC_MPLY, KC_MSTP, KC_MPRV, KC_MNXT, KC_VOLU, KC_PGUP, KC_HOME, KC_UP, KC_END, WZ_CMOD, KC_DEL, //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| - XXXXXXX, OS_LGUI, OS_LALT, OS_LSFT, OS_LCTL, KC_VOLD, WZ_PSTE, KC_LEFT, KC_DOWN, KC_RGHT, KC_PGDN, KC_BSPC, + XXXXXXX, OS_LGUI, OS_LALT, OS_LSFT, OS_LCTL, KC_VOLD, KC_PGDN, KC_LEFT, KC_DOWN, KC_RGHT, WZ_PSTE, _______, //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| - XXXXXXX, CK_UNDO, CK_CUT, CK_COPY, CK_PSTE, KC_CALC, KC_0, KC_1, KC_2, KC_3, KC_4, KC_ENT, + XXXXXXX, CK_UNDO, CK_CUT, CK_COPY, CK_PSTE, KC_CALC, KC_0, KC_1, KC_2, KC_3, KC_4, KC_5, //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| - XXXXXXX, XXXXXXX, _______, XXXXXXX, XXXXXXX, XXXXXXX + XXXXXXX, _______, XXXXXXX, _______, _______, XXXXXXX //`--------------------------' `--------------------------' ), [NUM] = LAYOUT_split_3x6_3( //,-----------------------------------------------------. ,-----------------------------------------------------. - XXXXXXX, KC_F12, KC_F7, KC_F8, KC_F9, KC_PSCR, KC_SLSH, KC_7, KC_8, KC_9, KC_MINS, KC_DEL, + XXXXXXX, KC_MINS, KC_7, KC_8, KC_9, KC_SLSH, XXXXXXX, KC_F7, KC_F8, KC_F9, KC_F10, _______, //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| - XXXXXXX, KC_F11, KC_F4, KC_F5, KC_F6, KC_SCRL, KC_ASTR, KC_4, KC_5, KC_6, KC_PLUS, KC_BSPC, + XXXXXXX, KC_PLUS, KC_4, KC_5, KC_6, KC_ASTR, XXXXXXX, KC_F4, KC_F5, KC_F6, KC_F11, _______, //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| - XXXXXXX, KC_F10, KC_F1, KC_F2, KC_F3, KC_PAUS, KC_0, KC_1, KC_2, KC_3, KC_DOT, KC_ENT, + XXXXXXX, KC_0, KC_1, KC_2, KC_3, KC_DOT, XXXXXXX, KC_F1, KC_F2, KC_F3, KC_F12, XXXXXXX, //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| - XXXXXXX, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX + XXXXXXX, _______, _______, XXXXXXX, _______, XXXXXXX //`--------------------------' `--------------------------' ), [SYM] = LAYOUT_split_3x6_3( //,-----------------------------------------------------. ,-----------------------------------------------------. - XXXXXXX, XXXXXXX, KC_LABK, KC_DLR, KC_RABK, XXXXXXX, XXXXXXX, KC_LBRC, KC_UNDS, KC_RBRC, XXXXXXX, XXXXXXX, + XXXXXXX, KC_GRV, KC_LABK, KC_MINS, KC_RABK, XXXXXXX, XXXXXXX, KC_LBRC, KC_UNDS, KC_RBRC, TRIPDOT, XXXXXXX, //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| - KC_MINS, KC_BSLS, KC_LPRN, KC_DQUO, KC_RPRN, KC_HASH, KC_PERC, KC_LCBR, KC_EQL, KC_RCBR, KC_PIPE, KC_SCLN, + XXXXXXX, KC_EXLM, KC_LPRN, KC_EQL, KC_RPRN, KC_HASH, KC_PERC, KC_LCBR, KC_DLR, KC_RCBR, KC_SCLN, XXXXXXX, //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| - XXXXXXX, XXXXXXX, KC_COLN, KC_ASTR, KC_PLUS, XXXXXXX, XXXXXXX, KC_AMPR, KC_CIRC, KC_TILD, XXXXXXX, XXXXXXX, + XXXXXXX, KC_COLN, KC_AMPR, KC_CIRC, KC_AT, XXXXXXX, XXXXXXX, KC_ASTR, KC_SLSH, KC_BSLS, KC_PIPE, XXXXXXX, //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX //`--------------------------' `--------------------------' ), - [MOD] = LAYOUT_split_3x6_3( + [FUN] = LAYOUT_split_3x6_3( //,-----------------------------------------------------. ,-----------------------------------------------------. QK_BOOT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| @@ -129,44 +136,21 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, //|--------+--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------+--------| - XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX + XXXXXXX, _______, XXXXXXX, XXXXXXX, _______, XXXXXXX //`--------------------------' `--------------------------' ) }; // clang-format on -/* Achordion: - * https://getreuer.info/posts/keyboards/achordion/index.html */ - -bool achordion_chord(uint16_t tap_hold_keycode, keyrecord_t *tap_hold_record, uint16_t other_keycode, - keyrecord_t *other_record) { - switch (tap_hold_keycode) { - // Exceptionally consider the following chords as holds, even though they - // are on the same hand. - case SPC_NAV: - case BAK_NUM: return true; break; - } - // Otherwise follow opposite hands rule. - return achordion_opposite_hands(tap_hold_record, other_record); -} - -/* Custom keycodes: - * Program the behaviour of any keycode */ - -bool process_record_user(uint16_t keycode, keyrecord_t *record) { - if (!process_achordion(keycode, record)) { - return false; - } - return true; -} - /* Repeat key: - * Configure additional keys to be ignored */ + * Configure additional key */ bool remember_last_key_user(uint16_t keycode, keyrecord_t *record, uint8_t *remembered_mods) { - // Forget Shift on letter keys when Shift or AltGr are the only mods. switch (keycode) { + case NAV_REP: return false; + case NUM_MAG: return false; + // Forget Shift on letter keys when Shift or AltGr are the only mods. case KC_A ... KC_Z: if ((*remembered_mods & ~(MOD_MASK_SHIFT | MOD_BIT(KC_RALT))) == 0) { *remembered_mods &= ~MOD_MASK_SHIFT; @@ -179,25 +163,73 @@ bool remember_last_key_user(uint16_t keycode, keyrecord_t *record, uint8_t *reme /* Alternate repeat key: * dynamically adjust output based on the most recent previous keycode */ +// clang-format off uint16_t get_alt_repeat_key_keycode_user(uint16_t keycode, uint8_t mods) { switch (keycode) { - case MT_R: return KC_L; // For "RL" bigram. - case MT_S: return KC_Y; // For "SY" bigram. - case KC_Y: return KC_S; // For "YS" bigram. - case KC_P: return KC_T; // For "PT" bigram. - case MT_I: return KC_U; // For "IU" bigram. - case KC_U: return KC_I; // For "UI" bigram. - case KC_O: return KC_E; // For "OE" bigram. - case MT_E: return KC_O; // For "EO" bigram. - case MT_N: return KC_F; // For "NF" bigram. + case KC_Y: return KC_S; // "YS" sfb (0.123%) + case HRM_E: return KC_O; // "EO" sfb (0.121%) + case HRM_R: return KC_L; // "RL" sfb (0.114%) + case KC_U: return KC_I; // "UI" sfb (0.073%) + case KC_O: return KC_E; // "OE" sfb (0.060%) + case KC_P: return KC_T; // "PT" sfb (0.050%) + case HRM_N: return KC_F; // "NF" sfb (0.036%) + case HRM_S: return KC_Y; // "SY" sfb (0.024%) + case HRM_D: return KC_G; // "DG" sfb (0.021%) + + // Magic Keycodes + case KC_F: return MG_OR; + case HRM_I: return MG_ON; + case KC_V: return MG_ER; + case HRM_T: return MG_HA; + case KC_COMM: return MG_BUT; } return KC_TRNS; } +// clang-format on -/* Custom matrix scanning: - * This function gets called at every matrix scan */ +/* Custom keycodes: + * Program the behaviour of any keycode */ -void matrix_scan_user(void) { achordion_task(); } +// clang-format off +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case NAV_REP: + if (record->tap.count) { + process_repeat_key(QK_REP, record); + return false; + } + case NUM_MAG: + if (record->tap.count) { + process_repeat_key(QK_AREP, record); + return false; + } + } + + if (record->event.pressed) { + int rep_count = get_repeat_key_count(); + switch (keycode) { + case TRIPDOT: SEND_STRING("..." ); return false; + case MG_OR: SEND_STRING(/*f*/ "or" ); return false; // "for" trigram (1.181%) + case MG_ON: SEND_STRING(/*i*/ "on" ); return false; // "ion" trigram (0.851%) + case MG_ER: SEND_STRING(/*v*/ "er" ); return false; // "ver" trigram (1.273%) + case MG_HA: SEND_STRING(/*t*/ "ha" ); return false; // "tha" trigram (1.864%) + case MG_BUT: SEND_STRING(/*,*/ " but"); return false; // ", but" brief + } + if (rep_count > 0) { + switch (keycode) { + case HRM_A: SEND_STRING(/*a*/ "nd" ); return false; // "and" trigram (3.293%) + case HRM_I: SEND_STRING(/*i*/ "ng" ); return false; // "ing" trigram (3.476%) + case KC_Y: SEND_STRING(/*y*/ "ou" ); return false; // "you" trigram (3.492%) + case KC_COMM: SEND_STRING(/*,*/ " and"); return false; // ", and" brief + case KC_SPC: SEND_STRING(/* */ "the" ); return false; // " the" brief + } + } + } + return true; +} +// clang-format on + +layer_state_t layer_state_set_user(layer_state_t state) { return update_tri_layer_state(state, NAV, NUM, FUN); } #ifdef OLED_ENABLE // Declare screen rotation for each half @@ -218,7 +250,7 @@ void oled_render_master(void) { case NAV: oled_write(" NAV ", false); break; case NUM: oled_write(" NUM ", false); break; case SYM: oled_write(" SYM ", false); break; - case MOD: oled_write(" MOD ", false); break; + case FUN: oled_write(" FUN ", false); break; default: oled_write(" UND ", false); } diff --git a/keyboards/crkbd/keymaps/sajenim/rules.mk b/keyboards/crkbd/keymaps/sajenim/rules.mk index 5c4a160..7f90815 100644 --- a/keyboards/crkbd/keymaps/sajenim/rules.mk +++ b/keyboards/crkbd/keymaps/sajenim/rules.mk @@ -13,9 +13,6 @@ OLED_ENABLE = yes REPEAT_KEY_ENABLE = yes RGBLIGHT_ENABLE = yes -# Feature libraries -SRC += features/achordion.c - # Oled display configuration ifeq ($(OLED_ENABLE),yes) OLED_DRIVER = ssd1306