Skip to content

Commit

Permalink
pre-commit: re-format using clang-format hook (v18.1.8)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximevince authored and petejohanson committed Sep 13, 2024
1 parent 82a22d7 commit 67d595f
Show file tree
Hide file tree
Showing 16 changed files with 45 additions and 59 deletions.
2 changes: 1 addition & 1 deletion app/boards/arm/corneish_zen/widgets/battery_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void battery_status_update_cb(struct battery_status_state state) {
static struct battery_status_state battery_status_get_state(const zmk_event_t *eh) {
const struct zmk_battery_state_changed *ev = as_zmk_battery_state_changed(eh);

return (struct battery_status_state) {
return (struct battery_status_state){
.level = (ev != NULL) ? ev->state_of_charge : zmk_battery_state_of_charge(),
#if IS_ENABLED(CONFIG_USB_DEVICE_STACK)
.usb_present = zmk_usb_is_powered(),
Expand Down
2 changes: 1 addition & 1 deletion app/boards/shields/nice_view/widgets/peripheral_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static void battery_status_update_cb(struct battery_status_state state) {
}

static struct battery_status_state battery_status_get_state(const zmk_event_t *eh) {
return (struct battery_status_state) {
return (struct battery_status_state){
.level = zmk_battery_state_of_charge(),
#if IS_ENABLED(CONFIG_USB_DEVICE_STACK)
.usb_present = zmk_usb_is_powered(),
Expand Down
2 changes: 1 addition & 1 deletion app/boards/shields/nice_view/widgets/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ static void battery_status_update_cb(struct battery_status_state state) {
static struct battery_status_state battery_status_get_state(const zmk_event_t *eh) {
const struct zmk_battery_state_changed *ev = as_zmk_battery_state_changed(eh);

return (struct battery_status_state) {
return (struct battery_status_state){
.level = (ev != NULL) ? ev->state_of_charge : zmk_battery_state_of_charge(),
#if IS_ENABLED(CONFIG_USB_DEVICE_STACK)
.usb_present = zmk_usb_is_powered(),
Expand Down
13 changes: 10 additions & 3 deletions app/include/drivers/behavior.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ struct zmk_behavior_local_id_map {
#if IS_ENABLED(CONFIG_ZMK_BEHAVIOR_METADATA)

#define ZMK_BEHAVIOR_METADATA_INITIALIZER(node_id) \
{ .display_name = DT_PROP_OR(node_id, display_name, DEVICE_DT_NAME(node_id)), }
{ \
.display_name = DT_PROP_OR(node_id, display_name, DEVICE_DT_NAME(node_id)), \
}

#else

Expand All @@ -132,10 +134,15 @@ struct zmk_behavior_local_id_map {
#endif // IS_ENABLED(CONFIG_ZMK_BEHAVIOR_METADATA)

#define ZMK_BEHAVIOR_REF_INITIALIZER(node_id, _dev) \
{ .device = _dev, .metadata = ZMK_BEHAVIOR_METADATA_INITIALIZER(node_id), }
{ \
.device = _dev, \
.metadata = ZMK_BEHAVIOR_METADATA_INITIALIZER(node_id), \
}

#define ZMK_BEHAVIOR_LOCAL_ID_MAP_INITIALIZER(node_id, _dev) \
{ .device = _dev, }
{ \
.device = _dev, \
}

#define ZMK_BEHAVIOR_REF_DEFINE(name, node_id, _dev) \
static const STRUCT_SECTION_ITERABLE(zmk_behavior_ref, name) = \
Expand Down
2 changes: 1 addition & 1 deletion app/include/zmk/virtual_key_position.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
/**
* Gets the sensor number from the virtual key position.
*/
#define ZMK_SENSOR_POSITION_FROM_VIRTUAL_KEY_POSITION(vkp) ((vkp)-ZMK_KEYMAP_LEN)
#define ZMK_SENSOR_POSITION_FROM_VIRTUAL_KEY_POSITION(vkp) ((vkp) - ZMK_KEYMAP_LEN)

/**
* Gets the virtual key position to use for the combo with the given index.
Expand Down
5 changes: 1 addition & 4 deletions app/src/behaviors/behavior_caps_word.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,7 @@ static int behavior_caps_word_init(const struct device *dev) {
#define CAPS_WORD_LABEL(i, _n) DT_INST_LABEL(i)

#define PARSE_BREAK(i) \
{ \
.page = ZMK_HID_USAGE_PAGE(i), .id = ZMK_HID_USAGE_ID(i), \
.implicit_modifiers = SELECT_MODS(i) \
}
{.page = ZMK_HID_USAGE_PAGE(i), .id = ZMK_HID_USAGE_ID(i), .implicit_modifiers = SELECT_MODS(i)}

#define BREAK_ITEM(i, n) PARSE_BREAK(DT_INST_PROP_BY_IDX(n, continue_list, i))

Expand Down
2 changes: 1 addition & 1 deletion app/src/behaviors/behavior_tap_dance.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ static int behavior_tap_dance_init(const struct device *dev) {
#define _TRANSFORM_ENTRY(idx, node) ZMK_KEYMAP_EXTRACT_BINDING(idx, node)

#define TRANSFORMED_BINDINGS(node) \
{ LISTIFY(DT_INST_PROP_LEN(node, bindings), _TRANSFORM_ENTRY, (, ), DT_DRV_INST(node)) }
{LISTIFY(DT_INST_PROP_LEN(node, bindings), _TRANSFORM_ENTRY, (, ), DT_DRV_INST(node))}

#define KP_INST(n) \
static struct zmk_behavior_binding \
Expand Down
2 changes: 1 addition & 1 deletion app/src/display/widgets/battery_status.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void battery_status_update_cb(struct battery_status_state state) {
static struct battery_status_state battery_status_get_state(const zmk_event_t *eh) {
const struct zmk_battery_state_changed *ev = as_zmk_battery_state_changed(eh);

return (struct battery_status_state) {
return (struct battery_status_state){
.level = (ev != NULL) ? ev->state_of_charge : zmk_battery_state_of_charge(),
#if IS_ENABLED(CONFIG_USB_DEVICE_STACK)
.usb_present = zmk_usb_is_powered(),
Expand Down
4 changes: 1 addition & 3 deletions app/src/endpoints.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ int zmk_endpoints_toggle_transport(void) {
return zmk_endpoints_select_transport(new_transport);
}

struct zmk_endpoint_instance zmk_endpoints_selected(void) {
return current_instance;
}
struct zmk_endpoint_instance zmk_endpoints_selected(void) { return current_instance; }

static int send_keyboard_report(void) {
switch (current_instance.transport) {
Expand Down
12 changes: 3 additions & 9 deletions app/src/hid.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,18 +435,12 @@ void zmk_hid_mouse_clear(void) { memset(&mouse_report.body, 0, sizeof(mouse_repo

#endif // IS_ENABLED(CONFIG_ZMK_MOUSE)

struct zmk_hid_keyboard_report *zmk_hid_get_keyboard_report(void) {
return &keyboard_report;
}
struct zmk_hid_keyboard_report *zmk_hid_get_keyboard_report(void) { return &keyboard_report; }

struct zmk_hid_consumer_report *zmk_hid_get_consumer_report(void) {
return &consumer_report;
}
struct zmk_hid_consumer_report *zmk_hid_get_consumer_report(void) { return &consumer_report; }

#if IS_ENABLED(CONFIG_ZMK_MOUSE)

struct zmk_hid_mouse_report *zmk_hid_get_mouse_report(void) {
return &mouse_report;
}
struct zmk_hid_mouse_report *zmk_hid_get_mouse_report(void) { return &mouse_report; }

#endif // IS_ENABLED(CONFIG_ZMK_MOUSE)
13 changes: 6 additions & 7 deletions app/src/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ static zmk_keymap_layer_id_t _zmk_keymap_layer_default = 0;
#endif

#define TRANSFORMED_LAYER(node) \
{ \
COND_CODE_1( \
DT_NODE_HAS_PROP(node, bindings), \
(LISTIFY(DT_PROP_LEN(node, bindings), ZMK_KEYMAP_EXTRACT_BINDING, (, ), node)), ()) \
}
{COND_CODE_1(DT_NODE_HAS_PROP(node, bindings), \
(LISTIFY(DT_PROP_LEN(node, bindings), ZMK_KEYMAP_EXTRACT_BINDING, (, ), node)), \
())}

#if ZMK_KEYMAP_HAS_SENSORS
#define _TRANSFORM_SENSOR_ENTRY(idx, layer) \
Expand Down Expand Up @@ -841,11 +839,12 @@ static int keymap_handle_set(const char *name, size_t len, settings_read_cb read
binding_setting.behavior_local_id);
}

zmk_keymap[layer][key_position] = (struct zmk_behavior_binding) {
zmk_keymap[layer][key_position] = (struct zmk_behavior_binding){
#if IS_ENABLED(CONFIG_ZMK_BEHAVIOR_LOCAL_IDS_IN_BINDINGS)
.local_id = binding_setting.behavior_local_id,
#endif
.behavior_dev = name, .param1 = binding_setting.param1,
.behavior_dev = name,
.param1 = binding_setting.param1,
.param2 = binding_setting.param2,
};
}
Expand Down
3 changes: 2 additions & 1 deletion app/src/kscan_sideband_behaviors.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ static const struct kscan_driver_api ksbb_api = {

#define ENTRY(e) \
{ \
.row = DT_PROP(e, row), .column = DT_PROP(e, column), \
.row = DT_PROP(e, row), \
.column = DT_PROP(e, column), \
.binding = ZMK_KEYMAP_EXTRACT_BINDING(0, e), \
}

Expand Down
4 changes: 3 additions & 1 deletion app/src/physical_layouts.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ struct zmk_kscan_event {
uint32_t state;
};

static struct zmk_kscan_msg_processor { struct k_work work; } msg_processor;
static struct zmk_kscan_msg_processor {
struct k_work work;
} msg_processor;

K_MSGQ_DEFINE(physical_layouts_kscan_msgq, sizeof(struct zmk_kscan_event),
CONFIG_ZMK_KSCAN_EVENT_QUEUE_SIZE, 4);
Expand Down
26 changes: 10 additions & 16 deletions app/src/sensors.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,22 @@ struct sensors_item_cfg {
};

#define _SENSOR_ITEM(idx, node) \
{ \
.dev = DEVICE_DT_GET_OR_NULL(node), \
.trigger = {.type = SENSOR_TRIG_DATA_READY, .chan = SENSOR_CHAN_ROTATION}, \
.config = &configs[idx], .sensor_index = idx \
}
{.dev = DEVICE_DT_GET_OR_NULL(node), \
.trigger = {.type = SENSOR_TRIG_DATA_READY, .chan = SENSOR_CHAN_ROTATION}, \
.config = &configs[idx], \
.sensor_index = idx}
#define SENSOR_ITEM(idx, _i) _SENSOR_ITEM(idx, ZMK_KEYMAP_SENSORS_BY_IDX(idx))

#define PLUS_ONE(n) +1
#define ZMK_KEYMAP_SENSORS_CHILD_COUNT (0 DT_FOREACH_CHILD(ZMK_KEYMAP_SENSORS_NODE, PLUS_ONE))
#define SENSOR_CHILD_ITEM(node) \
{ \
.triggers_per_rotation = \
DT_PROP_OR(node, triggers_per_rotation, \
DT_PROP_OR(ZMK_KEYMAP_SENSORS_NODE, triggers_per_rotation, \
CONFIG_ZMK_KEYMAP_SENSORS_DEFAULT_TRIGGERS_PER_ROTATION)) \
}
{.triggers_per_rotation = \
DT_PROP_OR(node, triggers_per_rotation, \
DT_PROP_OR(ZMK_KEYMAP_SENSORS_NODE, triggers_per_rotation, \
CONFIG_ZMK_KEYMAP_SENSORS_DEFAULT_TRIGGERS_PER_ROTATION))}
#define SENSOR_CHILD_DEFAULTS(idx, arg) \
{ \
.triggers_per_rotation = \
DT_PROP_OR(ZMK_KEYMAP_SENSORS_NODE, triggers_per_rotation, \
CONFIG_ZMK_KEYMAP_SENSORS_DEFAULT_TRIGGERS_PER_ROTATION) \
}
{.triggers_per_rotation = DT_PROP_OR(ZMK_KEYMAP_SENSORS_NODE, triggers_per_rotation, \
CONFIG_ZMK_KEYMAP_SENSORS_DEFAULT_TRIGGERS_PER_ROTATION)}

static struct zmk_sensor_config configs[] = {
#if ZMK_KEYMAP_SENSORS_CHILD_COUNT > 0
Expand Down
8 changes: 2 additions & 6 deletions app/src/studio/rpc.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ static enum studio_framing_state rpc_framing_state;
static K_MUTEX_DEFINE(rpc_transport_mutex);
static struct zmk_rpc_transport *selected_transport;

struct ring_buf *zmk_rpc_get_rx_buf(void) {
return &rpc_rx_buf;
}
struct ring_buf *zmk_rpc_get_rx_buf(void) { return &rpc_rx_buf; }

void zmk_rpc_rx_notify(void) { k_sem_give(&rpc_rx_sem); }

Expand Down Expand Up @@ -118,9 +116,7 @@ static pb_istream_t pb_istream_for_rx_ring_buf() {

RING_BUF_DECLARE(rpc_tx_buf, CONFIG_ZMK_STUDIO_RPC_TX_BUF_SIZE);

struct ring_buf *zmk_rpc_get_tx_buf(void) {
return &rpc_tx_buf;
}
struct ring_buf *zmk_rpc_get_tx_buf(void) { return &rpc_tx_buf; }

static bool rpc_tx_buffer_write(pb_ostream_t *stream, const uint8_t *buf, size_t count) {
void *user_data = stream->state;
Expand Down
4 changes: 1 addition & 3 deletions app/src/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ K_THREAD_STACK_DEFINE(lowprio_q_stack, CONFIG_ZMK_LOW_PRIORITY_THREAD_STACK_SIZE

static struct k_work_q lowprio_work_q;

struct k_work_q *zmk_workqueue_lowprio_work_q(void) {
return &lowprio_work_q;
}
struct k_work_q *zmk_workqueue_lowprio_work_q(void) { return &lowprio_work_q; }

static int workqueue_init(void) {
static const struct k_work_queue_config queue_config = {.name = "Low Priority Work Queue"};
Expand Down

0 comments on commit 67d595f

Please sign in to comment.