From 02ab7b1888e6572178543ca0b944e4fa14cdf974 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Wed, 29 Sep 2021 11:37:11 -0700 Subject: [Core] Fix "6kro enable" and clarify naming (#14563) * Fix USB_6KRO_ENABLE compilation errors * Add info to docs * Rename define to be more accurate * Remove unused rule * Refixe docs --- tmk_core/common.mk | 4 ++-- tmk_core/common/report.c | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) (limited to 'tmk_core') diff --git a/tmk_core/common.mk b/tmk_core/common.mk index 7f74200590..e44ff2f0ab 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk @@ -63,8 +63,8 @@ ifeq ($(strip $(NKRO_ENABLE)), yes) endif endif -ifeq ($(strip $(USB_6KRO_ENABLE)), yes) - TMK_COMMON_DEFS += -DUSB_6KRO_ENABLE +ifeq ($(strip $(RING_BUFFERED_6KRO_REPORT_ENABLE)), yes) + TMK_COMMON_DEFS += -DRING_BUFFERED_6KRO_REPORT_ENABLE endif ifeq ($(strip $(SLEEP_LED_ENABLE)), yes) diff --git a/tmk_core/common/report.c b/tmk_core/common/report.c index 1bcb6f2adb..2a7fc006c4 100644 --- a/tmk_core/common/report.c +++ b/tmk_core/common/report.c @@ -21,6 +21,16 @@ #include "util.h" #include +#ifdef RING_BUFFERED_6KRO_REPORT_ENABLE +# define RO_ADD(a, b) ((a + b) % KEYBOARD_REPORT_KEYS) +# define RO_SUB(a, b) ((a - b + KEYBOARD_REPORT_KEYS) % KEYBOARD_REPORT_KEYS) +# define RO_INC(a) RO_ADD(a, 1) +# define RO_DEC(a) RO_SUB(a, 1) +static int8_t cb_head = 0; +static int8_t cb_tail = 0; +static int8_t cb_count = 0; +#endif + /** \brief has_anykey * * FIXME: Needs doc @@ -54,7 +64,7 @@ uint8_t get_first_key(report_keyboard_t* keyboard_report) { return i << 3 | biton(keyboard_report->nkro.bits[i]); } #endif -#ifdef USB_6KRO_ENABLE +#ifdef RING_BUFFERED_6KRO_REPORT_ENABLE uint8_t i = cb_head; do { if (keyboard_report->keys[i] != 0) { @@ -99,7 +109,7 @@ bool is_key_pressed(report_keyboard_t* keyboard_report, uint8_t key) { * FIXME: Needs doc */ void add_key_byte(report_keyboard_t* keyboard_report, uint8_t code) { -#ifdef USB_6KRO_ENABLE +#ifdef RING_BUFFERED_6KRO_REPORT_ENABLE int8_t i = cb_head; int8_t empty = -1; if (cb_count) { @@ -166,7 +176,7 @@ void add_key_byte(report_keyboard_t* keyboard_report, uint8_t code) { * FIXME: Needs doc */ void del_key_byte(report_keyboard_t* keyboard_report, uint8_t code) { -#ifdef USB_6KRO_ENABLE +#ifdef RING_BUFFERED_6KRO_REPORT_ENABLE uint8_t i = cb_head; if (cb_count) { do { -- cgit v1.2.3