Merge branch 'zmkfirmware:main' into main
This commit is contained in:
commit
0255a7cf6b
12 changed files with 133 additions and 58 deletions
|
@ -78,6 +78,7 @@ if (CONFIG_ZMK_SPLIT_BLE AND CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL)
|
|||
target_sources(app PRIVATE src/split/bluetooth/central.c)
|
||||
endif()
|
||||
target_sources_ifdef(CONFIG_USB_DEVICE_STACK app PRIVATE src/usb.c)
|
||||
target_sources_ifdef(CONFIG_ZMK_USB app PRIVATE src/usb_hid.c)
|
||||
target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/hog.c)
|
||||
target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/rgb_underglow.c)
|
||||
target_sources_ifdef(CONFIG_ZMK_BACKLIGHT app PRIVATE src/backlight.c)
|
||||
|
|
|
@ -477,6 +477,10 @@ if ZMK_USB_LOGGING
|
|||
config ZMK_LOG_LEVEL
|
||||
default 4
|
||||
|
||||
# We do this to avoid log loop where logging to USB generates more log messages.
|
||||
config USB_CDC_ACM_LOG_LEVEL
|
||||
default 1
|
||||
|
||||
config USB_CDC_ACM_RINGBUF_SIZE
|
||||
default 1024
|
||||
|
||||
|
@ -486,6 +490,9 @@ config LOG_BUFFER_SIZE
|
|||
config LOG_STRDUP_BUF_COUNT
|
||||
default 16
|
||||
|
||||
config LOG_PROCESS_THREAD_STARTUP_DELAY_MS
|
||||
default 1000
|
||||
|
||||
#ZMK_USB_LOGGING
|
||||
endif
|
||||
|
||||
|
|
|
@ -23,7 +23,3 @@ enum zmk_usb_conn_state zmk_usb_get_conn_state();
|
|||
|
||||
static inline bool zmk_usb_is_powered() { return zmk_usb_get_conn_state() != ZMK_USB_CONN_NONE; }
|
||||
static inline bool zmk_usb_is_hid_ready() { return zmk_usb_get_conn_state() == ZMK_USB_CONN_HID; }
|
||||
|
||||
#ifdef CONFIG_ZMK_USB
|
||||
int zmk_usb_hid_send_report(const uint8_t *report, size_t len);
|
||||
#endif /* CONFIG_ZMK_USB */
|
9
app/include/zmk/usb_hid.h
Normal file
9
app/include/zmk/usb_hid.h
Normal file
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
* Copyright (c) 2020 The ZMK Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
int zmk_usb_hid_send_report(const uint8_t *report, size_t len);
|
|
@ -398,6 +398,11 @@ static void connected(struct bt_conn *conn, uint8_t err) {
|
|||
|
||||
LOG_DBG("Connected %s", log_strdup(addr));
|
||||
|
||||
err = bt_conn_le_param_update(conn, BT_LE_CONN_PARAM(0x0006, 0x000c, 30, 400));
|
||||
if (err) {
|
||||
LOG_WRN("Failed to update LE parameters (err %d)", err);
|
||||
}
|
||||
|
||||
#if IS_SPLIT_PERIPHERAL
|
||||
bt_conn_le_phy_update(conn, BT_CONN_LE_PHY_PARAM_2M);
|
||||
#endif
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <zmk/endpoints.h>
|
||||
#include <zmk/hid.h>
|
||||
#include <dt-bindings/zmk/hid_usage_pages.h>
|
||||
#include <zmk/usb.h>
|
||||
#include <zmk/usb_hid.h>
|
||||
#include <zmk/hog.h>
|
||||
#include <zmk/event_manager.h>
|
||||
#include <zmk/events/ble_active_profile_changed.h>
|
||||
|
|
|
@ -26,41 +26,6 @@ static void raise_usb_status_changed_event(struct k_work *_work) {
|
|||
|
||||
K_WORK_DEFINE(usb_status_notifier_work, raise_usb_status_changed_event);
|
||||
|
||||
#ifdef CONFIG_ZMK_USB
|
||||
|
||||
static const struct device *hid_dev;
|
||||
|
||||
static K_SEM_DEFINE(hid_sem, 1, 1);
|
||||
|
||||
static void in_ready_cb(const struct device *dev) { k_sem_give(&hid_sem); }
|
||||
|
||||
static const struct hid_ops ops = {
|
||||
.int_in_ready = in_ready_cb,
|
||||
};
|
||||
|
||||
int zmk_usb_hid_send_report(const uint8_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);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CONFIG_ZMK_USB */
|
||||
|
||||
enum usb_dc_status_code zmk_usb_get_status() { return usb_status; }
|
||||
|
||||
enum zmk_usb_conn_state zmk_usb_get_conn_state() {
|
||||
|
@ -87,19 +52,6 @@ void usb_status_cb(enum usb_dc_status_code status, const uint8_t *params) {
|
|||
static int zmk_usb_init(const struct device *_arg) {
|
||||
int usb_enable_ret;
|
||||
|
||||
#ifdef CONFIG_ZMK_USB
|
||||
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_init(hid_dev);
|
||||
|
||||
#endif /* CONFIG_ZMK_USB */
|
||||
|
||||
usb_enable_ret = usb_enable(usb_status_cb);
|
||||
|
||||
if (usb_enable_ret != 0) {
|
||||
|
|
64
app/src/usb_hid.c
Normal file
64
app/src/usb_hid.c
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Copyright (c) 2020 The ZMK Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <device.h>
|
||||
#include <init.h>
|
||||
|
||||
#include <usb/usb_device.h>
|
||||
#include <usb/class/usb_hid.h>
|
||||
|
||||
#include <zmk/usb.h>
|
||||
#include <zmk/hid.h>
|
||||
#include <zmk/keymap.h>
|
||||
#include <zmk/event_manager.h>
|
||||
|
||||
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
|
||||
|
||||
static const struct device *hid_dev;
|
||||
|
||||
static K_SEM_DEFINE(hid_sem, 1, 1);
|
||||
|
||||
static void in_ready_cb(const struct device *dev) { k_sem_give(&hid_sem); }
|
||||
|
||||
static const struct hid_ops ops = {
|
||||
.int_in_ready = in_ready_cb,
|
||||
};
|
||||
|
||||
int zmk_usb_hid_send_report(const uint8_t *report, size_t len) {
|
||||
switch (zmk_usb_get_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);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
static int zmk_usb_hid_init(const struct device *_arg) {
|
||||
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_init(hid_dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYS_INIT(zmk_usb_hid_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);
|
|
@ -74,7 +74,7 @@ The following changes have [already been completed](https://github.com/zmkfirmwa
|
|||
|
||||
### RGB Underglow
|
||||
|
||||
Zephyr's WS2812 `led_strip` driver added a new required property. When adding [underglow](/docs/features/underglow#adding-rgb-underglow-to-a-board) to a board, you now must also add a `color-mapping` property, like:
|
||||
Zephyr's WS2812 `led_strip` driver added a new required property. When adding [underglow](/docs/features/underglow#adding-rgb-underglow-to-a-board) to a board, you now must also add the additional include `#include <dt-bindings/led/led.h>` at the top of your devicetree file, and add a `color-mapping` property like:
|
||||
|
||||
```
|
||||
led_strip: ws2812@0 {
|
||||
|
|
|
@ -7,8 +7,6 @@ sidebar_label: Sticky Key
|
|||
|
||||
A sticky key stays pressed until another key is pressed. It is often used for 'sticky shift'. By using a sticky shift, you don't have to hold the shift key to write a capital.
|
||||
|
||||
By default, sticky keys stay pressed for a second if you don't press any other key. You can configure this with the `release-after-ms` setting (see below).
|
||||
|
||||
### Behavior Binding
|
||||
|
||||
- Reference: `&sk`
|
||||
|
@ -28,11 +26,25 @@ You can use any keycode that works for `&kp` as parameter to `&sk`:
|
|||
|
||||
### Configuration
|
||||
|
||||
You can configure a different `release-after-ms` in your keymap:
|
||||
#### `release-after-ms`
|
||||
|
||||
By default, sticky keys stay pressed for a second if you don't press any other key. You can configure this with the `release-after-ms` setting.
|
||||
|
||||
#### `quick-release`
|
||||
|
||||
Some typists may find that using a sticky shift key interspersed with rapid typing results in two or more capitalized letters instead of one. This happens as the sticky key is active until the next key is released, under which other keys may be pressed and will receive the modifier. You can enable the `quick-release` setting to instead deactivate the sticky key on the next key being pressed, as opposed to released.
|
||||
|
||||
#### `ignore-modifiers`
|
||||
|
||||
This setting is enabled by default. It ensures that if a sticky key modifier is pressed before a previously pressed sticky key is released, the modifiers will get combined so you can add more sticky keys or press a regular key to apply the modifiers. This is to accommodate _callum-style mods_ where you are prone to rolling sticky keys. If you want sticky key modifiers to only chain after release, you can disable this setting.
|
||||
|
||||
#### Example
|
||||
|
||||
```
|
||||
&sk {
|
||||
release-after-ms = <2000>;
|
||||
quick-release;
|
||||
/delete-property/ ignore-modifiers;
|
||||
};
|
||||
|
||||
/ {
|
||||
|
@ -42,6 +54,27 @@ You can configure a different `release-after-ms` in your keymap:
|
|||
};
|
||||
```
|
||||
|
||||
This configuration would apply to all sticky keys. This may not be appropriate if using `quick-release` as you'll lose the ability to chain sticky key modifiers. A better approach for this use case would be to create a new behavior:
|
||||
|
||||
```
|
||||
/ {
|
||||
behaviors {
|
||||
skq: sticky_key_quick_release {
|
||||
compatible = "zmk,behavior-sticky-key";
|
||||
label = "STICKY_KEY_QUICK_RELEASE";
|
||||
#binding-cells = <1>;
|
||||
bindings = <&kp>;
|
||||
release-after-ms = <1000>;
|
||||
quick-release;
|
||||
};
|
||||
};
|
||||
|
||||
keymap {
|
||||
...
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
### Advanced usage
|
||||
|
||||
Sticky keys can be combined; if you tap `&sk LCTRL` and then `&sk LSHIFT` and then `&kp A`, the output will be ctrl+shift+a.
|
||||
|
|
|
@ -6,7 +6,11 @@ sidebar_label: Backlight
|
|||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
Backlight is a feature used to control array of LEDs, usually placed through or under switches. Unlike [RGB Underglow](underglow.md), backlight currently allows only one color per LED, also LEDs are not addressable, so you can't control individual LEDs.
|
||||
Backlight is a feature used to control an array of LEDs, usually placed through or under switches.
|
||||
|
||||
:::info
|
||||
Unlike [RGB Underglow](underglow.md), backlight can only control single color LEDs. Additionally, because backlight LEDs all receive the same power, it's not possible to dim individual LEDs.
|
||||
:::
|
||||
|
||||
## Enabling Backlight
|
||||
|
||||
|
|
|
@ -5,6 +5,10 @@ sidebar_label: RGB Underglow
|
|||
|
||||
RGB underglow is a feature used to control "strips" of RGB LEDs. Most of the time this is called underglow and creates a glow underneath the board using a ring of LEDs around the edge, hence the name. However, this can be extended to be used to control anything from a single LED to a long string of LEDs anywhere on the keyboard.
|
||||
|
||||
:::info
|
||||
RGB underglow can also be used for under-key lighting. If you have RGB LEDs on your keyboard, this is what you want. For PWM/single color LEDs, see [Backlight](backlight.md).
|
||||
:::
|
||||
|
||||
ZMK supports all the RGB LEDs supported by Zephyr. Here's the current list supported:
|
||||
|
||||
- WS2812-ish (WS2812B, WS2813, SK6812, or compatible)
|
||||
|
|
Loading…
Add table
Reference in a new issue