mirror of
https://github.com/zmkfirmware/zmk.git
synced 2026-03-19 20:45:18 -05:00
Feature: input processor behavior invocation (#2714)
refactor(pointing): Allow stopping event propagation
Allow input processors to return a special value if a given input event
should not be further processed/propagated.
feat(pointing): Add behavior input processor
Add the ability to intercept certain input events and trigger behaviors
when they occur.
Co-authored-by: Jorge Villalobos <minusfive@users.noreply.github.com>
Co-authored-by: Cem Aksoylar <caksoylar@users.noreply.github.com>
This commit is contained in:
@@ -13,6 +13,9 @@
|
||||
#include <zephyr/device.h>
|
||||
#include <zephyr/input/input.h>
|
||||
|
||||
#define ZMK_INPUT_PROC_CONTINUE 0
|
||||
#define ZMK_INPUT_PROC_STOP 1
|
||||
|
||||
struct zmk_input_processor_entry {
|
||||
const struct device *dev;
|
||||
uint32_t param1;
|
||||
@@ -33,6 +36,7 @@ struct zmk_input_processor_entry {
|
||||
}
|
||||
|
||||
struct zmk_input_processor_state {
|
||||
uint8_t input_device_index;
|
||||
int16_t *remainder;
|
||||
};
|
||||
|
||||
|
||||
16
app/include/zmk/combos.h
Normal file
16
app/include/zmk/combos.h
Normal file
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) 2020 The ZMK Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <zephyr/devicetree.h>
|
||||
|
||||
#define ZMK_COMBOS_UTIL_ONE(n) 1
|
||||
|
||||
#define ZMK_COMBOS_LEN \
|
||||
COND_CODE_1( \
|
||||
DT_HAS_COMPAT_STATUS_OKAY(zmk_combos), \
|
||||
(DT_FOREACH_CHILD_STATUS_OKAY_SEP(DT_INST(0, zmk_combos), ZMK_COMBOS_UTIL_ONE, (+))), (0))
|
||||
14
app/include/zmk/input_listeners.h
Normal file
14
app/include/zmk/input_listeners.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (c) 2020 The ZMK Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <zephyr/devicetree.h>
|
||||
|
||||
#define ZMK_INPUT_LISTENERS_UTIL_ONE(n) 1 +
|
||||
|
||||
#define ZMK_INPUT_LISTENERS_LEN \
|
||||
(DT_FOREACH_STATUS_OKAY(zmk_input_listener, ZMK_INPUT_LISTENERS_UTIL_ONE) 0)
|
||||
@@ -7,6 +7,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <zmk/matrix.h>
|
||||
#include <zmk/combos.h>
|
||||
#include <zmk/input_listeners.h>
|
||||
#include <zmk/sensors.h>
|
||||
|
||||
/**
|
||||
@@ -22,4 +24,9 @@
|
||||
/**
|
||||
* Gets the virtual key position to use for the combo with the given index.
|
||||
*/
|
||||
#define ZMK_VIRTUAL_KEY_POSITION_COMBO(index) (ZMK_KEYMAP_LEN + ZMK_KEYMAP_SENSORS_LEN + (index))
|
||||
#define ZMK_VIRTUAL_KEY_POSITION_COMBO(index) \
|
||||
(ZMK_VIRTUAL_KEY_POSITION_SENSOR(ZMK_KEYMAP_SENSORS_LEN) + (index))
|
||||
|
||||
#define ZMK_VIRTUAL_KEY_POSITION_BEHAVIOR_INPUT_PROCESSOR(listener_index, processor_index) \
|
||||
(ZMK_VIRTUAL_KEY_POSITION_COMBO(ZMK_COMBOS_LEN) + \
|
||||
(ZMK_INPUT_LISTENERS_LEN * (processor_index)) + (listener_index))
|
||||
|
||||
Reference in New Issue
Block a user