-
Notifications
You must be signed in to change notification settings - Fork 1
Wip raw hid #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
maxistar
wants to merge
4
commits into
main
Choose a base branch
from
wip_raw_hid
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Wip raw hid #21
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| # SPDX-License-Identifier: MIT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| / { | ||
| behaviors { | ||
| raw_layer: raw_layer { | ||
| compatible = "zmk,behavior-raw-layer"; | ||
| #binding-cells = <1>; | ||
| }; | ||
| }; | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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: . |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new
raw_layernode usescompatible = "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 👍 / 👎.