feat(behaviors): Add &pim447_to and &pim447_mo behaviors.
This commit is contained in:
parent
e907e03271
commit
d081ac7a76
5 changed files with 134 additions and 0 deletions
|
@ -66,6 +66,7 @@ if ((NOT CONFIG_ZMK_SPLIT) OR CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL)
|
||||||
target_sources(app PRIVATE src/behaviors/behavior_mouse_key_press.c)
|
target_sources(app PRIVATE src/behaviors/behavior_mouse_key_press.c)
|
||||||
target_sources(app PRIVATE src/behaviors/behavior_mouse_move.c)
|
target_sources(app PRIVATE src/behaviors/behavior_mouse_move.c)
|
||||||
target_sources(app PRIVATE src/behaviors/behavior_mouse_scroll.c)
|
target_sources(app PRIVATE src/behaviors/behavior_mouse_scroll.c)
|
||||||
|
target_sources(app PRIVATE src/behaviors/behavior_trackball_pim447.c)
|
||||||
target_sources_ifdef(CONFIG_ZMK_EXT_POWER app PRIVATE src/behaviors/behavior_ext_power.c)
|
target_sources_ifdef(CONFIG_ZMK_EXT_POWER app PRIVATE src/behaviors/behavior_ext_power.c)
|
||||||
target_sources(app PRIVATE src/combo.c)
|
target_sources(app PRIVATE src/combo.c)
|
||||||
target_sources(app PRIVATE src/keymap.c)
|
target_sources(app PRIVATE src/keymap.c)
|
||||||
|
|
|
@ -17,3 +17,4 @@
|
||||||
#include <behaviors/mouse_key_press.dtsi>
|
#include <behaviors/mouse_key_press.dtsi>
|
||||||
#include <behaviors/mouse_move.dtsi>
|
#include <behaviors/mouse_move.dtsi>
|
||||||
#include <behaviors/mouse_scroll.dtsi>
|
#include <behaviors/mouse_scroll.dtsi>
|
||||||
|
#include <behaviors/trackball_pim447.dtsi>
|
||||||
|
|
56
app/dts/behaviors/trackball_pim447.dtsi
Normal file
56
app/dts/behaviors/trackball_pim447.dtsi
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021 The ZMK Contributors
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <dt-bindings/zmk/trackball_pim447.h>
|
||||||
|
|
||||||
|
/ {
|
||||||
|
behaviors {
|
||||||
|
/omit-if-no-ref/ pim447_move: behavior_trackball_pim447_move {
|
||||||
|
compatible = "zmk,behavior-trackball-pim447";
|
||||||
|
label = "PIM447_MOVE";
|
||||||
|
mode = <PIM447_MOVE>;
|
||||||
|
#binding-cells = <0>;
|
||||||
|
};
|
||||||
|
|
||||||
|
/omit-if-no-ref/ pim447_scroll: behavior_trackball_pim447_scroll {
|
||||||
|
compatible = "zmk,behavior-trackball-pim447";
|
||||||
|
label = "PIM447_SCROLL";
|
||||||
|
mode = <PIM447_SCROLL>;
|
||||||
|
#binding-cells = <0>;
|
||||||
|
};
|
||||||
|
|
||||||
|
/omit-if-no-ref/ pim447_toggle: behavior_trackball_pim447_toggle {
|
||||||
|
compatible = "zmk,behavior-trackball-pim447";
|
||||||
|
label = "PIM447_TOGGLE";
|
||||||
|
mode = <PIM447_TOGGLE>;
|
||||||
|
#binding-cells = <0>;
|
||||||
|
};
|
||||||
|
|
||||||
|
/omit-if-no-ref/ pim447_move_scroll: behavior_trackball_pim447_move_scroll {
|
||||||
|
compatible = "zmk,behavior-trackball-pim447";
|
||||||
|
label = "PIM447_MOVE_SCROLL";
|
||||||
|
mode = <PIM447_MOVE>;
|
||||||
|
momentary;
|
||||||
|
#binding-cells = <0>;
|
||||||
|
};
|
||||||
|
|
||||||
|
/omit-if-no-ref/ pim447_scroll_move: behavior_trackball_pim447_scroll_move {
|
||||||
|
compatible = "zmk,behavior-trackball-pim447";
|
||||||
|
label = "PIM447_SCROLL_MOVE";
|
||||||
|
mode = <PIM447_SCROLL>;
|
||||||
|
momentary;
|
||||||
|
#binding-cells = <0>;
|
||||||
|
};
|
||||||
|
|
||||||
|
/omit-if-no-ref/ pim447_toggle_toggle: behavior_trackball_pim447_toggle_toggle {
|
||||||
|
compatible = "zmk,behavior-trackball-pim447";
|
||||||
|
label = "PIM447_TOGGLE_TOGGLE";
|
||||||
|
mode = <PIM447_TOGGLE>;
|
||||||
|
momentary;
|
||||||
|
#binding-cells = <0>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
|
@ -0,0 +1,15 @@
|
||||||
|
# Copyright (c) 2021 The ZMK Contributors
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
description: Trackball PIM447 behavior
|
||||||
|
|
||||||
|
compatible: "zmk,behavior-trackball-pim447"
|
||||||
|
|
||||||
|
include: zero_param.yaml
|
||||||
|
|
||||||
|
properties:
|
||||||
|
mode:
|
||||||
|
type: int
|
||||||
|
required: true
|
||||||
|
momentary:
|
||||||
|
type: boolean
|
61
app/src/behaviors/behavior_trackball_pim447.c
Normal file
61
app/src/behaviors/behavior_trackball_pim447.c
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2021 The ZMK Contributors
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define DT_DRV_COMPAT zmk_behavior_trackball_pim447
|
||||||
|
|
||||||
|
#include <devicetree.h>
|
||||||
|
#include <drivers/behavior.h>
|
||||||
|
#include <zmk/trackball_pim447.h>
|
||||||
|
|
||||||
|
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
|
||||||
|
|
||||||
|
struct config {
|
||||||
|
int mode;
|
||||||
|
bool momentary;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int behavior_trackball_pim447_init(const struct device *dev) { return 0; };
|
||||||
|
|
||||||
|
static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding,
|
||||||
|
struct zmk_behavior_binding_event event) {
|
||||||
|
const struct device *device = device_get_binding(binding->behavior_dev);
|
||||||
|
const struct config *config = device->config;
|
||||||
|
|
||||||
|
zmk_trackball_pim447_set_mode(config->mode);
|
||||||
|
|
||||||
|
return ZMK_BEHAVIOR_OPAQUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int on_keymap_binding_released(struct zmk_behavior_binding *binding,
|
||||||
|
struct zmk_behavior_binding_event event) {
|
||||||
|
const struct device *device = device_get_binding(binding->behavior_dev);
|
||||||
|
const struct config *config = device->config;
|
||||||
|
|
||||||
|
if (config->momentary) {
|
||||||
|
zmk_trackball_pim447_set_mode(PIM447_TOGGLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ZMK_BEHAVIOR_OPAQUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct behavior_driver_api behavior_trackball_pim447_driver_api = {
|
||||||
|
.binding_pressed = on_keymap_binding_pressed,
|
||||||
|
.binding_released = on_keymap_binding_released,
|
||||||
|
};
|
||||||
|
|
||||||
|
#define PIM447_INST(n) \
|
||||||
|
static const struct config config_##n = { \
|
||||||
|
.mode = DT_INST_PROP(n, mode), \
|
||||||
|
.momentary = DT_INST_PROP(n, momentary) \
|
||||||
|
}; \
|
||||||
|
\
|
||||||
|
DEVICE_DT_INST_DEFINE(n, behavior_trackball_pim447_init, device_pm_control_nop, \
|
||||||
|
NULL, &config_##n, APPLICATION, \
|
||||||
|
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_trackball_pim447_driver_api);
|
||||||
|
|
||||||
|
DT_INST_FOREACH_STATUS_OKAY(PIM447_INST)
|
||||||
|
|
||||||
|
#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */
|
Loading…
Add table
Reference in a new issue