mirror of
https://github.com/zmkfirmware/zmk.git
synced 2026-03-20 04:55:20 -05:00
* feat(mouse): Add mouse move and scroll support
* Use Zephyr input subsystem for all pointers.
* Input processors for modifying events, e.g. scaling, swapping
codes, temporary (mouse) layers, etc.
* Mouse move/scroll behaviors.
* Infrastructure in place for physical pointer input devices.
* feat: Add input split support.
* docs: Add initial pointer docs.
---------
Co-authored-by: Cem Aksoylar <caksoylar@users.noreply.github.com>
Co-authored-by: Alexander Krikun <krikun98@gmail.com>
Co-authored-by: Robert U <urob@users.noreply.github.com>
Co-authored-by: Shawn Meier <ftc@users.noreply.github.com>
Co-authored-by: Chris Andreae <chris@andreae.gen.nz>
Co-authored-by: Anant Thazhemadam <47104651+thazhemadam@users.noreply.github.com>
Co-authored-by: Erik Tollerud <erik.tollerud@gmail.com>
Co-authored-by: Nicolas Munnich <98408764+Nick-Munnich@users.noreply.github.com>
69 lines
3.1 KiB
C
69 lines
3.1 KiB
C
/*
|
|
* 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_DBG("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_ZMK_INPUT_SPLIT_INIT_PRIORITY, NULL);
|
|
|
|
#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);
|
|
|
|
#endif
|
|
|
|
DT_INST_FOREACH_STATUS_OKAY(ZIS_INST) |