Skip to content

Commit 6970b68

Browse files
committed
fix(tests): Tweak source handling for non-BLE environments.
1 parent 0387410 commit 6970b68

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

app/include/zmk/behavior.h

+2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
#pragma once
88

9+
10+
911
struct zmk_behavior_binding {
1012
char *behavior_dev;
1113
uint32_t param1;

app/include/zmk/events/position_state_changed.h

+7-3
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@
1010
#include <zmk/event_manager.h>
1111
#include <bluetooth/addr.h>
1212

13-
struct position_state_changed {
14-
struct zmk_event_header header;
1513
#if IS_ENABLED(CONFIG_ZMK_BLE)
16-
const bt_addr_le_t *source;
14+
typedef const bt_addr_le_t *zmk_position_state_changed_source_t;
15+
#else
16+
typedef void *zmk_position_state_changed_source_t;
1717
#endif
18+
19+
struct position_state_changed {
20+
struct zmk_event_header header;
21+
zmk_position_state_changed_source_t source;
1822
uint32_t position;
1923
bool state;
2024
int64_t timestamp;

app/include/zmk/keymap.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#pragma once
88

9-
#include <bluetooth/addr.h>
9+
#include <zmk/events/position_state_changed.h>
1010

1111
typedef uint32_t zmk_keymap_layers_state_t;
1212

@@ -18,5 +18,5 @@ int zmk_keymap_layer_activate(uint8_t layer);
1818
int zmk_keymap_layer_deactivate(uint8_t layer);
1919
int zmk_keymap_layer_toggle(uint8_t layer);
2020

21-
int zmk_keymap_position_state_changed(const bt_addr_le_t *source, uint32_t position, bool pressed,
21+
int zmk_keymap_position_state_changed(zmk_position_state_changed_source_t source, uint32_t position, bool pressed,
2222
int64_t timestamp);

app/src/keymap.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ int invoke_locally(struct zmk_behavior_binding *binding, struct zmk_behavior_bin
129129
}
130130
}
131131

132-
int zmk_keymap_apply_position_state(const bt_addr_le_t *source, int layer, uint32_t position,
133-
bool pressed, int64_t timestamp) {
132+
int zmk_keymap_apply_position_state(zmk_position_state_changed_source_t source, int layer,
133+
uint32_t position, bool pressed, int64_t timestamp) {
134134
struct zmk_behavior_binding *binding = &zmk_keymap[layer][position];
135135
const struct device *behavior;
136136
struct zmk_behavior_binding_event event = {
@@ -156,10 +156,10 @@ int zmk_keymap_apply_position_state(const bt_addr_le_t *source, int layer, uint3
156156
return err;
157157
}
158158

159-
char source_str[BT_ADDR_LE_STR_LEN];
160-
bt_addr_le_to_str(source, source_str, sizeof(source_str));
159+
// char source_str[BT_ADDR_LE_STR_LEN];
160+
// bt_addr_le_to_str(source, source_str, sizeof(source_str));
161161

162-
LOG_DBG("Behavior locality: %d, event source: %s", locality, log_strdup(source_str));
162+
// LOG_DBG("Behavior locality: %d, event source: %s", locality, log_strdup(source_str));
163163

164164
switch (locality) {
165165
case BEHAVIOR_LOCALITY_CENTRAL:
@@ -184,8 +184,8 @@ int zmk_keymap_apply_position_state(const bt_addr_le_t *source, int layer, uint3
184184
return -ENOTSUP;
185185
}
186186

187-
int zmk_keymap_position_state_changed(const bt_addr_le_t *source, uint32_t position, bool pressed,
188-
int64_t timestamp) {
187+
int zmk_keymap_position_state_changed(zmk_position_state_changed_source_t source, uint32_t position,
188+
bool pressed, int64_t timestamp) {
189189
if (pressed) {
190190
zmk_keymap_active_behavior_layer[position] = _zmk_keymap_layer_state;
191191
}

0 commit comments

Comments
 (0)