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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

keymap_in_eeprom.h 2.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. Copyright 2013,2014 Kai Ryu <[email protected]>
  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 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #ifndef KEYMAP_IN_EEPROM_H
  15. #define KEYMAP_IN_EEPROM_H
  16. #ifdef KEYMAP_IN_EEPROM_ENABLE
  17. #include <stdint.h>
  18. #include <stdbool.h>
  19. #ifndef EECONFIG_KEYMAP_IN_EEPROM
  20. #define EECONFIG_KEYMAP_IN_EEPROM 0x10
  21. #endif
  22. #ifndef FN_ACTIONS_COUNT
  23. #define FN_ACTIONS_COUNT 32
  24. #endif
  25. #ifndef KEYMAPS_COUNT
  26. #define KEYMAPS_COUNT 1
  27. #endif
  28. #ifndef MATRIX_SIZE
  29. #define MATRIX_SIZE (matrix_rows() * matrix_cols())
  30. #endif
  31. #define KEYS_COUNT (KEYMAPS_COUNT * MATRIX_SIZE)
  32. typedef struct {
  33. uint16_t checksum;
  34. uint16_t fn_actions[FN_ACTIONS_COUNT];
  35. uint8_t keymaps[KEYMAPS_COUNT][MATRIX_ROWS][MATRIX_COLS];
  36. } keymap_in_eeprom_t;
  37. #define EECONFIG_KEYMAP_CHECKSUM (uint16_t *)(EECONFIG_KEYMAP_IN_EEPROM)
  38. #define EECONFIG_KEYMAP_FN_ACTIONS (uint16_t *)(EECONFIG_KEYMAP_CHECKSUM + 1)
  39. #define EECONFIG_KEYMAP_KEYMAPS (uint8_t *)(EECONFIG_KEYMAP_FN_ACTIONS + FN_ACTIONS_COUNT)
  40. #define EECONFIG_KEYMAP_DEBUG (uint16_t *)(EECONFIG_KEYMAP_CHECKSUM - 1)
  41. #define KEYMAP_SIZE (sizeof(uint16_t) * FN_ACTIONS_COUNT + sizeof(uint8_t) * KEYS_COUNT)
  42. #define KEYMAP_WORD_SIZE ((KEYMAP_SIZE + 1) / 2)
  43. #define KEY_OFFSET(layer, row, col) (layer * matrix_rows() * matrix_cols() + row * matrix_cols() + col)
  44. void keymap_in_eeprom_init(void);
  45. void keymap_in_eeprom_disable(void);
  46. bool check_keymap_in_eeprom(void);
  47. void write_keymap_to_eeprom(void);
  48. uint8_t eeconfig_read_keymap_key(uint8_t layer, uint8_t row, uint8_t col);
  49. void eeconfig_write_keymap_key(uint8_t layer, uint8_t row, uint8_t col, uint8_t key);
  50. uint8_t eeconfig_read_keymap_key_by_index(uint16_t index);
  51. void eeconfig_write_keymap_key_by_index(uint16_t index, uint8_t key);
  52. uint16_t eeconfig_read_keymap_fn_action(uint8_t index);
  53. void eeconfig_write_keymap_fn_action(uint8_t index, uint16_t fn_action);
  54. const uint8_t* keymaps_pointer(void);
  55. const uint16_t* fn_actions_pointer(void);
  56. uint16_t keys_count(void);
  57. uint16_t fn_actions_count(void);
  58. #endif
  59. #endif