From cd92946f492bf13e09c6a5e6d24dcc4bbc523e6a Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Tue, 19 Dec 2023 21:44:34 +0100 Subject: Added the qmk firmware for sofle keyboard --- qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c | 78 ++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c (limited to 'qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c') diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c b/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c new file mode 100644 index 0000000..e0f8994 --- /dev/null +++ b/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c @@ -0,0 +1,78 @@ +#include QMK_KEYBOARD_H +#include "keymap_bepo.h" +#include "keycodes.h" + +/* + * Rules and modifier to apply over the keycodes. This includes the keys + * redefinitions and the keys to include in the caps_word mecanism. + * + * All thoses update are working over the custom keys declared in `keycodes.h` + */ + +/* + * This function need to be declared after the key definition, including the + * tapdance keys because I need to reference the keycode here if I want to + * include them in the caps_word mecanism. + */ +bool caps_word_press_user(uint16_t keycode) { + switch (keycode) { + // Keycodes that continue Caps Word, with shift applied. + case KC_A ... KC_Z: + case KC_1 ... KC_0: + case KC_MINS: + case KEY_C: // Add also the tapdance keys here. + case KEY_W: + case KEY_E: + case BP_Z: // Additionals keys from the bepo layout. + case BP_M: + case BP_G: + case BP_H: + case BP_N: + add_weak_mods(MOD_BIT(KC_LSFT)); // Apply shift to next key. + return true; + + // Keycodes that continue Caps Word, without shifting. + case KC_BSPC: + case KC_DEL: + return true; + case KC_SPACE: + // The space key is used in order to generate the _ symbol, + // I check which modifier is applied, it’s ok when it’s ALT + return get_mods() & MOD_MASK_ALT; + + default: + return false; // Deactivate Caps Word. + } +} + +// +// Override the symbol ° and replace it by ` +// The symbol is still available in the symbol layer with the key just below. +// +const key_override_t perc_key_override = + ko_make_basic(MOD_MASK_SHIFT, KEY_PRC, LSFT(BP_PERC)); + +// +// I don’t care of the mapping CTRL+Ç and using the mod_tap does not work well +// when I type too fast because of tap-dance, so I remap the pattern here. +// +const key_override_t c_key_override = + ko_make_basic(MOD_MASK_CTRL, KEY_C, LCTL(BP_C)); + +// Same here, I override the key W with CTRL because the tapdance activate the +// caps_word which does not make sense here. +const key_override_t w_key_override = + ko_make_basic(MOD_MASK_CTRL, KEY_W, LCTL(BP_W)); + +const key_override_t e_key_override = + ko_make_basic(MOD_MASK_CTRL, KEY_E, RCTL(BP_E)); + + +// This globally defines all key overrides to be used +const key_override_t **key_overrides = (const key_override_t *[]){ + &perc_key_override, + &c_key_override, + &w_key_override, + &e_key_override, + NULL +}; -- cgit v1.2.3