From 87dfa4e753ecd857158760a0d2c6c10a3c72aba6 Mon Sep 17 00:00:00 2001 From: phewphewb Date: Sun, 25 Jan 2026 20:35:58 -0500 Subject: [PATCH 1/2] add active layer raw hid push for klayi app --- klayi/active_layer_indicator.c | 39 ++++++++++++++++++++++++++++++++++ klayi/active_layer_indicator.h | 12 +++++++++++ klayi/qmk_module.json | 7 ++++++ 3 files changed, 58 insertions(+) create mode 100644 klayi/active_layer_indicator.c create mode 100644 klayi/active_layer_indicator.h create mode 100644 klayi/qmk_module.json diff --git a/klayi/active_layer_indicator.c b/klayi/active_layer_indicator.c new file mode 100644 index 0000000..c1c575c --- /dev/null +++ b/klayi/active_layer_indicator.c @@ -0,0 +1,39 @@ +// Copyright 2025 Nomisolutions +// SPDX-License-Identifier: GPL-2.0-or-later + +#include QMK_KEYBOARD_H +#include "active_layer_indicator.h" +#include "raw_hid.h" + +ASSERT_COMMUNITY_MODULES_MIN_API_VERSION(1, 1, 1); + +#ifndef RAW_EPSIZE +# define RAW_EPSIZE 32 +#endif + +static uint8_t current_layer = 0; + +static void send_layer_event(uint8_t layer) { + uint8_t buffer[RAW_EPSIZE] = {0}; + buffer[0] = ACTIVE_LAYER_INDICATOR_MESSAGE; + buffer[1] = ACTIVE_LAYER_PUSH; + buffer[2] = layer; + raw_hid_send(buffer, RAW_EPSIZE); +} + +layer_state_t layer_state_set_active_layer_indicator(layer_state_t state) { + state = layer_state_set_active_layer_indicator_kb(state); + + uint8_t layer = get_highest_layer(state | default_layer_state); + if (current_layer != layer) { + current_layer = layer; + send_layer_event(layer); + } + + return state; +} + +layer_state_t default_layer_state_set_active_layer_indicator(layer_state_t state) { + layer_state_set_active_layer_indicator(state | layer_state); + return default_layer_state_set_active_layer_indicator_kb(state); +} diff --git a/klayi/active_layer_indicator.h b/klayi/active_layer_indicator.h new file mode 100644 index 0000000..5c792ff --- /dev/null +++ b/klayi/active_layer_indicator.h @@ -0,0 +1,12 @@ +// Copyright 2025 Nomisolutions +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "quantum.h" + +#define ACTIVE_LAYER_INDICATOR_MESSAGE 0xA5 + +enum active_layer_indicator_command_id { + ACTIVE_LAYER_PUSH = 0x01, +}; diff --git a/klayi/qmk_module.json b/klayi/qmk_module.json new file mode 100644 index 0000000..c302df2 --- /dev/null +++ b/klayi/qmk_module.json @@ -0,0 +1,7 @@ +{ + "maintainer": "Nomisolutions", + "module_name": "klayi", + "features": { + "raw": true + } +} \ No newline at end of file From d1a03e14832879a79b4803f05015e9ed733847c9 Mon Sep 17 00:00:00 2001 From: phewphewb Date: Mon, 26 Jan 2026 13:34:24 -0500 Subject: [PATCH 2/2] renaming to modules name --- klayi/{active_layer_indicator.c => klayi.c} | 12 ++++++------ klayi/{active_layer_indicator.h => klayi.h} | 0 2 files changed, 6 insertions(+), 6 deletions(-) rename klayi/{active_layer_indicator.c => klayi.c} (65%) rename klayi/{active_layer_indicator.h => klayi.h} (100%) diff --git a/klayi/active_layer_indicator.c b/klayi/klayi.c similarity index 65% rename from klayi/active_layer_indicator.c rename to klayi/klayi.c index c1c575c..2020e1e 100644 --- a/klayi/active_layer_indicator.c +++ b/klayi/klayi.c @@ -2,7 +2,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include QMK_KEYBOARD_H -#include "active_layer_indicator.h" +#include "klayi.h" #include "raw_hid.h" ASSERT_COMMUNITY_MODULES_MIN_API_VERSION(1, 1, 1); @@ -21,8 +21,8 @@ static void send_layer_event(uint8_t layer) { raw_hid_send(buffer, RAW_EPSIZE); } -layer_state_t layer_state_set_active_layer_indicator(layer_state_t state) { - state = layer_state_set_active_layer_indicator_kb(state); +layer_state_t layer_state_set_klayi(layer_state_t state) { + state = layer_state_set_klayi_kb(state); uint8_t layer = get_highest_layer(state | default_layer_state); if (current_layer != layer) { @@ -33,7 +33,7 @@ layer_state_t layer_state_set_active_layer_indicator(layer_state_t state) { return state; } -layer_state_t default_layer_state_set_active_layer_indicator(layer_state_t state) { - layer_state_set_active_layer_indicator(state | layer_state); - return default_layer_state_set_active_layer_indicator_kb(state); +layer_state_t default_layer_state_set_klayi(layer_state_t state) { + layer_state_set_klayi(state | layer_state); + return default_layer_state_set_klayi_kb(state); } diff --git a/klayi/active_layer_indicator.h b/klayi/klayi.h similarity index 100% rename from klayi/active_layer_indicator.h rename to klayi/klayi.h