update keychron q4

This commit is contained in:
♥ Minnie ♥ 2023-01-08 01:57:43 +08:00
parent 5e409ae774
commit 0ad20bbee8
No known key found for this signature in database
GPG key ID: 3FF749264D02B336
4 changed files with 58 additions and 131 deletions

View file

@ -1,7 +1,7 @@
#pragma once
// Configure the global tapping term (default: 200ms)
#define TAPPING_TERM 250
#define TAPPING_TERM 200
// Activate the modifier when another key is pressed and released while the mod-tap is held.
#define PERMISSIVE_HOLD
@ -19,12 +19,3 @@
// Caps Word
#define CAPS_WORD_IDLE_TIMEOUT 5000
// Leader Key
#define LEADER_PER_KEY_TIMING
#define LEADER_TIMEOUT 500
// Auto Shift
#define AUTO_SHIFT_TIMEOUT 200
#define AUTO_SHIFT_MODIFIERS
#define RETRO_SHIFT 500

View file

@ -3,14 +3,20 @@
// Layers
#define SPACEFN LT(_SPACEFN, KC_SPC)
// Dead keys
#define DK_MOD4 OSM(MOD_LGUI)
#define DK_HYPR OSM(MOD_HYPR)
#define DK_MEH OSM(MOD_MEH)
// Shortcuts
#define DELWORD LCTL(KC_W)
// One Shot Keys
#define OS_LCTL OSM(MOD_LCTL)
#define OS_LSFT OSM(MOD_LSFT)
#define OS_LALT OSM(MOD_LALT)
#define OS_LGUI OSM(MOD_LGUI)
#define OS_RCTL OSM(MOD_RCTL)
#define OS_RSFT OSM(MOD_RSFT)
#define OS_RALT OSM(MOD_RALT)
#define OS_RGUI OSM(MOD_RGUI)
// Left-hand home row mods
#define HOME_C LGUI_T(KC_C)
#define HOME_R LALT_T(KC_R)
@ -22,3 +28,4 @@
#define HOME_E RSFT_T(KC_E)
#define HOME_I RALT_T(KC_I)
#define HOME_A RGUI_T(KC_A)

View file

@ -23,8 +23,6 @@ enum layers {
// Our default layouts
_QWERTY,
_CANARY,
// Optimized dead-key positioning + homerow mods and a few misc features
_MODCANARY,
// layouts that enable extra functionality
_SPACEFN,
_FN1,
@ -33,13 +31,13 @@ enum layers {
/* Define our custom keycodes */
enum custom_keycodes {
MOD_TOG = SAFE_RANGE,
VI_SAVE = SAFE_RANGE,
VI_EXIT,
};
/* Define our combo keycodes */
enum combos {
NE_ESCAPE,
SE_CAPSWRD,
COMBO_LENGTH
};
@ -47,13 +45,11 @@ enum combos {
uint16_t COMBO_LEN = COMBO_LENGTH;
// Define key sequences
const uint16_t PROGMEM esc_combo[] = {HOME_N, HOME_E, COMBO_END};
const uint16_t PROGMEM capswrd_combo[] = {HOME_S, HOME_E, COMBO_END};
const uint16_t PROGMEM ne_combo[] = {HOME_N, HOME_E, COMBO_END};
// List the combination of keys and there resulting action
combo_t key_combos[] = {
[NE_ESCAPE] = COMBO(esc_combo, KC_ESC),
[SE_CAPSWRD] = COMBO(capswrd_combo, CAPSWRD),
[NE_ESCAPE] = COMBO(ne_combo, KC_ESC),
};
/* Define our keymaps */
@ -72,16 +68,16 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
*
* LSHIFT Z X C V B N M , . / RSHIFT
*
* CTRLGUI ALT SPACE ALT FN1 FN2 CTRL
* CTRLGUI ALT SPACEFN ALT FN1 FN2 CTRL
*
*
*/
[_QWERTY] = LAYOUT_ansi_61(
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_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,
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_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT,
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FN1), MO(_FN2), KC_RCTL),
CW_TOGG, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT,
OS_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, OS_RSFT,
OS_LCTL, OS_LGUI, OS_LALT, SPACEFN, OS_RALT, MO(_FN1), MO(_FN2), OS_RCTL),
/**
* Canary
@ -98,41 +94,18 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
*
* LSHIFT J V D G Q M H / , . RSHIFT
*
* CTRLGUI ALT SPACE ALT FN1 FN2 CTRL
*
*
*/
[_CANARY] = LAYOUT_ansi_61(
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_W, KC_L, KC_Y, KC_P, KC_K, KC_Z, KC_X, KC_O, KC_U, KC_SCLN, KC_LBRC, KC_RBRC, KC_BSLS,
KC_CAPS, KC_C, KC_R, KC_S, KC_T, KC_B, KC_F, KC_N, KC_E, KC_I, KC_A, KC_QUOT, KC_ENT,
KC_LSFT, KC_J, KC_V, KC_D, KC_G, KC_Q, KC_M, KC_H, KC_SLSH, KC_COMM, KC_DOT, KC_RSFT,
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FN1), MO(_FN2), KC_RCTL),
/**
* MODIFIERS + MISC FEATURES
*
*
* `
*
*
*
* MOD4 GUIALTSFTCTL CTLSFTALTGUI
*
*
*
* HYPRMEH LEAD SPACEFN
* CTRLGUI ALT SPACEFN ALT FN1 FN2 CTRL
*
*
* Credit: https://precondition.github.io/home-row-mods
*
*/
[_MODCANARY] = LAYOUT_ansi_61(
KC_GRV, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
DK_MOD4, HOME_C, HOME_R, HOME_S, HOME_T, _______, _______, HOME_N, HOME_E, HOME_I, HOME_A, _______, _______,
XXXXXXX, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, XXXXXXX,
DK_HYPR, DK_MEH, QK_LEAD, SPACEFN, XXXXXXX, _______, _______, XXXXXXX),
[_CANARY] = LAYOUT_ansi_61(
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_W, KC_L, KC_Y, KC_P, KC_K, KC_Z, KC_X, KC_O, KC_U, KC_SCLN, KC_LBRC, KC_RBRC, KC_BSLS,
CW_TOGG, HOME_C, HOME_R, HOME_S, HOME_T, KC_B, KC_F, HOME_N, HOME_E, HOME_I, HOME_A, KC_QUOT, KC_ENT,
OS_LSFT, KC_J, KC_V, KC_D, KC_G, KC_Q, KC_M, KC_H, KC_SLSH, KC_COMM, KC_DOT, KC_RSFT,
OS_LCTL, OS_LGUI, OS_LALT, SPACEFN, OS_RALT, MO(_FN1), MO(_FN2), OS_RCTL),
/**
* SPACEFN
@ -140,11 +113,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
*
* F1 F2 F3 F4 F5 F6 F7 F8 F9 F10F11F12DELWORD
*
* HOMENDPUPPDN
* :w :q!PUPPDN HOMEND
*
* GUIALTSFTCTL LFTDWNUP RGTDEL
* GUIALTSFTCTL LFTDWNUP RGT INSERT
*
* INS BAK
* BAK DEL
*
*
*
@ -154,16 +127,16 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
*/
[_SPACEFN] = LAYOUT_ansi_61(
XXXXXXX, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, DELWORD,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_HOME, KC_END, KC_PGUP, KC_PGDN, XXXXXXX, XXXXXXX, XXXXXXX,
XXXXXXX, KC_LGUI, KC_LALT, KC_LSFT, KC_LCTL, XXXXXXX, XXXXXXX, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_DEL, XXXXXXX,
XXXXXXX, XXXXXXX, XXXXXXX, KC_INS, XXXXXXX, XXXXXXX, XXXXXXX, KC_BSPC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
XXXXXXX, VI_SAVE, VI_EXIT, KC_PGUP, KC_PGDN, XXXXXXX, XXXXXXX, KC_HOME, KC_END, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
XXXXXXX, KC_LGUI, KC_LALT, KC_LSFT, KC_LCTL, XXXXXXX, XXXXXXX, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, XXXXXXX, KC_INS,
XXXXXXX, XXXXXXX, XXXXXXX, KC_BSPC, XXXXXXX, XXXXXXX, XXXXXXX, KC_DEL, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX),
/**
* Function 1
*
*
* F1 F2 F3 F4 F5 F6 F7 F8 F9 F10F11F12
* F1 F2 F3 F4 F5 F6 F7 F8 F9 F10F11F12DELETE
*
* UP
*
@ -176,7 +149,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
*
*/
[_FN1] = LAYOUT_ansi_61(
XXXXXXX, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX,
XXXXXXX, 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,
XXXXXXX, XXXXXXX, KC_UP, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
XXXXXXX, KC_LEFT, KC_DOWN, KC_RGHT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
@ -186,9 +159,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
* Function 2
*
*
* MOD BOOTLDR
* BOOTLDR
*
* RGB
*
*
*
*
@ -199,8 +172,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
*
*/
[_FN2] = LAYOUT_ansi_61(
MOD_TOG, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, QK_BOOT,
RGB_TOG, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, QK_BOOT,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX),
@ -209,62 +182,21 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
/* Define the behaviour of our custom keycodes */
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case MOD_TOG:
if (record->event.pressed && layer_state_is(_CANARY)) {
layer_invert(_MODCANARY);
}
return false;
default:
return true;
}
}
/* Custom layer handling */
layer_state_t layer_state_set_user(layer_state_t state) {
switch (get_highest_layer(state)) {
case _MODCANARY:
autoshift_enable();
combo_enable();
break;
default:
autoshift_disable();
combo_disable();
break;
}
return state;
};
/* Configure which keys are auto-shifted */
bool get_custom_auto_shifted_key(uint16_t keycode, keyrecord_t *record) {
switch(keycode) {
// Left-hand home row mods
case HOME_C:
case HOME_R:
case HOME_S:
case HOME_T:
// Right-hand home row mods
case HOME_N:
case HOME_E:
case HOME_I:
case HOME_A:
return true;
default:
return false;
}
};
/* Configure our dip switch */
bool dip_switch_update_mask_user(uint32_t state) {
if (state & (1UL<<0) && state & (1UL<<1)) {
layer_on(_QWERTY);
} else {
layer_clear();
}
if (state & (1UL<<0)) {
layer_on(_CANARY);
} else {
layer_clear();
case VI_SAVE:
if (record->event.pressed) {
tap_code(KC_ESC);
SEND_STRING(":w");
tap_code(KC_ENT);
}
break;
case VI_EXIT:
if (record->event.pressed) {
tap_code(KC_ESC);
SEND_STRING(":q!");
tap_code(KC_ENT);
}
break;
}
return true;
}
};

View file

@ -1,10 +1,7 @@
# Squeezing the most out of AVR
LTO_ENABLE = yes
LTO_ENABLE = yes
# Enable some features
CAPS_WORD_ENABLE = yes
LEADER_ENABLE = yes
COMBO_ENABLE = yes
AUTO_SHIFT_ENABLE = yes
DIP_SWITCH_ENABLE = yes