1
0
This repo is archived. You can view files and clone it, but cannot push or open issues or pull requests.
tmk_keyboard_custom/common/keymap_in_eeprom.h

74 lines
2.5 KiB
C
Raw Normal View History

/*
Copyright 2013,2014 Kai Ryu <kai1103@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KEYMAP_IN_EEPROM_H
#define KEYMAP_IN_EEPROM_H
#ifdef KEYMAP_IN_EEPROM_ENABLE
#include <stdint.h>
#include <stdbool.h>
2014-05-26 03:48:10 +00:00
#ifndef EECONFIG_KEYMAP_IN_EEPROM
#define EECONFIG_KEYMAP_IN_EEPROM 0x10
2014-05-26 03:48:10 +00:00
#endif
#ifndef FN_ACTIONS_COUNT
#define FN_ACTIONS_COUNT 32
#endif
#ifndef KEYMAPS_COUNT
#define KEYMAPS_COUNT 1
#endif
2014-05-26 08:31:01 +00:00
#ifndef MATRIX_SIZE
#define MATRIX_SIZE (matrix_rows() * matrix_cols())
#endif
#define KEYS_COUNT (KEYMAPS_COUNT * MATRIX_SIZE)
typedef struct {
uint16_t checksum;
uint16_t fn_actions[FN_ACTIONS_COUNT];
uint8_t keymaps[KEYMAPS_COUNT][MATRIX_ROWS][MATRIX_COLS];
} keymap_in_eeprom_t;
#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)
2014-04-10 06:55:11 +00:00
#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)
2014-05-26 03:48:10 +00:00
#define KEY_OFFSET(layer, row, col) (layer * matrix_rows() * matrix_cols() + row * matrix_cols() + col)
void keymap_in_eeprom_init(void);
void keymap_in_eeprom_disable(void);
bool check_keymap_in_eeprom(void);
void write_keymap_to_eeprom(void);
uint8_t eeconfig_read_keymap_key(uint8_t layer, uint8_t row, uint8_t col);
void eeconfig_write_keymap_key(uint8_t layer, uint8_t row, uint8_t col, uint8_t key);
uint8_t eeconfig_read_keymap_key_by_index(uint16_t index);
void eeconfig_write_keymap_key_by_index(uint16_t index, uint8_t key);
uint16_t eeconfig_read_keymap_fn_action(uint8_t index);
void eeconfig_write_keymap_fn_action(uint8_t index, uint16_t fn_action);
const uint8_t* keymaps_pointer(void);
const uint16_t* fn_actions_pointer(void);
uint16_t keys_count(void);
uint16_t fn_actions_count(void);
#endif
#endif