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.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #define EECONFIG_KEYMAP_IN_EEPROM 0x10
  20. #ifndef FN_ACTIONS_COUNT
  21. #define FN_ACTIONS_COUNT 32
  22. #endif
  23. #ifndef KEYMAPS_COUNT
  24. #define KEYMAPS_COUNT 1
  25. #endif
  26. #define KEYS_COUNT (KEYMAPS_COUNT * MATRIX_ROWS * MATRIX_COLS)
  27. typedef struct {
  28. uint16_t checksum;
  29. uint16_t fn_actions[FN_ACTIONS_COUNT];
  30. uint8_t keymaps[KEYMAPS_COUNT][MATRIX_ROWS][MATRIX_COLS];
  31. } keymap_in_eeprom_t;
  32. #define EECONFIG_KEYMAP_CHECKSUM (uint16_t *)(EECONFIG_KEYMAP_IN_EEPROM)
  33. #define EECONFIG_KEYMAP_FN_ACTIONS (uint16_t *)(EECONFIG_KEYMAP_CHECKSUM + 1)
  34. #define EECONFIG_KEYMAP_KEYMAPS (uint8_t *)(EECONFIG_KEYMAP_FN_ACTIONS + FN_ACTIONS_COUNT)
  35. #define EECONFIG_KEYMAP_DEBUG (uint16_t *)(EECONFIG_KEYMAP_CHECKSUM - 1)
  36. #define KEYMAP_SIZE (sizeof(uint16_t) * FN_ACTIONS_COUNT + sizeof(uint8_t) * KEYS_COUNT)
  37. #define KEYMAP_WORD_SIZE ((KEYMAP_SIZE + 1) / 2)
  38. #define KEY_OFFSET(layer, row, col) (layer * MATRIX_ROWS * MATRIX_COLS + row * MATRIX_COLS + col)
  39. void keymap_in_eeprom_init(void);
  40. void keymap_in_eeprom_disable(void);
  41. bool check_keymap_in_eeprom(void);
  42. void write_keymap_to_eeprom(void);
  43. uint8_t eeconfig_read_keymap_key(uint8_t layer, uint8_t row, uint8_t col);
  44. void eeconfig_write_keymap_key(uint8_t layer, uint8_t row, uint8_t col, uint8_t key);
  45. uint8_t eeconfig_read_keymap_key_by_index(uint16_t index);
  46. void eeconfig_write_keymap_key_by_index(uint16_t index, uint8_t key);
  47. uint16_t eeconfig_read_keymap_fn_action(uint8_t index);
  48. void eeconfig_write_keymap_fn_action(uint8_t index, uint16_t fn_action);
  49. const uint8_t* keymaps_pointer(void);
  50. const uint16_t* fn_actions_pointer(void);
  51. uint16_t keys_count(void);
  52. uint16_t fn_actions_count(void);
  53. #endif
  54. #endif