diff options
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/endpoints.c | 17 | ||||
-rw-r--r-- | src/endpoints.h | 5 | ||||
-rw-r--r-- | src/handlers.c | 11 | ||||
-rw-r--r-- | src/handlers.h | 8 | ||||
-rw-r--r-- | src/keymap.h | 3 | ||||
-rw-r--r-- | src/keys.h | 11 | ||||
-rw-r--r-- | src/usb_hid.h | 6 |
8 files changed, 43 insertions, 19 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6b09b3a..12b44c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ target_include_directories(app PRIVATE include) target_sources(app PRIVATE src/kscan.c) target_sources(app PRIVATE src/keymap.c) target_sources(app PRIVATE src/usb_hid.c) +target_sources(app PRIVATE src/endpoints.c) target_sources(app PRIVATE src/main.c) target_sources(app PRIVATE src/handlers.c) diff --git a/src/endpoints.c b/src/endpoints.c new file mode 100644 index 0000000..c4cd416 --- /dev/null +++ b/src/endpoints.c @@ -0,0 +1,17 @@ + +#include "endpoints.h" +#include "usb_hid.h" + +int zmk_endpoints_send_key_event(struct zmk_key_event key_event) +{ + if (key_event.pressed) + { + zmk_usb_hid_press_key(key_event.key); + } + else + { + zmk_usb_hid_release_key(key_event.key); + } + + return 0; +}
\ No newline at end of file diff --git a/src/endpoints.h b/src/endpoints.h new file mode 100644 index 0000000..1a72c32 --- /dev/null +++ b/src/endpoints.h @@ -0,0 +1,5 @@ +#pragma once + +#include "keys.h" + +int zmk_endpoints_send_key_event(struct zmk_key_event key_event);
\ No newline at end of file diff --git a/src/handlers.c b/src/handlers.c index 7c329c5..9383e75 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -1,7 +1,7 @@ #include "handlers.h" -#include "usb_hid.h" +#include "endpoints.h" __attribute__((weak)) bool zmk_handle_key_user(struct zmk_key_event *key_event) { @@ -15,12 +15,5 @@ void zmk_handle_key(struct zmk_key_event key_event) return; } - if (key_event.pressed) - { - zmk_usb_hid_press_key(key_event.key); - } - else - { - zmk_usb_hid_release_key(key_event.key); - } + zmk_endpoints_send_key_event(key_event); }; diff --git a/src/handlers.h b/src/handlers.h index 3a93572..382f3b8 100644 --- a/src/handlers.h +++ b/src/handlers.h @@ -1,12 +1,8 @@ #pragma once -#include "keymap.h" #include <dt-bindings/zmk/keys.h> -struct zmk_key_event -{ - zmk_key key; - bool pressed; -}; +#include "keymap.h" +#include "keys.h" void zmk_handle_key(struct zmk_key_event key_event); diff --git a/src/keymap.h b/src/keymap.h index bb758d8..20bd483 100644 --- a/src/keymap.h +++ b/src/keymap.h @@ -6,12 +6,11 @@ #include "dt-bindings/zmk/keys.h" #include "zmk.h" +#include "keys.h" #define ZMK_KEYMAP_NODE DT_CHOSEN(zmk_keymap) #define ZMK_KEYMAP_LAYERS_LEN DT_PROP_LEN(ZMK_KEYMAP_NODE, layers) -typedef u64_t zmk_key; - bool zmk_keymap_layer_activate(u8_t layer); bool zmk_keymap_layer_deactivate(u8_t layer); diff --git a/src/keys.h b/src/keys.h new file mode 100644 index 0000000..bfe8dd9 --- /dev/null +++ b/src/keys.h @@ -0,0 +1,11 @@ +#pragma once + +#include <zephyr.h> + +typedef u64_t zmk_key; + +struct zmk_key_event +{ + zmk_key key; + bool pressed; +};
\ No newline at end of file diff --git a/src/usb_hid.h b/src/usb_hid.h index 5bcd8bf..1f331cd 100644 --- a/src/usb_hid.h +++ b/src/usb_hid.h @@ -4,11 +4,13 @@ #include <usb/usb_device.h> #include <usb/class/usb_hid.h> +#include "keys.h" + int zmk_usb_hid_init(); // TODO: Modifiers! -int zmk_usb_hid_press_key(enum hid_kbd_code code); -int zmk_usb_hid_release_key(enum hid_kbd_code code); +int zmk_usb_hid_press_key(zmk_key key); +int zmk_usb_hid_release_key(zmk_key key); #endif |