From f4596fc784d11aa2d03ff0b7fa0a921600fc2db2 Mon Sep 17 00:00:00 2001 From: innovaker <66737976+innovaker@users.noreply.github.com> Date: Tue, 27 Oct 2020 22:35:44 +0000 Subject: refactor(hid): Refactor keypad report to use a configurable integer array Replace NKRO bit array with configurable integer (DV) array. --- app/include/zmk/hid.h | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) (limited to 'app/include') diff --git a/app/include/zmk/hid.h b/app/include/zmk/hid.h index 744de98..aa024dc 100644 --- a/app/include/zmk/hid.h +++ b/app/include/zmk/hid.h @@ -9,13 +9,11 @@ #include #include -#include - #include #define COLLECTION_REPORT 0x03 -#define ZMK_HID_MAX_KEYCODE GUI +#define ZMK_HID_KEYPAD_NKRO_SIZE 6 static const u8_t zmk_hid_report_desc[] = { /* USAGE_PAGE (Generic Desktop) */ @@ -62,36 +60,25 @@ static const u8_t zmk_hid_report_desc[] = { /* LOGICAL_MINIMUM (0) */ HID_GI_LOGICAL_MIN(1), 0x00, - /* LOGICAL_MAXIMUM (1) */ + /* LOGICAL_MAXIMUM (0xFF) */ HID_GI_LOGICAL_MAX(1), - 0x01, + 0xFF, /* USAGE_MINIMUM (Reserved) */ HID_LI_USAGE_MIN(1), 0x00, /* USAGE_MAXIMUM (Keyboard Application) */ HID_LI_USAGE_MAX(1), - ZMK_HID_MAX_KEYCODE, - /* REPORT_SIZE (8) */ + 0xFF, + /* REPORT_SIZE (1) */ HID_GI_REPORT_SIZE, - 0x01, - /* REPORT_COUNT (6) */ + 0x08, + /* REPORT_COUNT (ZMK_HID_KEYPAD_NKRO_SIZE) */ HID_GI_REPORT_COUNT, - ZMK_HID_MAX_KEYCODE + 1, + ZMK_HID_KEYPAD_NKRO_SIZE, /* INPUT (Data,Ary,Abs) */ HID_MI_INPUT, - 0x02, - /* USAGE_PAGE (Keypad) */ - HID_GI_USAGE_PAGE, - USAGE_GEN_DESKTOP_KEYPAD, - /* REPORT_SIZE (8) */ - HID_GI_REPORT_SIZE, - 0x02, - /* REPORT_COUNT (6) */ - HID_GI_REPORT_COUNT, - 0x01, - /* INPUT (Cnst,Var,Abs) */ - HID_MI_INPUT, - 0x03, + 0x00, + /* END_COLLECTION */ HID_MI_COLLECTION_END, /* USAGE_PAGE (Consumer) */ @@ -142,7 +129,7 @@ static const u8_t zmk_hid_report_desc[] = { struct zmk_hid_keypad_report_body { zmk_mod_flags modifiers; - u8_t keys[13]; + u8_t keys[ZMK_HID_KEYPAD_NKRO_SIZE]; } __packed; struct zmk_hid_keypad_report { -- cgit v1.2.3 From 8ce7d8de0133242d5896333add10be9ba2ae9363 Mon Sep 17 00:00:00 2001 From: innovaker <66737976+innovaker@users.noreply.github.com> Date: Tue, 27 Oct 2020 18:42:41 +0000 Subject: refactor(hid): Refactor consumer report to a configurable size --- app/include/zmk/hid.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'app/include') diff --git a/app/include/zmk/hid.h b/app/include/zmk/hid.h index aa024dc..d09ffde 100644 --- a/app/include/zmk/hid.h +++ b/app/include/zmk/hid.h @@ -15,6 +15,8 @@ #define ZMK_HID_KEYPAD_NKRO_SIZE 6 +#define ZMK_HID_CONSUMER_NKRO_SIZE 6 + static const u8_t zmk_hid_report_desc[] = { /* USAGE_PAGE (Generic Desktop) */ HID_GI_USAGE_PAGE, @@ -111,9 +113,9 @@ static const u8_t zmk_hid_report_desc[] = { /* REPORT_SIZE (8) */ HID_GI_REPORT_SIZE, 0x08, - /* REPORT_COUNT (8) */ + /* REPORT_COUNT (ZMK_HID_CONSUMER_NKRO_SIZE) */ HID_GI_REPORT_COUNT, - 0x06, + ZMK_HID_CONSUMER_NKRO_SIZE, HID_MI_INPUT, 0x00, /* END COLLECTION */ @@ -138,7 +140,7 @@ struct zmk_hid_keypad_report { } __packed; struct zmk_hid_consumer_report_body { - u8_t keys[6]; + u8_t keys[ZMK_HID_CONSUMER_NKRO_SIZE]; } __packed; struct zmk_hid_consumer_report { -- cgit v1.2.3 From c402e953f6e9655898cd45af9b120d2a45dd45e0 Mon Sep 17 00:00:00 2001 From: innovaker <66737976+innovaker@users.noreply.github.com> Date: Tue, 27 Oct 2020 17:42:00 +0000 Subject: feat(hid): Make keypad report boot friendly Add missing byte to make keypad report boot friendly. --- app/include/zmk/hid.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'app/include') diff --git a/app/include/zmk/hid.h b/app/include/zmk/hid.h index d09ffde..1ce5cc9 100644 --- a/app/include/zmk/hid.h +++ b/app/include/zmk/hid.h @@ -56,6 +56,19 @@ static const u8_t zmk_hid_report_desc[] = { HID_MI_INPUT, 0x02, + /* USAGE_PAGE (Keypad) */ + HID_GI_USAGE_PAGE, + USAGE_GEN_DESKTOP_KEYPAD, + /* REPORT_SIZE (8) */ + HID_GI_REPORT_SIZE, + 0x08, + /* REPORT_COUNT (1) */ + HID_GI_REPORT_COUNT, + 0x01, + /* INPUT (Cnst,Var,Abs) */ + HID_MI_INPUT, + 0x03, + /* USAGE_PAGE (Keypad) */ HID_GI_USAGE_PAGE, USAGE_GEN_DESKTOP_KEYPAD, @@ -131,6 +144,7 @@ static const u8_t zmk_hid_report_desc[] = { struct zmk_hid_keypad_report_body { zmk_mod_flags modifiers; + u8_t _reserved; u8_t keys[ZMK_HID_KEYPAD_NKRO_SIZE]; } __packed; -- cgit v1.2.3