diff --git a/keyboard/gh60/Makefile b/keyboard/gh60/Makefile index 70768548..f158fe6d 100644 --- a/keyboard/gh60/Makefile +++ b/keyboard/gh60/Makefile @@ -59,6 +59,7 @@ else SRC := keymap_poker.c $(SRC) endif + CONFIG_H = config.h @@ -111,6 +112,12 @@ OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT # USBaspLoader 2048 OPT_DEFS += -DBOOTLOADER_SIZE=4096 +# PCB Revision +ifdef REV + OPT_DEFS += -DGH60_REV_$(REV) +endif + +OPT_DEFS += -DBACKLIGHT_CUSTOM # Build Options # comment out to disable the options. diff --git a/keyboard/gh60/backlight.c b/keyboard/gh60/backlight.c index 9a248b52..2cf129c3 100644 --- a/keyboard/gh60/backlight.c +++ b/keyboard/gh60/backlight.c @@ -20,7 +20,7 @@ along with this program. If not, see . #include #include "backlight.h" -#ifdef GH60_REV_C +#ifdef GH60_REV_CHN static const uint8_t backlight_table[] PROGMEM = { 0, 16, 128, 255 }; @@ -51,4 +51,6 @@ void backlight_set(uint8_t level) OCR1B = 0; } } +#else +void backlight_set(uint8_t level) {} #endif diff --git a/keyboard/gh60/keymap_common.c b/keyboard/gh60/keymap_common.c index 7b6379f6..ae934eea 100644 --- a/keyboard/gh60/keymap_common.c +++ b/keyboard/gh60/keymap_common.c @@ -16,15 +16,34 @@ along with this program. If not, see . */ #include "keymap_common.h" - /* translates key to keycode */ uint8_t keymap_key_to_keycode(uint8_t layer, key_t key) { +#ifndef KEYMAP_EX_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_EX_ENABLE + .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) +#else + .code = eeconfig_read_keymap_fn_action(FN_INDEX(keycode)) +#endif + }; } + +#ifdef KEYMAP_EX_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..e94f013c 100644 --- a/keyboard/gh60/keymap_common.h +++ b/keyboard/gh60/keymap_common.h @@ -28,10 +28,18 @@ along with this program. If not, see . #include "print.h" #include "debug.h" #include "keymap.h" +#include "keymap_ex.h" +/* +#ifdef KEYMAP_EX_ENABLE +extern const uint8_t keymaps[KEYMAPS_COUNT][MATRIX_ROWS][MATRIX_COLS]; +extern const uint16_t fn_actions[FN_ACTIONS_COUNT]; +#else +*/ extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; extern const uint16_t fn_actions[]; +//#endif /* GH60 keymap definition macro diff --git a/keyboard/gh60/keymap_poker.c b/keyboard/gh60/keymap_poker.c index 7a612ee4..f2035b43 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_EX_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 diff --git a/keyboard/gh60/keymap_poker2.h b/keyboard/gh60/keymap_poker2.c similarity index 82% rename from keyboard/gh60/keymap_poker2.h rename to keyboard/gh60/keymap_poker2.c index 0eae7364..cfcadccf 100644 --- a/keyboard/gh60/keymap_poker2.h +++ b/keyboard/gh60/keymap_poker2.c @@ -1,8 +1,10 @@ +#include "keymap_common.h" + // Poker2 #ifdef KEYMAP_SECTION_ENABLE -const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = { +const uint8_t keymaps[KEYMAPS_COUNT][MATRIX_ROWS][MATRIX_COLS] __attribute__ ((section (".keymap.keymaps"))) = { #else -static const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { +const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { #endif /* Keymap 0: Default Layer * ,-----------------------------------------------------------. @@ -48,9 +50,9 @@ static const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS] PROGMEM = { * Fn action definition */ #ifdef KEYMAP_SECTION_ENABLE -const uint16_t fn_actions[] __attribute__ ((section (".keymap.fn_actions"))) = { +const uint16_t fn_actions[FN_ACTIONS_COUNT] __attribute__ ((section (".keymap.fn_actions"))) = { #else -static const uint16_t fn_actions[] PROGMEM = { +const uint16_t fn_actions[] PROGMEM = { #endif /* Poker2 Layout */ [0] = ACTION_LAYER_MOMENTARY(1), @@ -58,3 +60,13 @@ static const uint16_t fn_actions[] PROGMEM = { [2] = ACTION_BACKLIGHT_TOGGLE(), [3] = ACTION_BACKLIGHT_INCREASE() }; + +#ifdef KEYMAP_EX_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