forked from kofal.net/zmk
chore: clang-format the codebase.
* Use the LLVM style * Override indent width (8) and column limit (100) * Fixes #142.
This commit is contained in:
@@ -3,20 +3,19 @@
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <kernel.h>
|
||||
#include <zephyr/types.h>
|
||||
|
||||
struct zmk_event_type
|
||||
{
|
||||
struct zmk_event_type {
|
||||
const char *name;
|
||||
};
|
||||
|
||||
struct zmk_event_header {
|
||||
const struct zmk_event_type* event;
|
||||
const struct zmk_event_type *event;
|
||||
u8_t last_listener_index;
|
||||
};
|
||||
|
||||
@@ -24,8 +23,7 @@ struct zmk_event_header {
|
||||
#define ZMK_EV_EVENT_CAPTURED 2
|
||||
|
||||
typedef int (*zmk_listener_callback_t)(const struct zmk_event_header *eh);
|
||||
struct zmk_listener
|
||||
{
|
||||
struct zmk_listener {
|
||||
zmk_listener_callback_t callback;
|
||||
};
|
||||
|
||||
@@ -34,55 +32,50 @@ struct zmk_event_subscription {
|
||||
const struct zmk_listener *listener;
|
||||
};
|
||||
|
||||
#define ZMK_EVENT_DECLARE(event_type) \
|
||||
struct event_type* new_##event_type(); \
|
||||
bool is_##event_type(const struct zmk_event_header *eh); \
|
||||
struct event_type* cast_##event_type(const struct zmk_event_header *eh); \
|
||||
#define ZMK_EVENT_DECLARE(event_type) \
|
||||
struct event_type *new_##event_type(); \
|
||||
bool is_##event_type(const struct zmk_event_header *eh); \
|
||||
struct event_type *cast_##event_type(const struct zmk_event_header *eh); \
|
||||
extern const struct zmk_event_type zmk_event_##event_type;
|
||||
|
||||
#define ZMK_EVENT_IMPL(event_type) \
|
||||
const struct zmk_event_type zmk_event_##event_type = { \
|
||||
.name = STRINGIFY(event_type) \
|
||||
}; \
|
||||
const struct zmk_event_type* zmk_event_ref_##event_type __used __attribute__((__section__(".event_type"))) = &zmk_event_##event_type; \
|
||||
struct event_type* new_##event_type() { \
|
||||
struct event_type* ev = (struct event_type *) k_malloc(sizeof(struct event_type)); \
|
||||
ev->header.event = &zmk_event_##event_type; \
|
||||
return ev; \
|
||||
}; \
|
||||
bool is_##event_type(const struct zmk_event_header *eh) { \
|
||||
return eh->event == &zmk_event_##event_type; \
|
||||
}; \
|
||||
struct event_type* cast_##event_type(const struct zmk_event_header *eh) {\
|
||||
return (struct event_type*)eh; \
|
||||
};
|
||||
|
||||
|
||||
#define ZMK_LISTENER(mod, cb) \
|
||||
const struct zmk_listener zmk_listener_##mod = { \
|
||||
.callback = cb \
|
||||
#define ZMK_EVENT_IMPL(event_type) \
|
||||
const struct zmk_event_type zmk_event_##event_type = {.name = STRINGIFY(event_type)}; \
|
||||
const struct zmk_event_type *zmk_event_ref_##event_type __used \
|
||||
__attribute__((__section__(".event_type"))) = &zmk_event_##event_type; \
|
||||
struct event_type *new_##event_type() { \
|
||||
struct event_type *ev = (struct event_type *)k_malloc(sizeof(struct event_type)); \
|
||||
ev->header.event = &zmk_event_##event_type; \
|
||||
return ev; \
|
||||
}; \
|
||||
bool is_##event_type(const struct zmk_event_header *eh) { \
|
||||
return eh->event == &zmk_event_##event_type; \
|
||||
}; \
|
||||
struct event_type *cast_##event_type(const struct zmk_event_header *eh) { \
|
||||
return (struct event_type *)eh; \
|
||||
};
|
||||
|
||||
#define ZMK_SUBSCRIPTION(mod, ev_type) \
|
||||
const Z_DECL_ALIGN(struct zmk_event_subscription) _CONCAT(_CONCAT(zmk_event_sub_,mod),ev_type) __used __attribute__((__section__(".event_subscription"))) = { \
|
||||
.event_type = &zmk_event_##ev_type, \
|
||||
.listener = &zmk_listener_##mod, \
|
||||
#define ZMK_LISTENER(mod, cb) const struct zmk_listener zmk_listener_##mod = {.callback = cb};
|
||||
|
||||
#define ZMK_SUBSCRIPTION(mod, ev_type) \
|
||||
const Z_DECL_ALIGN(struct zmk_event_subscription) \
|
||||
_CONCAT(_CONCAT(zmk_event_sub_, mod), ev_type) __used \
|
||||
__attribute__((__section__(".event_subscription"))) = { \
|
||||
.event_type = &zmk_event_##ev_type, \
|
||||
.listener = &zmk_listener_##mod, \
|
||||
};
|
||||
|
||||
#define ZMK_EVENT_RAISE(ev) \
|
||||
zmk_event_manager_raise((struct zmk_event_header *)ev);
|
||||
#define ZMK_EVENT_RAISE(ev) zmk_event_manager_raise((struct zmk_event_header *)ev);
|
||||
|
||||
#define ZMK_EVENT_RAISE_AFTER(ev, mod) \
|
||||
#define ZMK_EVENT_RAISE_AFTER(ev, mod) \
|
||||
zmk_event_manager_raise_after((struct zmk_event_header *)ev, &zmk_listener_##mod);
|
||||
|
||||
|
||||
#define ZMK_EVENT_RAISE_AT(ev, mod) \
|
||||
#define ZMK_EVENT_RAISE_AT(ev, mod) \
|
||||
zmk_event_manager_raise_at((struct zmk_event_header *)ev, &zmk_listener_##mod);
|
||||
|
||||
#define ZMK_EVENT_RELEASE(ev) \
|
||||
zmk_event_manager_release((struct zmk_event_header *)ev);
|
||||
#define ZMK_EVENT_RELEASE(ev) zmk_event_manager_release((struct zmk_event_header *)ev);
|
||||
|
||||
int zmk_event_manager_raise(struct zmk_event_header *event);
|
||||
int zmk_event_manager_raise_after(struct zmk_event_header *event, const struct zmk_listener *listener);
|
||||
int zmk_event_manager_raise_after(struct zmk_event_header *event,
|
||||
const struct zmk_listener *listener);
|
||||
int zmk_event_manager_raise_at(struct zmk_event_header *event, const struct zmk_listener *listener);
|
||||
int zmk_event_manager_release(struct zmk_event_header *event);
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
#include <zmk/ble/profile.h>
|
||||
|
||||
|
||||
struct ble_active_profile_changed {
|
||||
struct zmk_event_header header;
|
||||
u8_t index;
|
||||
|
||||
@@ -18,9 +18,9 @@ struct keycode_state_changed {
|
||||
|
||||
ZMK_EVENT_DECLARE(keycode_state_changed);
|
||||
|
||||
inline struct keycode_state_changed* create_keycode_state_changed(u8_t usage_page, u32_t keycode, bool state)
|
||||
{
|
||||
struct keycode_state_changed* ev = new_keycode_state_changed();
|
||||
inline struct keycode_state_changed *create_keycode_state_changed(u8_t usage_page, u32_t keycode,
|
||||
bool state) {
|
||||
struct keycode_state_changed *ev = new_keycode_state_changed();
|
||||
ev->usage_page = usage_page;
|
||||
ev->keycode = keycode;
|
||||
ev->state = state;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <zephyr.h>
|
||||
@@ -18,9 +18,9 @@ struct modifiers_state_changed {
|
||||
|
||||
ZMK_EVENT_DECLARE(modifiers_state_changed);
|
||||
|
||||
inline struct modifiers_state_changed* create_modifiers_state_changed(zmk_mod_flags modifiers, bool state)
|
||||
{
|
||||
struct modifiers_state_changed* ev = new_modifiers_state_changed();
|
||||
inline struct modifiers_state_changed *create_modifiers_state_changed(zmk_mod_flags modifiers,
|
||||
bool state) {
|
||||
struct modifiers_state_changed *ev = new_modifiers_state_changed();
|
||||
ev->modifiers = modifiers;
|
||||
ev->state = state;
|
||||
|
||||
|
||||
@@ -140,25 +140,21 @@ static const u8_t zmk_hid_report_desc[] = {
|
||||
// u8_t keys[6];
|
||||
// } __packed;
|
||||
|
||||
struct zmk_hid_keypad_report_body
|
||||
{
|
||||
struct zmk_hid_keypad_report_body {
|
||||
zmk_mod_flags modifiers;
|
||||
u8_t keys[13];
|
||||
} __packed;
|
||||
|
||||
struct zmk_hid_keypad_report
|
||||
{
|
||||
struct zmk_hid_keypad_report {
|
||||
u8_t report_id;
|
||||
struct zmk_hid_keypad_report_body body;
|
||||
} __packed;
|
||||
|
||||
struct zmk_hid_consumer_report_body
|
||||
{
|
||||
struct zmk_hid_consumer_report_body {
|
||||
u8_t keys[6];
|
||||
} __packed;
|
||||
|
||||
struct zmk_hid_consumer_report
|
||||
{
|
||||
struct zmk_hid_consumer_report {
|
||||
u8_t report_id;
|
||||
struct zmk_hid_consumer_report_body body;
|
||||
} __packed;
|
||||
|
||||
@@ -14,8 +14,7 @@ typedef u8_t zmk_action;
|
||||
typedef u8_t zmk_mod;
|
||||
typedef u8_t zmk_mod_flags;
|
||||
|
||||
struct zmk_key_event
|
||||
{
|
||||
struct zmk_key_event {
|
||||
u32_t column;
|
||||
u32_t row;
|
||||
zmk_key key;
|
||||
|
||||
@@ -15,20 +15,20 @@
|
||||
#define ZMK_KEYMAP_TRANSFORM_NODE DT_CHOSEN(zmk_matrix_transform)
|
||||
#define ZMK_KEYMAP_LEN DT_PROP_LEN(ZMK_KEYMAP_TRANSFORM_NODE, map)
|
||||
|
||||
#define ZMK_MATRIX_ROWS DT_PROP(ZMK_KEYMAP_TRANSFORM_NODE,rows)
|
||||
#define ZMK_MATRIX_COLS DT_PROP(ZMK_KEYMAP_TRANSFORM_NODE,columns)
|
||||
#define ZMK_MATRIX_ROWS DT_PROP(ZMK_KEYMAP_TRANSFORM_NODE, rows)
|
||||
#define ZMK_MATRIX_COLS DT_PROP(ZMK_KEYMAP_TRANSFORM_NODE, columns)
|
||||
|
||||
#else /* DT_HAS_CHOSEN(zmk_matrix_transform) */
|
||||
|
||||
#if DT_NODE_HAS_PROP(ZMK_MATRIX_NODE_ID,row_gpios)
|
||||
#define ZMK_MATRIX_ROWS DT_PROP_LEN(ZMK_MATRIX_NODE_ID,row_gpios)
|
||||
#define ZMK_MATRIX_COLS DT_PROP_LEN(ZMK_MATRIX_NODE_ID,col_gpios)
|
||||
#elif DT_NODE_HAS_PROP(ZMK_MATRIX_NODE_ID,input_gpios)
|
||||
#if DT_NODE_HAS_PROP(ZMK_MATRIX_NODE_ID, row_gpios)
|
||||
#define ZMK_MATRIX_ROWS DT_PROP_LEN(ZMK_MATRIX_NODE_ID, row_gpios)
|
||||
#define ZMK_MATRIX_COLS DT_PROP_LEN(ZMK_MATRIX_NODE_ID, col_gpios)
|
||||
#elif DT_NODE_HAS_PROP(ZMK_MATRIX_NODE_ID, input_gpios)
|
||||
#define ZMK_MATRIX_ROWS 1
|
||||
#define ZMK_MATRIX_COLS DT_PROP_LEN(ZMK_MATRIX_NODE_ID,input_gpios)
|
||||
#define ZMK_MATRIX_COLS DT_PROP_LEN(ZMK_MATRIX_NODE_ID, input_gpios)
|
||||
#else
|
||||
#define ZMK_MATRIX_ROWS DT_PROP(ZMK_MATRIX_NODE_ID,rows)
|
||||
#define ZMK_MATRIX_COLS DT_PROP(ZMK_MATRIX_NODE_ID,columns)
|
||||
#define ZMK_MATRIX_ROWS DT_PROP(ZMK_MATRIX_NODE_ID, rows)
|
||||
#define ZMK_MATRIX_COLS DT_PROP(ZMK_MATRIX_NODE_ID, columns)
|
||||
#endif
|
||||
|
||||
#define ZMK_KEYMAP_LEN (ZMK_MATRIX_COLS * ZMK_MATRIX_ROWS)
|
||||
|
||||
@@ -3,10 +3,9 @@
|
||||
#include <bluetooth/uuid.h>
|
||||
|
||||
#ifndef BT_UUID_NUM_OF_DIGITALS
|
||||
#define BT_UUID_NUM_OF_DIGITALS BT_UUID_DECLARE_16(0x2909)
|
||||
#define BT_UUID_NUM_OF_DIGITALS BT_UUID_DECLARE_16(0x2909)
|
||||
#endif
|
||||
|
||||
#define ZMK_BT_SPLIT_UUID(num) BT_UUID_128_ENCODE(num, 0x0096, 0x7107, 0xc967, 0xc5cfb1c2482a)
|
||||
#define ZMK_BT_SPLIT_UUID(num) BT_UUID_128_ENCODE(num, 0x0096, 0x7107, 0xc967, 0xc5cfb1c2482a)
|
||||
#define ZMK_SPLIT_BT_SERVICE_UUID ZMK_BT_SPLIT_UUID(0x00000000)
|
||||
#define ZMK_SPLIT_BT_CHAR_POSITION_STATE_UUID ZMK_BT_SPLIT_UUID(0x00000001)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user