aboutsummaryrefslogtreecommitdiffstats
path: root/quantum/dynamic_keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/dynamic_keymap.c')
-rw-r--r--quantum/dynamic_keymap.c55
1 files changed, 31 insertions, 24 deletions
diff --git a/quantum/dynamic_keymap.c b/quantum/dynamic_keymap.c
index ca056f630..11d28592d 100644
--- a/quantum/dynamic_keymap.c
+++ b/quantum/dynamic_keymap.c
@@ -20,28 +20,37 @@
#include "progmem.h" // to read default from flash
#include "quantum.h" // for send_string()
#include "dynamic_keymap.h"
-
-#ifdef DYNAMIC_KEYMAP_ENABLE
-
-# ifndef DYNAMIC_KEYMAP_EEPROM_ADDR
-# error DYNAMIC_KEYMAP_EEPROM_ADDR not defined
-# endif
-
-# ifndef DYNAMIC_KEYMAP_LAYER_COUNT
-# error DYNAMIC_KEYMAP_LAYER_COUNT not defined
-# endif
-
-# ifndef DYNAMIC_KEYMAP_MACRO_COUNT
-# error DYNAMIC_KEYMAP_MACRO_COUNT not defined
-# endif
-
-# ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR
-# error DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR not defined
-# endif
-
-# ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE
-# error DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE not defined
-# endif
+#include "via.h" // for default VIA_EEPROM_ADDR_END
+
+#ifndef DYNAMIC_KEYMAP_LAYER_COUNT
+# define DYNAMIC_KEYMAP_LAYER_COUNT 4
+#endif
+
+#ifndef DYNAMIC_KEYMAP_MACRO_COUNT
+# define DYNAMIC_KEYMAP_MACRO_COUNT 16
+#endif
+
+// If DYNAMIC_KEYMAP_EEPROM_ADDR not explicitly defined in config.h,
+// default it start after VIA_EEPROM_CUSTOM_ADDR+VIA_EEPROM_CUSTOM_SIZE
+#ifndef DYNAMIC_KEYMAP_EEPROM_ADDR
+# ifdef VIA_EEPROM_CUSTOM_CONFIG_ADDR
+# define DYNAMIC_KEYMAP_EEPROM_ADDR (VIA_EEPROM_CUSTOM_CONFIG_ADDR+VIA_EEPROM_CUSTOM_CONFIG_SIZE)
+# else
+# error DYNAMIC_KEYMAP_EEPROM_ADDR not defined
+# endif
+#endif
+
+// Dynamic macro starts after dynamic keymaps
+#ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR
+# define DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR (DYNAMIC_KEYMAP_EEPROM_ADDR+(DYNAMIC_KEYMAP_LAYER_COUNT*MATRIX_ROWS*MATRIX_COLS*2))
+#endif
+
+// Dynamic macro uses up all remaining memory
+// Assumes 1K EEPROM on ATMega32U4
+// Override for anything different
+#ifndef DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE
+# define DYNAMIC_KEYMAP_MACRO_EEPROM_SIZE (1024-DYNAMIC_KEYMAP_MACRO_EEPROM_ADDR)
+#endif
uint8_t dynamic_keymap_get_layer_count(void) { return DYNAMIC_KEYMAP_LAYER_COUNT; }
@@ -208,5 +217,3 @@ void dynamic_keymap_macro_send(uint8_t id) {
send_string(data);
}
}
-
-#endif // DYNAMIC_KEYMAP_ENABLE