diff options
Diffstat (limited to 'tmk_core/common')
| -rw-r--r-- | tmk_core/common/bootmagic.c | 163 | ||||
| -rw-r--r-- | tmk_core/common/bootmagic.h | 102 | ||||
| -rw-r--r-- | tmk_core/common/bootmagic_lite.c | 49 | ||||
| -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 |
6 files changed, 0 insertions, 366 deletions
diff --git a/tmk_core/common/bootmagic.c b/tmk_core/common/bootmagic.c deleted file mode 100644 index c1b3adf94..000000000 --- a/tmk_core/common/bootmagic.c +++ /dev/null | |||
| @@ -1,163 +0,0 @@ | |||
| 1 | #include <stdint.h> | ||
| 2 | #include <stdbool.h> | ||
| 3 | #include "wait.h" | ||
| 4 | #include "matrix.h" | ||
| 5 | #include "bootloader.h" | ||
| 6 | #include "debug.h" | ||
| 7 | #include "keymap.h" | ||
| 8 | #include "host.h" | ||
| 9 | #include "action_layer.h" | ||
| 10 | #include "eeconfig.h" | ||
| 11 | #include "bootmagic.h" | ||
| 12 | |||
| 13 | keymap_config_t keymap_config; | ||
| 14 | |||
| 15 | /** \brief Bootmagic | ||
| 16 | * | ||
| 17 | * FIXME: needs doc | ||
| 18 | */ | ||
| 19 | void bootmagic(void) { | ||
| 20 | /* check signature */ | ||
| 21 | if (!eeconfig_is_enabled()) { | ||
| 22 | eeconfig_init(); | ||
| 23 | } | ||
| 24 | |||
| 25 | /* do scans in case of bounce */ | ||
| 26 | print("bootmagic scan: ... "); | ||
| 27 | uint8_t scan = 100; | ||
| 28 | while (scan--) { | ||
| 29 | matrix_scan(); | ||
| 30 | wait_ms(10); | ||
| 31 | } | ||
| 32 | print("done.\n"); | ||
| 33 | |||
| 34 | /* bootmagic skip */ | ||
| 35 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SKIP)) { | ||
| 36 | return; | ||
| 37 | } | ||
| 38 | |||
| 39 | /* eeconfig clear */ | ||
| 40 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EEPROM_CLEAR)) { | ||
| 41 | eeconfig_init(); | ||
| 42 | } | ||
| 43 | |||
| 44 | /* bootloader */ | ||
| 45 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_BOOTLOADER)) { | ||
| 46 | bootloader_jump(); | ||
| 47 | } | ||
| 48 | |||
| 49 | /* debug enable */ | ||
| 50 | debug_config.raw = eeconfig_read_debug(); | ||
| 51 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_ENABLE)) { | ||
| 52 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_MATRIX)) { | ||
| 53 | debug_config.matrix = !debug_config.matrix; | ||
| 54 | } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_KEYBOARD)) { | ||
| 55 | debug_config.keyboard = !debug_config.keyboard; | ||
| 56 | } else if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEBUG_MOUSE)) { | ||
| 57 | debug_config.mouse = !debug_config.mouse; | ||
| 58 | } else { | ||
| 59 | debug_config.enable = !debug_config.enable; | ||
| 60 | } | ||
| 61 | } | ||
| 62 | eeconfig_update_debug(debug_config.raw); | ||
| 63 | |||
| 64 | /* keymap config */ | ||
| 65 | keymap_config.raw = eeconfig_read_keymap(); | ||
| 66 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_CONTROL_CAPSLOCK)) { | ||
| 67 | keymap_config.swap_control_capslock = !keymap_config.swap_control_capslock; | ||
| 68 | } | ||
| 69 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_CAPSLOCK_TO_CONTROL)) { | ||
| 70 | keymap_config.capslock_to_control = !keymap_config.capslock_to_control; | ||
| 71 | } | ||
| 72 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_LALT_LGUI)) { | ||
| 73 | keymap_config.swap_lalt_lgui = !keymap_config.swap_lalt_lgui; | ||
| 74 | } | ||
| 75 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_RALT_RGUI)) { | ||
| 76 | keymap_config.swap_ralt_rgui = !keymap_config.swap_ralt_rgui; | ||
| 77 | } | ||
| 78 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_NO_GUI)) { | ||
| 79 | keymap_config.no_gui = !keymap_config.no_gui; | ||
| 80 | } | ||
| 81 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_GRAVE_ESC)) { | ||
| 82 | keymap_config.swap_grave_esc = !keymap_config.swap_grave_esc; | ||
| 83 | } | ||
| 84 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_SWAP_BACKSLASH_BACKSPACE)) { | ||
| 85 | keymap_config.swap_backslash_backspace = !keymap_config.swap_backslash_backspace; | ||
| 86 | } | ||
| 87 | if (bootmagic_scan_keycode(BOOTMAGIC_HOST_NKRO)) { | ||
| 88 | keymap_config.nkro = !keymap_config.nkro; | ||
| 89 | } | ||
| 90 | eeconfig_update_keymap(keymap_config.raw); | ||
| 91 | |||
| 92 | /* default layer */ | ||
| 93 | uint8_t default_layer = 0; | ||
| 94 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_0)) { | ||
| 95 | default_layer |= (1 << 0); | ||
| 96 | } | ||
| 97 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_1)) { | ||
| 98 | default_layer |= (1 << 1); | ||
| 99 | } | ||
| 100 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_2)) { | ||
| 101 | default_layer |= (1 << 2); | ||
| 102 | } | ||
| 103 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_3)) { | ||
| 104 | default_layer |= (1 << 3); | ||
| 105 | } | ||
| 106 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_4)) { | ||
| 107 | default_layer |= (1 << 4); | ||
| 108 | } | ||
| 109 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_5)) { | ||
| 110 | default_layer |= (1 << 5); | ||
| 111 | } | ||
| 112 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_6)) { | ||
| 113 | default_layer |= (1 << 6); | ||
| 114 | } | ||
| 115 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_7)) { | ||
| 116 | default_layer |= (1 << 7); | ||
| 117 | } | ||
| 118 | if (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 | |||
| 128 | /* EE_HANDS handedness */ | ||
| 129 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_LEFT)) { | ||
| 130 | eeconfig_update_handedness(true); | ||
| 131 | } | ||
| 132 | if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EE_HANDS_RIGHT)) { | ||
| 133 | eeconfig_update_handedness(false); | ||
| 134 | } | ||
| 135 | } | ||
| 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/tmk_core/common/bootmagic.h deleted file mode 100644 index 8209d0194..000000000 --- a/tmk_core/common/bootmagic.h +++ /dev/null | |||
| @@ -1,102 +0,0 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | /* FIXME: Add special doxygen comments for defines here. */ | ||
| 4 | |||
| 5 | /* bootmagic salt key */ | ||
| 6 | #ifndef BOOTMAGIC_KEY_SALT | ||
| 7 | # define BOOTMAGIC_KEY_SALT KC_SPACE | ||
| 8 | #endif | ||
| 9 | |||
| 10 | /* skip bootmagic and eeconfig */ | ||
| 11 | #ifndef BOOTMAGIC_KEY_SKIP | ||
| 12 | # define BOOTMAGIC_KEY_SKIP KC_ESC | ||
| 13 | #endif | ||
| 14 | |||
| 15 | /* eeprom clear */ | ||
| 16 | #ifndef BOOTMAGIC_KEY_EEPROM_CLEAR | ||
| 17 | # define BOOTMAGIC_KEY_EEPROM_CLEAR KC_BSPACE | ||
| 18 | #endif | ||
| 19 | |||
| 20 | /* kick up bootloader */ | ||
| 21 | #ifndef BOOTMAGIC_KEY_BOOTLOADER | ||
| 22 | # define BOOTMAGIC_KEY_BOOTLOADER KC_B | ||
| 23 | #endif | ||
| 24 | |||
| 25 | /* debug enable */ | ||
| 26 | #ifndef BOOTMAGIC_KEY_DEBUG_ENABLE | ||
| 27 | # define BOOTMAGIC_KEY_DEBUG_ENABLE KC_D | ||
| 28 | #endif | ||
| 29 | #ifndef BOOTMAGIC_KEY_DEBUG_MATRIX | ||
| 30 | # define BOOTMAGIC_KEY_DEBUG_MATRIX KC_X | ||
| 31 | #endif | ||
| 32 | #ifndef BOOTMAGIC_KEY_DEBUG_KEYBOARD | ||
| 33 | # define BOOTMAGIC_KEY_DEBUG_KEYBOARD KC_K | ||
| 34 | #endif | ||
| 35 | #ifndef BOOTMAGIC_KEY_DEBUG_MOUSE | ||
| 36 | # define BOOTMAGIC_KEY_DEBUG_MOUSE KC_M | ||
| 37 | #endif | ||
| 38 | #ifndef BOOTMAGIC_KEY_EE_HANDS_LEFT | ||
| 39 | # define BOOTMAGIC_KEY_EE_HANDS_LEFT KC_L | ||
| 40 | #endif | ||
| 41 | #ifndef BOOTMAGIC_KEY_EE_HANDS_RIGHT | ||
| 42 | # define BOOTMAGIC_KEY_EE_HANDS_RIGHT KC_R | ||
| 43 | #endif | ||
| 44 | |||
| 45 | /* | ||
| 46 | * keymap config | ||
| 47 | */ | ||
| 48 | #ifndef BOOTMAGIC_KEY_SWAP_CONTROL_CAPSLOCK | ||
| 49 | # define BOOTMAGIC_KEY_SWAP_CONTROL_CAPSLOCK KC_LCTRL | ||
| 50 | #endif | ||
| 51 | #ifndef BOOTMAGIC_KEY_CAPSLOCK_TO_CONTROL | ||
| 52 | # define BOOTMAGIC_KEY_CAPSLOCK_TO_CONTROL KC_CAPSLOCK | ||
| 53 | #endif | ||
| 54 | #ifndef BOOTMAGIC_KEY_SWAP_LALT_LGUI | ||
| 55 | # define BOOTMAGIC_KEY_SWAP_LALT_LGUI KC_LALT | ||
| 56 | #endif | ||
| 57 | #ifndef BOOTMAGIC_KEY_SWAP_RALT_RGUI | ||
| 58 | # define BOOTMAGIC_KEY_SWAP_RALT_RGUI KC_RALT | ||
| 59 | #endif | ||
| 60 | #ifndef BOOTMAGIC_KEY_NO_GUI | ||
| 61 | # define BOOTMAGIC_KEY_NO_GUI KC_LGUI | ||
| 62 | #endif | ||
| 63 | #ifndef BOOTMAGIC_KEY_SWAP_GRAVE_ESC | ||
| 64 | # define BOOTMAGIC_KEY_SWAP_GRAVE_ESC KC_GRAVE | ||
| 65 | #endif | ||
| 66 | #ifndef BOOTMAGIC_KEY_SWAP_BACKSLASH_BACKSPACE | ||
| 67 | # define BOOTMAGIC_KEY_SWAP_BACKSLASH_BACKSPACE KC_BSLASH | ||
| 68 | #endif | ||
| 69 | #ifndef BOOTMAGIC_HOST_NKRO | ||
| 70 | # define BOOTMAGIC_HOST_NKRO KC_N | ||
| 71 | #endif | ||
| 72 | |||
| 73 | /* | ||
| 74 | * change default layer | ||
| 75 | */ | ||
| 76 | #ifndef BOOTMAGIC_KEY_DEFAULT_LAYER_0 | ||
| 77 | # define BOOTMAGIC_KEY_DEFAULT_LAYER_0 KC_0 | ||
| 78 | #endif | ||
| 79 | #ifndef BOOTMAGIC_KEY_DEFAULT_LAYER_1 | ||
| 80 | # define BOOTMAGIC_KEY_DEFAULT_LAYER_1 KC_1 | ||
| 81 | #endif | ||
| 82 | #ifndef BOOTMAGIC_KEY_DEFAULT_LAYER_2 | ||
| 83 | # define BOOTMAGIC_KEY_DEFAULT_LAYER_2 KC_2 | ||
| 84 | #endif | ||
| 85 | #ifndef BOOTMAGIC_KEY_DEFAULT_LAYER_3 | ||
| 86 | # define BOOTMAGIC_KEY_DEFAULT_LAYER_3 KC_3 | ||
| 87 | #endif | ||
| 88 | #ifndef BOOTMAGIC_KEY_DEFAULT_LAYER_4 | ||
| 89 | # define BOOTMAGIC_KEY_DEFAULT_LAYER_4 KC_4 | ||
| 90 | #endif | ||
| 91 | #ifndef BOOTMAGIC_KEY_DEFAULT_LAYER_5 | ||
| 92 | # define BOOTMAGIC_KEY_DEFAULT_LAYER_5 KC_5 | ||
| 93 | #endif | ||
| 94 | #ifndef BOOTMAGIC_KEY_DEFAULT_LAYER_6 | ||
| 95 | # define BOOTMAGIC_KEY_DEFAULT_LAYER_6 KC_6 | ||
| 96 | #endif | ||
| 97 | #ifndef BOOTMAGIC_KEY_DEFAULT_LAYER_7 | ||
| 98 | # define BOOTMAGIC_KEY_DEFAULT_LAYER_7 KC_7 | ||
| 99 | #endif | ||
| 100 | |||
| 101 | void bootmagic(void); | ||
| 102 | bool bootmagic_scan_keycode(uint8_t keycode); | ||
diff --git a/tmk_core/common/bootmagic_lite.c b/tmk_core/common/bootmagic_lite.c deleted file mode 100644 index cbf756a17..000000000 --- a/tmk_core/common/bootmagic_lite.c +++ /dev/null | |||
| @@ -1,49 +0,0 @@ | |||
| 1 | #include "quantum.h" | ||
| 2 | |||
| 3 | /** \brief Reset eeprom | ||
| 4 | * | ||
| 5 | * ...just incase someone wants to only change the eeprom behaviour | ||
| 6 | */ | ||
| 7 | __attribute__((weak)) void bootmagic_lite_reset_eeprom(void) { | ||
| 8 | #if defined(VIA_ENABLE) | ||
| 9 | via_eeprom_reset(); | ||
| 10 | #else | ||
| 11 | eeconfig_disable(); | ||
| 12 | #endif | ||
| 13 | } | ||
| 14 | |||
| 15 | /** \brief The lite version of TMK's bootmagic based on Wilba. | ||
| 16 | * | ||
| 17 | * 100% less potential for accidentally making the keyboard do stupid things. | ||
| 18 | */ | ||
| 19 | __attribute__((weak)) void bootmagic_lite(void) { | ||
| 20 | // We need multiple scans because debouncing can't be turned off. | ||
| 21 | matrix_scan(); | ||
| 22 | #if defined(DEBOUNCE) && DEBOUNCE > 0 | ||
| 23 | wait_ms(DEBOUNCE * 2); | ||
| 24 | #else | ||
| 25 | wait_ms(30); | ||
| 26 | #endif | ||
| 27 | matrix_scan(); | ||
| 28 | |||
| 29 | // If the configured key (commonly Esc) is held down on power up, | ||
| 30 | // reset the EEPROM valid state and jump to bootloader. | ||
| 31 | // This isn't very generalized, but we need something that doesn't | ||
| 32 | // rely on user's keymaps in firmware or EEPROM. | ||
| 33 | uint8_t row = BOOTMAGIC_LITE_ROW; | ||
| 34 | uint8_t col = BOOTMAGIC_LITE_COLUMN; | ||
| 35 | |||
| 36 | #if defined(SPLIT_KEYBOARD) && defined(BOOTMAGIC_LITE_ROW_RIGHT) && defined(BOOTMAGIC_LITE_COLUMN_RIGHT) | ||
| 37 | if (!is_keyboard_left()) { | ||
| 38 | row = BOOTMAGIC_LITE_ROW_RIGHT; | ||
| 39 | col = BOOTMAGIC_LITE_COLUMN_RIGHT; | ||
| 40 | } | ||
| 41 | #endif | ||
| 42 | |||
| 43 | if (matrix_get_row(row) & (1 << col)) { | ||
| 44 | bootmagic_lite_reset_eeprom(); | ||
| 45 | |||
| 46 | // Jump to bootloader. | ||
| 47 | bootloader_jump(); | ||
| 48 | } | ||
| 49 | } | ||
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); | ||
