mirror of
https://github.com/zmkfirmware/zmk.git
synced 2026-03-20 04:55:20 -05:00
chore: clang-format the codebase.
* Use the LLVM style * Override indent width (8) and column limit (100) * Fixes #142.
This commit is contained in:
@@ -19,19 +19,20 @@
|
||||
* (Internal use only.)
|
||||
*/
|
||||
|
||||
typedef int (*behavior_keymap_binding_callback_t)(struct device *dev, u32_t position, u32_t param1, u32_t param2);
|
||||
typedef int (*behavior_sensor_keymap_binding_callback_t)(struct device *dev, struct device *sensor, u32_t param1, u32_t param2);
|
||||
typedef int (*behavior_keymap_binding_callback_t)(struct device *dev, u32_t position, u32_t param1,
|
||||
u32_t param2);
|
||||
typedef int (*behavior_sensor_keymap_binding_callback_t)(struct device *dev, struct device *sensor,
|
||||
u32_t param1, u32_t param2);
|
||||
|
||||
__subsystem struct behavior_driver_api {
|
||||
behavior_keymap_binding_callback_t binding_pressed;
|
||||
behavior_keymap_binding_callback_t binding_released;
|
||||
behavior_sensor_keymap_binding_callback_t sensor_binding_triggered;
|
||||
behavior_keymap_binding_callback_t binding_pressed;
|
||||
behavior_keymap_binding_callback_t binding_released;
|
||||
behavior_sensor_keymap_binding_callback_t sensor_binding_triggered;
|
||||
};
|
||||
/**
|
||||
* @endcond
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Handle the keymap binding being pressed
|
||||
* @param dev Pointer to the device structure for the driver instance.
|
||||
@@ -41,18 +42,18 @@ __subsystem struct behavior_driver_api {
|
||||
* @retval 0 If successful.
|
||||
* @retval Negative errno code if failure.
|
||||
*/
|
||||
__syscall int behavior_keymap_binding_pressed(struct device *dev, u32_t position, u32_t param1, u32_t param2);
|
||||
__syscall int behavior_keymap_binding_pressed(struct device *dev, u32_t position, u32_t param1,
|
||||
u32_t param2);
|
||||
|
||||
static inline int z_impl_behavior_keymap_binding_pressed(struct device *dev, u32_t position, u32_t param1, u32_t param2)
|
||||
{
|
||||
const struct behavior_driver_api *api =
|
||||
(const struct behavior_driver_api *)dev->driver_api;
|
||||
static inline int z_impl_behavior_keymap_binding_pressed(struct device *dev, u32_t position,
|
||||
u32_t param1, u32_t param2) {
|
||||
const struct behavior_driver_api *api = (const struct behavior_driver_api *)dev->driver_api;
|
||||
|
||||
if (api->binding_pressed == NULL) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
if (api->binding_pressed == NULL) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
return api->binding_pressed(dev, position, param1, param2);
|
||||
return api->binding_pressed(dev, position, param1, param2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,18 +64,18 @@ static inline int z_impl_behavior_keymap_binding_pressed(struct device *dev, u32
|
||||
* @retval 0 If successful.
|
||||
* @retval Negative errno code if failure.
|
||||
*/
|
||||
__syscall int behavior_keymap_binding_released(struct device *dev, u32_t position, u32_t param1, u32_t param2);
|
||||
__syscall int behavior_keymap_binding_released(struct device *dev, u32_t position, u32_t param1,
|
||||
u32_t param2);
|
||||
|
||||
static inline int z_impl_behavior_keymap_binding_released(struct device *dev, u32_t position, u32_t param1, u32_t param2)
|
||||
{
|
||||
const struct behavior_driver_api *api =
|
||||
(const struct behavior_driver_api *)dev->driver_api;
|
||||
static inline int z_impl_behavior_keymap_binding_released(struct device *dev, u32_t position,
|
||||
u32_t param1, u32_t param2) {
|
||||
const struct behavior_driver_api *api = (const struct behavior_driver_api *)dev->driver_api;
|
||||
|
||||
if (api->binding_released == NULL) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
if (api->binding_released == NULL) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
return api->binding_released(dev, position, param1, param2);
|
||||
return api->binding_released(dev, position, param1, param2);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,21 +88,21 @@ static inline int z_impl_behavior_keymap_binding_released(struct device *dev, u3
|
||||
* @retval 0 If successful.
|
||||
* @retval Negative errno code if failure.
|
||||
*/
|
||||
__syscall int behavior_sensor_keymap_binding_triggered(struct device *dev, struct device *sensor, u32_t param1, u32_t param2);
|
||||
__syscall int behavior_sensor_keymap_binding_triggered(struct device *dev, struct device *sensor,
|
||||
u32_t param1, u32_t param2);
|
||||
|
||||
static inline int z_impl_behavior_sensor_keymap_binding_triggered(struct device *dev, struct device *sensor, u32_t param1, u32_t param2)
|
||||
{
|
||||
const struct behavior_driver_api *api =
|
||||
(const struct behavior_driver_api *)dev->driver_api;
|
||||
static inline int z_impl_behavior_sensor_keymap_binding_triggered(struct device *dev,
|
||||
struct device *sensor,
|
||||
u32_t param1, u32_t param2) {
|
||||
const struct behavior_driver_api *api = (const struct behavior_driver_api *)dev->driver_api;
|
||||
|
||||
if (api->sensor_binding_triggered == NULL) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
if (api->sensor_binding_triggered == NULL) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
return api->sensor_binding_triggered(dev, sensor, param1, param2);
|
||||
return api->sensor_binding_triggered(dev, sensor, param1, param2);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#define BT_CLR_CMD 0
|
||||
#define BT_NXT_CMD 1
|
||||
#define BT_PRV_CMD 2
|
||||
#define BT_SEL_CMD 3
|
||||
#define BT_CLR_CMD 0
|
||||
#define BT_NXT_CMD 1
|
||||
#define BT_PRV_CMD 2
|
||||
#define BT_SEL_CMD 3
|
||||
// #define BT_FULL_RESET_CMD 4
|
||||
|
||||
/*
|
||||
@@ -15,7 +15,7 @@ Note: Some future commands will include additional parameters, so we
|
||||
defines these aliases up front.
|
||||
*/
|
||||
|
||||
#define BT_CLR BT_CLR_CMD 0
|
||||
#define BT_NXT BT_NXT_CMD 0
|
||||
#define BT_PRV BT_PRV_CMD 0
|
||||
#define BT_SEL BT_SEL_CMD
|
||||
#define BT_CLR BT_CLR_CMD 0
|
||||
#define BT_NXT BT_NXT_CMD 0
|
||||
#define BT_PRV BT_PRV_CMD 0
|
||||
#define BT_SEL BT_SEL_CMD
|
||||
@@ -55,7 +55,7 @@
|
||||
#define QUOT 0x34
|
||||
#define GRAV 0x35
|
||||
#define CMMA 0x36
|
||||
#define DOT 0x37
|
||||
#define DOT 0x37
|
||||
#define FSLH 0x38
|
||||
#define CLCK 0x39
|
||||
#define F1 0x3A
|
||||
@@ -77,8 +77,8 @@
|
||||
#define INS 0x49
|
||||
#define HOME 0x4A
|
||||
#define PGUP 0x4B
|
||||
#define DEL 0x4C
|
||||
#define END 0x4D
|
||||
#define DEL 0x4C
|
||||
#define END 0x4D
|
||||
#define PGDN 0x4E
|
||||
#define RARW 0x4F
|
||||
#define LARW 0x50
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#define RST_WARM 0x00
|
||||
#define RST_COLD 0x01
|
||||
#define RST_WARM 0x00
|
||||
#define RST_COLD 0x01
|
||||
|
||||
// AdaFruit nrf52 Bootloader Specific. See https://github.com/adafruit/Adafruit_nRF52_Bootloader/blob/d6b28e66053eea467166f44875e3c7ec741cb471/src/main.c#L107
|
||||
// AdaFruit nrf52 Bootloader Specific. See
|
||||
// https://github.com/adafruit/Adafruit_nRF52_Bootloader/blob/d6b28e66053eea467166f44875e3c7ec741cb471/src/main.c#L107
|
||||
|
||||
#define RST_UF2 0x57
|
||||
#define RST_UF2 0x57
|
||||
@@ -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