chore: clang-format the codebase.

* Use the LLVM style
* Override indent width (8) and column limit (100)
* Fixes #142.
This commit is contained in:
Pete Johanson
2020-09-13 22:53:24 -04:00
parent 296a89ce63
commit 191a2d755a
51 changed files with 2171 additions and 2547 deletions

View File

@@ -22,71 +22,56 @@ static struct device *hid_dev;
static K_SEM_DEFINE(hid_sem, 1, 1);
static void in_ready_cb(void)
{
k_sem_give(&hid_sem);
}
static void in_ready_cb(void) { k_sem_give(&hid_sem); }
static const struct hid_ops ops =
{
.int_in_ready = in_ready_cb,
static const struct hid_ops ops = {
.int_in_ready = in_ready_cb,
};
int zmk_usb_hid_send_report(const u8_t *report, size_t len)
{
switch(usb_status) {
case USB_DC_SUSPEND:
return usb_wakeup_request();
case USB_DC_ERROR:
case USB_DC_RESET:
case USB_DC_DISCONNECTED:
case USB_DC_UNKNOWN:
return -ENODEV;
default:
k_sem_take(&hid_sem, K_MSEC(30));
int err = hid_int_ep_write(hid_dev, report, len, NULL);
int zmk_usb_hid_send_report(const u8_t *report, size_t len) {
switch (usb_status) {
case USB_DC_SUSPEND:
return usb_wakeup_request();
case USB_DC_ERROR:
case USB_DC_RESET:
case USB_DC_DISCONNECTED:
case USB_DC_UNKNOWN:
return -ENODEV;
default:
k_sem_take(&hid_sem, K_MSEC(30));
int err = hid_int_ep_write(hid_dev, report, len, NULL);
if (err) {
k_sem_give(&hid_sem);
}
if (err) {
k_sem_give(&hid_sem);
}
return err;
}
return err;
}
}
void usb_hid_status_cb(enum usb_dc_status_code status, const u8_t *params)
{
usb_status = status;
};
void usb_hid_status_cb(enum usb_dc_status_code status, const u8_t *params) { usb_status = status; };
static int zmk_usb_hid_init(struct device *_arg)
{
int usb_enable_ret;
static int zmk_usb_hid_init(struct device *_arg) {
int usb_enable_ret;
hid_dev = device_get_binding("HID_0");
if (hid_dev == NULL)
{
LOG_ERR("Unable to locate HID device");
return -EINVAL;
}
hid_dev = device_get_binding("HID_0");
if (hid_dev == NULL) {
LOG_ERR("Unable to locate HID device");
return -EINVAL;
}
usb_hid_register_device(hid_dev,
zmk_hid_report_desc, sizeof(zmk_hid_report_desc),
&ops);
usb_hid_register_device(hid_dev, zmk_hid_report_desc, sizeof(zmk_hid_report_desc), &ops);
usb_hid_init(hid_dev);
usb_hid_init(hid_dev);
usb_enable_ret = usb_enable(usb_hid_status_cb);
usb_enable_ret = usb_enable(usb_hid_status_cb);
if (usb_enable_ret != 0)
{
LOG_ERR("Unable to enable USB");
return -EINVAL;
}
if (usb_enable_ret != 0) {
LOG_ERR("Unable to enable USB");
return -EINVAL;
}
return 0;
return 0;
}
SYS_INIT(zmk_usb_hid_init,
APPLICATION,
CONFIG_ZMK_USB_INIT_PRIORITY);
SYS_INIT(zmk_usb_hid_init, APPLICATION, CONFIG_ZMK_USB_INIT_PRIORITY);