diff --git a/doc/build.md b/doc/build.md index bfe5de9f..c7522e4d 100644 --- a/doc/build.md +++ b/doc/build.md @@ -133,6 +133,7 @@ Optional. Note that ***comment out*** to disable them. SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend #NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA #BACKLIGHT_ENABLE = yes # Enable keyboard backlight functionality + #KEYMAP_IN_EEPROM_ENABLE = yes # Read keymap from eeprom ### 3. Programmer Optional. Set proper command for your controller, bootloader and programmer. This command can be used with `make program`. Not needed if you use `FLIP`, `dfu-programmer` or `Teensy Loader`. diff --git a/keyboard/gh60/Makefile b/keyboard/gh60/Makefile index fd202c17..8a821e31 100644 --- a/keyboard/gh60/Makefile +++ b/keyboard/gh60/Makefile @@ -118,9 +118,10 @@ BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) MOUSEKEY_ENABLE = yes # Mouse keys(+4700) EXTRAKEY_ENABLE = yes # Audio control and System control(+450) CONSOLE_ENABLE = yes # Console for debug(+400) -COMMAND_ENABLE = yes # Commands for debug and configuration -#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend -NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA +COMMAND_ENABLE = yes # Commands for debug and configuration +#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend +NKRO_ENABLE = yes # USB Nkey Rollover +KEYMAP_IN_EEPROM_ENABLE = yes # Read keymap from eeprom # Optimize size but this may cause error "relocation truncated to fit" diff --git a/keyboard/gh60/Makefile.pjrc b/keyboard/gh60/Makefile.pjrc index 9655ff65..723d4411 100644 --- a/keyboard/gh60/Makefile.pjrc +++ b/keyboard/gh60/Makefile.pjrc @@ -88,11 +88,12 @@ OPT_DEFS += -DBOOTLOADER_SIZE=4096 BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000) MOUSEKEY_ENABLE = yes # Mouse keys(+5000) EXTRAKEY_ENABLE = yes # Audio control and System control(+600) -CONSOLE_ENABLE = yes # Console for debug -COMMAND_ENABLE = yes # Commands for debug and configuration -SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend +CONSOLE_ENABLE = yes # Console for debug +COMMAND_ENABLE = yes # Commands for debug and configuration +#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend NKRO_ENABLE = yes # USB Nkey Rollover(+500) #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support +KEYMAP_IN_EEPROM_ENABLE = yes # Read keymap from eeprom # Search Path @@ -102,15 +103,3 @@ VPATH += $(TOP_DIR) include $(TOP_DIR)/protocol/pjrc.mk include $(TOP_DIR)/common.mk include $(TOP_DIR)/rules.mk - -plain: OPT_DEFS += -DKEYMAP_PLAIN -plain: all - -poker: OPT_DEFS += -DKEYMAP_POKER -poker: all - -poker_set: OPT_DEFS += -DKEYMAP_POKER_SET -poker_set: all - -poker_bit: OPT_DEFS += -DKEYMAP_POKER_BIT -poker_bit: all diff --git a/keyboard/gh60/config.h b/keyboard/gh60/config.h index e9c0f436..4f7ad422 100644 --- a/keyboard/gh60/config.h +++ b/keyboard/gh60/config.h @@ -31,6 +31,10 @@ along with this program. If not, see . #define MATRIX_ROWS 5 #define MATRIX_COLS 14 +/* keymap in eeprom */ +#define FN_ACTIONS_COUNT 32 +#define KEYMAPS_COUNT 8 + /* define if matrix has ghost */ //#define MATRIX_HAS_GHOST diff --git a/keyboard/gh60/keymap_common.c b/keyboard/gh60/keymap_common.c index 7b6379f6..53087379 100644 --- a/keyboard/gh60/keymap_common.c +++ b/keyboard/gh60/keymap_common.c @@ -20,11 +20,31 @@ along with this program. If not, see . /* translates key to keycode */ uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) { +#ifndef KEYMAP_IN_EEPROM_ENABLE return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]); +#else + return eeconfig_read_keymap_key(layer, key.row, key.col); +#endif } /* translates Fn keycode to action */ action_t keymap_fn_to_action(uint8_t keycode) { - return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) }; + return (action_t) { +#ifndef KEYMAP_IN_EEPROM_ENABLE + .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) +#else + .code = eeconfig_read_keymap_fn_action(FN_INDEX(keycode)) +#endif + }; } + +#ifdef KEYMAP_IN_EEPROM_ENABLE +const uint8_t* keymaps_pointer(void) { + return (const uint8_t*)keymaps; +} + +const uint16_t* fn_actions_pointer(void) { + return fn_actions; +} +#endif diff --git a/keyboard/gh60/keymap_common.h b/keyboard/gh60/keymap_common.h index 896badd7..8e4bc3bf 100644 --- a/keyboard/gh60/keymap_common.h +++ b/keyboard/gh60/keymap_common.h @@ -28,6 +28,7 @@ along with this program. If not, see . #include "print.h" #include "debug.h" #include "keymap.h" +#include "keymap_in_eeprom.h" extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; diff --git a/keyboard/gh60/keymap_poker.c b/keyboard/gh60/keymap_poker.c index 7a612ee4..f0d0f963 100644 --- a/keyboard/gh60/keymap_poker.c +++ b/keyboard/gh60/keymap_poker.c @@ -102,3 +102,13 @@ const uint16_t PROGMEM fn_actions[] = { [7] = ACTION_DEFAULT_LAYER_SET(2), // set dvorak layout [8] = ACTION_DEFAULT_LAYER_SET(3), // set workman layout }; + +#ifdef KEYMAP_IN_EEPROM_ENABLE +uint16_t keys_count(void) { + return sizeof(keymaps) / sizeof(keymaps[0]) * MATRIX_ROWS * MATRIX_COLS; +} + +uint16_t fn_actions_count(void) { + return sizeof(fn_actions) / sizeof(fn_actions[0]); +} +#endif