summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Johanson <peter@peterjohanson.com>2020-06-30 15:21:42 -0400
committerPete Johanson <peter@peterjohanson.com>2020-06-30 15:21:42 -0400
commit57e061ac91ba95fb333139cbb3b0df97d1b22c98 (patch)
treec403358b736473a8454620fecc12cb88d378309c
parent96ec16da9246c3c7c07986a0c6a2900d3bbfddaa (diff)
Lots of cleanup of old events/behavior mash.
-rw-r--r--app/CMakeLists.txt3
-rw-r--r--app/dts/behaviors.dtsi3
-rw-r--r--app/dts/behaviors/hid.dtsi9
-rw-r--r--app/include/zmk/events.h9
-rw-r--r--app/src/behaviors/behavior_mod_tap.c1
-rw-r--r--app/src/behaviors/behavior_momentary_layer.c1
-rw-r--r--app/src/events.c83
-rw-r--r--app/src/hid_listener.c (renamed from app/src/behaviors/behavior_hid.c)53
8 files changed, 16 insertions, 146 deletions
diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt
index 9bfc8d6..5be628b 100644
--- a/app/CMakeLists.txt
+++ b/app/CMakeLists.txt
@@ -29,14 +29,13 @@ zephyr_linker_sources(RODATA include/linker/zmk-events.ld)
target_include_directories(app PRIVATE include)
target_sources(app PRIVATE src/kscan.c)
target_sources(app PRIVATE src/matrix_transform.c)
-target_sources(app PRIVATE src/events.c)
target_sources(app PRIVATE src/keymap.c)
+target_sources(app PRIVATE src/hid_listener.c)
target_sources(app PRIVATE src/hid.c)
target_sources(app PRIVATE src/event_manager.c)
target_sources(app PRIVATE src/events/position_state_changed.c)
target_sources(app PRIVATE src/events/keycode_state_changed.c)
target_sources(app PRIVATE src/events/modifiers_state_changed.c)
-target_sources(app PRIVATE src/behaviors/behavior_hid.c)
target_sources(app PRIVATE src/behaviors/behavior_key_press.c)
target_sources(app PRIVATE src/behaviors/behavior_reset.c)
target_sources(app PRIVATE src/behaviors/behavior_mod_tap.c)
diff --git a/app/dts/behaviors.dtsi b/app/dts/behaviors.dtsi
index 7a4f8fb..86cd7b7 100644
--- a/app/dts/behaviors.dtsi
+++ b/app/dts/behaviors.dtsi
@@ -2,5 +2,4 @@
#include <behaviors/transparent.dtsi>
#include <behaviors/mod_tap.dtsi>
#include <behaviors/momentary_layer.dtsi>
-#include <behaviors/reset.dtsi>
-#include <behaviors/hid.dtsi> \ No newline at end of file
+#include <behaviors/reset.dtsi> \ No newline at end of file
diff --git a/app/dts/behaviors/hid.dtsi b/app/dts/behaviors/hid.dtsi
deleted file mode 100644
index 30ebb09..0000000
--- a/app/dts/behaviors/hid.dtsi
+++ /dev/null
@@ -1,9 +0,0 @@
-/ {
- behaviors {
- hid_behavior: behavior_hid {
- compatible = "zmk,behavior-hid", "zmk,behavior-global";
- label = "HID";
- #binding-cells = <0>;
- };
- };
-};
diff --git a/app/include/zmk/events.h b/app/include/zmk/events.h
deleted file mode 100644
index 178686c..0000000
--- a/app/include/zmk/events.h
+++ /dev/null
@@ -1,9 +0,0 @@
-#pragma once
-
-#include <zmk/keys.h>
-
-int zmk_events_modifiers_pressed(zmk_mod_flags modifiers);
-int zmk_events_modifiers_released(zmk_mod_flags modifiers);
-
-// TODO: Encoders?
-// TODO: Sensors? \ No newline at end of file
diff --git a/app/src/behaviors/behavior_mod_tap.c b/app/src/behaviors/behavior_mod_tap.c
index 3746183..62604eb 100644
--- a/app/src/behaviors/behavior_mod_tap.c
+++ b/app/src/behaviors/behavior_mod_tap.c
@@ -13,7 +13,6 @@
#include <zmk/event-manager.h>
#include <zmk/events/keycode-state-changed.h>
#include <zmk/events/modifiers-state-changed.h>
-#include <zmk/events.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
diff --git a/app/src/behaviors/behavior_momentary_layer.c b/app/src/behaviors/behavior_momentary_layer.c
index 904051e..8a8584a 100644
--- a/app/src/behaviors/behavior_momentary_layer.c
+++ b/app/src/behaviors/behavior_momentary_layer.c
@@ -10,7 +10,6 @@
#include <drivers/behavior.h>
#include <logging/log.h>
-#include <zmk/events.h>
#include <zmk/keymap.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
diff --git a/app/src/events.c b/app/src/events.c
deleted file mode 100644
index fabb93e..0000000
--- a/app/src/events.c
+++ /dev/null
@@ -1,83 +0,0 @@
-
-#include <zephyr.h>
-#include <drivers/behavior.h>
-#include <zmk/behavior.h>
-#include <zmk/events.h>
-#include <sys/util.h>
-
-#define DT_DRV_COMPAT zmk_behavior_global
-#define GLOBAL_BEHAVIOR_LEN DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT)
-
-#define LABEL_ENTRY(i) DT_INST_LABEL(i),
-static const char *global_behaviors[] = {
- DT_INST_FOREACH_STATUS_OKAY(LABEL_ENTRY)
-};
-
-int zmk_events_position_pressed(u32_t position)
-{
- for (int i = 0; i < GLOBAL_BEHAVIOR_LEN; i++) {
- const char* label = global_behaviors[i];
- struct device *dev = device_get_binding(label);
- behavior_position_pressed(dev, position);
- }
- return 0;
-};
-
-int zmk_events_position_released(u32_t position)
-{
- for (int i = 0; i < GLOBAL_BEHAVIOR_LEN; i++) {
- const char* label = global_behaviors[i];
- struct device *dev = device_get_binding(label);
- behavior_position_released(dev, position);
- }
- return 0;
-};
-
-int zmk_events_keycode_pressed(u8_t usage_page, u32_t keycode)
-{
- for (int i = 0; i < GLOBAL_BEHAVIOR_LEN; i++) {
- const char* label = global_behaviors[i];
- struct device *dev = device_get_binding(label);
- behavior_keycode_pressed(dev, usage_page, keycode);
- }
- return 0;
-};
-
-int zmk_events_keycode_released(u8_t usage_page, u32_t keycode)
-{
- for (int i = 0; i < GLOBAL_BEHAVIOR_LEN; i++) {
- const char* label = global_behaviors[i];
- struct device *dev = device_get_binding(label);
- behavior_keycode_released(dev, usage_page, keycode);
- }
- return 0;
-};
-
-int zmk_events_modifiers_pressed(zmk_mod_flags modifiers)
-{
- for (int i = 0; i < GLOBAL_BEHAVIOR_LEN; i++) {
- const char* label = global_behaviors[i];
- struct device *dev = device_get_binding(label);
- behavior_modifiers_pressed(dev, modifiers);
- }
- return 0;
-};
-
-int zmk_events_modifiers_released(zmk_mod_flags modifiers)
-{
- for (int i = 0; i < GLOBAL_BEHAVIOR_LEN; i++) {
- const char* label = global_behaviors[i];
- struct device *dev = device_get_binding(label);
- behavior_modifiers_released(dev, modifiers);
- }
- return 0;
-};
-
-int zmk_events_consumer_key_pressed(u32_t usage)
-{
- return 0;
-};
-int zmk_events_consumer_key_released(u32_t usage)
-{
- return 0;
-};
diff --git a/app/src/behaviors/behavior_hid.c b/app/src/hid_listener.c
index 9e1fb6b..69aa23e 100644
--- a/app/src/behaviors/behavior_hid.c
+++ b/app/src/hid_listener.c
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: MIT
*/
-#define DT_DRV_COMPAT zmk_behavior_hid
-
-#include <device.h>
-#include <power/reboot.h>
#include <drivers/behavior.h>
#include <logging/log.h>
@@ -19,14 +15,11 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#include <zmk/hid.h>
#include <zmk/endpoints.h>
-struct behavior_hid_config { };
-struct behavior_hid_data { };
-
-static int behaviour_hid_keycode_pressed(u8_t usage_page, u32_t keycode)
+static int hid_listener_keycode_pressed(u8_t usage_page, u32_t keycode)
{
int err;
- LOG_DBG("keycode %d", keycode);
+ LOG_DBG("usage_page 0x%02X keycode 0x%02X", usage_page, keycode);
switch (usage_page) {
case USAGE_KEYPAD:
@@ -48,10 +41,10 @@ static int behaviour_hid_keycode_pressed(u8_t usage_page, u32_t keycode)
return zmk_endpoints_send_report(usage_page);
}
-static int behaviour_hid_keycode_released(u8_t usage_page, u32_t keycode)
+static int hid_listener_keycode_released(u8_t usage_page, u32_t keycode)
{
int err;
- LOG_DBG("keycode %d", keycode);
+ LOG_DBG("usage_page 0x%02X keycode 0x%02X", usage_page, keycode);
switch (usage_page) {
case USAGE_KEYPAD:
@@ -72,7 +65,7 @@ static int behaviour_hid_keycode_released(u8_t usage_page, u32_t keycode)
return zmk_endpoints_send_report(usage_page);
}
-static int behavior_hid_modifiers_pressed(zmk_mod_flags modifiers)
+static int hid_listener_modifiers_pressed(zmk_mod_flags modifiers)
{
LOG_DBG("modifiers %d", modifiers);
@@ -80,7 +73,7 @@ static int behavior_hid_modifiers_pressed(zmk_mod_flags modifiers)
return zmk_endpoints_send_report(USAGE_KEYPAD);
}
-static int behavior_hid_modifiers_released(zmk_mod_flags modifiers)
+static int hid_listener_modifiers_released(zmk_mod_flags modifiers)
{
LOG_DBG("modifiers %d", modifiers);
@@ -88,44 +81,26 @@ static int behavior_hid_modifiers_released(zmk_mod_flags modifiers)
return zmk_endpoints_send_report(USAGE_KEYPAD);
}
-int behavior_hid_listener(const struct zmk_event_header *eh)
+int hid_listener(const struct zmk_event_header *eh)
{
if (is_keycode_state_changed(eh)) {
const struct keycode_state_changed *ev = cast_keycode_state_changed(eh);
if (ev->state) {
- behaviour_hid_keycode_pressed(ev->usage_page, ev->keycode);
+ hid_listener_keycode_pressed(ev->usage_page, ev->keycode);
} else {
- behaviour_hid_keycode_released(ev->usage_page, ev->keycode);
+ hid_listener_keycode_released(ev->usage_page, ev->keycode);
}
} else if (is_modifiers_state_changed(eh)) {
const struct modifiers_state_changed *ev = cast_modifiers_state_changed(eh);
if (ev->state) {
- behavior_hid_modifiers_pressed(ev->modifiers);
+ hid_listener_modifiers_pressed(ev->modifiers);
} else {
- behavior_hid_modifiers_released(ev->modifiers);
+ hid_listener_modifiers_released(ev->modifiers);
}
}
return 0;
}
-ZMK_LISTENER(behavior_hid, behavior_hid_listener);
-ZMK_SUBSCRIPTION(behavior_hid, keycode_state_changed);
-ZMK_SUBSCRIPTION(behavior_hid, modifiers_state_changed);
-
-static int behavior_hid_init(struct device *dev)
-{
- return 0;
-};
-
-static const struct behavior_driver_api behavior_hid_driver_api = {
-};
-
-static const struct behavior_hid_config behavior_hid_config = {};
-
-static struct behavior_hid_data behavior_hid_data;
-
-DEVICE_AND_API_INIT(behavior_hid, DT_INST_LABEL(0), behavior_hid_init,
- &behavior_hid_data,
- &behavior_hid_config,
- APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT,
- &behavior_hid_driver_api); \ No newline at end of file
+ZMK_LISTENER(hid_listener, hid_listener);
+ZMK_SUBSCRIPTION(hid_listener, keycode_state_changed);
+ZMK_SUBSCRIPTION(hid_listener, modifiers_state_changed); \ No newline at end of file