diff options
author | tmk <nobody@nowhere> | 2013-06-22 16:14:56 +0900 |
---|---|---|
committer | tmk <nobody@nowhere> | 2013-06-22 16:24:56 +0900 |
commit | 9de9d719527c7a8cac71d0bc49ba1d2d4f63cf06 (patch) | |
tree | 5cfd02ffd53d5be7c40453644558319f75b48fa8 /common | |
parent | 2593ae132812414f02e7cf483bb141cd2c78595c (diff) | |
download | qmk_firmware-9de9d719527c7a8cac71d0bc49ba1d2d4f63cf06.tar.gz |
Add default layer config to bootmagic
Diffstat (limited to 'common')
-rw-r--r-- | common/action_layer.c | 4 | ||||
-rw-r--r-- | common/action_layer.h | 2 | ||||
-rw-r--r-- | common/bootmagic.c | 18 | ||||
-rw-r--r-- | common/bootmagic.h | 4 | ||||
-rw-r--r-- | common/command.c | 4 | ||||
-rw-r--r-- | common/eeconfig.c | 4 | ||||
-rw-r--r-- | common/eeconfig.h | 4 |
7 files changed, 31 insertions, 9 deletions
diff --git a/common/action_layer.c b/common/action_layer.c index d24aa2e19..526e24d53 100644 --- a/common/action_layer.c +++ b/common/action_layer.c @@ -30,9 +30,9 @@ void default_layer_debug(void) dprintf("%08lX(%u)", default_layer_state, biton32(default_layer_state)); } -void default_layer_set(uint8_t layer) +void default_layer_set(uint32_t state) { - default_layer_state_set(1UL<<layer); + default_layer_state_set(state); } #ifndef NO_ACTION_LAYER diff --git a/common/action_layer.h b/common/action_layer.h index 23f8a00bb..034e00027 100644 --- a/common/action_layer.h +++ b/common/action_layer.h @@ -27,7 +27,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ extern uint32_t default_layer_state; void default_layer_debug(void); -void default_layer_set(uint8_t layer); +void default_layer_set(uint32_t state); #ifndef NO_ACTION_LAYER /* bitwise operation */ diff --git a/common/bootmagic.c b/common/bootmagic.c index 716f5d956..11eef3c3c 100644 --- a/common/bootmagic.c +++ b/common/bootmagic.c @@ -74,6 +74,24 @@ void bootmagic(void) keymap_config.swap_backslash_backspace = !keymap_config.swap_backslash_backspace; } eeconfig_write_keymap(keymap_config.raw); + + /* default layer */ + uint8_t default_layer = 0; + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_0)) { default_layer |= (1<<0); } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_1)) { default_layer |= (1<<1); } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_2)) { default_layer |= (1<<2); } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_3)) { default_layer |= (1<<3); } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_4)) { default_layer |= (1<<4); } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_5)) { default_layer |= (1<<5); } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_6)) { default_layer |= (1<<6); } + if (bootmagic_scan_keycode(BOOTMAGIC_KEY_DEFAULT_LAYER_7)) { default_layer |= (1<<7); } + if (default_layer) { + eeconfig_write_default_layer(default_layer); + default_layer_set((uint32_t)default_layer); + } else { + default_layer = eeconfig_read_default_layer(); + default_layer_set((uint32_t)default_layer); + } } bool bootmagic_scan_keycode(uint8_t keycode) diff --git a/common/bootmagic.h b/common/bootmagic.h index 2e7496ebc..68935e970 100644 --- a/common/bootmagic.h +++ b/common/bootmagic.h @@ -41,6 +41,10 @@ #define BOOTMAGIC_KEY_DEFAULT_LAYER_1 KC_1 #define BOOTMAGIC_KEY_DEFAULT_LAYER_2 KC_2 #define BOOTMAGIC_KEY_DEFAULT_LAYER_3 KC_3 +#define BOOTMAGIC_KEY_DEFAULT_LAYER_4 KC_4 +#define BOOTMAGIC_KEY_DEFAULT_LAYER_5 KC_5 +#define BOOTMAGIC_KEY_DEFAULT_LAYER_6 KC_6 +#define BOOTMAGIC_KEY_DEFAULT_LAYER_7 KC_7 void bootmagic(void); diff --git a/common/command.c b/common/command.c index 74b7c5ebc..73a72b4a1 100644 --- a/common/command.c +++ b/common/command.c @@ -129,7 +129,7 @@ static void command_common_help(void) #ifdef BOOTMAGIC_ENABLE static void print_eeconfig(void) { - print("default_layer: "); print_dec(eeconfig_read_defalt_layer()); print("\n"); + print("default_layer: "); print_dec(eeconfig_read_default_layer()); print("\n"); debug_config_t dc; dc.raw = eeconfig_read_debug(); @@ -579,6 +579,6 @@ static void switch_default_layer(uint8_t layer) { print("switch_default_layer: "); print_dec(biton32(default_layer_state)); print(" to "); print_dec(layer); print("\n"); - default_layer_set(layer); + default_layer_set(1UL<<layer); clear_keyboard(); } diff --git a/common/eeconfig.c b/common/eeconfig.c index 0481d4b9c..a833f4db9 100644 --- a/common/eeconfig.c +++ b/common/eeconfig.c @@ -30,8 +30,8 @@ bool eeconfig_is_enabled(void) uint8_t eeconfig_read_debug(void) { return eeprom_read_byte(EECONFIG_DEBUG); } void eeconfig_write_debug(uint8_t val) { eeprom_write_byte(EECONFIG_DEBUG, val); } -uint8_t eeconfig_read_defalt_layer(void) { return eeprom_read_byte(EECONFIG_DEFAULT_LAYER); } -void eeconfig_write_defalt_layer(uint8_t val) { eeprom_write_byte(EECONFIG_DEFAULT_LAYER, val); } +uint8_t eeconfig_read_default_layer(void) { return eeprom_read_byte(EECONFIG_DEFAULT_LAYER); } +void eeconfig_write_default_layer(uint8_t val) { eeprom_write_byte(EECONFIG_DEFAULT_LAYER, val); } uint8_t eeconfig_read_keymap(void) { return eeprom_read_byte(EECONFIG_KEYMAP); } void eeconfig_write_keymap(uint8_t val) { eeprom_write_byte(EECONFIG_KEYMAP, val); } diff --git a/common/eeconfig.h b/common/eeconfig.h index 526cee783..0b605fc7b 100644 --- a/common/eeconfig.h +++ b/common/eeconfig.h @@ -58,8 +58,8 @@ void eeconfig_disable(void); uint8_t eeconfig_read_debug(void); void eeconfig_write_debug(uint8_t val); -uint8_t eeconfig_read_defalt_layer(void); -void eeconfig_write_defalt_layer(uint8_t val); +uint8_t eeconfig_read_default_layer(void); +void eeconfig_write_default_layer(uint8_t val); uint8_t eeconfig_read_keymap(void); void eeconfig_write_keymap(uint8_t val); |