-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
uart_comm: Handle FN reports from Keyboard
- Loading branch information
Showing
6 changed files
with
80 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -16,7 +16,7 @@ HW-75 Dynamic | |
- [x] 旋钮力反馈 (FOC) | ||
- [x] 墨水屏 | ||
- [x] 上位机 | ||
- [ ] 键盘联动 | ||
- [x] 键盘联动 | ||
|
||
## 烧录 | ||
|
||
|
This file contains 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
7 changes: 7 additions & 0 deletions
7
config/boards/arm/hw75_dynamic/app/uart_comm/handler/CMakeLists.txt
This file contains 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 @@ | ||
# Copyright (c) 2022-2023 XiNGRZ | ||
# SPDX-License-Identifier: MIT | ||
|
||
# handler - fn-state | ||
|
||
zephyr_library_sources(handler_fn_state.c) | ||
zephyr_library_include_directories(${CMAKE_SOURCE_DIR}/include) |
12 changes: 12 additions & 0 deletions
12
config/boards/arm/hw75_dynamic/app/uart_comm/handler/handler.h
This file contains 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,12 @@ | ||
/* | ||
* Copyright (c) 2022-2023 XiNGRZ | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "uart_comm.pb.h" | ||
|
||
typedef bool (*uart_comm_handler_t)(const uart_comm_MessageK2D *k2d); | ||
|
||
bool handle_fn_state(const uart_comm_MessageK2D *k2d); |
24 changes: 24 additions & 0 deletions
24
config/boards/arm/hw75_dynamic/app/uart_comm/handler/handler_fn_state.c
This file contains 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,24 @@ | ||
/* | ||
* Copyright (c) 2022-2023 XiNGRZ | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#include "handler.h" | ||
|
||
#include <zmk/keymap.h> | ||
|
||
static uint8_t current_layer = 0; | ||
|
||
bool handle_fn_state(const uart_comm_MessageK2D *k2d) | ||
{ | ||
const uart_comm_FnState *report = &k2d->payload.fn_state; | ||
|
||
if (report->pressed) { | ||
current_layer = zmk_keymap_highest_layer_active(); | ||
zmk_keymap_layer_to(1); | ||
} else { | ||
zmk_keymap_layer_to(current_layer); | ||
} | ||
|
||
return true; | ||
} |
This file contains 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