Support for odd-byte keymap
This commit is contained in:
parent
6aeb9cac41
commit
237bd9e5fe
@ -36,8 +36,10 @@ void keymap_in_eeprom_disable(void) {
|
||||
bool check_keymap_in_eeprom(void) {
|
||||
uint16_t checksum_in_eeprom = eeprom_read_word(EECONFIG_KEYMAP_CHECKSUM);
|
||||
uint16_t checksum = EECONFIG_MAGIC_NUMBER;
|
||||
for (uint16_t i = 0; i < KEYMAP_WORD_SIZE; i++) {
|
||||
checksum += eeprom_read_word(EECONFIG_KEYMAP_FN_ACTIONS + i);
|
||||
for (uint16_t i = 0; i < KEYMAP_SIZE; i++) {
|
||||
uint8_t byte = eeprom_read_byte((uint8_t *)EECONFIG_KEYMAP_FN_ACTIONS + i);
|
||||
uint16_t word = (i & 1) ? byte << 8 : byte;
|
||||
checksum += word;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
eeprom_write_word(EECONFIG_KEYMAP_DEBUG, checksum);
|
||||
|
@ -41,7 +41,7 @@ typedef struct {
|
||||
#define EECONFIG_KEYMAP_CHECKSUM (uint16_t *)(EECONFIG_KEYMAP_IN_EEPROM)
|
||||
#define EECONFIG_KEYMAP_FN_ACTIONS (uint16_t *)(EECONFIG_KEYMAP_CHECKSUM + 1)
|
||||
#define EECONFIG_KEYMAP_KEYMAPS (uint8_t *)(EECONFIG_KEYMAP_FN_ACTIONS + FN_ACTIONS_COUNT)
|
||||
#define EECONFIG_KEYMAP_DEBUG (uint16_t *)(EECONFIG_KEYMAP_KEYMAPS + KEYS_COUNT)
|
||||
#define EECONFIG_KEYMAP_DEBUG (uint16_t *)(EECONFIG_KEYMAP_CHECKSUM - 1)
|
||||
|
||||
#define KEYMAP_SIZE (sizeof(uint16_t) * FN_ACTIONS_COUNT + sizeof(uint8_t) * KEYS_COUNT)
|
||||
#define KEYMAP_WORD_SIZE ((KEYMAP_SIZE + 1) / 2)
|
||||
|
Reference in New Issue
Block a user