diff options
| -rw-r--r-- | common_features.mk | 21 | ||||
| -rw-r--r-- | quantum/bootmagic/bootmagic.h | 24 | ||||
| -rw-r--r-- | quantum/bootmagic/bootmagic_full.c (renamed from tmk_core/common/bootmagic.c) | 104 | ||||
| -rw-r--r-- | quantum/bootmagic/bootmagic_full.h (renamed from tmk_core/common/bootmagic.h) | 21 | ||||
| -rw-r--r-- | quantum/bootmagic/bootmagic_lite.c (renamed from tmk_core/common/bootmagic_lite.c) | 17 | ||||
| -rw-r--r-- | quantum/bootmagic/bootmagic_lite.h | 25 | ||||
| -rw-r--r-- | quantum/bootmagic/magic.c | 54 | ||||
| -rw-r--r-- | quantum/bootmagic/magic.h | 18 | ||||
| -rw-r--r-- | quantum/quantum.c | 8 | ||||
| -rw-r--r-- | quantum/quantum.h | 10 | ||||
| -rw-r--r-- | tmk_core/common.mk | 22 | ||||
| -rw-r--r-- | tmk_core/common/keyboard.c | 10 | ||||
| -rw-r--r-- | tmk_core/common/magic.c | 39 | ||||
| -rw-r--r-- | tmk_core/common/magic.h | 3 | ||||
| -rw-r--r-- | tmk_core/protocol.mk | 4 |
15 files changed, 227 insertions, 153 deletions
diff --git a/common_features.mk b/common_features.mk index d238b2812..109c50c5f 100644 --- a/common_features.mk +++ b/common_features.mk | |||
| @@ -421,10 +421,6 @@ ifeq ($(strip $(TERMINAL_ENABLE)), yes) | |||
| 421 | OPT_DEFS += -DUSER_PRINT | 421 | OPT_DEFS += -DUSER_PRINT |
| 422 | endif | 422 | endif |
| 423 | 423 | ||
| 424 | ifeq ($(strip $(USB_HID_ENABLE)), yes) | ||
| 425 | include $(TMK_DIR)/protocol/usb_hid.mk | ||
| 426 | endif | ||
| 427 | |||
| 428 | ifeq ($(strip $(WPM_ENABLE)), yes) | 424 | ifeq ($(strip $(WPM_ENABLE)), yes) |
| 429 | SRC += $(QUANTUM_DIR)/wpm.c | 425 | SRC += $(QUANTUM_DIR)/wpm.c |
| 430 | OPT_DEFS += -DWPM_ENABLE | 426 | OPT_DEFS += -DWPM_ENABLE |
| @@ -458,6 +454,23 @@ ifeq ($(strip $(DIP_SWITCH_ENABLE)), yes) | |||
| 458 | SRC += $(QUANTUM_DIR)/dip_switch.c | 454 | SRC += $(QUANTUM_DIR)/dip_switch.c |
| 459 | endif | 455 | endif |
| 460 | 456 | ||
| 457 | VALID_MAGIC_TYPES := yes full lite | ||
| 458 | BOOTMAGIC_ENABLE ?= no | ||
| 459 | ifneq ($(strip $(BOOTMAGIC_ENABLE)), no) | ||
| 460 | ifeq ($(filter $(BOOTMAGIC_ENABLE),$(VALID_MAGIC_TYPES)),) | ||
| 461 | $(error BOOTMAGIC_ENABLE="$(BOOTMAGIC_ENABLE)" is not a valid type of magic) | ||
| 462 | endif | ||
| 463 | ifeq ($(strip $(BOOTMAGIC_ENABLE)), lite) | ||
| 464 | OPT_DEFS += -DBOOTMAGIC_LITE | ||
| 465 | QUANTUM_SRC += $(QUANTUM_DIR)/bootmagic/bootmagic_lite.c | ||
| 466 | else | ||
| 467 | OPT_DEFS += -DBOOTMAGIC_ENABLE | ||
| 468 | QUANTUM_SRC += $(QUANTUM_DIR)/bootmagic/bootmagic_full.c | ||
| 469 | endif | ||
| 470 | endif | ||
| 471 | COMMON_VPATH += $(QUANTUM_DIR)/bootmagic | ||
| 472 | QUANTUM_SRC += $(QUANTUM_DIR)/bootmagic/magic.c | ||
| 473 | |||
| 461 | VALID_CUSTOM_MATRIX_TYPES:= yes lite no | 474 | VALID_CUSTOM_MATRIX_TYPES:= yes lite no |
| 462 | 475 | ||
| 463 | CUSTOM_MATRIX ?= no | 476 | CUSTOM_MATRIX ?= no |
diff --git a/quantum/bootmagic/bootmagic.h b/quantum/bootmagic/bootmagic.h new file mode 100644 index 000000000..959750178 --- /dev/null +++ b/quantum/bootmagic/bootmagic.h | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #pragma once | ||
| 17 | |||
| 18 | #if defined(BOOTMAGIC_ENABLE) | ||
| 19 | # include "bootmagic_full.h" | ||
| 20 | #elif defined(BOOTMAGIC_LITE) | ||
| 21 | # include "bootmagic_lite.h" | ||
| 22 | #endif | ||
| 23 | |||
| 24 | void bootmagic(void); | ||
diff --git a/tmk_core/common/bootmagic.c b/quantum/bootmagic/bootmagic_full.c index c1b3adf94..18c28cde8 100644 --- a/tmk_core/common/bootmagic.c +++ b/quantum/bootmagic/bootmagic_full.c | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #include <stdint.h> | 16 | #include <stdint.h> |
| 2 | #include <stdbool.h> | 17 | #include <stdbool.h> |
| 3 | #include "wait.h" | 18 | #include "wait.h" |
| @@ -10,18 +25,35 @@ | |||
| 10 | #include "eeconfig.h" | 25 | #include "eeconfig.h" |
| 11 | #include "bootmagic.h" | 26 | #include "bootmagic.h" |
| 12 | 27 | ||
| 13 | keymap_config_t keymap_config; | 28 | /** \brief Scan Keycode |
| 14 | |||
| 15 | /** \brief Bootmagic | ||
| 16 | * | 29 | * |
| 17 | * FIXME: needs doc | 30 | * FIXME: needs doc |
| 18 | */ | 31 | */ |
| 19 | void bootmagic(void) { | 32 | static bool scan_keycode(uint8_t keycode) { |
| 20 | /* check signature */ | 33 | for (uint8_t r = 0; r < MATRIX_ROWS; r++) { |
| 21 | if (!eeconfig_is_enabled()) { | 34 | matrix_row_t matrix_row = matrix_get_row(r); |
| 22 | eeconfig_init(); | 35 | for (uint8_t c = 0; c < MATRIX_COLS; c++) { |
| 36 | if (matrix_row & ((matrix_row_t)1 << c)) { | ||
| 37 | if (keycode == keymap_key_to_keycode(0, (keypos_t){.row = r, .col = c})) { | ||
| 38 | return true; | ||
| 39 | } | ||
| 40 | } | ||
| 41 | } | ||
| 23 | } | 42 | } |
| 43 | return false; | ||
| 44 | } | ||
| 45 | |||
| 46 | /** \brief Bootmagic Scan Keycode | ||
| 47 | * | ||
| 48 | * FIXME: needs doc | ||
| 49 | */ | ||
| 50 | static bool bootmagic_scan_keycode(uint8_t keycode) { | ||
| 51 | if (!scan_keycode(BOOTMAGIC_KEY_SALT)) return false; | ||
| 52 | |||
| 53 | return scan_keycode(keycode); | ||
| 54 | } | ||
| 24 | 55 | ||
| 56 | void bootmagic(void) { | ||
| 25 | /* do scans in case of bounce */ | 57 | /* do scans in case of bounce */ |
| 26 | print("bootmagic scan: ... "); | 58 | print("bootmagic scan: ... "); |
| 27 | uint8_t scan = 100; | 59 | uint8_t scan = 100; |
| @@ -46,8 +78,6 @@ void bootmagic(void) { | |||
| 46 | bootloader_jump(); | 78 | bootloader_jump(); |
| 47 | } | 79 | } |
| 48 | 80 | ||
| 49 | /* debug enable */ | ||
| 50 | debug_config.raw = eeconfig_read_debug(); | ||
| 51 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_ENABLE)) { | 81 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_ENABLE)) { |
| 52 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_MATRIX)) { | 82 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_MATRIX)) { |
| 53 | debug_config.matrix = !debug_config.matrix; | 83 | debug_config.matrix = !debug_config.matrix; |
| @@ -61,8 +91,6 @@ void bootmagic(void) { | |||
| 61 | } | 91 | } |
| 62 | eeconfig_update_debug(debug_config.raw); | 92 | eeconfig_update_debug(debug_config.raw); |
| 63 | 93 | ||
| 64 | /* keymap config */ | ||
| 65 | keymap_config.raw = eeconfig_read_keymap(); | ||
| 66 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_CONTROL_CAPSLOCK)) { | 94 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_CONTROL_CAPSLOCK)) { |
| 67 | keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock; | 95 | keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock; |
| 68 | } | 96 | } |
| @@ -94,70 +122,34 @@ void bootmagic(void) { | |||
| 94 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_0)) { | 122 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_0)) { |
| 95 | default_layer |= (1 << 0); | 123 | default_layer |= (1 << 0); |
| 96 | } | 124 | } |
| 97 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_1)) { | 125 | else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_1)) { |
| 98 | default_layer |= (1 << 1); | 126 | default_layer |= (1 << 1); |
| 99 | } | 127 | } |
| 100 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_2)) { | 128 | else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_2)) { |
| 101 | default_layer |= (1 << 2); | 129 | default_layer |= (1 << 2); |
| 102 | } | 130 | } |
| 103 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_3)) { | 131 | else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_3)) { |
| 104 | default_layer |= (1 << 3); | 132 | default_layer |= (1 << 3); |
| 105 | } | 133 | } |
| 106 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_4)) { | 134 | else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_4)) { |
| 107 | default_layer |= (1 << 4); | 135 | default_layer |= (1 << 4); |
| 108 | } | 136 | } |
| 109 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_5)) { | 137 | else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_5)) { |
| 110 | default_layer |= (1 << 5); | 138 | default_layer |= (1 << 5); |
| 111 | } | 139 | } |
| 112 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_6)) { | 140 | else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_6)) { |
| 113 | default_layer |= (1 << 6); | 141 | default_layer |= (1 << 6); |
| 114 | } | 142 | } |
| 115 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_7)) { | 143 | else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_7)) { |
| 116 | default_layer |= (1 << 7); | 144 | default_layer |= (1 << 7); |
| 117 | } | 145 | } |
| 118 | if (default_layer) { | 146 | eeconfig_update_default_layer(default_layer); |
| 119 | eeconfig_update_default_layer(default_layer); | ||
| 120 | default_layer_set((layer_state_t)default_layer); | ||
| 121 | } else { | ||
| 122 | default_layer = eeconfig_read_default_layer(); | ||
| 123 | default_layer_set((layer_state_t)default_layer); | ||
| 124 | } | ||
| 125 | /* Also initialize layer state to trigger callback functions for layer_state */ | ||
| 126 | layer_state_set_kb((layer_state_t)layer_state); | ||
| 127 | 147 | ||
| 128 | /* EE_HANDS handedness */ | 148 | /* EE_HANDS handedness */ |
| 129 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_LEFT)) { | 149 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_LEFT)) { |
| 130 | eeconfig_update_handedness(true); | 150 | eeconfig_update_handedness(true); |
| 131 | } | 151 | } |
| 132 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_RIGHT)) { | 152 | else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_RIGHT)) { |
| 133 | eeconfig_update_handedness(false); | 153 | eeconfig_update_handedness(false); |
| 134 | } | 154 | } |
| 135 | } | 155 | } |
| 136 | |||
| 137 | /** \brief Scan Keycode | ||
| 138 | * | ||
| 139 | * FIXME: needs doc | ||
| 140 | */ | ||
| 141 | static bool scan_keycode(uint8_t keycode) { | ||
| 142 | for (uint8_t r = 0; r < MATRIX_ROWS; r++) { | ||
| 143 | matrix_row_t matrix_row = matrix_get_row(r); | ||
| 144 | for (uint8_t c = 0; c < MATRIX_COLS; c++) { | ||
| 145 | if (matrix_row & ((matrix_row_t)1 << c)) { | ||
| 146 | if (keycode == keymap_key_to_keycode(0, (keypos_t){.row = r, .col = c})) { | ||
| 147 | return true; | ||
| 148 | } | ||
| 149 | } | ||
| 150 | } | ||
| 151 | } | ||
| 152 | return false; | ||
| 153 | } | ||
| 154 | |||
| 155 | /** \brief Bootmagic Scan Keycode | ||
| 156 | * | ||
| 157 | * FIXME: needs doc | ||
| 158 | */ | ||
| 159 | bool bootmagic_scan_keycode(uint8_t keycode) { | ||
| 160 | if (!scan_keycode(BOOTMAGIC_KEY_SALT)) return false; | ||
| 161 | |||
| 162 | return scan_keycode(keycode); | ||
| 163 | } | ||
diff --git a/tmk_core/common/bootmagic.h b/quantum/bootmagic/bootmagic_full.h index 8209d0194..28f914c1b 100644 --- a/tmk_core/common/bootmagic.h +++ b/quantum/bootmagic/bootmagic_full.h | |||
| @@ -1,3 +1,19 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 1 | #pragma once | 17 | #pragma once |
| 2 | 18 | ||
| 3 | /* FIXME: Add special doxygen comments for defines here. */ | 19 | /* FIXME: Add special doxygen comments for defines here. */ |
| @@ -96,7 +112,4 @@ | |||
| 96 | #endif | 112 | #endif |
| 97 | #ifndef BOOTMAGIC_KEY_DEFAULT_LAYER_7 | 113 | #ifndef BOOTMAGIC_KEY_DEFAULT_LAYER_7 |
| 98 | # define BOOTMAGIC_KEY_DEFAULT_LAYER_7 KC_7 | 114 | # define BOOTMAGIC_KEY_DEFAULT_LAYER_7 KC_7 |
| 99 | #endif | 115 | #endif \ No newline at end of file |
| 100 | |||
| 101 | void bootmagic(void); | ||
| 102 | bool bootmagic_scan_keycode(uint8_t keycode); | ||
diff --git a/tmk_core/common/bootmagic_lite.c b/quantum/bootmagic/bootmagic_lite.c index cbf756a17..9cbdcb0bb 100644 --- a/tmk_core/common/bootmagic_lite.c +++ b/quantum/bootmagic/bootmagic_lite.c | |||
| @@ -1,3 +1,18 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 1 | #include "quantum.h" | 16 | #include "quantum.h" |
| 2 | 17 | ||
| 3 | /** \brief Reset eeprom | 18 | /** \brief Reset eeprom |
| @@ -47,3 +62,5 @@ __attribute__((weak)) void bootmagic_lite(void) { | |||
| 47 | bootloader_jump(); | 62 | bootloader_jump(); |
| 48 | } | 63 | } |
| 49 | } | 64 | } |
| 65 | |||
| 66 | void bootmagic(void) { bootmagic_lite(); } | ||
diff --git a/quantum/bootmagic/bootmagic_lite.h b/quantum/bootmagic/bootmagic_lite.h new file mode 100644 index 000000000..17777e6b4 --- /dev/null +++ b/quantum/bootmagic/bootmagic_lite.h | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #pragma once | ||
| 17 | |||
| 18 | #ifndef BOOTMAGIC_LITE_COLUMN | ||
| 19 | # define BOOTMAGIC_LITE_COLUMN 0 | ||
| 20 | #endif | ||
| 21 | #ifndef BOOTMAGIC_LITE_ROW | ||
| 22 | # define BOOTMAGIC_LITE_ROW 0 | ||
| 23 | #endif | ||
| 24 | |||
| 25 | void bootmagic_lite(void); | ||
diff --git a/quantum/bootmagic/magic.c b/quantum/bootmagic/magic.c new file mode 100644 index 000000000..f1cb11c39 --- /dev/null +++ b/quantum/bootmagic/magic.c | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #include <stdint.h> | ||
| 17 | #include <stdbool.h> | ||
| 18 | #include "wait.h" | ||
| 19 | #include "matrix.h" | ||
| 20 | #include "bootloader.h" | ||
| 21 | #include "debug.h" | ||
| 22 | #include "keymap.h" | ||
| 23 | #include "host.h" | ||
| 24 | #include "action_layer.h" | ||
| 25 | #include "eeconfig.h" | ||
| 26 | #include "bootmagic.h" | ||
| 27 | |||
| 28 | keymap_config_t keymap_config; | ||
| 29 | |||
| 30 | __attribute__((weak)) void bootmagic(void) {} | ||
| 31 | |||
| 32 | /** \brief Magic | ||
| 33 | * | ||
| 34 | * FIXME: Needs doc | ||
| 35 | */ | ||
| 36 | void magic(void) { | ||
| 37 | /* check signature */ | ||
| 38 | if (!eeconfig_is_enabled()) { | ||
| 39 | eeconfig_init(); | ||
| 40 | } | ||
| 41 | |||
| 42 | /* init globals */ | ||
| 43 | debug_config.raw = eeconfig_read_debug(); | ||
| 44 | keymap_config.raw = eeconfig_read_keymap(); | ||
| 45 | |||
| 46 | bootmagic(); | ||
| 47 | |||
| 48 | /* read here just incase bootmagic process changed its value */ | ||
| 49 | layer_state_t default_layer = (layer_state_t)eeconfig_read_default_layer(); | ||
| 50 | default_layer_set(default_layer); | ||
| 51 | |||
| 52 | /* Also initialize layer state to trigger callback functions for layer_state */ | ||
| 53 | layer_state_set_kb((layer_state_t)layer_state); | ||
| 54 | } | ||
diff --git a/quantum/bootmagic/magic.h b/quantum/bootmagic/magic.h new file mode 100644 index 000000000..2c3969b85 --- /dev/null +++ b/quantum/bootmagic/magic.h | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | /* Copyright 2021 QMK | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 3 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | #pragma once | ||
| 17 | |||
| 18 | void magic(void); | ||
diff --git a/quantum/quantum.c b/quantum/quantum.c index db99e80fa..7345ab0d5 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | 16 | ||
| 17 | #include <ctype.h> | 17 | #include <ctype.h> |
| 18 | #include "quantum.h" | 18 | #include "quantum.h" |
| 19 | #include "magic.h" | ||
| 19 | 20 | ||
| 20 | #ifdef BLUETOOTH_ENABLE | 21 | #ifdef BLUETOOTH_ENABLE |
| 21 | # include "outputselect.h" | 22 | # include "outputselect.h" |
| @@ -601,12 +602,7 @@ void tap_random_base64(void) { | |||
| 601 | } | 602 | } |
| 602 | 603 | ||
| 603 | void matrix_init_quantum() { | 604 | void matrix_init_quantum() { |
| 604 | #ifdef BOOTMAGIC_LITE | 605 | magic(); |
| 605 | bootmagic_lite(); | ||
| 606 | #endif | ||
| 607 | if (!eeconfig_is_enabled()) { | ||
| 608 | eeconfig_init(); | ||
| 609 | } | ||
| 610 | #if defined(LED_NUM_LOCK_PIN) || defined(LED_CAPS_LOCK_PIN) || defined(LED_SCROLL_LOCK_PIN) || defined(LED_COMPOSE_PIN) || defined(LED_KANA_PIN) | 606 | #if defined(LED_NUM_LOCK_PIN) || defined(LED_CAPS_LOCK_PIN) || defined(LED_SCROLL_LOCK_PIN) || defined(LED_COMPOSE_PIN) || defined(LED_KANA_PIN) |
| 611 | // TODO: remove calls to led_init_ports from keyboards and remove ifdef | 607 | // TODO: remove calls to led_init_ports from keyboards and remove ifdef |
| 612 | led_init_ports(); | 608 | led_init_ports(); |
diff --git a/quantum/quantum.h b/quantum/quantum.h index 36a983d57..7bb6e796e 100644 --- a/quantum/quantum.h +++ b/quantum/quantum.h | |||
| @@ -52,6 +52,7 @@ | |||
| 52 | #include "action_layer.h" | 52 | #include "action_layer.h" |
| 53 | #include "eeconfig.h" | 53 | #include "eeconfig.h" |
| 54 | #include "bootloader.h" | 54 | #include "bootloader.h" |
| 55 | #include "bootmagic.h" | ||
| 55 | #include "timer.h" | 56 | #include "timer.h" |
| 56 | #include "sync_timer.h" | 57 | #include "sync_timer.h" |
| 57 | #include "config_common.h" | 58 | #include "config_common.h" |
| @@ -283,15 +284,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record); | |||
| 283 | void post_process_record_kb(uint16_t keycode, keyrecord_t *record); | 284 | void post_process_record_kb(uint16_t keycode, keyrecord_t *record); |
| 284 | void post_process_record_user(uint16_t keycode, keyrecord_t *record); | 285 | void post_process_record_user(uint16_t keycode, keyrecord_t *record); |
| 285 | 286 | ||
| 286 | #ifndef BOOTMAGIC_LITE_COLUMN | ||
| 287 | # define BOOTMAGIC_LITE_COLUMN 0 | ||
| 288 | #endif | ||
| 289 | #ifndef BOOTMAGIC_LITE_ROW | ||
| 290 | # define BOOTMAGIC_LITE_ROW 0 | ||
| 291 | #endif | ||
| 292 | |||
| 293 | void bootmagic_lite(void); | ||
| 294 | |||
| 295 | void reset_keyboard(void); | 287 | void reset_keyboard(void); |
| 296 | 288 | ||
| 297 | void startup_user(void); | 289 | void startup_user(void); |
diff --git a/tmk_core/common.mk b/tmk_core/common.mk index 238b3c69f..c2fc522ce 100644 --- a/tmk_core/common.mk +++ b/tmk_core/common.mk | |||
| @@ -24,28 +24,6 @@ else | |||
| 24 | include $(TMK_PATH)/$(COMMON_DIR)/lib_printf.mk | 24 | include $(TMK_PATH)/$(COMMON_DIR)/lib_printf.mk |
| 25 | endif | 25 | endif |
| 26 | 26 | ||
| 27 | # Option modules | ||
| 28 | BOOTMAGIC_ENABLE ?= no | ||
| 29 | VALID_MAGIC_TYPES := yes full lite | ||
| 30 | ifneq ($(strip $(BOOTMAGIC_ENABLE)), no) | ||
| 31 | ifeq ($(filter $(BOOTMAGIC_ENABLE),$(VALID_MAGIC_TYPES)),) | ||
| 32 | $(error BOOTMAGIC_ENABLE="$(BOOTMAGIC_ENABLE)" is not a valid type of magic) | ||
| 33 | endif | ||
| 34 | ifeq ($(strip $(BOOTMAGIC_ENABLE)), lite) | ||
| 35 | TMK_COMMON_DEFS += -DBOOTMAGIC_LITE | ||
| 36 | TMK_COMMON_SRC += $(COMMON_DIR)/bootmagic_lite.c | ||
| 37 | |||
| 38 | TMK_COMMON_DEFS += -DMAGIC_ENABLE | ||
| 39 | TMK_COMMON_SRC += $(COMMON_DIR)/magic.c | ||
| 40 | else | ||
| 41 | TMK_COMMON_DEFS += -DBOOTMAGIC_ENABLE | ||
| 42 | TMK_COMMON_SRC += $(COMMON_DIR)/bootmagic.c | ||
| 43 | endif | ||
| 44 | else | ||
| 45 | TMK_COMMON_DEFS += -DMAGIC_ENABLE | ||
| 46 | TMK_COMMON_SRC += $(COMMON_DIR)/magic.c | ||
| 47 | endif | ||
| 48 | |||
| 49 | SHARED_EP_ENABLE = no | 27 | SHARED_EP_ENABLE = no |
| 50 | MOUSE_SHARED_EP ?= yes | 28 | MOUSE_SHARED_EP ?= yes |
| 51 | ifeq ($(strip $(KEYBOARD_SHARED_EP)), yes) | 29 | ifeq ($(strip $(KEYBOARD_SHARED_EP)), yes) |
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index ce3255c06..65d9e00c7 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c | |||
| @@ -34,11 +34,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 34 | #ifdef BACKLIGHT_ENABLE | 34 | #ifdef BACKLIGHT_ENABLE |
| 35 | # include "backlight.h" | 35 | # include "backlight.h" |
| 36 | #endif | 36 | #endif |
| 37 | #ifdef BOOTMAGIC_ENABLE | ||
| 38 | # include "bootmagic.h" | ||
| 39 | #else | ||
| 40 | # include "magic.h" | ||
| 41 | #endif | ||
| 42 | #ifdef MOUSEKEY_ENABLE | 37 | #ifdef MOUSEKEY_ENABLE |
| 43 | # include "mousekey.h" | 38 | # include "mousekey.h" |
| 44 | #endif | 39 | #endif |
| @@ -296,11 +291,6 @@ void keyboard_init(void) { | |||
| 296 | #ifdef ADB_MOUSE_ENABLE | 291 | #ifdef ADB_MOUSE_ENABLE |
| 297 | adb_mouse_init(); | 292 | adb_mouse_init(); |
| 298 | #endif | 293 | #endif |
| 299 | #ifdef BOOTMAGIC_ENABLE | ||
| 300 | bootmagic(); | ||
| 301 | #else | ||
| 302 | magic(); | ||
| 303 | #endif | ||
| 304 | #ifdef BACKLIGHT_ENABLE | 294 | #ifdef BACKLIGHT_ENABLE |
| 305 | backlight_init(); | 295 | backlight_init(); |
| 306 | #endif | 296 | #endif |
diff --git a/tmk_core/common/magic.c b/tmk_core/common/magic.c deleted file mode 100644 index e14994164..000000000 --- a/tmk_core/common/magic.c +++ /dev/null | |||
| @@ -1,39 +0,0 @@ | |||
| 1 | #include <stdint.h> | ||
| 2 | #include <stdbool.h> | ||
| 3 | #if defined(__AVR__) | ||
| 4 | # include <util/delay.h> | ||
| 5 | #endif | ||
| 6 | #include "matrix.h" | ||
| 7 | #include "bootloader.h" | ||
| 8 | #include "debug.h" | ||
| 9 | #include "keymap.h" | ||
| 10 | #include "host.h" | ||
| 11 | #include "action_layer.h" | ||
| 12 | #include "eeconfig.h" | ||
| 13 | #include "magic.h" | ||
| 14 | |||
| 15 | keymap_config_t keymap_config; | ||
| 16 | |||
| 17 | /** \brief Magic | ||
| 18 | * | ||
| 19 | * FIXME: Needs doc | ||
| 20 | */ | ||
| 21 | void magic(void) { | ||
| 22 | /* check signature */ | ||
| 23 | if (!eeconfig_is_enabled()) { | ||
| 24 | eeconfig_init(); | ||
| 25 | } | ||
| 26 | |||
| 27 | /* debug enable */ | ||
| 28 | debug_config.raw = eeconfig_read_debug(); | ||
| 29 | |||
| 30 | /* keymap config */ | ||
| 31 | keymap_config.raw = eeconfig_read_keymap(); | ||
| 32 | |||
| 33 | uint8_t default_layer = 0; | ||
| 34 | default_layer = eeconfig_read_default_layer(); | ||
| 35 | default_layer_set((layer_state_t)default_layer); | ||
| 36 | |||
| 37 | /* Also initialize layer state to trigger callback functions for layer_state */ | ||
| 38 | layer_state_set_kb((layer_state_t)layer_state); | ||
| 39 | } | ||
diff --git a/tmk_core/common/magic.h b/tmk_core/common/magic.h deleted file mode 100644 index a6552c04d..000000000 --- a/tmk_core/common/magic.h +++ /dev/null | |||
| @@ -1,3 +0,0 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | void magic(void); | ||
diff --git a/tmk_core/protocol.mk b/tmk_core/protocol.mk index 0c41642b9..cc87e8347 100644 --- a/tmk_core/protocol.mk +++ b/tmk_core/protocol.mk | |||
| @@ -54,5 +54,9 @@ ifeq ($(strip $(XT_ENABLE)), yes) | |||
| 54 | OPT_DEFS += -DXT_ENABLE | 54 | OPT_DEFS += -DXT_ENABLE |
| 55 | endif | 55 | endif |
| 56 | 56 | ||
| 57 | ifeq ($(strip $(USB_HID_ENABLE)), yes) | ||
| 58 | include $(TMK_DIR)/protocol/usb_hid.mk | ||
| 59 | endif | ||
| 60 | |||
| 57 | # Search Path | 61 | # Search Path |
| 58 | VPATH += $(TMK_DIR)/protocol | 62 | VPATH += $(TMK_DIR)/protocol |
