valdur's mod
This commit is contained in:
parent
e1fc10651c
commit
01d0749411
9 changed files with 244 additions and 3 deletions
|
|
@ -31,6 +31,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
|
|||
#if IS_ENABLED(CONFIG_ZMK_SPLIT_PERIPHERAL_HID_INDICATORS)
|
||||
#include <zmk/events/hid_indicators_changed.h>
|
||||
#endif // IS_ENABLED(CONFIG_ZMK_SPLIT_PERIPHERAL_HID_INDICATORS)
|
||||
#include <zmk/split/bluetooth/peripheral_layers.h>
|
||||
|
||||
#include <zmk/events/sensor_event.h>
|
||||
#include <zmk/sensors.h>
|
||||
|
|
@ -139,6 +140,29 @@ static ssize_t split_svc_get_selected_phys_layout(struct bt_conn *conn,
|
|||
return bt_gatt_attr_read(conn, attrs, buf, len, offset, &selected, sizeof(selected));
|
||||
}
|
||||
|
||||
static uint32_t layers = 0;
|
||||
|
||||
static void split_svc_update_layers_callback(struct k_work *work) {
|
||||
LOG_DBG("Setting peripheral layers: %x", layers);
|
||||
set_peripheral_layers_state(layers);
|
||||
}
|
||||
|
||||
static K_WORK_DEFINE(split_svc_update_layers_work, split_svc_update_layers_callback);
|
||||
|
||||
static ssize_t split_svc_update_layers(struct bt_conn *conn, const struct bt_gatt_attr *attr,
|
||||
const void *buf, uint16_t len, uint16_t offset,
|
||||
uint8_t flags) {
|
||||
if (offset + len > sizeof(uint32_t)) {
|
||||
return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET);
|
||||
}
|
||||
|
||||
memcpy((uint8_t *)&layers + offset, buf, len);
|
||||
|
||||
k_work_submit(&split_svc_update_layers_work);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
#if IS_ENABLED(CONFIG_ZMK_INPUT_SPLIT)
|
||||
|
||||
static void split_input_events_ccc(const struct bt_gatt_attr *attr, uint16_t value) {
|
||||
|
|
@ -204,8 +228,11 @@ BT_GATT_SERVICE_DEFINE(
|
|||
BT_GATT_CHARACTERISTIC(BT_UUID_DECLARE_128(ZMK_SPLIT_BT_SELECT_PHYS_LAYOUT_UUID),
|
||||
BT_GATT_CHRC_WRITE | BT_GATT_CHRC_READ,
|
||||
BT_GATT_PERM_WRITE_ENCRYPT | BT_GATT_PERM_READ_ENCRYPT,
|
||||
split_svc_get_selected_phys_layout, split_svc_select_phys_layout,
|
||||
NULL), );
|
||||
split_svc_get_selected_phys_layout, split_svc_select_phys_layout, NULL),
|
||||
|
||||
BT_GATT_CHARACTERISTIC(BT_UUID_DECLARE_128(ZMK_SPLIT_BT_UPDATE_LAYERS_UUID),
|
||||
BT_GATT_CHRC_WRITE_WITHOUT_RESP, BT_GATT_PERM_WRITE_ENCRYPT, NULL,
|
||||
split_svc_update_layers, NULL), );
|
||||
|
||||
K_THREAD_STACK_DEFINE(service_q_stack, CONFIG_ZMK_SPLIT_BLE_PERIPHERAL_STACK_SIZE);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue