Extend reset eeconfig of bootmagic to reset keymap too
This commit is contained in:
parent
ef8d032029
commit
8b75dd43ba
@ -30,6 +30,7 @@ void bootmagic(void)
|
|||||||
|
|
||||||
/* eeconfig clear */
|
/* eeconfig clear */
|
||||||
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EEPROM_CLEAR)) {
|
if (bootmagic_scan_keycode(BOOTMAGIC_KEY_EEPROM_CLEAR)) {
|
||||||
|
eeconfig_disable();
|
||||||
eeconfig_init();
|
eeconfig_init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <avr/eeprom.h>
|
#include <avr/eeprom.h>
|
||||||
#include "eeconfig.h"
|
#include "eeconfig.h"
|
||||||
|
#include "keymap_ex.h"
|
||||||
|
|
||||||
void eeconfig_init(void)
|
void eeconfig_init(void)
|
||||||
{
|
{
|
||||||
@ -13,6 +14,9 @@ void eeconfig_init(void)
|
|||||||
#ifdef BACKLIGHT_ENABLE
|
#ifdef BACKLIGHT_ENABLE
|
||||||
eeprom_write_byte(EECONFIG_BACKLIGHT, 0);
|
eeprom_write_byte(EECONFIG_BACKLIGHT, 0);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef KEYMAP_EX_ENABLE
|
||||||
|
keymap_ex_init();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void eeconfig_enable(void)
|
void eeconfig_enable(void)
|
||||||
@ -22,6 +26,9 @@ void eeconfig_enable(void)
|
|||||||
|
|
||||||
void eeconfig_disable(void)
|
void eeconfig_disable(void)
|
||||||
{
|
{
|
||||||
|
#ifdef KEYMAP_EX_ENABLE
|
||||||
|
keymap_ex_disable();
|
||||||
|
#endif
|
||||||
eeprom_write_word(EECONFIG_MAGIC, 0xFFFF);
|
eeprom_write_word(EECONFIG_MAGIC, 0xFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,12 +23,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
#ifdef KEYMAP_EX_ENABLE
|
#ifdef KEYMAP_EX_ENABLE
|
||||||
|
|
||||||
void keymap_init(void) {
|
void keymap_ex_init(void) {
|
||||||
if (!check_keymap_in_eeprom()) {
|
if (!check_keymap_in_eeprom()) {
|
||||||
write_keymap_to_eeprom();
|
write_keymap_to_eeprom();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void keymap_ex_disable(void) {
|
||||||
|
eeprom_write_word((void*)EECONFIG_KEYMAP_CHECKSUM, eeprom_read_word((void*)EECONFIG_KEYMAP_CHECKSUM) + 1);
|
||||||
|
}
|
||||||
|
|
||||||
bool check_keymap_in_eeprom(void) {
|
bool check_keymap_in_eeprom(void) {
|
||||||
uint16_t checksum_in_eeprom = eeprom_read_word(&((keymap_ex_t*)EECONFIG_KEYMAP_EX)->checksum);
|
uint16_t checksum_in_eeprom = eeprom_read_word(&((keymap_ex_t*)EECONFIG_KEYMAP_EX)->checksum);
|
||||||
uint16_t checksum = EECONFIG_MAGIC_NUMBER;
|
uint16_t checksum = EECONFIG_MAGIC_NUMBER;
|
||||||
|
@ -47,7 +47,8 @@ typedef struct {
|
|||||||
#define FN_ACTION_OFFSET(index) (sizeof(uint16_t) * index)
|
#define FN_ACTION_OFFSET(index) (sizeof(uint16_t) * index)
|
||||||
#define KEY_OFFSET(layer, row, col) (sizeof(uint8_t) * (layer * MATRIX_ROWS * MATRIX_COLS + row * MATRIX_COLS + col))
|
#define KEY_OFFSET(layer, row, col) (sizeof(uint8_t) * (layer * MATRIX_ROWS * MATRIX_COLS + row * MATRIX_COLS + col))
|
||||||
|
|
||||||
void keymap_init(void);
|
void keymap_ex_init(void);
|
||||||
|
void keymap_ex_disable(void);
|
||||||
bool check_keymap_in_eeprom(void);
|
bool check_keymap_in_eeprom(void);
|
||||||
void write_keymap_to_eeprom(void);
|
void write_keymap_to_eeprom(void);
|
||||||
uint8_t eeconfig_read_keymap_key(uint8_t layer, uint8_t row, uint8_t col);
|
uint8_t eeconfig_read_keymap_key(uint8_t layer, uint8_t row, uint8_t col);
|
||||||
|
Reference in New Issue
Block a user