fmt: clang-format

This commit is contained in:
♥ Minnie ♥ 2024-08-08 13:37:18 +08:00
parent 3bfec02cd2
commit aa206ced07
Signed by: jasmine
GPG key ID: 8563E358D4E8040E
3 changed files with 202 additions and 157 deletions

View file

@ -1,4 +1,4 @@
// Dictionary management // clang-format off
// name result chord keys // name result chord keys
COMB(NE_ESC, KC_ESC, RCTL_T(KC_N), RSFT_T(KC_E)) COMB(NE_ESC, KC_ESC, RCTL_T(KC_N), RSFT_T(KC_E))

View file

@ -1,9 +1,11 @@
#pragma once #pragma once
// By default, the firmware does not know which side is which; it needs some help to determine that. // By default, the firmware does not know which side is which; it needs some
// help to determine that.
#define MASTER_LEFT #define MASTER_LEFT
// Alternate way in QMK to enter the embedded mass storage UF2 boot-loader of the RP2040. // Alternate way in QMK to enter the embedded mass storage UF2 boot-loader of
// the RP2040.
#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET #define RP2040_BOOTLOADER_DOUBLE_TAP_RESET
#define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_TIMEOUT 200U #define RP2040_BOOTLOADER_DOUBLE_TAP_RESET_TIMEOUT 200U
@ -13,10 +15,14 @@
#define ENABLE_COMPILE_KEYCODE #define ENABLE_COMPILE_KEYCODE
// Tap-Hold configuration for home row mods. // Tap-Hold configuration for home row mods.
#define TAPPING_TERM 175 // time window in which you need to release the key in order to register a tap #define TAPPING_TERM \
#define PERMISSIVE_HOLD // activates the modifier when another key is pressed and released while the mod-tap is held, regardless of the tapping term 175 // time window in which you need to release the key in order to register a
#define QUICK_TAP_TERM 0 // disable the auto-repeat feature entirely // tap
#define ACHORDION_STREAK // disables hold behaviors when in a typing streak #define PERMISSIVE_HOLD // activates the modifier when another key is pressed
// and released while the mod-tap is held, regardless of
// the tapping term
#define QUICK_TAP_TERM 0 // disable the auto-repeat feature entirely
#define ACHORDION_STREAK // disables hold behaviors when in a typing streak
// Timeouts // Timeouts
#define ONESHOT_TIMEOUT 3000 #define ONESHOT_TIMEOUT 3000
@ -27,19 +33,19 @@
// RGB // RGB
#ifdef RGBLIGHT_ENABLE #ifdef RGBLIGHT_ENABLE
#define RGBLIGHT_SLEEP #define RGBLIGHT_SLEEP
#define RGBLIGHT_EFFECT_BREATHING #define RGBLIGHT_EFFECT_BREATHING
#define RGBLIGHT_EFFECT_RAINBOW_MOOD #define RGBLIGHT_EFFECT_RAINBOW_MOOD
#define RGBLIGHT_EFFECT_RAINBOW_SWIRL #define RGBLIGHT_EFFECT_RAINBOW_SWIRL
#define RGBLIGHT_EFFECT_SNAKE #define RGBLIGHT_EFFECT_SNAKE
#define RGBLIGHT_EFFECT_KNIGHT #define RGBLIGHT_EFFECT_KNIGHT
#define RGBLIGHT_EFFECT_CHRISTMAS #define RGBLIGHT_EFFECT_CHRISTMAS
#define RGBLIGHT_EFFECT_STATIC_GRADIENT #define RGBLIGHT_EFFECT_STATIC_GRADIENT
#define RGBLIGHT_EFFECT_RGB_TEST #define RGBLIGHT_EFFECT_RGB_TEST
#define RGBLIGHT_EFFECT_ALTERNATING #define RGBLIGHT_EFFECT_ALTERNATING
#define RGBLIGHT_EFFECT_TWINKLE #define RGBLIGHT_EFFECT_TWINKLE
#define RGBLIGHT_LIMIT_VAL 120 #define RGBLIGHT_LIMIT_VAL 120
#define RGBLIGHT_HUE_STEP 10 #define RGBLIGHT_HUE_STEP 10
#define RGBLIGHT_SAT_STEP 17 #define RGBLIGHT_SAT_STEP 17
#define RGBLIGHT_VAL_STEP 17 #define RGBLIGHT_VAL_STEP 17
#endif #endif

View file

@ -17,22 +17,25 @@
#include QMK_KEYBOARD_H #include QMK_KEYBOARD_H
// Awesome features created by getreuer // Awesome features created by getreuer
#include "features/sentence_case.h"
#include "features/achordion.h" #include "features/achordion.h"
#include "features/select_word.h"
#include "features/layer_lock.h" #include "features/layer_lock.h"
#include "features/select_word.h"
#include "features/sentence_case.h"
// https://github.com/getreuer/qmk-keymap/tree/main/features // https://github.com/getreuer/qmk-keymap/tree/main/features
// Our super useful layers, why we run qmk exclusively. // Our super useful layers, why we run qmk exclusively.
enum layers { enum layers {
CANARY, // This layout is the result of collaboration between many of the top layout creators from the AKL community. CANARY, // This layout is the result of collaboration between many of the top
NAV, // Inspired by the colemak communities extend layer, Brings navigation and editing to the home position. // layout creators from the AKL community.
NAV, // Inspired by the colemak communities extend layer, Brings navigation
// and editing to the home position.
NUM, // Contains our numpad and function keys. NUM, // Contains our numpad and function keys.
SYM, // Contains our symbols. SYM, // Contains our symbols.
MOD, // Contains keyboard related modifications. MOD, // Contains keyboard related modifications.
}; };
// Combo dictionary management (layer names must be defined before engine include) // Combo dictionary management (layer names must be defined before engine
// include)
#include "g/keymap_combo.h" #include "g/keymap_combo.h"
// Our custom keycodes // Our custom keycodes
@ -53,8 +56,9 @@ enum custom_keycodes {
MG_XES, MG_XES,
}; };
// This keymap uses Magic Canary, it is inspired by Ikcelaks' Magic Sturdy layout. // This keymap uses Magic Canary, it is inspired by Ikcelaks' Magic Sturdy
// The magic key is triggered with the fn combo. Currently only SFB and some common words are considered. // layout. The magic key is triggered with the fn combo. Currently only SFB and
// some common words are considered.
// https://github.com/Ikcelaks/keyboard_layouts // https://github.com/Ikcelaks/keyboard_layouts
// This keymap uses home row mods. In addition to mods, I have home row // This keymap uses home row mods. In addition to mods, I have home row
@ -69,21 +73,21 @@ enum custom_keycodes {
// +-------+ +-------+ // +-------+ +-------+
// Left hand home row mods for CANARY layer. // Left hand home row mods for CANARY layer.
#define HRM_C LGUI_T(KC_C) #define HRM_C LGUI_T(KC_C)
#define HRM_R LALT_T(KC_R) #define HRM_R LALT_T(KC_R)
#define HRM_S LSFT_T(KC_S) #define HRM_S LSFT_T(KC_S)
#define HRM_T LCTL_T(KC_T) #define HRM_T LCTL_T(KC_T)
// Right hand home row mods for CANARY layer. // Right hand home row mods for CANARY layer.
#define HRM_N RCTL_T(KC_N) #define HRM_N RCTL_T(KC_N)
#define HRM_E RSFT_T(KC_E) #define HRM_E RSFT_T(KC_E)
#define HRM_I RALT_T(KC_I) #define HRM_I RALT_T(KC_I)
#define HRM_A RGUI_T(KC_A) #define HRM_A RGUI_T(KC_A)
// Bottom row mods for CANARY layer. // Bottom row mods for CANARY layer.
#define HRM_D LT(SYM, KC_D) #define HRM_D LT(SYM, KC_D)
#define HRM_H LT(SYM, KC_H) #define HRM_H LT(SYM, KC_H)
// Oneshot mods are available on our navigation layer. // Oneshot mods are available on our navigation layer.
// This allows easy chords with typical window manager and terminal // This allows easy chords with typical window manager and terminal
// bindings. Oneshot mods persist through layer changes. // bindings. Oneshot mods persist through layer changes.
// Left hand one shot keys. // Left hand one shot keys.
@ -105,16 +109,17 @@ enum custom_keycodes {
#define BAK_NUM LT(NUM, KC_BSPC) #define BAK_NUM LT(NUM, KC_BSPC)
// Shortcuts // Shortcuts
#define CK_UNDO LCTL(KC_Z) // Undo #define CK_UNDO LCTL(KC_Z) // Undo
#define CK_CUT LCTL(KC_X) // Cut #define CK_CUT LCTL(KC_X) // Cut
#define CK_COPY LCTL(KC_C) // Copy #define CK_COPY LCTL(KC_C) // Copy
#define CK_PSTE LCTL(KC_V) // Paste #define CK_PSTE LCTL(KC_V) // Paste
#define DELWORD LCTL(KC_BSPC) // Delete word #define DELWORD LCTL(KC_BSPC) // Delete word
#define WZ_CMOD LCTL(LSFT(KC_X)) // Wezterm activate copy mode. #define WZ_CMOD LCTL(LSFT(KC_X)) // Wezterm activate copy mode.
#define WZ_PSTE LCTL(LSFT(KC_V)) // Wezterm paste from clipboard. #define WZ_PSTE LCTL(LSFT(KC_V)) // Wezterm paste from clipboard.
// clang-format off
//Keymaps
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[CANARY] = LAYOUT_split_3x6_3( [CANARY] = LAYOUT_split_3x6_3(
//,-----------------------------------------------------. ,-----------------------------------------------------. //,-----------------------------------------------------. ,-----------------------------------------------------.
@ -176,136 +181,171 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
), ),
}; };
// clang-format on
// Bilateral combination exceptions // Bilateral combination exceptions
bool achordion_chord(uint16_t tap_hold_keycode, keyrecord_t* tap_hold_record, uint16_t other_keycode, keyrecord_t* other_record) { 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) { switch (tap_hold_keycode) {
// Excempt some mod/layer taps. // Excempt some mod/layer taps.
case SPC_NAV: case SPC_NAV:
case ENT_SFT: case ENT_SFT:
case BAK_NUM: case BAK_NUM:
return true; return true;
break; break;
} }
// Otherwise follow opposite hands rule. // Otherwise follow opposite hands rule.
return achordion_opposite_hands(tap_hold_record, other_record); return achordion_opposite_hands(tap_hold_record, other_record);
} }
bool remember_last_key_user(uint16_t keycode, keyrecord_t* record, uint8_t* remembered_mods) { 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. // Forget Shift on letter keys when Shift or AltGr are the only mods.
switch (keycode) { switch (keycode) {
case KC_A ... KC_Z: case KC_A ... KC_Z:
if ((*remembered_mods & ~(MOD_MASK_SHIFT | MOD_BIT(KC_RALT))) == 0) { if ((*remembered_mods & ~(MOD_MASK_SHIFT | MOD_BIT(KC_RALT))) == 0) {
*remembered_mods &= ~MOD_MASK_SHIFT; *remembered_mods &= ~MOD_MASK_SHIFT;
} }
break; break;
} }
return true; return true;
} }
uint16_t get_alt_repeat_key_keycode_user(uint16_t keycode, uint8_t mods) { uint16_t get_alt_repeat_key_keycode_user(uint16_t keycode, uint8_t mods) {
switch (keycode) { switch (keycode) {
// Minimize SFB on canary layout // Minimize SFB on canary layout
case HRM_R: return KC_L; case HRM_R:
case KC_V: return KC_Y; return KC_L;
case HRM_S: return KC_Y; case KC_V:
case KC_Y: return KC_S; return KC_Y;
case KC_P: return KC_T; case HRM_S:
case HRM_I: return KC_U; return KC_Y;
case KC_U: return KC_I; case KC_Y:
case KC_O: return KC_E; return KC_S;
case HRM_E: return KC_O; case KC_P:
// Remove problem scissors bigrams return KC_T;
case KC_L: return KC_V; case HRM_I:
return KC_U;
case KC_U:
return KC_I;
case KC_O:
return KC_E;
case HRM_E:
return KC_O;
// Remove problem scissors bigrams
case KC_L:
return KC_V;
// Briefs // Briefs
case SPC_NAV: return MG_THE; case SPC_NAV:
case KC_COMM: return MG_BUT; return MG_THE;
case KC_B: return MG_BEFORE; case KC_COMM:
case KC_J: return MG_JUST; return MG_BUT;
case KC_M: return MG_MENT; case KC_B:
case HRM_N: return MG_NION; return MG_BEFORE;
case HRM_T: return MG_TMENT; case KC_J:
case KC_W: return MG_WHICH; return MG_JUST;
case KC_X: return MG_XES; case KC_M:
return MG_MENT;
case HRM_N:
return MG_NION;
case HRM_T:
return MG_TMENT;
case KC_W:
return MG_WHICH;
case KC_X:
return MG_XES;
// vim optimisations // vim optimisations
case HRM_C: return KC_W; // change word case HRM_C:
case HRM_D: return KC_W; // delete word return KC_W; // change word
case HRM_D:
return KC_W; // delete word
} }
return KC_TRNS; return KC_TRNS;
} }
bool process_record_user(uint16_t keycode, keyrecord_t* record) { bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (!process_sentence_case(keycode, record)) { return false; } if (!process_sentence_case(keycode, record)) {
if (!process_achordion(keycode, record)) { return false; } return false;
if (!process_select_word(keycode, record, SELWORD)) { return false; } }
if (!process_layer_lock(keycode, record, LLOCK)) { return false; } if (!process_achordion(keycode, record)) {
return false;
}
if (!process_select_word(keycode, record, SELWORD)) {
return false;
}
if (!process_layer_lock(keycode, record, LLOCK)) {
return false;
}
if (record->event.pressed) { if (record->event.pressed) {
int rep_count = get_repeat_key_count(); int rep_count = get_repeat_key_count();
// Define the behaviour of our custom keycodes. // Define the behaviour of our custom keycodes.
switch (keycode) { switch (keycode) {
case SC_TOGG: // Toggle sentence case on/off. case SC_TOGG: // Toggle sentence case on/off.
sentence_case_toggle(); sentence_case_toggle();
return false; return false;
// Magic key briefs // Magic key briefs
case MG_THE: case MG_THE:
SEND_STRING(/* */"the"); SEND_STRING(/* */ "the");
return false; return false;
case MG_BUT: case MG_BUT:
SEND_STRING(/*,*/" but"); SEND_STRING(/*,*/ " but");
return false; return false;
case MG_BEFORE: case MG_BEFORE:
SEND_STRING(/*b*/"efore"); SEND_STRING(/*b*/ "efore");
return false; return false;
case MG_JUST: case MG_JUST:
SEND_STRING(/*j*/"ust"); SEND_STRING(/*j*/ "ust");
return false; return false;
case MG_MENT: case MG_MENT:
SEND_STRING(/*m*/"ent"); SEND_STRING(/*m*/ "ent");
return false; return false;
case MG_NION: case MG_NION:
SEND_STRING(/*n*/"ion"); SEND_STRING(/*n*/ "ion");
return false; return false;
case MG_TMENT: case MG_TMENT:
SEND_STRING(/*t*/"ment"); SEND_STRING(/*t*/ "ment");
return false; return false;
case MG_WHICH: case MG_WHICH:
SEND_STRING(/*w*/"hich"); SEND_STRING(/*w*/ "hich");
return false; return false;
case MG_XES: case MG_XES:
SEND_STRING(/*x*/"es"); SEND_STRING(/*x*/ "es");
return false; return false;
} }
if (rep_count > 0) { if (rep_count > 0) {
// Repeat key overrides. // Repeat key overrides.
switch (keycode) { switch (keycode) {
// Minimize SFB on canary layout // Minimize SFB on canary layout
case HRM_N: SEND_STRING(/*n*/"f"); return false; case HRM_N:
// Briefs SEND_STRING(/*n*/ "f");
case SPC_NAV: return false;
SEND_STRING(/* */"for"); // Briefs
return false; case SPC_NAV:
case KC_COMM: SEND_STRING(/* */ "for");
SEND_STRING(/*,*/" and"); return false;
return false; case KC_COMM:
case HRM_A: SEND_STRING(/*,*/ " and");
SEND_STRING(/*a*/"nd"); return false;
return false; case HRM_A:
case HRM_I: SEND_STRING(/*a*/ "nd");
SEND_STRING(/*i*/"ng"); return false;
return false; case HRM_I:
case KC_Y: SEND_STRING(/*i*/ "ng");
SEND_STRING(/*y*/"ou"); return false;
return false; case KC_Y:
case KC_B: SEND_STRING(/*y*/ "ou");
SEND_STRING(/*b*/"ecause"); return false;
return false; case KC_B:
case KC_W: SEND_STRING(/*b*/ "ecause");
SEND_STRING(/*w*/"ould"); return false;
return false; case KC_W:
SEND_STRING(/*w*/ "ould");
return false;
} }
} }
} }
@ -313,9 +353,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t* record) {
return true; return true;
} }
void matrix_scan_user(void) { void matrix_scan_user(void) { achordion_task(); }
achordion_task();
}
#ifdef OLED_ENABLE #ifdef OLED_ENABLE
// Declare screen rotation for each half // Declare screen rotation for each half
@ -420,15 +458,16 @@ void oled_render_master(void) {
oled_write(" wpm", false); oled_write(" wpm", false);
} }
// Corne keyboard logo // Corne keyboard logo
void oled_render_logo(void) { void oled_render_logo(void) {
static const char PROGMEM crkbd_logo[] = { static const char PROGMEM crkbd_logo[] = {
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a,
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0xa0,
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab,
0}; 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xc0, 0xc1,
oled_write_P(crkbd_logo, false); 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc,
0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0};
oled_write_P(crkbd_logo, false);
} }
// Render our screens // Render our screens