summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.vscode/tasks.json28
-rw-r--r--CMakeLists.txt10
-rw-r--r--Kconfig8
-rw-r--r--boards/shields/petejohanson_handwire/keymaps/default/keymap.c7
-rw-r--r--include/zmk/ble.h7
-rw-r--r--include/zmk/endpoints.h (renamed from src/endpoints.h)4
-rw-r--r--include/zmk/handlers.h (renamed from src/handlers.h)4
-rw-r--r--include/zmk/hid.h (renamed from src/hid.h)4
-rw-r--r--include/zmk/hog.h9
-rw-r--r--include/zmk/keymap.h (renamed from src/keymap.h)6
-rw-r--r--include/zmk/keys.h (renamed from src/keys.h)0
-rw-r--r--include/zmk/kscan.h (renamed from src/kscan.h)0
-rw-r--r--include/zmk/matrix.h (renamed from src/zmk.h)4
-rw-r--r--include/zmk/usb_hid.h (renamed from src/usb_hid.h)4
-rw-r--r--prj.conf11
-rw-r--r--src/ble.c2
-rw-r--r--src/ble.h5
-rw-r--r--src/endpoints.c15
-rw-r--r--src/handlers.c9
-rw-r--r--src/hid.c4
-rw-r--r--src/hog.c6
-rw-r--r--src/hog.h9
-rw-r--r--src/keymap.c2
-rw-r--r--src/kscan.c5
-rw-r--r--src/main.c6
-rw-r--r--src/usb_hid.c4
26 files changed, 109 insertions, 64 deletions
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 0000000..0902d0e
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,28 @@
+{
+ // See https://go.microsoft.com/fwlink/?LinkId=733558
+ // for the documentation about the tasks.json format
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "Build",
+ "type": "shell",
+ "command": "west build",
+ "group": {
+ "kind": "build",
+ "isDefault": true
+ }
+ },
+ {
+ "label": "Flash",
+ "type": "shell",
+ "command": "west flash",
+ "group": "test"
+ },
+ {
+ "label": "Debug",
+ "type": "shell",
+ "command": "west debug",
+ "group": "test"
+ }
+ ]
+}
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dc8ccda..9348b9c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,15 +9,21 @@ include(cmake/keymap.cmake)
find_package(Zephyr)
project(zmk)
+if(EXISTS ${KEYMAP_DIR}/${KEYMAP}/keymap.c)
+ message(STATUS "ADDING THE KEYMAP SOURCE")
+ target_sources(app PRIVATE ${KEYMAP_DIR}/${KEYMAP}/keymap.c)
+endif()
+
+
# Add your source file to the "app" target. This must come after
# find_package(Zephyr) which defines the target.
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/hid.c)
-target_sources(app PRIVATE src/ble.c)
+target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/ble.c)
target_sources(app PRIVATE src/usb_hid.c)
-target_sources(app PRIVATE src/hog.c)
+target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/hog.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/Kconfig b/Kconfig
index d92a1a4..2ab2c6f 100644
--- a/Kconfig
+++ b/Kconfig
@@ -4,6 +4,14 @@ config ZMK_KSCAN_EVENT_QUEUE_SIZE
int "Size of the event queue for KSCAN events to buffer events"
default 4
+config ZMK_BLE
+ bool "Enable low energy bluetooth support"
+ select BT
+ select BT_SMP
+ select BT_SMP_SC_PAIR_ONLY
+ select BT_PERIPHERAL
+ select BT_GATT_DIS
+ select BT_GATT_BAS
module = ZMK_KSCAN
module-str = zmk_kscan
diff --git a/boards/shields/petejohanson_handwire/keymaps/default/keymap.c b/boards/shields/petejohanson_handwire/keymaps/default/keymap.c
new file mode 100644
index 0000000..349d755
--- /dev/null
+++ b/boards/shields/petejohanson_handwire/keymaps/default/keymap.c
@@ -0,0 +1,7 @@
+
+#include <zmk/keys.h>
+
+bool zmk_handle_key_user(struct zmk_key_event *key_event)
+{
+ return true;
+};
diff --git a/include/zmk/ble.h b/include/zmk/ble.h
new file mode 100644
index 0000000..a77237d
--- /dev/null
+++ b/include/zmk/ble.h
@@ -0,0 +1,7 @@
+
+#pragma once
+
+#include <zmk/keys.h>
+
+int zmk_ble_init();
+bool zmk_ble_handle_key_user(struct zmk_key_event *key_event);
diff --git a/src/endpoints.h b/include/zmk/endpoints.h
index cc200f1..42734aa 100644
--- a/src/endpoints.h
+++ b/include/zmk/endpoints.h
@@ -1,6 +1,6 @@
#pragma once
-#include "keys.h"
+#include <zmk/keys.h>
int zmk_endpoints_init();
-int zmk_endpoints_send_key_event(struct zmk_key_event key_event); \ No newline at end of file
+int zmk_endpoints_send_key_event(struct zmk_key_event key_event);
diff --git a/src/handlers.h b/include/zmk/handlers.h
index 382f3b8..a10851f 100644
--- a/src/handlers.h
+++ b/include/zmk/handlers.h
@@ -2,7 +2,7 @@
#include <dt-bindings/zmk/keys.h>
-#include "keymap.h"
-#include "keys.h"
+#include <zmk/keymap.h>
+#include <zmk/keys.h>
void zmk_handle_key(struct zmk_key_event key_event);
diff --git a/src/hid.h b/include/zmk/hid.h
index 0f34df2..9f0760a 100644
--- a/src/hid.h
+++ b/include/zmk/hid.h
@@ -5,7 +5,7 @@
#include <dt-bindings/zmk/keys.h>
-#include "keys.h"
+#include <zmk/keys.h>
#define ZMK_HID_MAX_KEYCODE KC_APP
@@ -104,4 +104,4 @@ struct zmk_hid_report
int zmk_hid_press_key(zmk_key key);
int zmk_hid_release_key(zmk_key key);
-struct zmk_hid_report *zmk_hid_get_report(); \ No newline at end of file
+struct zmk_hid_report *zmk_hid_get_report();
diff --git a/include/zmk/hog.h b/include/zmk/hog.h
new file mode 100644
index 0000000..a48fa98
--- /dev/null
+++ b/include/zmk/hog.h
@@ -0,0 +1,9 @@
+
+#pragma once
+
+#include <zmk/keys.h>
+#include <zmk/hid.h>
+
+int zmk_hog_init();
+
+int zmk_hog_send_report(struct zmk_hid_report *report);
diff --git a/src/keymap.h b/include/zmk/keymap.h
index 20bd483..9b58cc0 100644
--- a/src/keymap.h
+++ b/include/zmk/keymap.h
@@ -3,10 +3,10 @@
#include <devicetree.h>
#include <usb/usb_device.h>
#include <usb/class/usb_hid.h>
-#include "dt-bindings/zmk/keys.h"
+#include <dt-bindings/zmk/keys.h>
-#include "zmk.h"
-#include "keys.h"
+#include <zmk/matrix.h>
+#include <zmk/keys.h>
#define ZMK_KEYMAP_NODE DT_CHOSEN(zmk_keymap)
#define ZMK_KEYMAP_LAYERS_LEN DT_PROP_LEN(ZMK_KEYMAP_NODE, layers)
diff --git a/src/keys.h b/include/zmk/keys.h
index b61ef81..b61ef81 100644
--- a/src/keys.h
+++ b/include/zmk/keys.h
diff --git a/src/kscan.h b/include/zmk/kscan.h
index ebffccd..ebffccd 100644
--- a/src/kscan.h
+++ b/include/zmk/kscan.h
diff --git a/src/zmk.h b/include/zmk/matrix.h
index 82ef3b6..83a8e2d 100644
--- a/src/zmk.h
+++ b/include/zmk/matrix.h
@@ -1,8 +1,6 @@
-#ifndef ZMK_H
-#define ZMK_H
+#pragma once
#define ZMK_MATRIX_NODE_ID DT_CHOSEN(zmk_kscan)
#define ZMK_MATRIX_ROWS DT_PROP_LEN(ZMK_MATRIX_NODE_ID,row_gpios)
#define ZMK_MATRIX_COLS DT_PROP_LEN(ZMK_MATRIX_NODE_ID,col_gpios)
-#endif
diff --git a/src/usb_hid.h b/include/zmk/usb_hid.h
index 4b55688..893e7e4 100644
--- a/src/usb_hid.h
+++ b/include/zmk/usb_hid.h
@@ -4,8 +4,8 @@
#include <usb/usb_device.h>
#include <usb/class/usb_hid.h>
-#include "keys.h"
-#include "hid.h"
+#include <zmk/keys.h>
+#include <zmk/hid.h>
int zmk_usb_hid_init();
diff --git a/prj.conf b/prj.conf
index 949a828..9250cce 100644
--- a/prj.conf
+++ b/prj.conf
@@ -1,22 +1,14 @@
CONFIG_KSCAN=y
CONFIG_KSCAN_GPIO=y
-# CONFIG_ZMK_KSCAN_LOG_LEVEL_DBG=y
-# CONFIG_ZMK_USB_HID_LOG_LEVEL_DBG=y
CONFIG_USB=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_HID=y
CONFIG_USB_DEVICE_PRODUCT="ZMK Firmware"
-CONFIG_BT=y
-CONFIG_BT_SMP=y
-CONFIG_BT_SMP_SC_PAIR_ONLY=y
-CONFIG_BT_PERIPHERAL=y
-CONFIG_BT_GATT_DIS=y
+CONFIG_ZMK_BLE=y
# HID GATT notifications sent this way are *not* picked up by Linux, and possibly others.
CONFIG_BT_GATT_NOTIFY_MULTIPLE=n
-CONFIG_BT_GATT_BAS=y
CONFIG_BT_DEVICE_NAME="ZMK Keyboard"
CONFIG_BT_DEVICE_APPEARANCE=961
-CONFIG_BT_FIXED_PASSKEY=y
# Incresed stack due to settings API usage
# CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
@@ -27,4 +19,3 @@ CONFIG_BT_FIXED_PASSKEY=y
# CONFIG_FLASH_MAP=y
# CONFIG_NVS=y
# CONFIG_SETTINGS=y
-# CONFIG_SETTINGS_NONE=n
diff --git a/src/ble.c b/src/ble.c
index 266185f..18b4fe3 100644
--- a/src/ble.c
+++ b/src/ble.c
@@ -8,7 +8,7 @@
#include <bluetooth/uuid.h>
#include <bluetooth/gatt.h>
-#include "keys.h"
+#include <zmk/keys.h>
static struct bt_conn *auth_passkey_entry_conn;
static u8_t passkey_entries[6] = {0, 0, 0, 0, 0, 0};
diff --git a/src/ble.h b/src/ble.h
deleted file mode 100644
index 03b34fe..0000000
--- a/src/ble.h
+++ /dev/null
@@ -1,5 +0,0 @@
-
-#pragma once
-
-int zmk_ble_init();
-bool zmk_ble_handle_key_user(struct zmk_key_event *key_event); \ No newline at end of file
diff --git a/src/endpoints.c b/src/endpoints.c
index 1f78cb7..6854370 100644
--- a/src/endpoints.c
+++ b/src/endpoints.c
@@ -1,8 +1,8 @@
-#include "endpoints.h"
-#include "hid.h"
-#include "usb_hid.h"
-#include "hog.h"
+#include <zmk/endpoints.h>
+#include <zmk/hid.h>
+#include <zmk/usb_hid.h>
+#include <zmk/hog.h>
int zmk_endpoints_init()
{
@@ -15,6 +15,7 @@ int zmk_endpoints_init()
return err;
}
+#ifdef CONFIG_ZMK_BLE
err = zmk_hog_init();
if (err)
{
@@ -22,6 +23,8 @@ int zmk_endpoints_init()
return err;
}
+#endif /* CONFIG_ZMK_BLE */
+
return 0;
}
@@ -46,12 +49,14 @@ int zmk_endpoints_send_key_event(struct zmk_key_event key_event)
// // LOG_DBG("USB Send Failed");
// }
+#ifdef CONFIG_ZMK_BLE
err = zmk_hog_send_report(report);
if (err)
{
printk("FAILED TO SEND OVER HOG: %d\n", err);
// LOG_DBG("HID Over GATTP Send Failed");
}
+#endif /* CONFIG_ZMK_BLE */
return 0;
-} \ No newline at end of file
+}
diff --git a/src/handlers.c b/src/handlers.c
index 0ab93f6..b73c92c 100644
--- a/src/handlers.c
+++ b/src/handlers.c
@@ -1,8 +1,7 @@
-#include "handlers.h"
-
-#include "ble.h"
-#include "endpoints.h"
+#include <zmk/ble.h>
+#include <zmk/handlers.h>
+#include <zmk/endpoints.h>
__attribute__((weak)) bool zmk_handle_key_user(struct zmk_key_event *key_event)
{
@@ -16,10 +15,12 @@ void zmk_handle_key(struct zmk_key_event key_event)
return;
}
+#ifdef CONFIG_ZMK_BLE
if (!zmk_ble_handle_key_user(&key_event))
{
return;
}
+#endif /* CONFIG_ZMK_BLE */
zmk_endpoints_send_key_event(key_event);
};
diff --git a/src/hid.c b/src/hid.c
index 8c42df5..faf3cfc 100644
--- a/src/hid.c
+++ b/src/hid.c
@@ -1,4 +1,4 @@
-#include "hid.h"
+#include <zmk/hid.h>
static struct zmk_hid_report report = {
.modifiers = 0,
@@ -53,4 +53,4 @@ int zmk_hid_release_key(zmk_key code)
struct zmk_hid_report *zmk_hid_get_report()
{
return &report;
-} \ No newline at end of file
+}
diff --git a/src/hog.c b/src/hog.c
index dcddba6..67ccf5b 100644
--- a/src/hog.c
+++ b/src/hog.c
@@ -3,9 +3,9 @@
#include <bluetooth/bluetooth.h>
#include <bluetooth/gatt.h>
-#include "ble.h"
-#include "hog.h"
-#include "hid.h"
+#include <zmk/ble.h>
+#include <zmk/hog.h>
+#include <zmk/hid.h>
int zmk_hog_init()
{
diff --git a/src/hog.h b/src/hog.h
deleted file mode 100644
index a1e4142..0000000
--- a/src/hog.h
+++ /dev/null
@@ -1,9 +0,0 @@
-
-#pragma once
-
-#include "keys.h"
-#include "hid.h"
-
-int zmk_hog_init();
-
-int zmk_hog_send_report(struct zmk_hid_report *report); \ No newline at end of file
diff --git a/src/keymap.c b/src/keymap.c
index 1f55b1f..b47809b 100644
--- a/src/keymap.c
+++ b/src/keymap.c
@@ -1,5 +1,5 @@
-#include "keymap.h"
+#include <zmk/keymap.h>
static u32_t zmk_keymap_layer_state = 0;
static u8_t zmk_keymap_layer_default = 0;
diff --git a/src/kscan.c b/src/kscan.c
index 25bbbfa..09ca387 100644
--- a/src/kscan.c
+++ b/src/kscan.c
@@ -11,9 +11,8 @@
LOG_MODULE_REGISTER(zmk_kscan, CONFIG_ZMK_KSCAN_LOG_LEVEL);
-#include "keymap.h"
-#include "usb_hid.h"
-#include "handlers.h"
+#include <zmk/keymap.h>
+#include <zmk/handlers.h>
#define ZMK_KSCAN_EVENT_STATE_PRESSED 0
#define ZMK_KSCAN_EVENT_STATE_RELEASED 1
diff --git a/src/main.c b/src/main.c
index 708f4ff..00a1cd0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -8,9 +8,9 @@
#include <device.h>
#include <devicetree.h>
-#include "zmk.h"
-#include "kscan.h"
-#include "endpoints.h"
+#include <zmk/matrix.h>
+#include <zmk/kscan.h>
+#include <zmk/endpoints.h>
#define ZMK_KSCAN_DEV DT_LABEL(ZMK_MATRIX_NODE_ID)
diff --git a/src/usb_hid.c b/src/usb_hid.c
index 80b2138..ee8ee13 100644
--- a/src/usb_hid.c
+++ b/src/usb_hid.c
@@ -5,8 +5,8 @@
#include <usb/class/usb_hid.h>
#include <dt-bindings/zmk/keys.h>
-#include "hid.h"
-#include "keymap.h"
+#include <zmk/hid.h>
+#include <zmk/keymap.h>
LOG_MODULE_REGISTER(zmk_usb_hid, CONFIG_ZMK_USB_HID_LOG_LEVEL);