From a6a0dc803908a426c331b698acab663a900c2b10 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Tue, 21 Jan 2025 08:24:39 +1100 Subject: [PATCH 1/3] Consolidate send_string implementations. (#24817) --- builddefs/common_features.mk | 4 ++ quantum/dynamic_keymap.c | 66 +++++------------------ quantum/send_string/send_string.c | 88 ++++++++++++++----------------- quantum/send_string/send_string.h | 8 +++ 4 files changed, 64 insertions(+), 102 deletions(-) diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk index bb272099a67..989048d7174 100644 --- a/builddefs/common_features.mk +++ b/builddefs/common_features.mk @@ -635,6 +635,10 @@ ifeq ($(strip $(VIA_ENABLE)), yes) TRI_LAYER_ENABLE := yes endif +ifeq ($(strip $(DYNAMIC_KEYMAP_ENABLE)), yes) + SEND_STRING_ENABLE := yes +endif + VALID_CUSTOM_MATRIX_TYPES:= yes lite no CUSTOM_MATRIX ?= no diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c index 3c22bbd4457..beb7f9d18f2 100644 --- a/quantum/dynamic_keymap.c +++ b/quantum/dynamic_keymap.c @@ -245,6 +245,17 @@ void dynamic_keymap_macro_set_buffer(uint16_t offset, uint16_t size, uint8_t *da } } +typedef struct send_string_eeprom_state_t { + const uint8_t *ptr; +} send_string_eeprom_state_t; + +char send_string_get_next_eeprom(void *arg) { + send_string_eeprom_state_t *state = (send_string_eeprom_state_t *)arg; + char ret = eeprom_read_byte(state->ptr); + state->ptr++; + return ret; +} + void dynamic_keymap_macro_reset(void) { void *p = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR); void *end = (void *)(DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR + DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE); @@ -284,57 +295,6 @@ void dynamic_keymap_macro_send(uint8_t id) { ++p; } - // Send the macro string by making a temporary string. - char data[8] = {0}; - // We already checked there was a null at the end of - // the buffer, so this cannot go past the end - while (1) { - data[0] = eeprom_read_byte(p++); - data[1] = 0; - // Stop at the null terminator of this macro string - if (data[0] == 0) { - break; - } - if (data[0] == SS_QMK_PREFIX) { - // Get the code - data[1] = eeprom_read_byte(p++); - // Unexpected null, abort. - if (data[1] == 0) { - return; - } - if (data[1] == SS_TAP_CODE || data[1] == SS_DOWN_CODE || data[1] == SS_UP_CODE) { - // Get the keycode - data[2] = eeprom_read_byte(p++); - // Unexpected null, abort. - if (data[2] == 0) { - return; - } - // Null terminate - data[3] = 0; - } else if (data[1] == SS_DELAY_CODE) { - // Get the number and '|' - // At most this is 4 digits plus '|' - uint8_t i = 2; - while (1) { - data[i] = eeprom_read_byte(p++); - // Unexpected null, abort - if (data[i] == 0) { - return; - } - // Found '|', send it - if (data[i] == '|') { - data[i + 1] = 0; - break; - } - // If haven't found '|' by i==6 then - // number too big, abort - if (i == 6) { - return; - } - ++i; - } - } - } - send_string_with_delay(data, DYNAMIC_KEYMAP_MACRO_DELAY); - } + send_string_eeprom_state_t state = {p}; + send_string_with_delay_impl(send_string_get_next_eeprom, &state, DYNAMIC_KEYMAP_MACRO_DELAY); } diff --git a/quantum/send_string/send_string.c b/quantum/send_string/send_string.c index 44c5ec5ab99..602f24dabe3 100644 --- a/quantum/send_string/send_string.c +++ b/quantum/send_string/send_string.c @@ -150,48 +150,65 @@ void send_string(const char *string) { send_string_with_delay(string, TAP_CODE_DELAY); } -void send_string_with_delay(const char *string, uint8_t interval) { +void send_string_with_delay_impl(char (*getter)(void *), void *arg, uint8_t interval) { while (1) { - char ascii_code = *string; + char ascii_code = getter(arg); if (!ascii_code) break; if (ascii_code == SS_QMK_PREFIX) { - ascii_code = *(++string); + ascii_code = getter(arg); if (ascii_code == SS_TAP_CODE) { // tap - uint8_t keycode = *(++string); + uint8_t keycode = getter(arg); tap_code(keycode); } else if (ascii_code == SS_DOWN_CODE) { // down - uint8_t keycode = *(++string); + uint8_t keycode = getter(arg); register_code(keycode); } else if (ascii_code == SS_UP_CODE) { // up - uint8_t keycode = *(++string); + uint8_t keycode = getter(arg); unregister_code(keycode); } else if (ascii_code == SS_DELAY_CODE) { // delay - int ms = 0; - uint8_t keycode = *(++string); + int ms = 0; + ascii_code = getter(arg); - while (isdigit(keycode)) { + while (isdigit(ascii_code)) { ms *= 10; - ms += keycode - '0'; - keycode = *(++string); + ms += ascii_code - '0'; + ascii_code = getter(arg); } wait_ms(ms); } wait_ms(interval); + + // if we had a delay that terminated with a null, we're done + if (ascii_code == 0) break; } else { send_char_with_delay(ascii_code, interval); } - - ++string; } } +typedef struct send_string_memory_state_t { + const char *string; +} send_string_memory_state_t; + +char send_string_get_next_ram(void *arg) { + send_string_memory_state_t *state = (send_string_memory_state_t *)arg; + char ret = *state->string; + state->string++; + return ret; +} + +void send_string_with_delay(const char *string, uint8_t interval) { + send_string_memory_state_t state = {string}; + send_string_with_delay_impl(send_string_get_next_ram, &state, interval); +} + void send_char(char ascii_code) { send_char_with_delay(ascii_code, TAP_CODE_DELAY); } @@ -297,42 +314,15 @@ void send_string_P(const char *string) { send_string_with_delay_P(string, TAP_CODE_DELAY); } +char send_string_get_next_progmem(void *arg) { + send_string_memory_state_t *state = (send_string_memory_state_t *)arg; + char ret = pgm_read_byte(state->string); + state->string++; + return ret; +} + void send_string_with_delay_P(const char *string, uint8_t interval) { - while (1) { - char ascii_code = pgm_read_byte(string); - if (!ascii_code) break; - if (ascii_code == SS_QMK_PREFIX) { - ascii_code = pgm_read_byte(++string); - - if (ascii_code == SS_TAP_CODE) { - // tap - uint8_t keycode = pgm_read_byte(++string); - tap_code(keycode); - } else if (ascii_code == SS_DOWN_CODE) { - // down - uint8_t keycode = pgm_read_byte(++string); - register_code(keycode); - } else if (ascii_code == SS_UP_CODE) { - // up - uint8_t keycode = pgm_read_byte(++string); - unregister_code(keycode); - } else if (ascii_code == SS_DELAY_CODE) { - // delay - int ms = 0; - uint8_t keycode = pgm_read_byte(++string); - - while (isdigit(keycode)) { - ms *= 10; - ms += keycode - '0'; - keycode = pgm_read_byte(++string); - } - wait_ms(ms); - } - } else { - send_char_with_delay(ascii_code, interval); - } - - ++string; - } + send_string_memory_state_t state = {string}; + send_string_with_delay_impl(send_string_get_next_progmem, &state, interval); } #endif diff --git a/quantum/send_string/send_string.h b/quantum/send_string/send_string.h index f727ec507da..4f91252075d 100644 --- a/quantum/send_string/send_string.h +++ b/quantum/send_string/send_string.h @@ -161,4 +161,12 @@ void send_string_with_delay_P(const char *string, uint8_t interval); */ #define SEND_STRING_DELAY(string, interval) send_string_with_delay_P(PSTR(string), interval) +/** + * \brief Actual implementation function that iterates and sends the string returned by the getter function. + * + * The getter assumes that the next byte is available to be read, and returns it. `arg` is passed in and can be whatever + * makes most sense for the getter -- each invocation of `getter` must advance its position in the source. + */ +void send_string_with_delay_impl(char (*getter)(void *), void *arg, uint8_t interval); + /** \} */ From a573931fef26427e761456698de83e58458df17c Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Tue, 21 Jan 2025 08:32:52 +1100 Subject: [PATCH 2/3] License violations updates. (#24831) --- docs/license_violations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/license_violations.md b/docs/license_violations.md index b21bb286ac5..f899deb07c3 100644 --- a/docs/license_violations.md +++ b/docs/license_violations.md @@ -20,13 +20,13 @@ If you own a board from one of the following vendors already, consider asking th | Vendor | Reason | |------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | BBB Keyboard | Selling tri-mode boards based on QMK without sources, attempted upstreaming crippled firmware without wireless. | -| Chillkey | | | CIDOO | Selling wired boards based on QMK without sources, just `via.json` provided. | | Darmoshark | Selling wired boards based on QMK without sources, just `via.json` provided. | | Epomaker | Lots of historical keyboards with `via.json` but no corresponding sources. Wireless code for a small handful provided, pending core cleanup for QMK upstreaming. Most other boards have source nowhere to be seen. | | Ergokbd (IFKB) | At least their crkbd clone ships with QMK+Vial, seemingly refuses to disclose sources despite multiple customers requesting them. | | iLovBee | Official 30-day copyright source code request issued Sep 11 2024 due to deception on PR, no response received. Ambiguity on PRs -- marketing says wireless, PR author said wired-only, then included wireless code anyway. Seemingly intentionally deceptive. | | KiiBOOM | Seems to use the same OEM as Epomaker, same problems. | +| kprepublic | Makes no attempt to release source code, all boards in QMK are reverse-engineered, created, and supported by the community. New board variants magically appear without telling customers they're incompatible with existing QMK versions, in some cases bricking boards or requiring ISP flashing. | | Luminkey | Selling tri-mode boards based on QMK without sources, just `via.json` provided. | | Meletrix | Selling tri-mode boards based on QMK without sources, just `via.json` provided. | | mmd / Smartmmd / i-game.tech | Ambiguity on PRs -- marketing says wireless, PR author said wired-only, then included wireless code anyway. Seemingly intentionally deceptive. | @@ -36,13 +36,13 @@ If you own a board from one of the following vendors already, consider asking th | Redragon | Selling tri-mode boards based on QMK without sources, attempted upstreaming crippled firmware without wireless. | | Royal Kludge | PRs for fake boards in order to attain VIA compatibility identified. Lots of other keyboards with `via.json` but no corresponding sources, attempted upstreaming crippled firmware without wireless. Wireless code for some provided, pending core cleanup for QMK upstreaming. PRs including different manufacturer names as well. | | Shenzhen Hangsheng | PR submissions with crippled firmware, debating with maintainers about wireless despite marketing material clearly stating tri-mode. | -| Shortcut Studio | Selling tri-mode boards based on QMK without sources, just `via.json` provided. | | Tacworks | Selling tri-mode boards based on QMK, crippled firmware already merged into QMK without wireless without QMK team realising. | | TKD / Vertex | Selling tri-mode boards based on QMK without sources, attempted upstreaming crippled firmware without wireless. | | WOBKEY | Selling tri-mode boards based on QMK without sources, attempted upstreaming crippled firmware without wireless. | | Weikav | Selling tri-mode boards based on QMK without sources, just `via.json` provided. | | Womier | Selling tri-mode boards based on QMK without sources, attempted upstreaming crippled firmware without wireless. | | Wuque Studio | Selling wired and tri-mode boards based on QMK without sources, just `via.json` provided. | +| XVX | Ambiguity on PRs -- marketing says wireless, PR author said wired-only. Seemingly intentionally deceptive. | | Zuoya | Selling tri-mode boards based on QMK without sources, just `via.json` provided. | ::: danger Violations From 7431401116c744e4e3d8e92e5047c9dc3baebb9f Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Tue, 21 Jan 2025 08:54:41 +1100 Subject: [PATCH 3/3] Fix up CI with `DEFAULT_FOLDER`. (#24842) --- keyboards/rgbkb/pan/rules.mk | 2 -- 1 file changed, 2 deletions(-) diff --git a/keyboards/rgbkb/pan/rules.mk b/keyboards/rgbkb/pan/rules.mk index b6f1d46a653..9a696492896 100644 --- a/keyboards/rgbkb/pan/rules.mk +++ b/keyboards/rgbkb/pan/rules.mk @@ -1,3 +1 @@ WS2812_DRIVER_REQUIRED = yes - -DEFAULT_FOLDER = rgbkb/pan/rev1