fix(bahavior): allow the sleep time between taps to be modified
This commit is contained in:
parent
5d8a1d8e43
commit
e9f9050810
2 changed files with 10 additions and 5 deletions
|
@ -11,6 +11,9 @@ properties:
|
||||||
bindings:
|
bindings:
|
||||||
type: phandle-array
|
type: phandle-array
|
||||||
required: true
|
required: true
|
||||||
|
sleep:
|
||||||
|
type: int
|
||||||
|
default: 10
|
||||||
mode:
|
mode:
|
||||||
type: string
|
type: string
|
||||||
default: "key-down"
|
default: "key-down"
|
||||||
|
|
|
@ -39,6 +39,7 @@ enum mode {
|
||||||
|
|
||||||
struct behavior_simple_macro_config {
|
struct behavior_simple_macro_config {
|
||||||
int mode;
|
int mode;
|
||||||
|
int sleep;
|
||||||
int behavior_count;
|
int behavior_count;
|
||||||
struct zmk_behavior_binding* behaviors;
|
struct zmk_behavior_binding* behaviors;
|
||||||
};
|
};
|
||||||
|
@ -62,9 +63,9 @@ static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t _
|
||||||
struct device *behavior = device_get_binding(cfg->behaviors[index].behavior_dev);
|
struct device *behavior = device_get_binding(cfg->behaviors[index].behavior_dev);
|
||||||
if (behavior) {
|
if (behavior) {
|
||||||
LOG_DBG("tapping: binding name: %s", log_strdup(cfg->behaviors[index].behavior_dev));
|
LOG_DBG("tapping: binding name: %s", log_strdup(cfg->behaviors[index].behavior_dev));
|
||||||
k_msleep(10);
|
k_msleep(cfg->sleep);
|
||||||
behavior_keymap_binding_pressed(behavior, position, cfg->behaviors[index].param1, cfg->behaviors[index].param2);
|
behavior_keymap_binding_pressed(behavior, position, cfg->behaviors[index].param1, cfg->behaviors[index].param2);
|
||||||
k_msleep(10);
|
k_msleep(cfg->sleep);
|
||||||
behavior_keymap_binding_released(behavior, position, cfg->behaviors[index].param1, cfg->behaviors[index].param2);
|
behavior_keymap_binding_released(behavior, position, cfg->behaviors[index].param1, cfg->behaviors[index].param2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -96,9 +97,9 @@ static int on_keymap_binding_released(struct device *dev, u32_t position, u32_t
|
||||||
struct device *behavior = device_get_binding(cfg->behaviors[index].behavior_dev);
|
struct device *behavior = device_get_binding(cfg->behaviors[index].behavior_dev);
|
||||||
if (behavior) {
|
if (behavior) {
|
||||||
LOG_DBG("tapping: binding name: %s", log_strdup(cfg->behaviors[index].behavior_dev));
|
LOG_DBG("tapping: binding name: %s", log_strdup(cfg->behaviors[index].behavior_dev));
|
||||||
k_msleep(10);
|
k_msleep(cfg->sleep);
|
||||||
behavior_keymap_binding_pressed(behavior, position, cfg->behaviors[index].param1, cfg->behaviors[index].param2);
|
behavior_keymap_binding_pressed(behavior, position, cfg->behaviors[index].param1, cfg->behaviors[index].param2);
|
||||||
k_msleep(10);
|
k_msleep(cfg->sleep);
|
||||||
behavior_keymap_binding_released(behavior, position, cfg->behaviors[index].param1, cfg->behaviors[index].param2);
|
behavior_keymap_binding_released(behavior, position, cfg->behaviors[index].param1, cfg->behaviors[index].param2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,6 +129,7 @@ static const struct behavior_driver_api behavior_simple_macro_driver_api = {
|
||||||
static struct behavior_simple_macro_config behavior_simple_macro_config_##n = { \
|
static struct behavior_simple_macro_config behavior_simple_macro_config_##n = { \
|
||||||
.behaviors = behavior_simple_macro_config_##n##_bindings, \
|
.behaviors = behavior_simple_macro_config_##n##_bindings, \
|
||||||
.behavior_count = DT_INST_PROP_LEN(n, bindings), \
|
.behavior_count = DT_INST_PROP_LEN(n, bindings), \
|
||||||
|
.sleep = DT_INST_PROP(n, sleep), \
|
||||||
.mode = DT_ENUM_IDX(DT_DRV_INST(n), mode), \
|
.mode = DT_ENUM_IDX(DT_DRV_INST(n), mode), \
|
||||||
}; \
|
}; \
|
||||||
static struct behavior_simple_macro_data behavior_simple_macro_data_##n; \
|
static struct behavior_simple_macro_data behavior_simple_macro_data_##n; \
|
||||||
|
|
Loading…
Add table
Reference in a new issue