Merge pull request #357 from petejohanson/ble/remove-unpair-combo
fix(ble): Remove unpair combo code.
This commit is contained in:
commit
0031f9bd4d
26 changed files with 1 additions and 192 deletions
|
|
@ -30,7 +30,6 @@ target_sources(app PRIVATE src/hid.c)
|
|||
target_sources(app PRIVATE src/sensors.c)
|
||||
target_sources_ifdef(CONFIG_ZMK_DISPLAY app PRIVATE src/display.c)
|
||||
target_sources(app PRIVATE src/event_manager.c)
|
||||
target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/ble_unpair_combo.c)
|
||||
target_sources_ifdef(CONFIG_ZMK_EXT_POWER app PRIVATE src/ext_power_generic.c)
|
||||
target_sources(app PRIVATE src/events/position_state_changed.c)
|
||||
target_sources(app PRIVATE src/events/keycode_state_changed.c)
|
||||
|
|
|
|||
|
|
@ -58,10 +58,6 @@ RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10
|
|||
|
||||
};
|
||||
|
||||
bt_unpair_combo: bt_unpair_combo {
|
||||
compatible = "zmk,bt-unpair-combo";
|
||||
};
|
||||
|
||||
// TODO: per-key RGB node(s)?
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,3 @@
|
|||
, <&pro_micro_d 14 GPIO_ACTIVE_HIGH>
|
||||
;
|
||||
};
|
||||
|
||||
&bt_unpair_combo {
|
||||
key-positions = <0 38>;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,7 +20,3 @@
|
|||
, <&pro_micro_a 3 GPIO_ACTIVE_HIGH>
|
||||
;
|
||||
};
|
||||
|
||||
&bt_unpair_combo {
|
||||
key-positions = <11 39>;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -44,8 +44,4 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,2) RC(4,9) RC(3,6) RC(3,7)
|
|||
;
|
||||
|
||||
};
|
||||
|
||||
bt_unpair_combo: bt_unpair_combo {
|
||||
compatible = "zmk,bt-unpair-combo";
|
||||
};
|
||||
};
|
||||
|
|
@ -16,7 +16,3 @@
|
|||
, <&pro_micro_d 10 GPIO_ACTIVE_HIGH>
|
||||
;
|
||||
};
|
||||
|
||||
&bt_unpair_combo {
|
||||
key-positions = <0 42>;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,7 +20,3 @@
|
|||
, <&pro_micro_a 1 GPIO_ACTIVE_HIGH>
|
||||
;
|
||||
};
|
||||
|
||||
&bt_unpair_combo {
|
||||
key-positions = <11 43>;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -81,10 +81,6 @@ RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9)
|
|||
sensors = <&left_encoder &right_encoder>;
|
||||
};
|
||||
|
||||
bt_unpair_combo: bt_unpair_combo {
|
||||
compatible = "zmk,bt-unpair-combo";
|
||||
};
|
||||
|
||||
// TODO: RGB node(s)
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,3 @@
|
|||
&left_encoder {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&bt_unpair_combo {
|
||||
key-positions = <0 44>;
|
||||
};
|
||||
|
|
@ -27,7 +27,3 @@
|
|||
&right_encoder {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&bt_unpair_combo {
|
||||
key-positions = <11 45>;
|
||||
};
|
||||
|
|
@ -57,10 +57,6 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,5) RC(4,6) RC(3,6) RC(3,7)
|
|||
compatible = "zmk,keymap-sensors";
|
||||
sensors = <&left_encoder>;
|
||||
};
|
||||
|
||||
bt_unpair_combo: bt_unpair_combo {
|
||||
compatible = "zmk,bt-unpair-combo";
|
||||
};
|
||||
};
|
||||
|
||||
&pro_micro_i2c {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,3 @@
|
|||
&left_encoder {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&bt_unpair_combo {
|
||||
key-positions = <0 53>;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,7 +20,3 @@
|
|||
, <&pro_micro_a 1 GPIO_ACTIVE_HIGH>
|
||||
;
|
||||
};
|
||||
|
||||
&bt_unpair_combo {
|
||||
key-positions = <11 54>;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -56,11 +56,5 @@ RC(6,4) RC(6,3) RC(6,2) RC(6,1) RC(6,0) RC(5,7) RC(5,6) RC(5,5) RC(5,4) RC
|
|||
RC(6,5) RC(6,6) RC(6,7) RC(7,0) RC(7,1) RC(7,2) RC(7,3) RC(7,4)
|
||||
>;
|
||||
};
|
||||
|
||||
bt_unpair_combo: bt_unpair_combo {
|
||||
compatible = "zmk,bt-unpair-combo";
|
||||
key-positions = <0 53>;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -30,11 +30,5 @@
|
|||
;
|
||||
|
||||
};
|
||||
|
||||
bt_unpair_combo: bt_unpair_combo {
|
||||
compatible = "zmk,bt-unpair-combo";
|
||||
key-positions = <0 11>;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -66,10 +66,6 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,5) RC(4,6) RC(3,6) RC(3,7)
|
|||
compatible = "zmk,keymap-sensors";
|
||||
sensors = <&left_encoder &right_encoder>;
|
||||
};
|
||||
|
||||
bt_unpair_combo: bt_unpair_combo {
|
||||
compatible = "zmk,bt-unpair-combo";
|
||||
};
|
||||
};
|
||||
|
||||
&pro_micro_i2c {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,3 @@
|
|||
&left_encoder {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&bt_unpair_combo {
|
||||
key-positions = <0 54>;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -24,7 +24,3 @@
|
|||
&right_encoder {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&bt_unpair_combo {
|
||||
key-positions = <11 55>;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
# Copyright (c) 2020, Pete Johanson
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
description: |
|
||||
Defines a set of key positions that will unpair all BT devices if held on startup.
|
||||
|
||||
compatible: "zmk,bt-unpair-combo"
|
||||
|
||||
properties:
|
||||
key-positions:
|
||||
type: array
|
||||
required: true
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2020 The ZMK Contributors
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include <device.h>
|
||||
#include <init.h>
|
||||
|
||||
#define DT_DRV_COMPAT zmk_bt_unpair_combo
|
||||
|
||||
#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT)
|
||||
|
||||
#include <logging/log.h>
|
||||
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
|
||||
|
||||
#include <zmk/ble.h>
|
||||
#include <zmk/event-manager.h>
|
||||
#include <zmk/events/position-state-changed.h>
|
||||
|
||||
static u8_t combo_state;
|
||||
|
||||
const u32_t key_positions[] = DT_INST_PROP(0, key_positions);
|
||||
#define KP_LEN DT_INST_PROP_LEN(0, key_positions)
|
||||
|
||||
int index_for_key_position(u32_t kp) {
|
||||
for (int i = 0; i < KP_LEN; i++) {
|
||||
if (key_positions[i] == kp) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int unpair_combo_listener(const struct zmk_event_header *eh) {
|
||||
if (is_position_state_changed(eh)) {
|
||||
const struct position_state_changed *psc = cast_position_state_changed(eh);
|
||||
|
||||
int kp_index = index_for_key_position(psc->position);
|
||||
if (kp_index < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
WRITE_BIT(combo_state, kp_index, psc->state);
|
||||
}
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
void unpair_combo_work_handler(struct k_work *work) {
|
||||
for (int i = 0; i < KP_LEN; i++) {
|
||||
if (!(combo_state & BIT(i))) {
|
||||
LOG_DBG("Key position %d not held, skipping unpair combo", key_positions[i]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
zmk_ble_unpair_all();
|
||||
};
|
||||
|
||||
struct k_delayed_work unpair_combo_work;
|
||||
|
||||
int zmk_ble_unpair_combo_init(struct device *_unused) {
|
||||
k_delayed_work_init(&unpair_combo_work, unpair_combo_work_handler);
|
||||
k_delayed_work_submit(&unpair_combo_work, K_SECONDS(2));
|
||||
|
||||
return 0;
|
||||
};
|
||||
|
||||
ZMK_LISTENER(zmk_ble_unpair_combo, unpair_combo_listener);
|
||||
ZMK_SUBSCRIPTION(zmk_ble_unpair_combo, position_state_changed);
|
||||
|
||||
SYS_INIT(zmk_ble_unpair_combo_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);
|
||||
|
||||
#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */
|
||||
Loading…
Add table
Add a link
Reference in a new issue