1
Fork 0

keychron: CTRL on CAPS

This commit is contained in:
Hadeed 2024-01-07 08:46:48 +05:00
parent 81d2e994cc
commit 5f3fd8ac9b
5 changed files with 23 additions and 137 deletions

View file

@ -1,5 +0,0 @@
#define TAPPING_TERM 150
#define QUICK_TAP_TERM 150
#undef HOLD_ON_OTHER_KEY_PRESS
#define PERMISSIVE_HOLD

View file

@ -1,23 +0,0 @@
#include QMK_KEYBOARD_H
#include "layers.h"
static void encoder_brightness(bool clockwise) {
if (clockwise)
rgb_matrix_increase_val_noeeprom();
else
rgb_matrix_decrease_val_noeeprom();
}
static void encoder_volume(bool clockwise) {
tap_code_delay(clockwise ? KC_VOLU : KC_VOLD, 10);
}
bool encoder_update_user(uint8_t index, bool clockwise) {
if (IS_LAYER_ON(FN))
encoder_brightness(clockwise);
else
encoder_volume(clockwise);
return false;
}

View file

@ -1,103 +1,34 @@
#include QMK_KEYBOARD_H #include QMK_KEYBOARD_H
#include "layers.h" enum layers{
BASE,
void set_backlight(void); FN
void change_default_layer(bool);
enum custom_keycodes {
CK_LRUP = SAFE_RANGE,
CK_LRDN
}; };
#define KC_TASK G(KC_TAB) #define KC_TASK LGUI(KC_TAB)
#define KC_FLXP G(KC_E) #define KC_FLXP LGUI(KC_E)
#define HRM_A LALT_T(KC_A)
#define HRM_S LGUI_T(KC_S)
#define HRM_D LCTL_T(KC_D)
#define HRM_F LSFT_T(KC_F)
#define HRM_J RSFT_T(KC_J)
#define HRM_K RCTL_T(KC_K)
#define HRM_L RGUI_T(KC_L)
#define HRM_SLN RALT_T(KC_SCLN)
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[LINUX] = LAYOUT_ansi_82( [BASE] = LAYOUT_ansi_82(
_______, 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, KC_MUTE,
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_PGUP,
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_PGDN,
KC_ESC, HRM_A, HRM_S, HRM_D, HRM_F, KC_G, KC_H, HRM_J, HRM_K, HRM_L, HRM_SLN, KC_QUOT, KC_ENT, KC_HOME,
_______, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, _______, KC_UP,
MO(NAV), _______, _______, KC_SPC, _______, MO(FN), _______, KC_LEFT, KC_DOWN, KC_RGHT),
[NAV] = LAYOUT_ansi_82(
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______),
/* ----------------------------------------------------------------------------------------------------------------------------------------------------------------- */
[DOTA] = LAYOUT_ansi_82(
KC_ESC, 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, KC_MUTE, KC_ESC, 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, KC_MUTE,
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_PGUP, 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_PGUP,
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_PGDN, 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_PGDN,
KC_LCTL, 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_HOME, KC_LCTL, 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_HOME,
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_UP, 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_UP,
KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT), KC_LCTL, KC_LCMD, KC_LALT, KC_SPC, KC_RALT, MO(FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT),
/* ----------------------------------------------------------------------------------------------------------------------------------------------------------------- */
[FN] = LAYOUT_ansi_82( [FN] = LAYOUT_ansi_82(
QK_RBT, KC_BRID, KC_BRIU, KC_TASK, KC_FLXP, RGB_VAD, RGB_VAI, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, _______, KC_BRID, KC_BRIU, KC_TASK, KC_FLXP, RGB_VAD, RGB_VAI, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, _______, RGB_TOG,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, CK_LRUP, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
RGB_TOG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, CK_LRDN, RGB_TOG, RGB_MOD, RGB_VAI, RGB_HUI, RGB_SAI, RGB_SPI, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, QK_BOOT, _______, _______, RGB_RMOD, RGB_VAD, RGB_HUD, RGB_SAD, RGB_SPD, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, NK_TOGG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, NK_TOGG, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______), _______, _______, _______, _______, _______, _______, _______, _______, _______, _______),
}; };
bool process_record_user(uint16_t keycode, keyrecord_t *record) { #if defined(ENCODER_MAP_ENABLE)
switch (keycode) { const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
case CK_LRUP: [BASE] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU)},
case CK_LRDN: [FN] = { ENCODER_CCW_CW(RGB_VAD, RGB_VAI)}
if (record->event.pressed) };
change_default_layer(keycode == CK_LRUP); #endif // ENCODER_MAP_ENABLE
return false;
}
return true;
}
// The boring stuff
void set_backlight(void) {
uint8_t v = rgb_matrix_get_val();
if (IS_LAYER_ON_STATE(default_layer_state, LINUX))
rgb_matrix_sethsv_noeeprom(HSV_WHITE);
else if (IS_LAYER_ON_STATE(default_layer_state, DOTA))
rgb_matrix_sethsv_noeeprom(HSV_RED);
rgb_matrix_sethsv_noeeprom(rgb_matrix_get_hue(), rgb_matrix_get_sat(), v);
}
void change_default_layer(bool layer_up) {
layer_state_t x = (layer_up ? default_layer_state<<1 : default_layer_state>>1) & ((1 << BASE_LAYERS) - 1);
default_layer_set(x != 0 ? x : (layer_up ? 1U : (1 << (BASE_LAYERS-1))));
set_backlight();
}
void keyboard_post_init_user(void) {
rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR);
rgb_matrix_sethsv_noeeprom(rgb_matrix_get_hue(), rgb_matrix_get_sat(), 128);
set_backlight();
}

View file

@ -1,15 +0,0 @@
#ifndef LAYERS_H
#define LAYERS_H
enum base_layers {
LINUX,
DOTA,
BASE_LAYERS
};
enum other_layers {
NAV = BASE_LAYERS,
FN,
};
#endif

View file

@ -1,3 +1 @@
SRC += encoder.c ENCODER_MAP_ENABLE = yes
ENCODER_MAP_ENABLE = no