Skip to content

Commit

Permalink
Migrate some common features to generic (qmk#22403)
Browse files Browse the repository at this point in the history
  • Loading branch information
zvecr authored and christrotter committed Nov 28, 2023
1 parent cad61da commit 2e83a4b
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 72 deletions.
72 changes: 12 additions & 60 deletions builddefs/common_features.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -360,18 +346,15 @@ 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
POST_CONFIG_H += $(QUANTUM_DIR)/led_matrix/post_config.h
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)
Expand Down Expand Up @@ -463,18 +446,15 @@ 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
POST_CONFIG_H += $(QUANTUM_DIR)/rgb_matrix/post_config.h
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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)),)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
18 changes: 15 additions & 3 deletions builddefs/generic_features.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,45 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

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")
Expand Down
1 change: 0 additions & 1 deletion builddefs/show_options.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
9 changes: 7 additions & 2 deletions docs/feature_os_detection.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
1 change: 0 additions & 1 deletion keyboards/ergodox_ez/keymaps/hacker_dvorak/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion keyboards/keebio/levinson/keymaps/drogglbecher/rules.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
AUTO_SHIFT_ENABLE = no
AUTO_SHIFT_MODIFIERS = no
RGBLIGHT_ENABLE = no
BACKLIGHT_ENABLE = no
UNICODE_ENABLE = yes
Expand Down
1 change: 0 additions & 1 deletion keyboards/planck/keymaps/sascha/rules.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
AUTO_SHIFT_ENABLE = no
AUTO_SHIFT_MODIFIERS = no
UNICODE_ENABLE = yes
LTO_ENABLE = yes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ OLED_ENABLE = yes

MOUSEKEY_ENABLE = yes
AUTO_SHIFT_ENABLE = yes
AUTO_SHIFT_MODIFIERS = no
COMBO_ENABLE = yes
LEADER_ENABLE = yes

Expand Down
4 changes: 2 additions & 2 deletions quantum/quantum.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
# include "process_leader.h"
#endif

#ifdef MAGIC_KEYCODE_ENABLE
#ifdef MAGIC_ENABLE
# include "process_magic.h"
#endif

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2e83a4b

Please sign in to comment.