-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3c0acbd
commit 4fed437
Showing
10 changed files
with
416 additions
and
63 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
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,15 @@ | ||
include: [base.yaml] | ||
|
||
compatible: "zmk,input-split" | ||
|
||
description: Device to wire up an input device for split use. | ||
|
||
properties: | ||
reg: | ||
required: true | ||
|
||
device: | ||
type: phandle | ||
|
||
input-processors: | ||
type: phandle-array |
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,10 @@ | ||
/* | ||
* Copyright (c) 2024 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#pragma once | ||
|
||
int zmk_input_split_report_peripheral_event(uint8_t reg, uint8_t type, uint16_t code, int32_t value, | ||
bool sync); |
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
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
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 |
---|---|---|
@@ -1,7 +1,8 @@ | ||
|
||
target_sources(app PRIVATE input_listener.c) | ||
target_sources_ifdef(CONFIG_ZMK_INPUT_LISTENER app PRIVATE input_listener.c) | ||
target_sources_ifdef(CONFIG_ZMK_INPUT_PROCESSOR_TRANSFORM app PRIVATE input_processor_transform.c) | ||
target_sources_ifdef(CONFIG_ZMK_INPUT_PROCESSOR_SCALER app PRIVATE input_processor_scaler.c) | ||
target_sources_ifdef(CONFIG_ZMK_INPUT_PROCESSOR_TEMP_LAYER app PRIVATE input_processor_temp_layer.c) | ||
target_sources_ifdef(CONFIG_ZMK_INPUT_PROCESSOR_CODE_MAPPER app PRIVATE input_processor_code_mapper.c) | ||
target_sources_ifdef(CONFIG_ZMK_MOUSE_SMOOTH_SCROLLING app PRIVATE resolution_multipliers.c) | ||
target_sources_ifdef(CONFIG_ZMK_MOUSE_SMOOTH_SCROLLING app PRIVATE resolution_multipliers.c) | ||
target_sources_ifdef(CONFIG_ZMK_INPUT_SPLIT app PRIVATE input_split.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
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,71 @@ | ||
/* | ||
* Copyright (c) 2024 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#define DT_DRV_COMPAT zmk_input_split | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zephyr/device.h> | ||
#include <zephyr/input/input.h> | ||
#include <drivers/input_processor.h> | ||
|
||
#include <zephyr/logging/log.h> | ||
|
||
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); | ||
|
||
#if IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL) | ||
|
||
struct zis_entry { | ||
uint8_t reg; | ||
const struct device *dev; | ||
}; | ||
|
||
#define ZIS_ENTRY(n) {.reg = DT_INST_REG_ADDR(n), .dev = DEVICE_DT_GET(DT_DRV_INST(n))}, | ||
|
||
static const struct zis_entry proxy_inputs[] = {DT_INST_FOREACH_STATUS_OKAY(ZIS_ENTRY)}; | ||
|
||
int zmk_input_split_report_peripheral_event(uint8_t reg, uint8_t type, uint16_t code, int32_t value, | ||
bool sync) { | ||
LOG_WRN("Got peripheral event for %d!", reg); | ||
for (size_t i = 0; i < ARRAY_SIZE(proxy_inputs); i++) { | ||
if (reg == proxy_inputs[i].reg) { | ||
return input_report(proxy_inputs[i].dev, type, code, value, sync, K_NO_WAIT); | ||
} | ||
} | ||
|
||
return -ENODEV; | ||
} | ||
|
||
#define ZIS_INST(n) \ | ||
DEVICE_DT_INST_DEFINE(n, NULL, NULL, NULL, NULL, POST_KERNEL, \ | ||
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, NULL); | ||
|
||
DT_INST_FOREACH_STATUS_OKAY(ZIS_INST) | ||
|
||
#else | ||
|
||
#include <zmk/split/bluetooth/service.h> | ||
|
||
#define ZIS_INST(n) \ | ||
static const struct zmk_input_processor_entry processors_##n[] = \ | ||
COND_CODE_1(DT_INST_NODE_HAS_PROP(n, input_processors), \ | ||
({LISTIFY(DT_INST_PROP_LEN(n, input_processors), \ | ||
ZMK_INPUT_PROCESSOR_ENTRY_AT_IDX, (, ), DT_DRV_INST(n))}), \ | ||
({})); \ | ||
BUILD_ASSERT(DT_INST_NODE_HAS_PROP(n, device), \ | ||
"Peripheral input splits need an `input` property set"); \ | ||
void split_input_handler_##n(struct input_event *evt) { \ | ||
for (size_t i = 0; i < ARRAY_SIZE(processors_##n); i++) { \ | ||
zmk_input_processor_handle_event(processors_##n[i].dev, evt, processors_##n[i].param1, \ | ||
processors_##n[i].param2, NULL); \ | ||
} \ | ||
zmk_split_bt_report_input(DT_INST_REG_ADDR(n), evt->type, evt->code, evt->value, \ | ||
evt->sync); \ | ||
} \ | ||
INPUT_CALLBACK_DEFINE(DEVICE_DT_GET(DT_INST_PHANDLE(n, device)), split_input_handler_##n); | ||
|
||
DT_INST_FOREACH_STATUS_OKAY(ZIS_INST) | ||
|
||
#endif |
Oops, something went wrong.