-
-
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
41c9d81
commit c986393
Showing
37 changed files
with
722 additions
and
1 deletion.
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
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 @@ | ||
/* | ||
* Copyright (c) 2022 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
/ { | ||
behaviors { | ||
/omit-if-no-ref/ leader: leader_key { | ||
compatible = "zmk,behavior-leader-key"; | ||
label = "LEADER"; | ||
#binding-cells = <0>; | ||
}; | ||
}; | ||
}; |
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,13 @@ | ||
# Copyright (c) 2022 The ZMK Contributors | ||
# SPDX-License-Identifier: MIT | ||
|
||
description: Leader key behavior | ||
|
||
compatible: "zmk,behavior-leader-key" | ||
|
||
include: zero_param.yaml | ||
|
||
properties: | ||
timeout-ms: | ||
type: int | ||
default: -1 |
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,22 @@ | ||
# Copyright (c) 2022, The ZMK Contributors | ||
# SPDX-License-Identifier: MIT | ||
|
||
description: Leader sequence container | ||
|
||
compatible: "zmk,leader-sequences" | ||
|
||
child-binding: | ||
description: "A leader sequence" | ||
|
||
properties: | ||
bindings: | ||
type: phandle-array | ||
required: true | ||
key-positions: | ||
type: array | ||
required: true | ||
layers: | ||
type: array | ||
default: [-1] | ||
immediate-trigger: | ||
type: boolean |
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,11 @@ | ||
/* | ||
* Copyright (c) 2022 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#pragma once | ||
|
||
void zmk_leader_activate(int32_t timeout, uint32_t position); | ||
void zmk_leader_deactivate(); | ||
bool zmk_leader_get_status(); |
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,53 @@ | ||
/* | ||
* Copyright (c) 2022 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#define DT_DRV_COMPAT zmk_behavior_leader_key | ||
|
||
#include <device.h> | ||
#include <drivers/behavior.h> | ||
#include <logging/log.h> | ||
|
||
#include <zmk/hid.h> | ||
#include <zmk/event_manager.h> | ||
#include <zmk/events/keycode_state_changed.h> | ||
#include <zmk/behavior.h> | ||
#include <zmk/leader.h> | ||
|
||
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); | ||
|
||
struct behavior_leader_key_config { | ||
int32_t timeout_ms; | ||
}; | ||
|
||
static int behavior_leader_key_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 *dev = device_get_binding(binding->behavior_dev); | ||
const struct behavior_leader_key_config *cfg = dev->config; | ||
|
||
zmk_leader_activate(cfg->timeout_ms, event.position); | ||
return ZMK_BEHAVIOR_OPAQUE; | ||
} | ||
|
||
static int on_keymap_binding_released(struct zmk_behavior_binding *binding, | ||
struct zmk_behavior_binding_event event) { | ||
return 0; | ||
} | ||
|
||
static const struct behavior_driver_api behavior_leader_key_driver_api = { | ||
.binding_pressed = on_keymap_binding_pressed, | ||
.binding_released = on_keymap_binding_released, | ||
}; | ||
|
||
#define LEAD_INST(n) \ | ||
static struct behavior_leader_key_config behavior_leader_key_config_##n = { \ | ||
.timeout_ms = DT_INST_PROP(n, timeout_ms)}; \ | ||
DEVICE_DT_INST_DEFINE(n, behavior_leader_key_init, NULL, NULL, \ | ||
&behavior_leader_key_config_##n, APPLICATION, \ | ||
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_leader_key_driver_api); | ||
|
||
DT_INST_FOREACH_STATUS_OKAY(LEAD_INST) |
Oops, something went wrong.