You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
2.0 KiB

  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 "quantum.h"
  17. /** \brief Reset eeprom
  18. *
  19. * ...just incase someone wants to only change the eeprom behaviour
  20. */
  21. __attribute__((weak)) void bootmagic_lite_reset_eeprom(void) { eeconfig_disable(); }
  22. /** \brief The lite version of TMK's bootmagic based on Wilba.
  23. *
  24. * 100% less potential for accidentally making the keyboard do stupid things.
  25. */
  26. __attribute__((weak)) void bootmagic_lite(void) {
  27. // We need multiple scans because debouncing can't be turned off.
  28. matrix_scan();
  29. #if defined(DEBOUNCE) && DEBOUNCE > 0
  30. wait_ms(DEBOUNCE * 2);
  31. #else
  32. wait_ms(30);
  33. #endif
  34. matrix_scan();
  35. // If the configured key (commonly Esc) is held down on power up,
  36. // reset the EEPROM valid state and jump to bootloader.
  37. // This isn't very generalized, but we need something that doesn't
  38. // rely on user's keymaps in firmware or EEPROM.
  39. uint8_t row = BOOTMAGIC_LITE_ROW;
  40. uint8_t col = BOOTMAGIC_LITE_COLUMN;
  41. #if defined(SPLIT_KEYBOARD) && defined(BOOTMAGIC_LITE_ROW_RIGHT) && defined(BOOTMAGIC_LITE_COLUMN_RIGHT)
  42. if (!is_keyboard_left()) {
  43. row = BOOTMAGIC_LITE_ROW_RIGHT;
  44. col = BOOTMAGIC_LITE_COLUMN_RIGHT;
  45. }
  46. #endif
  47. if (matrix_get_row(row) & (1 << col)) {
  48. bootmagic_lite_reset_eeprom();
  49. // Jump to bootloader.
  50. bootloader_jump();
  51. }
  52. }
  53. void bootmagic(void) { bootmagic_lite(); }