aboutsummaryrefslogtreecommitdiff
path: root/qmk/keyboards/sofle_choc
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2025-11-01 16:21:19 +0100
committerSébastien Dailly <sebastien@dailly.me>2025-11-01 16:21:19 +0100
commitd2cbc46f9a0b4e6fa1dc67778cdc6d7dfda83cb1 (patch)
treeccf64efb7270f118ea3bca1b719e6b74cc86b27e /qmk/keyboards/sofle_choc
parent7c32f69bc45bbcabebd73b24980f37e2a3eacdbb (diff)
Updated the shift key managementHEADmaster
Diffstat (limited to 'qmk/keyboards/sofle_choc')
-rw-r--r--qmk/keyboards/sofle_choc/keymaps/custom/callbacks.c30
-rw-r--r--qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c32
-rw-r--r--qmk/keyboards/sofle_choc/keymaps/custom/keycodes.h4
-rw-r--r--qmk/keyboards/sofle_choc/keymaps/custom/keymap.c8
-rw-r--r--qmk/keyboards/sofle_choc/keymaps/custom/lighting.c18
-rw-r--r--qmk/keyboards/sofle_choc/keymaps/custom/overrides.h2
-rw-r--r--qmk/keyboards/sofle_choc/keymaps/custom/quad_tapdance.c2
-rw-r--r--qmk/keyboards/sofle_choc/keymaps/custom/rules.mk3
-rw-r--r--qmk/keyboards/sofle_choc/keymaps/custom/shift_dance.c79
-rw-r--r--qmk/keyboards/sofle_choc/keymaps/custom/shift_dance.h6
-rw-r--r--qmk/keyboards/sofle_choc/keymaps/custom/star_key.h2
11 files changed, 89 insertions, 97 deletions
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/callbacks.c b/qmk/keyboards/sofle_choc/keymaps/custom/callbacks.c
new file mode 100644
index 0000000..305bacc
--- /dev/null
+++ b/qmk/keyboards/sofle_choc/keymaps/custom/callbacks.c
@@ -0,0 +1,30 @@
+#include QMK_KEYBOARD_H
+#include "star_key.h"
+#include "lighting.h"
+#include "enter_dance.h"
+#include "shift_dance.h"
+#include "keycodes.h"
+
+void keyboard_post_init_user(void) {
+ lighting_init();
+ star_key_init();
+}
+
+void housekeeping_task_user(void) {
+ if (is_keyboard_master()) {
+ sync_star_key();
+ }
+ housekeeping_task_lighting();
+}
+
+void oneshot_mods_changed_user(uint8_t mods) {
+ oneshot_mods_changed_lighting(mods);
+}
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ star_key_process_record(keycode, record);
+ shift_dance_process_record(keycode, record);
+ enter_dance_process_record(keycode, record);
+
+ return keycodes_process_record(keycode, record);
+}
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c b/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c
index 8819917..e82eed5 100644
--- a/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c
+++ b/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c
@@ -1,26 +1,6 @@
#include QMK_KEYBOARD_H
#include "keymap_bepo.h"
#include "keycodes.h"
-#include "star_key.h"
-#include "lighting.h"
-#include "enter_dance.h"
-#include "shift_dance.h"
-
-void keyboard_post_init_user(void) {
- lighting_init();
- star_key_init();
-}
-
-void housekeeping_task_user(void) {
- if (is_keyboard_master()) {
- sync_star_key();
- }
- housekeeping_task_lighting();
-}
-
-void oneshot_mods_changed_user(uint8_t mods) {
- oneshot_mods_changed_lighting(mods);
-}
/*
* Rules and modifier to apply over the keycodes. This includes the keys
@@ -82,7 +62,7 @@ static uint32_t key_timer; // timer for last keyboard activity, use
// idle time possible
static uint16_t latest_key = 0L;
-bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+bool keycodes_process_record(uint16_t keycode, keyrecord_t *record) {
if (!record->event.pressed) {
@@ -92,17 +72,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
latest_key = keycode;
}
- // Call the callback handlers
- star_key_process_record(keycode, record);
- shift_dance_process_record(keycode, record);
- enter_dance_process_record(keycode, record);
-
switch (keycode) {
- case KC_LEFT_SHIFT:
- if (host_keyboard_led_state().caps_lock) {
- tap_code16(KC_CAPS_LOCK);
- }
- return true;
case KC_ESC:
case AL_ENT:
if (layer_state_is(LAYER_SYMBOLS) && !record->event.pressed) {
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.h b/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.h
index d75d5d9..1f86bb6 100644
--- a/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.h
+++ b/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.h
@@ -1,4 +1,6 @@
#pragma once
+#include QMK_KEYBOARD_H
+#include "action.h"
enum {
// Transform the key W into SHIFT or CAPSLOCK
@@ -26,3 +28,5 @@ enum {
#define KEY_T MT(MOD_RCTL, BP_T)
#define KEY_INS MT(MOD_RGUI, KC_INS)
#define TD_ENTR TD(TD_ENTER)
+
+bool keycodes_process_record(uint16_t keycode, keyrecord_t *record);
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/keymap.c b/qmk/keyboards/sofle_choc/keymaps/custom/keymap.c
index fcea429..2b2b41f 100644
--- a/qmk/keyboards/sofle_choc/keymaps/custom/keymap.c
+++ b/qmk/keyboards/sofle_choc/keymaps/custom/keymap.c
@@ -30,7 +30,7 @@
// The functions for ACTION_TAP_DANCE_FN_ADVANCED or defined in "quand_dance"
tap_dance_action_t tap_dance_actions[] = {
[TD_PRC] = ACTION_TAP_DANCE_DOUBLE(BP_EQL, BP_PERC),
- [TD_W_CAPSLOCK] = ACTION_TAP_DANCE_FN_ADVANCED_WITH_RELEASE(NULL, w_released, w_finished, w_reset),
+ [TD_W_CAPSLOCK] = ACTION_TAP_DANCE_FN_ADVANCED_WITH_RELEASE(NULL, right_shift_released, right_shift_finished, right_shift_reset),
[TD_LAYER_SYMB] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, ql_finished, ql_reset),
[TD_EE] = ACTION_TAP_DANCE_DOUBLE(BP_COMM, BP_EGRV),
[TD_ENTER] = ACTION_TAP_DANCE_FN_ADVANCED_WITH_RELEASE(NULL, enter_released, enter_finished, enter_reset),
@@ -70,7 +70,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
// In the number layout, I keep the mod-tap modifiers applies to the middle letters :
//
-#define KEY_5 MT(MOD_LCTL, KC_P5)
+#define KEY_6 MT(MOD_LCTL, KC_P6)
#define KEY_DOWN MT(MOD_RCTL, KC_DOWN)
#define KEY_PGDN MT(MOD_RSFT, KC_PGDN)
@@ -78,13 +78,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[LAYER_SYMBOLS] = LAYOUT(
KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
KC_TRNS, KC_NO, KC_P7, KC_P8, KC_P9, KC_BSPC, KC_HOME, KC_UP, KC_END, KC_TRNS, KC_TRNS, S(BP_EQL),
- KC_TRNS, KC_NO, KC_P4, KEY_5, KC_P6, KC_NO, KC_LEFT, KC_DOWN, KC_RIGHT,KC_TRNS, KC_TRNS, KC_PGUP,
+ KC_TRNS, KC_NO, KC_P4, KC_P5, KEY_6, KC_NO, KC_LEFT, KC_DOWN, KC_RIGHT,KC_TRNS, KC_TRNS, KC_PGUP,
KC_LSFT, KC_NO, KC_P1, KC_P2, KC_P3, KC_NO, KC_MUTE, KC_MPLY, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KEY_PGDN,
KC_P0, KC_PDOT, KC_TRNS, KC_TRNS, AL_SPC, AL_ENT, KC_TRNS, KC_TRNS, KC_RGUI, KC_TRNS
),
[LAYER_DIACRITIC] = LAYOUT(
- KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
+ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, BP_PERC,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_BSPC, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, BP_CCED, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c b/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c
index 9e4001d..67ccf2c 100644
--- a/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c
+++ b/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c
@@ -2,6 +2,7 @@
uint8_t flags = 0;
#include "keycodes.h"
#include "lighting.h"
+#include "keymap_bepo.h"
// The variable is defined in star_key.h
// The LED is on when the key is pressed.
@@ -60,26 +61,31 @@ void housekeeping_task_lighting(void) {
counter += 1;
}
+ uint8_t matrix_mode = rgb_matrix_get_mode();
+ if (matrix_mode != RGB_MATRIX_BREATHING && host_keyboard_led_state().caps_lock) {
+ rgb_matrix_mode_noeeprom(RGB_MATRIX_BREATHING);
+ }
+
if (flags == last_flags) {
return;
}
last_flags = flags;
- if (get_mods()) {
- if (rgb_matrix_get_mode() != RGB_MATRIX_SOLID_COLOR) {
+ if (flags) {
+ if (matrix_mode != RGB_MATRIX_SOLID_COLOR) {
rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR);
}
uint8_t v = colors[flags].v;
if (counter >= 2)
v *= 2;
rgb_matrix_sethsv_noeeprom(colors[flags].h, colors[flags].s, v);
- } else if (rgb_matrix_get_mode() != RGB_MATRIX_SOLID_REACTIVE_SIMPLE) {
+ } else if (matrix_mode != RGB_MATRIX_SOLID_REACTIVE_SIMPLE) {
rgb_matrix_sethsv_noeeprom(HSV_WHITE);
rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_REACTIVE_SIMPLE);
}
}
-#define KEY_5 MT(MOD_LCTL, KC_P5)
+#define KEY_6 MT(MOD_LCTL, KC_P6)
#define KEY_DOWN MT(MOD_RCTL, KC_DOWN)
bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
// Activate effects depending of mods
@@ -115,9 +121,11 @@ bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
rgb_matrix_set_color(index, 128, 128, 128);
break;
case KC_P1 ... KC_P0:
- case KEY_5:
+ case KEY_6:
rgb_matrix_set_color(index, 100, 100, 0);
break;
+ case BP_CCED:
+ case BP_PERC:
case KC_PDOT:
// Add a bit of red for the punction symbol
rgb_matrix_set_color(index, 150, 50, 0);
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/overrides.h b/qmk/keyboards/sofle_choc/keymaps/custom/overrides.h
index 45c723c..79836d4 100644
--- a/qmk/keyboards/sofle_choc/keymaps/custom/overrides.h
+++ b/qmk/keyboards/sofle_choc/keymaps/custom/overrides.h
@@ -21,8 +21,6 @@ const key_override_t e_key_override ;
const key_override_t *key_overrides[]= (const key_override_t *[]){
&perc_key_override,
&e_key_override,
- &shift_space_override,
- //&shift_o_override,
// Override the key GUI + MENU and to map the key desktop from the
// typematrix
&(ko_make_basic(MOD_MASK_GUI, KEY_APP, MENU)),
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/quad_tapdance.c b/qmk/keyboards/sofle_choc/keymaps/custom/quad_tapdance.c
index 65e4e01..2b01fe9 100644
--- a/qmk/keyboards/sofle_choc/keymaps/custom/quad_tapdance.c
+++ b/qmk/keyboards/sofle_choc/keymaps/custom/quad_tapdance.c
@@ -85,7 +85,7 @@ void ql_finished(tap_dance_state_t *state, void *user_data) {
void ql_reset(tap_dance_state_t *state, void *user_data) {
// If the key was held down and now is released then switch off the layer
if (ql_tap_state.state == TD_SINGLE_HOLD) {
- layer_off(LAYER_SYMBOLS);
+ layer_clear();
}
ql_tap_state.state = TD_NONE;
}
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/rules.mk b/qmk/keyboards/sofle_choc/keymaps/custom/rules.mk
index 5cda5bd..90eda0e 100644
--- a/qmk/keyboards/sofle_choc/keymaps/custom/rules.mk
+++ b/qmk/keyboards/sofle_choc/keymaps/custom/rules.mk
@@ -17,4 +17,5 @@ SRC += star_key.c \
shift_dance.c \
keycodes.c \
overrides.c \
- lighting.c
+ lighting.c \
+ callbacks.c
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/shift_dance.c b/qmk/keyboards/sofle_choc/keymaps/custom/shift_dance.c
index 82448a4..403c3df 100644
--- a/qmk/keyboards/sofle_choc/keymaps/custom/shift_dance.c
+++ b/qmk/keyboards/sofle_choc/keymaps/custom/shift_dance.c
@@ -8,47 +8,54 @@
// The main usage is to send the letter W when pressed, but the key is also
// used to activate the SHIFT mode when pressed.
//
-static td_tap_t w_tap_state = {
+static td_tap_t right_shift_tap_state = {
.state = TD_NONE
};
// Do not switch the supended mode when the key is released.
// This allow to remove the mod earler without reactivating automatically.
static bool inhibit_mod = 0;
-
-// Flag telling if the suspended mode is active or not.
-static bool activated = 0;
+static bool lshift_interrupted = 0;
// If there is any other keypress before releasing the key, do not keep the
// layer once the key is release.
//
// This function is a callbackk called from process_record_user
void shift_dance_process_record(uint16_t keycode, keyrecord_t *record) {
- if (w_tap_state.state == TD_SINGLE_HOLD && record->event.pressed) {
+ if (right_shift_tap_state.state == TD_SINGLE_HOLD && record->event.pressed) {
+ // If there is any key pressed while holding the key, do not switch
+ // in caps lock mod on release.
inhibit_mod = 1;
}
switch (keycode) {
+ // If the key is pressed without any other combination, remove the
+ // caps lock if activated.
+ // Otherwise, act just as a modifier key.
case KC_LSFT:
- activated = 0;
- break;
- // Leave the suspended mode on ESC
+ if (record->event.pressed) {
+ lshift_interrupted = 0;
+ break;
+ }
+ if (lshift_interrupted) {
+ break;
+ }
+ // Continue on the next block
case KC_ESC:
- if (activated) {
- set_mods(get_mods() & (!MOD_MASK_SHIFT));
- activated = 0;
+ if (host_keyboard_led_state().caps_lock) {
+ tap_code16(KC_CAPS_LOCK);
}
break;
default:
+ lshift_interrupted = 1;
break;
}
return;
}
-void w_finished(tap_dance_state_t *state, void *user_data) {
- w_tap_state.state = cur_dance(state);
- switch (w_tap_state.state) {
+void right_shift_finished(tap_dance_state_t *state, void *user_data) {
+ right_shift_tap_state.state = cur_dance(state);
+ switch (right_shift_tap_state.state) {
case TD_SINGLE_HOLD:
- caps_word_off();
if (get_mods() & MOD_MASK_SHIFT) {
del_mods(MOD_MASK_SHIFT);
inhibit_mod = 1;
@@ -59,7 +66,7 @@ void w_finished(tap_dance_state_t *state, void *user_data) {
}
}
-void w_released(tap_dance_state_t *state, void *user_data) {
+void right_shift_released(tap_dance_state_t *state, void *user_data) {
if (state->finished && state->count > 1)
// Exit prevently, we are sure in the next conditions we don’t fall in
// this case.
@@ -68,47 +75,19 @@ void w_released(tap_dance_state_t *state, void *user_data) {
tap_code16(BP_W);
else if (!state->interrupted && !inhibit_mod) {
// Final case, the key was keeped pressed without any other action
- // in this case, inverse the Shift mode, and update the activation flag
- set_mods(get_mods() ^ MOD_MASK_SHIFT);
- activated = get_mods() & MOD_MASK_SHIFT;
+ // in this case, switch into CAPS LOCK
+ del_mods(MOD_MASK_SHIFT);
+ tap_code16(KC_CAPS_LOCK);
}
inhibit_mod = 0;
}
-void w_reset(tap_dance_state_t *state, void *user_data) {
- switch (w_tap_state.state) {
+void right_shift_reset(tap_dance_state_t *state, void *user_data) {
+ switch (right_shift_tap_state.state) {
case TD_SINGLE_HOLD:
unregister_code(KC_RIGHT_SHIFT);
break;
default: break;
}
- w_tap_state.state = TD_NONE;
+ right_shift_tap_state.state = TD_NONE;
}
-
-
-// Deactivate the shift mode for the space key when the suspended mode is
-// active. This allow to insert a normal space character instead of a
-// unbreakable space.
-const key_override_t shift_space_override =
- {.trigger_mods = MOD_MASK_SHIFT,
- .layers = ~0,
- .suppressed_mods = MOD_MASK_SHIFT,
- .options = ko_options_default,
- .negative_mod_mask = (uint8_t)0,
- .custom_action = NULL,
- .context = NULL,
- .trigger = AL_SPC,
- .replacement = AL_SPC,
- .enabled = &activated};
-
-const key_override_t shift_o_override =
- {.trigger_mods = MOD_MASK_SHIFT,
- .layers = ~0,
- .suppressed_mods = MOD_MASK_SHIFT,
- .options = ko_options_default,
- .negative_mod_mask = (uint8_t)0,
- .custom_action = NULL,
- .context = NULL,
- .trigger = KC_O,
- .replacement = KC_O,
- .enabled = &activated};
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/shift_dance.h b/qmk/keyboards/sofle_choc/keymaps/custom/shift_dance.h
index 8cff3fe..4eb7799 100644
--- a/qmk/keyboards/sofle_choc/keymaps/custom/shift_dance.h
+++ b/qmk/keyboards/sofle_choc/keymaps/custom/shift_dance.h
@@ -3,9 +3,9 @@
// For the x tap dance. Put it here so it can be used in any keymap
-void w_released(tap_dance_state_t *state, void *user_data);
-void w_finished(tap_dance_state_t *state, void *user_data);
-void w_reset(tap_dance_state_t *state, void *user_data);
+void right_shift_released(tap_dance_state_t *state, void *user_data);
+void right_shift_finished(tap_dance_state_t *state, void *user_data);
+void right_shift_reset(tap_dance_state_t *state, void *user_data);
void shift_dance_process_record(uint16_t keycode, keyrecord_t *record);
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/star_key.h b/qmk/keyboards/sofle_choc/keymaps/custom/star_key.h
index d67228f..a91d0a3 100644
--- a/qmk/keyboards/sofle_choc/keymaps/custom/star_key.h
+++ b/qmk/keyboards/sofle_choc/keymaps/custom/star_key.h
@@ -1,4 +1,6 @@
#pragma once
+#include QMK_KEYBOARD_H
+#include "action.h"
// Initialize the state.
void star_key_init(void);