Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
zzeneg committed Dec 25, 2024
1 parent 4aca91c commit 415ebdc
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 22 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
zephyr_library()
if (CONFIG_RAW_HID)
zephyr_library()

if ((NOT CONFIG_ZMK_SPLIT) OR CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
zephyr_library_sources_ifdef(CONFIG_ZMK_RAW_HID src/raw-hid/raw_hid.c)
zephyr_library_sources_ifdef(CONFIG_ZMK_RAW_HID src/raw-hid/usb_hid.c)
zephyr_library_sources(src/raw_hid.c)
zephyr_library_sources(src/usb_hid.c)

if (CONFIG_ZMK_BLE)
zephyr_library_sources_ifdef(CONFIG_ZMK_RAW_HID src/raw-hid/hog.c)
zephyr_library_sources(src/hog.c)
endif()

zephyr_include_directories(include)
Expand Down
15 changes: 8 additions & 7 deletions Kconfig
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
config ZMK_RAW_HID
config RAW_HID
bool "Enable Raw HID"
default n

config ZMK_RAW_HID_USAGE_PAGE
if RAW_HID

config RAW_HID_USAGE_PAGE
hex "Raw HID Usage Page"
default 0xFF60

config ZMK_RAW_HID_USAGE
config RAW_HID_USAGE
hex "Raw HID Usage"
default 0x61

config ZMK_RAW_HID_DEVICE
config RAW_HID_DEVICE
string "Raw HID Device"
default HID_1

module = ZMK_RAW_HID
module-str = ZMK_RAW_HID
source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config"
endif # RAW_HID

2 changes: 1 addition & 1 deletion boards/shields/raw_hid_adapter/raw_hid_adapter.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# enable Raw HID module
CONFIG_ZMK_RAW_HID=y
CONFIG_RAW_HID=y

# enable USB HID device
CONFIG_USB_DEVICE_HID=y
Expand Down
4 changes: 2 additions & 2 deletions include/zmk/raw-hid/raw_hid.h → include/raw_hid/raw_hid.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
#define HID_USAGE_PAGE16_SINGLE(a) HID_USAGE_PAGE16((a & 0xFF), ((a >> 8) & 0xFF))

static const uint8_t raw_hid_report_desc[] = {
HID_USAGE_PAGE16_SINGLE(CONFIG_ZMK_RAW_HID_USAGE_PAGE),
HID_USAGE(CONFIG_ZMK_RAW_HID_USAGE),
HID_USAGE_PAGE16_SINGLE(CONFIG_RAW_HID_USAGE_PAGE),
HID_USAGE(CONFIG_RAW_HID_USAGE),

HID_COLLECTION(0x01),

Expand Down
4 changes: 2 additions & 2 deletions src/raw-hid/hog.c → src/hog.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#include <zmk/raw-hid/raw_hid.h>
#include <raw_hid/raw_hid.h>

#include <zephyr/bluetooth/gatt.h>

#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(raw_hid, CONFIG_ZMK_RAW_HID_LOG_LEVEL);
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);

enum {
HIDS_REMOTE_WAKE = BIT(0),
Expand Down
4 changes: 2 additions & 2 deletions src/raw-hid/raw_hid.c → src/raw_hid.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <zmk/raw-hid/raw_hid.h>
#include <raw_hid/raw_hid.h>

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(raw_hid, CONFIG_ZMK_RAW_HID_LOG_LEVEL);
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);

__attribute__((weak)) void process_raw_hid_data(uint8_t *data, uint8_t length) {
LOG_WRN("display_process_raw_hid_data is not overriden");
Expand Down
6 changes: 3 additions & 3 deletions src/raw-hid/usb_hid.c → src/usb_hid.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <zmk/raw-hid/raw_hid.h>
#include <raw_hid/raw_hid.h>

#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(raw_hid, CONFIG_ZMK_RAW_HID_LOG_LEVEL);
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);

static const struct device *raw_hid_dev;

Expand Down Expand Up @@ -42,7 +42,7 @@ static const struct hid_ops ops = {
};

static int raw_hid_init(void) {
raw_hid_dev = device_get_binding(CONFIG_ZMK_RAW_HID_DEVICE);
raw_hid_dev = device_get_binding(CONFIG_RAW_HID_DEVICE);
if (raw_hid_dev == NULL) {
LOG_ERR("Unable to locate HID device");
return -EINVAL;
Expand Down

0 comments on commit 415ebdc

Please sign in to comment.