From 147865cf57feaf9dfb59aeeffa8b1d541c064d93 Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Thu, 9 Nov 2023 02:01:44 +0000 Subject: [PATCH] Migrate some common features to generic (#22403) --- builddefs/common_features.mk | 72 ++++--------------- builddefs/generic_features.mk | 18 ++++- builddefs/show_options.mk | 1 - docs/feature_os_detection.md | 9 ++- .../ergodox_ez/keymaps/hacker_dvorak/rules.mk | 1 - .../levinson/keymaps/drogglbecher/rules.mk | 1 - keyboards/planck/keymaps/sascha/rules.mk | 1 - .../sweep/keymaps/flinguenheld/rules.mk | 1 - quantum/quantum.c | 4 +- 9 files changed, 36 insertions(+), 72 deletions(-) diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk index 84a0300579..b6f888d30d 100644 --- a/builddefs/common_features.mk +++ b/builddefs/common_features.mk @@ -75,10 +75,7 @@ ifeq ($(strip $(AUDIO_ENABLE)), yes) endif ifeq ($(strip $(SEQUENCER_ENABLE)), yes) - OPT_DEFS += -DSEQUENCER_ENABLE MUSIC_ENABLE = yes - SRC += $(QUANTUM_DIR)/sequencer/sequencer.c - SRC += $(QUANTUM_DIR)/process_keycode/process_sequencer.c endif ifeq ($(strip $(MIDI_ENABLE)), yes) @@ -94,11 +91,6 @@ ifeq ($(strip $(MIDI_ENABLE)), yes) SRC += $(QUANTUM_DIR)/process_keycode/process_midi.c endif -MUSIC_ENABLE ?= no -ifeq ($(MUSIC_ENABLE), yes) - SRC += $(QUANTUM_DIR)/process_keycode/process_music.c -endif - VALID_STENO_PROTOCOL_TYPES := geminipr txbolt all STENO_PROTOCOL ?= all ifeq ($(strip $(STENO_ENABLE)), yes) @@ -124,14 +116,8 @@ ifeq ($(strip $(STENO_ENABLE)), yes) endif endif -ifeq ($(strip $(VIRTSER_ENABLE)), yes) - OPT_DEFS += -DVIRTSER_ENABLE -endif - ifeq ($(strip $(MOUSEKEY_ENABLE)), yes) - OPT_DEFS += -DMOUSEKEY_ENABLE MOUSE_ENABLE := yes - SRC += $(QUANTUM_DIR)/mousekey.c endif VALID_POINTING_DEVICE_DRIVER_TYPES := adns5050 adns9800 analog_joystick cirque_pinnacle_i2c cirque_pinnacle_spi paw3204 pmw3320 pmw3360 pmw3389 pimoroni_trackball custom @@ -360,10 +346,7 @@ ifeq ($(strip $(LED_MATRIX_ENABLE)), yes) endif OPT_DEFS += -DLED_MATRIX_ENABLE OPT_DEFS += -DLED_MATRIX_$(strip $(shell echo $(LED_MATRIX_DRIVER) | tr '[:lower:]' '[:upper:]')) -ifneq (,$(filter $(MCU), atmega16u2 atmega32u2 at90usb162)) - # ATmegaxxU2 does not have hardware MUL instruction - lib8tion must be told to use software multiplication routines - OPT_DEFS += -DLIB8_ATTINY -endif + COMMON_VPATH += $(QUANTUM_DIR)/led_matrix COMMON_VPATH += $(QUANTUM_DIR)/led_matrix/animations COMMON_VPATH += $(QUANTUM_DIR)/led_matrix/animations/runners @@ -371,7 +354,7 @@ endif SRC += $(QUANTUM_DIR)/process_keycode/process_backlight.c SRC += $(QUANTUM_DIR)/led_matrix/led_matrix.c SRC += $(QUANTUM_DIR)/led_matrix/led_matrix_drivers.c - SRC += $(LIB_PATH)/lib8tion/lib8tion.c + LIB8TION_ENABLE := yes CIE1931_CURVE := yes ifeq ($(strip $(LED_MATRIX_DRIVER)), is31fl3218) @@ -463,10 +446,7 @@ ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes) endif OPT_DEFS += -DRGB_MATRIX_ENABLE OPT_DEFS += -DRGB_MATRIX_$(strip $(shell echo $(RGB_MATRIX_DRIVER) | tr '[:lower:]' '[:upper:]')) -ifneq (,$(filter $(MCU), atmega16u2 atmega32u2 at90usb162)) - # ATmegaxxU2 does not have hardware MUL instruction - lib8tion must be told to use software multiplication routines - OPT_DEFS += -DLIB8_ATTINY -endif + COMMON_VPATH += $(QUANTUM_DIR)/rgb_matrix COMMON_VPATH += $(QUANTUM_DIR)/rgb_matrix/animations COMMON_VPATH += $(QUANTUM_DIR)/rgb_matrix/animations/runners @@ -474,7 +454,7 @@ endif SRC += $(QUANTUM_DIR)/color.c SRC += $(QUANTUM_DIR)/rgb_matrix/rgb_matrix.c SRC += $(QUANTUM_DIR)/rgb_matrix/rgb_matrix_drivers.c - SRC += $(LIB_PATH)/lib8tion/lib8tion.c + LIB8TION_ENABLE := yes CIE1931_CURVE := yes RGB_KEYCODES_ENABLE := yes @@ -632,8 +612,6 @@ ifeq ($(strip $(VIA_ENABLE)), yes) RAW_ENABLE := yes BOOTMAGIC_ENABLE := yes TRI_LAYER_ENABLE := yes - SRC += $(QUANTUM_DIR)/via.c - OPT_DEFS += -DVIA_ENABLE endif VALID_MAGIC_TYPES := yes @@ -718,17 +696,20 @@ ifeq ($(strip $(SPLIT_KEYBOARD)), yes) COMMON_VPATH += $(QUANTUM_PATH)/split_common endif -ifeq ($(strip $(CRC_ENABLE)), yes) - OPT_DEFS += -DCRC_ENABLE - SRC += crc.c -endif - ifeq ($(strip $(FNV_ENABLE)), yes) OPT_DEFS += -DFNV_ENABLE VPATH += $(LIB_PATH)/fnv SRC += qmk_fnv_type_validation.c hash_32a.c hash_64a.c endif +ifeq ($(strip $(LIB8TION_ENABLE)), yes) + ifneq (,$(filter $(MCU), atmega16u2 atmega32u2 at90usb162)) + # ATmegaxxU2 does not have hardware MUL instruction - lib8tion must be told to use software multiplication routines + OPT_DEFS += -DLIB8_ATTINY + endif + SRC += $(LIB_PATH)/lib8tion/lib8tion.c +endif + VALID_HAPTIC_DRIVER_TYPES := drv2605l solenoid ifeq ($(strip $(HAPTIC_ENABLE)),yes) ifeq ($(filter $(HAPTIC_DRIVER),$(VALID_HAPTIC_DRIVER_TYPES)),) @@ -819,27 +800,6 @@ ifeq ($(strip $(UNICODE_COMMON)), yes) $(QUANTUM_DIR)/unicode/utf8.c endif -MAGIC_ENABLE ?= yes -ifeq ($(strip $(MAGIC_ENABLE)), yes) - SRC += $(QUANTUM_DIR)/process_keycode/process_magic.c - OPT_DEFS += -DMAGIC_KEYCODE_ENABLE -endif - -SEND_STRING_ENABLE ?= yes -ifeq ($(strip $(SEND_STRING_ENABLE)), yes) - OPT_DEFS += -DSEND_STRING_ENABLE - COMMON_VPATH += $(QUANTUM_DIR)/send_string - SRC += $(QUANTUM_DIR)/send_string/send_string.c -endif - -ifeq ($(strip $(AUTO_SHIFT_ENABLE)), yes) - SRC += $(QUANTUM_DIR)/process_keycode/process_auto_shift.c - OPT_DEFS += -DAUTO_SHIFT_ENABLE - ifeq ($(strip $(AUTO_SHIFT_MODIFIERS)), yes) - OPT_DEFS += -DAUTO_SHIFT_MODIFIERS - endif -endif - ifeq ($(strip $(PS2_MOUSE_ENABLE)), yes) PS2_ENABLE := yes MOUSE_ENABLE := yes @@ -946,14 +906,6 @@ ifeq ($(strip $(ENCODER_ENABLE)), yes) endif endif -ifeq ($(strip $(OS_DETECTION_ENABLE)), yes) - SRC += $(QUANTUM_DIR)/os_detection.c - OPT_DEFS += -DOS_DETECTION_ENABLE - ifeq ($(strip $(OS_DETECTION_DEBUG_ENABLE)), yes) - OPT_DEFS += -DOS_DETECTION_DEBUG_ENABLE - endif -endif - VALID_WS2812_DRIVER_TYPES := bitbang custom i2c pwm spi vendor WS2812_DRIVER ?= bitbang diff --git a/builddefs/generic_features.mk b/builddefs/generic_features.mk index 261da564b2..9c86958625 100644 --- a/builddefs/generic_features.mk +++ b/builddefs/generic_features.mk @@ -13,33 +13,45 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -SPACE_CADET_ENABLE ?= yes GRAVE_ESC_ENABLE ?= yes +MAGIC_ENABLE ?= yes +SEND_STRING_ENABLE ?= yes +SPACE_CADET_ENABLE ?= yes GENERIC_FEATURES = \ + AUTO_SHIFT \ AUTOCORRECT \ CAPS_WORD \ COMBO \ COMMAND \ + CRC \ DEFERRED_EXEC \ DIGITIZER \ DIP_SWITCH \ DYNAMIC_KEYMAP \ DYNAMIC_MACRO \ + DYNAMIC_TAPPING_TERM \ GRAVE_ESC \ HAPTIC \ KEY_LOCK \ KEY_OVERRIDE \ LEADER \ + MAGIC \ + MOUSEKEY \ + MUSIC \ + OS_DETECTION \ PROGRAMMABLE_BUTTON \ REPEAT_KEY \ SECURE \ + SEND_STRING \ + SEQUENCER \ SPACE_CADET \ SWAP_HANDS \ TAP_DANCE \ + TRI_LAYER \ + VIA \ + VIRTSER \ WPM \ - DYNAMIC_TAPPING_TERM \ - TRI_LAYER define HANDLE_GENERIC_FEATURE # $$(info "Processing: $1_ENABLE $2.c") diff --git a/builddefs/show_options.mk b/builddefs/show_options.mk index 44e40e1f41..81d8400a80 100644 --- a/builddefs/show_options.mk +++ b/builddefs/show_options.mk @@ -37,7 +37,6 @@ OTHER_OPTION_NAMES = \ UNICODEMAP_ENABLE \ UNICODE_COMMON \ AUTO_SHIFT_ENABLE \ - AUTO_SHIFT_MODIFIERS \ DYNAMIC_TAPPING_TERM_ENABLE \ COMBO_ENABLE \ KEY_LOCK_ENABLE \ diff --git a/docs/feature_os_detection.md b/docs/feature_os_detection.md index f32e419807..907638bcfa 100644 --- a/docs/feature_os_detection.md +++ b/docs/feature_os_detection.md @@ -36,10 +36,15 @@ This time is quite short, probably hundreds of milliseconds, but this data may b If OS is guessed incorrectly, you may want to collect data about USB setup packets to refine the detection logic. -To do so in your `rules.mk` add: +To do so in your `config.h` add: + +```c +#define OS_DETECTION_DEBUG_ENABLE +``` + +And in your `rules.mk` add: ```make -OS_DETECTION_DEBUG_ENABLE = yes CONSOLE_ENABLE = yes ``` diff --git a/keyboards/ergodox_ez/keymaps/hacker_dvorak/rules.mk b/keyboards/ergodox_ez/keymaps/hacker_dvorak/rules.mk index 9da5278ed9..aaf4e53f6e 100644 --- a/keyboards/ergodox_ez/keymaps/hacker_dvorak/rules.mk +++ b/keyboards/ergodox_ez/keymaps/hacker_dvorak/rules.mk @@ -31,7 +31,6 @@ SWAP_HANDS_ENABLE = no # Allow swapping hands of keyboard. # POINTING_DEVICE_ENABLE = no # AUTO_SHIFT_ENABLE = no -# AUTO_SHIFT_MODIFIERS = no # This don't need argument? # CUSTOM_MATRIX # Custom matrix file for the ErgoDox EZ diff --git a/keyboards/keebio/levinson/keymaps/drogglbecher/rules.mk b/keyboards/keebio/levinson/keymaps/drogglbecher/rules.mk index b2a5451c82..a22dc3d2a9 100644 --- a/keyboards/keebio/levinson/keymaps/drogglbecher/rules.mk +++ b/keyboards/keebio/levinson/keymaps/drogglbecher/rules.mk @@ -1,5 +1,4 @@ AUTO_SHIFT_ENABLE = no -AUTO_SHIFT_MODIFIERS = no RGBLIGHT_ENABLE = no BACKLIGHT_ENABLE = no UNICODE_ENABLE = yes diff --git a/keyboards/planck/keymaps/sascha/rules.mk b/keyboards/planck/keymaps/sascha/rules.mk index 78ac4ca825..41157c39d7 100644 --- a/keyboards/planck/keymaps/sascha/rules.mk +++ b/keyboards/planck/keymaps/sascha/rules.mk @@ -1,5 +1,4 @@ AUTO_SHIFT_ENABLE = no -AUTO_SHIFT_MODIFIERS = no UNICODE_ENABLE = yes LTO_ENABLE = yes diff --git a/keyboards/splitkb/aurora/sweep/keymaps/flinguenheld/rules.mk b/keyboards/splitkb/aurora/sweep/keymaps/flinguenheld/rules.mk index 585c589d3a..dd3e45125d 100644 --- a/keyboards/splitkb/aurora/sweep/keymaps/flinguenheld/rules.mk +++ b/keyboards/splitkb/aurora/sweep/keymaps/flinguenheld/rules.mk @@ -10,7 +10,6 @@ OLED_ENABLE = yes MOUSEKEY_ENABLE = yes AUTO_SHIFT_ENABLE = yes -AUTO_SHIFT_MODIFIERS = no COMBO_ENABLE = yes LEADER_ENABLE = yes diff --git a/quantum/quantum.c b/quantum/quantum.c index f721ab0a1f..86c6768729 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -40,7 +40,7 @@ # include "process_leader.h" #endif -#ifdef MAGIC_KEYCODE_ENABLE +#ifdef MAGIC_ENABLE # include "process_magic.h" #endif @@ -366,7 +366,7 @@ bool process_record_quantum(keyrecord_t *record) { #ifdef SPACE_CADET_ENABLE process_space_cadet(keycode, record) && #endif -#ifdef MAGIC_KEYCODE_ENABLE +#ifdef MAGIC_ENABLE process_magic(keycode, record) && #endif #ifdef GRAVE_ESC_ENABLE