]> git.friedersdorff.com Git - max/tmk_keyboard.git/commitdiff
Add default layer config to bootmagic
authortmk <nobody@nowhere>
Sat, 22 Jun 2013 07:14:56 +0000 (16:14 +0900)
committertmk <nobody@nowhere>
Sat, 22 Jun 2013 07:24:56 +0000 (16:24 +0900)
README.md
common/action_layer.c
common/action_layer.h
common/bootmagic.c
common/bootmagic.h
common/command.c
common/eeconfig.c
common/eeconfig.h

index f3cfacb47d2dad1c4fa94f3ad9af1848a945bf5b..d4793e9bfb42f24f908adcaeee476fb84fccb832 100644 (file)
--- a/README.md
+++ b/README.md
@@ -149,6 +149,15 @@ Note that you must use keys of **Layer 0** as Magic keys. These settings are sto
 - Set Default Layer to 1(`1`)
 - Set Default Layer to 2(`2`)
 - Set Default Layer to 3(`3`)
+- Set Default Layer to 4(`4`)
+- Set Default Layer to 5(`5`)
+- Set Default Layer to 6(`6`)
+- Set Default Layer to 7(`7`)
+
+#### Caution
+Unintentional use of this feature will cause user confusion.
+
+TODO: Magic key combination to avoid unintentional press during plug in
 
 **TBD**
 
index d24aa2e19f3ae4097aa08332f8ca84b926ecb4e9..526e24d5397aedf6e5e9d1eb4204ee92ca5cad2d 100644 (file)
@@ -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
index 23f8a00bb7bd231e3b1b63d44f0b2d157e922452..034e00027b3ee07586edd30f6004ec48d88a3e5b 100644 (file)
@@ -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 */
index 716f5d956b6b9b2563446fd83f10a8c8e9d98203..11eef3c3c604d205fbbd737ce75fc6dd4cb61eb7 100644 (file)
@@ -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)
index 2e7496ebc5a7eae774d59cd4f8471411dbe381de..68935e9706c75a0ad5e401b88d3794ed606f222d 100644 (file)
 #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);
index 74b7c5ebcf50fad5e89fc0e5732396e8dc7cb3c1..73a72b4a1d84bfea9a04051c9b595918489ea81a 100644 (file)
@@ -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();
 }
index 0481d4b9c3231c98b9396143f47b3a47c02d25bc..a833f4db9c32b73a17851a0138275c2d31a24f51 100644 (file)
@@ -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); }
index 526cee78364b7b60e702b9229d094ef897a10426..0b605fc7bfdaae848044a638d43205e08c61437f 100644 (file)
@@ -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);