uncrustify

This commit is contained in:
Okke Formsma 2020-08-31 22:39:32 +02:00
parent 95361f37ea
commit c2540cb999

View file

@ -64,7 +64,8 @@ struct active_tap_hold active_tap_holds[ZMK_BHV_TAP_HOLD_MAX_HELD] = {};
const struct zmk_event_header *captured_events[ZMK_BHV_TAP_HOLD_MAX_CAPTURED_EVENTS] = {};
/************************************************************ CAPTURED POSITION HELPER FUNCTIONS */
static int capture_event(const struct zmk_event_header* event) {
static int capture_event(const struct zmk_event_header *event)
{
for (int i = 0; i < ZMK_BHV_TAP_HOLD_MAX_CAPTURED_EVENTS; i++) {
if (captured_events[i] == NULL) {
captured_events[i] = event;
@ -74,7 +75,8 @@ static int capture_event(const struct zmk_event_header* event) {
return -ENOMEM;
}
static struct position_state_changed* find_captured_keydown_event(u32_t position){
static struct position_state_changed *find_captured_keydown_event(u32_t position)
{
struct position_state_changed *last_match = NULL;
for (int i = 0; i < ZMK_BHV_TAP_HOLD_MAX_CAPTURED_EVENTS; i++) {
const struct zmk_event_header *eh = captured_events[i];
@ -89,11 +91,11 @@ static struct position_state_changed* find_captured_keydown_event(u32_t position
last_match = position_event;
}
}
return last_match;
}
static void release_captured_events() {
static void release_captured_events()
{
if (undecided_tap_hold != NULL) {
return;
}
@ -146,7 +148,8 @@ static void release_captured_events() {
/************************************************************ ACTIVE TAP HOLD HELPER FUNCTIONS */
static struct active_tap_hold* find_tap_hold(u32_t position) {
static struct active_tap_hold *find_tap_hold(u32_t position)
{
for (int i = 0; i < ZMK_BHV_TAP_HOLD_MAX_HELD; i++) {
if (active_tap_holds[i].position == position) {
return &active_tap_holds[i];
@ -155,7 +158,8 @@ static struct active_tap_hold* find_tap_hold(u32_t position) {
return NULL;
}
static struct active_tap_hold* store_tap_hold(u32_t position, const struct behavior_tap_hold_config* config) {
static struct active_tap_hold *store_tap_hold(u32_t position, const struct behavior_tap_hold_config *config)
{
for (int i = 0; i < ZMK_BHV_TAP_HOLD_MAX_HELD; i++) {
if (active_tap_holds[i].position != ZMK_BHV_TAP_HOLD_POSITION_NOT_USED) {
continue;
@ -169,7 +173,8 @@ static struct active_tap_hold* store_tap_hold(u32_t position, const struct behav
return NULL;
}
static void clear_tap_hold(struct active_tap_hold * tap_hold) {
static void clear_tap_hold(struct active_tap_hold *tap_hold)
{
tap_hold->position = ZMK_BHV_TAP_HOLD_POSITION_NOT_USED;
tap_hold->is_decided = false;
tap_hold->is_hold = false;
@ -183,7 +188,8 @@ enum decision_moment{
TH_TIMER_EVENT = 3,
};
static void decide_balanced(struct active_tap_hold * tap_hold, enum decision_moment event) {
static void decide_balanced(struct active_tap_hold *tap_hold, enum decision_moment event)
{
switch (event) {
case TH_KEY_UP:
tap_hold->is_hold = 0;
@ -201,7 +207,8 @@ static void decide_balanced(struct active_tap_hold * tap_hold, enum decision_mom
}
}
static void decide_tap_preferred(struct active_tap_hold * tap_hold, enum decision_moment event) {
static void decide_tap_preferred(struct active_tap_hold *tap_hold, enum decision_moment event)
{
switch (event) {
case TH_KEY_UP:
tap_hold->is_hold = 0;
@ -215,7 +222,8 @@ static void decide_tap_preferred(struct active_tap_hold * tap_hold, enum decisio
}
}
static void decide_hold_preferred(struct active_tap_hold * tap_hold, enum decision_moment event) {
static void decide_hold_preferred(struct active_tap_hold *tap_hold, enum decision_moment event)
{
switch (event) {
case TH_KEY_UP:
tap_hold->is_hold = 0;
@ -258,7 +266,6 @@ static void decide_tap_hold(struct active_tap_hold * tap_hold, enum decision_mom
}
LOG_DBG("%d decided %s (%s event %d)", tap_hold->position, tap_hold->is_hold ? "hold" : "tap", flavor, event);
undecided_tap_hold = NULL;
struct zmk_behavior_binding *behavior;
@ -302,6 +309,7 @@ static int on_tap_hold_binding_pressed(struct device *dev, u32_t position, u32_t
static int on_tap_hold_binding_released(struct device *dev, u32_t position, u32_t _, u32_t __)
{
struct active_tap_hold *tap_hold = find_tap_hold(position);
if (tap_hold == NULL) {
LOG_ERR("ACTIVE_TAP_HOLD_CLEANED_UP_TOO_EARLY");
return 0;
@ -339,7 +347,8 @@ static const struct behavior_driver_api behavior_tap_hold_driver_api = {
};
static int position_state_changed_listener(const struct zmk_event_header *eh) {
static int position_state_changed_listener(const struct zmk_event_header *eh)
{
struct position_state_changed *ev = cast_position_state_changed(eh);
if (undecided_tap_hold == NULL) {
@ -370,13 +379,16 @@ static int position_state_changed_listener(const struct zmk_event_header *eh) {
return ZMK_EV_EVENT_CAPTURED;
}
static bool is_mod(struct keycode_state_changed* ev) {
static bool is_mod(struct keycode_state_changed *ev)
{
return ev->usage_page == USAGE_KEYPAD && ev->keycode >= LCTL && ev->keycode <= RGUI;
}
static int keycode_state_changed_listener(const struct zmk_event_header *eh) {
static int keycode_state_changed_listener(const struct zmk_event_header *eh)
{
// we want to catch layer-up events too... how?
struct keycode_state_changed *ev = cast_keycode_state_changed(eh);
if (undecided_tap_hold == NULL) {
// LOG_DBG("0x%02X bubble (no undecided tap_hold active)", ev->keycode);
return 0;
@ -395,7 +407,8 @@ static int keycode_state_changed_listener(const struct zmk_event_header *eh) {
}
int behavior_tap_hold_listener(const struct zmk_event_header *eh) {
int behavior_tap_hold_listener(const struct zmk_event_header *eh)
{
if (is_position_state_changed(eh)) {
return position_state_changed_listener(eh);
} else if (is_keycode_state_changed(eh)) {
@ -413,6 +426,7 @@ ZMK_SUBSCRIPTION(behavior_tap_hold, keycode_state_changed);
void behavior_tap_hold_timer_work_handler(struct k_work *item)
{
struct active_tap_hold *tap_hold = CONTAINER_OF(item, struct active_tap_hold, work);
if (tap_hold->work_is_cancelled) {
clear_tap_hold(tap_hold);
} else {
@ -423,6 +437,7 @@ void behavior_tap_hold_timer_work_handler(struct k_work *item)
static int behavior_tap_hold_init(struct device *dev)
{
static bool init_first_run = true;
if (init_first_run) {
for (int i = 0; i < ZMK_BHV_TAP_HOLD_MAX_HELD; i++) {
k_delayed_work_init(&active_tap_holds[i].work, behavior_tap_hold_timer_work_handler);
@ -438,7 +453,8 @@ static struct behavior_tap_hold_data behavior_tap_hold_data;
/************************************************************ NODE CONFIG */
#define _TRANSFORM_ENTRY(idx, node) \
{ .behavior_dev = DT_LABEL(DT_INST_PHANDLE_BY_IDX(node, bindings, idx)), \
{ \
.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))), \
},
@ -454,7 +470,8 @@ static struct behavior_tap_hold_data behavior_tap_hold_data;
.tapping_term_ms = &behavior_tap_hold_config_##n##_gettime, \
.flavor = DT_INST_PROP(n, flavor), \
}; \
DEVICE_AND_API_INIT(behavior_tap_hold_##n, DT_INST_LABEL(n), behavior_tap_hold_init, \
DEVICE_AND_API_INIT( \
behavior_tap_hold_##n, DT_INST_LABEL(n), behavior_tap_hold_init, \
&behavior_tap_hold_data, \
&behavior_tap_hold_config_##n, \
APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, \