aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2025-10-09 08:32:59 +0200
committerSébastien Dailly <sebastien@dailly.me>2025-10-09 08:32:59 +0200
commita2b76703a9ed91e86ebbba3e4796525a856e27f2 (patch)
tree60072a66d0858b1ae3d4686ddf0ce84e1c4b2331
parent6f07047180a2e6b189200c18cafe5b4ccc9d2997 (diff)
Moved the star_key handler in it’s own file
-rw-r--r--qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c14
-rw-r--r--qmk/keyboards/sofle_choc/keymaps/custom/star_key.c34
-rw-r--r--qmk/keyboards/sofle_choc/keymaps/custom/star_key.h7
3 files changed, 34 insertions, 21 deletions
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c b/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c
index 802a97f..63bb76d 100644
--- a/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c
+++ b/qmk/keyboards/sofle_choc/keymaps/custom/keycodes.c
@@ -77,7 +77,6 @@ static uint32_t key_timer; // timer for last keyboard activity, use
// 32bit value and function to make longer
// idle time possible
static uint16_t latest_key = 0L;
-static uint8_t star_number = 0;
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
@@ -87,12 +86,11 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
// know if we are inside a typing sequence or not.
key_timer = timer_read32();
latest_key = keycode;
- if (keycode != KC_O && star_number != 0) {
- star_number = 0;
- set_star_key(0);
- }
}
+ // Call the star_key handler
+ star_key_process_record(keycode, record);
+
switch (keycode) {
case KC_LEFT_SHIFT:
if (host_keyboard_led_state().caps_lock) {
@@ -147,12 +145,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}
return true;
- // Handle the dead key in the ErgoL layout.
- // The variable is synchronized over the other side of the keyboard.
- case KC_O:
- star_number = (star_number + 1) % 3;
- set_star_key(star_number != 0);
- return true;
default:
return true; // Process all other keycodes normally
}
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/star_key.c b/qmk/keyboards/sofle_choc/keymaps/custom/star_key.c
index 8c04c00..03ce6b5 100644
--- a/qmk/keyboards/sofle_choc/keymaps/custom/star_key.c
+++ b/qmk/keyboards/sofle_choc/keymaps/custom/star_key.c
@@ -22,16 +22,36 @@ void star_key_init(void) {
}
}
-void set_star_key(bool status) {
- is_star = status;
- is_synced = 0;
-}
-
void sync_star_key(void) {
if (!is_synced) {
// Send the state to the other side of the keyboard
master_to_slave_t m2s = { is_star };
- transaction_rpc_send(SET_STAR_KEY, sizeof(m2s), &m2s);
- is_synced = 1;
+ is_synced = transaction_rpc_send(SET_STAR_KEY, sizeof(m2s), &m2s);
}
}
+static uint8_t star_number = 0;
+#define LY_SYMB TD(TD_LAYER_SYMB)
+void star_key_process_record(uint16_t keycode, keyrecord_t *record) {
+ switch (keycode) {
+ case KC_O:
+ star_number = (star_number + 1) % 3;
+ if (star_number != 0 && is_star == 0) {
+ is_star = 1;
+ is_synced = 0;
+ } else if (star_number == 0) {
+ is_star = 0;
+ is_synced = 0;
+ }
+ return;
+ case LY_SYMB:
+ // Ignore the layer events
+ return;
+ default:
+ if (star_number != 0) {
+ star_number = 0;
+ is_star = 0;
+ is_synced = 0;
+ }
+ return; // Process all other keycodes normally
+ }
+}
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/star_key.h b/qmk/keyboards/sofle_choc/keymaps/custom/star_key.h
index 3b4bb9e..d67228f 100644
--- a/qmk/keyboards/sofle_choc/keymaps/custom/star_key.h
+++ b/qmk/keyboards/sofle_choc/keymaps/custom/star_key.h
@@ -3,9 +3,10 @@
// Initialize the state.
void star_key_init(void);
-// Define the new value for the star key
-void set_star_key(bool status);
-
// This code is intended to be called from the master.
// Send the star key status to the other side of the keyboard
void sync_star_key(void);
+
+// Handle the keypress, turn the light on until the next press, or revert off
+// after a cycle of 3 presses.
+void star_key_process_record(uint16_t keycode, keyrecord_t *record);