From 8d0cf0a8feeefee7f7d76ecbfd43f78d516b794d Mon Sep 17 00:00:00 2001 From: SpaceComet Date: Sat, 1 Oct 2022 21:56:06 +0000 Subject: [PATCH] exposing caps word state --- app/CMakeLists.txt | 1 + app/include/zmk/caps_word.h | 12 ++++++++++++ app/src/behaviors/behavior_caps_word.c | 7 +++++++ app/src/caps_word.c | 6 ++++++ 4 files changed, 26 insertions(+) create mode 100644 app/include/zmk/caps_word.h create mode 100644 app/src/caps_word.c diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 4b61fc72..f69e65f7 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -60,6 +60,7 @@ if ((NOT CONFIG_ZMK_SPLIT) OR CONFIG_ZMK_SPLIT_ROLE_CENTRAL) target_sources(app PRIVATE src/events/endpoint_selection_changed.c) target_sources(app PRIVATE src/hid_listener.c) target_sources(app PRIVATE src/keymap.c) + target_sources(app PRIVATE src/caps_word.c) target_sources(app PRIVATE src/events/layer_state_changed.c) target_sources(app PRIVATE src/events/modifiers_state_changed.c) target_sources(app PRIVATE src/events/keycode_state_changed.c) diff --git a/app/include/zmk/caps_word.h b/app/include/zmk/caps_word.h new file mode 100644 index 00000000..46ee77d2 --- /dev/null +++ b/app/include/zmk/caps_word.h @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2022 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#pragma once + +#include + +extern bool last_state_of_caps_word; +bool zmk_caps_word_state(); \ No newline at end of file diff --git a/app/src/behaviors/behavior_caps_word.c b/app/src/behaviors/behavior_caps_word.c index 3842a31f..159140d3 100644 --- a/app/src/behaviors/behavior_caps_word.c +++ b/app/src/behaviors/behavior_caps_word.c @@ -20,6 +20,11 @@ #include #include +#include + +bool last_state_of_caps_word = false; +//bool zmk_caps_word_state() { return last_state_of_caps_word; } + LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) @@ -44,12 +49,14 @@ struct behavior_caps_word_data { static void activate_caps_word(const struct device *dev) { struct behavior_caps_word_data *data = dev->data; + last_state_of_caps_word = true; data->active = true; } static void deactivate_caps_word(const struct device *dev) { struct behavior_caps_word_data *data = dev->data; + last_state_of_caps_word = false; data->active = false; } diff --git a/app/src/caps_word.c b/app/src/caps_word.c new file mode 100644 index 00000000..7a7d49c1 --- /dev/null +++ b/app/src/caps_word.c @@ -0,0 +1,6 @@ +#include + +#include +#include + +bool zmk_caps_word_state() { return last_state_of_caps_word; } \ No newline at end of file