Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if(CONFIG_SHIELD_CORNEY_LEFT OR CONFIG_SHIELD_CORNEY_RIGHT)
zephyr_library_include_directories(${CMAKE_SOURCE_DIR}/include)
zephyr_library_sources(boards/shields/corney/rawhid_layer_behavior.c)
zephyr_library_sources(boards/shields/corney/rawhid_notify.c)
endif()
1 change: 1 addition & 0 deletions config/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# SPDX-License-Identifier: MIT
8 changes: 8 additions & 0 deletions config/boards/shields/corney/behaviors.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/ {
behaviors {
raw_layer: raw_layer {
compatible = "zmk,behavior-raw-layer";

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add binding for new raw-layer behavior compatible

The new raw_layer node uses compatible = "zmk,behavior-raw-layer", but this change set does not add a corresponding devicetree binding (dts/bindings/...yaml) for that compatible. In Zephyr/ZMK builds, introducing a custom compatible without a binding causes devicetree processing to fail (the node is rejected as having no binding), so firmware builds for this shield will fail before linking.

Useful? React with 👍 / 👎.

#binding-cells = <1>;
};
};
};
7 changes: 6 additions & 1 deletion config/boards/shields/corney/corney.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,9 @@ CONFIG_ZMK_MOUSE_TICK_DURATION=8
# Optional: Adjust mouse movement speed (default is 500)
CONFIG_ZMK_MOUSE_DEFAULT_SPEED=500

ZMK_KEYBOARD_NAME="Corney"

CONFIG_RAW_HID=y
CONFIG_RAW_HID_REPORT_SIZE=32
CONFIG_RAW_HID_DEVICE="HID_1"

CONFIG_ZMK_KEYBOARD_NAME="Corney"
22 changes: 21 additions & 1 deletion config/boards/shields/corney/corney.keymap
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,27 @@
#include <dt-bindings/zmk/mouse.h>

#include "corney_macros.dtsi"
#include "behaviors.dtsi"

/ {
macros {
// Нажал: отправили телеметрию + включили слой
// Держим: слой активен
// Отпустил: отпустили слой (и при желании отправили телеметрию "base")
mo_func_with_notify: mo_func_with_notify {
compatible = "zmk,behavior-macro";
#binding-cells = <0>;

bindings =
<&macro_press &raw_layer FUNC>, // <-- notify (твоё поведение)
<&macro_press &mo FUNC>, // <-- включить слой
<&macro_pause_for_release>, // держать пока удерживаем
<&macro_release &mo FUNC>; // отпустить слой
// опционально:
// , <&macro_tap &raw_layer BASE>;
};
};
};

/ {
keymap {
Expand All @@ -29,7 +49,7 @@
&kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp MINUS
&cycle_lang_de &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp SQT
&kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp COMMA &kp DOT &kp FSLH &kp RSHFT
&kp LCTRL &kp SPACE &mo FUNC &kp RGUI &mo CHARS &kp RALT
&kp LCTRL &kp SPACE &mo_func_with_notify &kp RGUI &mo CHARS &kp RALT
>;
};

Expand Down
45 changes: 45 additions & 0 deletions config/boards/shields/corney/rawhid_layer_behavior.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#define DT_DRV_COMPAT zmk_behavior_raw_layer

#include <zephyr/device.h>
#include <drivers/behavior.h>
#include <zephyr/logging/log.h>
#include <zephyr/sys/util.h>
#include <zmk/behavior.h>

LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);

extern void rawhid_send_layer(uint8_t layer, uint8_t flags);

#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)

static int behavior_rawhid_layer_pressed(struct zmk_behavior_binding *binding,
struct zmk_behavior_binding_event event) {
uint8_t layer = binding->param1;

LOG_DBG("position %d layer %d", event.position, layer);
rawhid_send_layer(layer, 0);

return ZMK_BEHAVIOR_OPAQUE;
}

static int behavior_rawhid_layer_released(struct zmk_behavior_binding *binding,
struct zmk_behavior_binding_event event) {
ARG_UNUSED(binding);
ARG_UNUSED(event);

return ZMK_BEHAVIOR_OPAQUE;
}

static const struct behavior_driver_api behavior_rawhid_layer_driver_api = {
.binding_pressed = behavior_rawhid_layer_pressed,
.binding_released = behavior_rawhid_layer_released,
};

#define RAW_LAYER_INST(n) \
BEHAVIOR_DT_INST_DEFINE(n, NULL, NULL, NULL, NULL, POST_KERNEL, \
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \
&behavior_rawhid_layer_driver_api);

DT_INST_FOREACH_STATUS_OKAY(RAW_LAYER_INST)

#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */
28 changes: 28 additions & 0 deletions config/boards/shields/corney/rawhid_notify.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <zephyr/kernel.h>
#include <stdint.h>
#include <string.h>

#if IS_ENABLED(CONFIG_RAW_HID)
#include <raw_hid/events.h>
#endif

#if IS_ENABLED(CONFIG_RAW_HID)
static uint8_t report_buf[CONFIG_RAW_HID_REPORT_SIZE];
#else
static uint8_t report_buf[32];
#endif

void rawhid_send_layer(uint8_t layer, uint8_t flags)
{
report_buf[0] = 0x01; // message type: layer update
report_buf[1] = layer;
report_buf[2] = flags;

// остальные байты нули
memset(report_buf + 3, 0, sizeof(report_buf) - 3);

#if IS_ENABLED(CONFIG_RAW_HID)
raise_raw_hid_sent_event(
(struct raw_hid_sent_event){.data = report_buf, .length = sizeof(report_buf)});
#endif
}
5 changes: 5 additions & 0 deletions config/dts/bindings/behaviors/zmk,behavior-raw-layer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
description: Raw HID layer report behavior

compatible: "zmk,behavior-raw-layer"

include: one_param.yaml
5 changes: 5 additions & 0 deletions config/west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ manifest:
remotes:
- name: zmkfirmware
url-base: https://github.com/zmkfirmware
- name: zzeneg
url-base: https://github.com/zzeneg
# Additional modules containing boards/shields/custom code can be listed here as well
# See https://docs.zephyrproject.org/3.2.0/develop/west/manifest.html#projects
projects:
- name: zmk
remote: zmkfirmware
revision: v0.2.1
import: app/west.yml
- name: zmk-raw-hid
remote: zzeneg
revision: main
self:
path: config
7 changes: 7 additions & 0 deletions config/zephyr/module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: corney-config
build:
cmake: .
kconfig: Kconfig
settings:
board_root: .
dts_root: .
Loading