fix: clang format
This commit is contained in:
parent
3c260301eb
commit
888896c3ef
1 changed files with 96 additions and 97 deletions
|
@ -21,9 +21,12 @@
|
|||
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
|
||||
|
||||
#define _TRANSFORM_ENTRY(idx, node) \
|
||||
{ .behavior_dev = DT_LABEL(DT_INST_PHANDLE_BY_IDX(node, bindings, idx)), \
|
||||
.param1 = COND_CODE_0(DT_INST_PHA_HAS_CELL_AT_IDX(node, bindings, idx, param1), (0), (DT_INST_PHA_BY_IDX(node, bindings, idx, param1))), \
|
||||
.param2 = COND_CODE_0(DT_INST_PHA_HAS_CELL_AT_IDX(node, bindings, idx, param2), (0), (DT_INST_PHA_BY_IDX(node, bindings, idx, param2))), \
|
||||
{ \
|
||||
.behavior_dev = DT_LABEL(DT_INST_PHANDLE_BY_IDX(node, bindings, idx)), \
|
||||
.param1 = COND_CODE_0(DT_INST_PHA_HAS_CELL_AT_IDX(node, bindings, idx, param1), (0), \
|
||||
(DT_INST_PHA_BY_IDX(node, bindings, idx, param1))), \
|
||||
.param2 = COND_CODE_0(DT_INST_PHA_HAS_CELL_AT_IDX(node, bindings, idx, param2), (0), \
|
||||
(DT_INST_PHA_BY_IDX(node, bindings, idx, param2))), \
|
||||
},
|
||||
|
||||
#define TRANSFORMED_BINDINGS(node) \
|
||||
|
@ -46,38 +49,34 @@ struct behavior_simple_macro_config {
|
|||
|
||||
struct behavior_simple_macro_data {};
|
||||
|
||||
static int behavior_simple_macro_init(struct device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static int behavior_simple_macro_init(struct device *dev) { return 0; }
|
||||
|
||||
static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t _, u32_t __)
|
||||
{
|
||||
static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t _, u32_t __) {
|
||||
const struct behavior_simple_macro_config *cfg = dev->config_info;
|
||||
|
||||
if (cfg->mode == ZMK_BHV_SIMPLE_MACRO_MODE_KEY_DOWN)
|
||||
{
|
||||
if (cfg->mode == ZMK_BHV_SIMPLE_MACRO_MODE_KEY_DOWN) {
|
||||
LOG_DBG("tapping on key up");
|
||||
for (int index = 0; index < cfg->behavior_count; index++)
|
||||
{
|
||||
for (int index = 0; index < cfg->behavior_count; index++) {
|
||||
struct device *behavior = device_get_binding(cfg->behaviors[index].behavior_dev);
|
||||
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(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(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (cfg->mode == ZMK_BHV_SIMPLE_MACRO_MODE_HOLD)
|
||||
{
|
||||
for (int index = 0; index < cfg->behavior_count; index++)
|
||||
{
|
||||
} else if (cfg->mode == ZMK_BHV_SIMPLE_MACRO_MODE_HOLD) {
|
||||
for (int index = 0; index < cfg->behavior_count; index++) {
|
||||
struct device *behavior = device_get_binding(cfg->behaviors[index].behavior_dev);
|
||||
if (behavior) {
|
||||
LOG_DBG("pressing: binding name: %s", log_strdup(cfg->behaviors[index].behavior_dev));
|
||||
behavior_keymap_binding_pressed(behavior, position, cfg->behaviors[index].param1, cfg->behaviors[index].param2);
|
||||
LOG_DBG("pressing: binding name: %s",
|
||||
log_strdup(cfg->behaviors[index].behavior_dev));
|
||||
behavior_keymap_binding_pressed(behavior, position, cfg->behaviors[index].param1,
|
||||
cfg->behaviors[index].param2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -85,33 +84,32 @@ static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t _
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int on_keymap_binding_released(struct device *dev, u32_t position, u32_t _, u32_t __)
|
||||
{
|
||||
static int on_keymap_binding_released(struct device *dev, u32_t position, u32_t _, u32_t __) {
|
||||
const struct behavior_simple_macro_config *cfg = dev->config_info;
|
||||
|
||||
if (cfg->mode == ZMK_BHV_SIMPLE_MACRO_MODE_KEY_UP)
|
||||
{
|
||||
if (cfg->mode == ZMK_BHV_SIMPLE_MACRO_MODE_KEY_UP) {
|
||||
LOG_DBG("tapping on key down");
|
||||
for (int index = 0; index < cfg->behavior_count; index++)
|
||||
{
|
||||
for (int index = 0; index < cfg->behavior_count; index++) {
|
||||
struct device *behavior = device_get_binding(cfg->behaviors[index].behavior_dev);
|
||||
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(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(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (cfg->mode == ZMK_BHV_SIMPLE_MACRO_MODE_HOLD)
|
||||
{
|
||||
for (int index = cfg->behavior_count - 1; index >= 0; index--)
|
||||
{
|
||||
} else if (cfg->mode == ZMK_BHV_SIMPLE_MACRO_MODE_HOLD) {
|
||||
for (int index = cfg->behavior_count - 1; index >= 0; index--) {
|
||||
struct device *behavior = device_get_binding(cfg->behaviors[index].behavior_dev);
|
||||
if (behavior) {
|
||||
LOG_DBG("releasing: binding name: %s", log_strdup(cfg->behaviors[index].behavior_dev));
|
||||
behavior_keymap_binding_released(behavior, position, cfg->behaviors[index].param1, cfg->behaviors[index].param2);
|
||||
LOG_DBG("releasing: binding name: %s",
|
||||
log_strdup(cfg->behaviors[index].behavior_dev));
|
||||
behavior_keymap_binding_released(behavior, position, cfg->behaviors[index].param1,
|
||||
cfg->behaviors[index].param2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +123,9 @@ static const struct behavior_driver_api behavior_simple_macro_driver_api = {
|
|||
};
|
||||
|
||||
#define KP_INST(n) \
|
||||
static struct zmk_behavior_binding behavior_simple_macro_config_##n##_bindings[DT_INST_PROP_LEN(n, bindings)] = TRANSFORMED_BINDINGS(n); \
|
||||
static struct zmk_behavior_binding \
|
||||
behavior_simple_macro_config_##n##_bindings[DT_INST_PROP_LEN(n, bindings)] = \
|
||||
TRANSFORMED_BINDINGS(n); \
|
||||
static struct behavior_simple_macro_config behavior_simple_macro_config_##n = { \
|
||||
.behaviors = behavior_simple_macro_config_##n##_bindings, \
|
||||
.behavior_count = DT_INST_PROP_LEN(n, bindings), \
|
||||
|
@ -134,8 +134,7 @@ static const struct behavior_driver_api behavior_simple_macro_driver_api = {
|
|||
}; \
|
||||
static struct behavior_simple_macro_data behavior_simple_macro_data_##n; \
|
||||
DEVICE_AND_API_INIT(behavior_simple_macro_##n, DT_INST_LABEL(n), behavior_simple_macro_init, \
|
||||
&behavior_simple_macro_data_##n, \
|
||||
&behavior_simple_macro_config_##n, \
|
||||
&behavior_simple_macro_data_##n, &behavior_simple_macro_config_##n, \
|
||||
APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \
|
||||
&behavior_simple_macro_driver_api);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue