Skip to content

Commit 46dfe41

Browse files
Merge branch 'zmkfirmware:main' into chiisai_v1.13
2 parents 6e5c24e + abb64ba commit 46dfe41

46 files changed

Lines changed: 1210 additions & 352 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/Kconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,6 @@ config BT_GATT_NOTIFY_MULTIPLE
219219
config BT_GATT_AUTO_SEC_REQ
220220
default (ZMK_SPLIT_BLE && !ZMK_SPLIT_ROLE_CENTRAL)
221221

222-
config BT_DEVICE_APPEARANCE
223-
default 961
224-
225222
config BT_PERIPHERAL_PREF_MIN_INT
226223
default 6
227224

app/Kconfig.defaults

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ config SYSTEM_WORKQUEUE_STACK_SIZE
55
default 2048 if SOC_RP2040
66
default 2048 if ZMK_BLE
77

8+
# Basic
9+
config BT_DEVICE_APPEARANCE
10+
default 961
11+
812
# HID
913
if ZMK_HID_REPORT_TYPE_HKRO
1014

@@ -110,4 +114,4 @@ config ZMK_BATTERY_REPORT_INTERVAL
110114
default 60
111115

112116
# Imports
113-
rsource "src/split/Kconfig.defaults"
117+
rsource "src/split/Kconfig.defaults"

app/dts/behaviors/to_layer.dtsi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
compatible = "zmk,behavior-to-layer";
1616
#binding-cells = <1>;
1717
display-name = "To Layer";
18+
locking;
1819
};
1920
};
2021
};

app/dts/behaviors/toggle_layer.dtsi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
compatible = "zmk,behavior-toggle-layer";
1616
#binding-cells = <1>;
1717
display-name = "Toggle Layer";
18+
locking;
1819
};
1920
};
2021
};

app/dts/bindings/behaviors/zmk,behavior-momentary-layer.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ description: Momentary layer on press/release behavior
66
compatible: "zmk,behavior-momentary-layer"
77

88
include: one_param.yaml
9+
10+
properties:
11+
locking:
12+
type: boolean
13+
description: Whether to "lock" the layer active, preventing behaviors without the "locking" property from deactivating the layer

app/dts/bindings/behaviors/zmk,behavior-to-layer.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,8 @@ description: To Layer
66
compatible: "zmk,behavior-to-layer"
77

88
include: one_param.yaml
9+
10+
properties:
11+
locking:
12+
type: boolean
13+
description: Whether to "lock" the layer active, preventing behaviors without the "locking" property from deactivating the layer

app/dts/bindings/behaviors/zmk,behavior-toggle-layer.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ include: one_param.yaml
1010
properties:
1111
toggle-mode:
1212
type: string
13-
required: false
1413
default: "flip"
1514
enum:
1615
- "on"
1716
- "off"
1817
- "flip"
18+
locking:
19+
type: boolean
20+
description: Whether to "lock" the layer active, preventing behaviors without the "locking" property from deactivating the layer

app/include/zmk/events/layer_state_changed.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212
struct zmk_layer_state_changed {
1313
uint8_t layer;
1414
bool state;
15+
bool locked;
1516
int64_t timestamp;
1617
};
1718

1819
ZMK_EVENT_DECLARE(zmk_layer_state_changed);
1920

20-
static inline int raise_layer_state_changed(uint8_t layer, bool state) {
21+
static inline int raise_layer_state_changed(uint8_t layer, bool state, bool locked) {
2122
return raise_zmk_layer_state_changed((struct zmk_layer_state_changed){
22-
.layer = layer, .state = state, .timestamp = k_uptime_get()});
23+
.layer = layer, .state = state, .locked = locked, .timestamp = k_uptime_get()});
2324
}

app/include/zmk/keymap.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,14 @@ zmk_keymap_layer_id_t zmk_keymap_layer_index_to_id(zmk_keymap_layer_index_t laye
4343

4444
zmk_keymap_layer_id_t zmk_keymap_layer_default(void);
4545
zmk_keymap_layers_state_t zmk_keymap_layer_state(void);
46+
zmk_keymap_layers_state_t zmk_keymap_layer_locks(void);
4647
bool zmk_keymap_layer_active(zmk_keymap_layer_id_t layer);
48+
bool zmk_keymap_layer_locked(zmk_keymap_layer_id_t layer);
4749
zmk_keymap_layer_index_t zmk_keymap_highest_layer_active(void);
48-
int zmk_keymap_layer_activate(zmk_keymap_layer_id_t layer);
49-
int zmk_keymap_layer_deactivate(zmk_keymap_layer_id_t layer);
50-
int zmk_keymap_layer_toggle(zmk_keymap_layer_id_t layer);
51-
int zmk_keymap_layer_to(zmk_keymap_layer_id_t layer);
50+
int zmk_keymap_layer_activate(zmk_keymap_layer_id_t layer, bool locking);
51+
int zmk_keymap_layer_deactivate(zmk_keymap_layer_id_t layer, bool locking);
52+
int zmk_keymap_layer_toggle(zmk_keymap_layer_id_t layer, bool locking);
53+
int zmk_keymap_layer_to(zmk_keymap_layer_id_t layer, bool locking);
5254
const char *zmk_keymap_layer_name(zmk_keymap_layer_id_t layer);
5355

5456
const struct zmk_behavior_binding *zmk_keymap_get_layer_binding_at_idx(zmk_keymap_layer_id_t layer,

app/src/behaviors/behavior_momentary_layer.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515

1616
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
1717

18+
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
19+
1820
#if IS_ENABLED(CONFIG_ZMK_BEHAVIOR_METADATA)
1921

2022
static const struct behavior_parameter_value_metadata param_values[] = {
@@ -36,16 +38,22 @@ static const struct behavior_parameter_metadata metadata = {
3638

3739
#endif
3840

41+
struct behavior_mo_config {
42+
bool locking;
43+
};
44+
3945
static int mo_keymap_binding_pressed(struct zmk_behavior_binding *binding,
4046
struct zmk_behavior_binding_event event) {
4147
LOG_DBG("position %d layer %d", event.position, binding->param1);
42-
return zmk_keymap_layer_activate(binding->param1);
48+
const struct behavior_mo_config *cfg = zmk_behavior_get_binding(binding->behavior_dev)->config;
49+
return zmk_keymap_layer_activate(binding->param1, cfg->locking);
4350
}
4451

4552
static int mo_keymap_binding_released(struct zmk_behavior_binding *binding,
4653
struct zmk_behavior_binding_event event) {
4754
LOG_DBG("position %d layer %d", event.position, binding->param1);
48-
return zmk_keymap_layer_deactivate(binding->param1);
55+
const struct behavior_mo_config *cfg = zmk_behavior_get_binding(binding->behavior_dev)->config;
56+
return zmk_keymap_layer_deactivate(binding->param1, cfg->locking);
4957
}
5058

5159
static const struct behavior_driver_api behavior_mo_driver_api = {
@@ -56,5 +64,13 @@ static const struct behavior_driver_api behavior_mo_driver_api = {
5664
#endif // IS_ENABLED(CONFIG_ZMK_BEHAVIOR_METADATA)
5765
};
5866

59-
BEHAVIOR_DT_INST_DEFINE(0, NULL, NULL, NULL, NULL, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
60-
&behavior_mo_driver_api);
67+
#define MO_INST(n) \
68+
static const struct behavior_mo_config behavior_mo_config_##n = { \
69+
.locking = DT_INST_PROP_OR(n, locking, false), \
70+
}; \
71+
BEHAVIOR_DT_INST_DEFINE(n, NULL, NULL, NULL, &behavior_mo_config_##n, POST_KERNEL, \
72+
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_mo_driver_api);
73+
74+
DT_INST_FOREACH_STATUS_OKAY(MO_INST)
75+
76+
#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */

0 commit comments

Comments
 (0)