]> git.donarmstrong.com Git - tmk_firmware.git/commitdiff
Add KEYCONF to eeconfig.c
authortmk <nobody@nowhere>
Sun, 10 Mar 2013 10:22:54 +0000 (19:22 +0900)
committertmk <nobody@nowhere>
Sun, 10 Mar 2013 10:22:54 +0000 (19:22 +0900)
common/bootmagic.c
common/bootmagic.h
common/command.c
common/eeconfig.c
common/eeconfig.h

index 31b8ae5e6207a3bc0d0e9b97a6d8303ad2f44fe7..46fbc180a468a372b1b11614cb90240a094aca12 100644 (file)
@@ -27,6 +27,28 @@ void bootmagic(void)
     if (bootmagic_scan_keycode(BOOTMAGIC_EEPROM_CLEAR_KEY)) {
         eeconfig_init();
     }
+
+    if (bootmagic_scan_keycode(BOOTMAGIC_SWAP_CONTROL_CPASLOCK)) {
+        eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_SWAP_CONTROL_CAPSLOCK);
+    }
+    if (bootmagic_scan_keycode(BOOTMAGIC_CAPSLOCK_TO_CONTROL)) {
+        eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_CAPSLOCK_TO_CONTROL);
+    }
+    if (bootmagic_scan_keycode(BOOTMAGIC_SWAP_LALT_LGUI)) {
+        eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_SWAP_LALT_LGUI);
+    }
+    if (bootmagic_scan_keycode(BOOTMAGIC_SWAP_RALT_RGUI)) {
+        eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_SWAP_RALT_RGUI);
+    }
+    if (bootmagic_scan_keycode(BOOTMAGIC_NO_GUI)) {
+        eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_NO_GUI);
+    }
+    if (bootmagic_scan_keycode(BOOTMAGIC_SWAP_GRAVE_ESC)) {
+        eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_SWAP_GRAVE_ESC);
+    }
+    if (bootmagic_scan_keycode(BOOTMAGIC_SWAP_BACKSLASH_BACKSPACE)) {
+        eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_SWAP_BACKSLASH_BACKSPACE);
+    }
 }
 
 bool bootmagic_scan_keycode(uint8_t keycode)
index 7aa224def90c002767f25a9992f0489dbb1d3cf1..d32a5bef88b5221b9f3d93a2f2d6cbb49d312c5d 100644 (file)
@@ -6,7 +6,7 @@
 #define BOOTMAGIC_IS_ENABLE()           true
 #endif
 
-/* bootloader */
+/* kick up bootloader */
 #ifndef BOOTMAGIC_BOOTLOADER_KEY
 #define BOOTMAGIC_BOOTLOADER_KEY        KC_B
 #endif
 #define BOOTMAGIC_EEPROM_CLEAR_KEY      KC_BSPACE
 #endif
 
-/* change default layer */
+/*
+ * key configure
+ */
+/* swap control and capslock */
+#ifndef BOOTMAGIC_SWAP_CONTROL_CPASLOCK
+#define BOOTMAGIC_SWAP_CONTROL_CPASLOCK     KC_LCTRL
+#endif
+/* capslock to control */
+#ifndef BOOTMAGIC_CAPSLOCK_TO_CONTROL
+#define BOOTMAGIC_CAPSLOCK_TO_CONTROL       KC_CAPSLOCK
+#endif
+/* swap alt and gui */
+#ifndef BOOTMAGIC_SWAP_LALT_LGUI
+#define BOOTMAGIC_SWAP_LALT_LGUI            KC_LALT
+#endif
+/* swap alt and gui */
+#ifndef BOOTMAGIC_SWAP_RALT_RGUI
+#define BOOTMAGIC_SWAP_RALT_RGUI            KC_RALT
+#endif
+/* no gui */
+#ifndef BOOTMAGIC_NO_GUI
+#define BOOTMAGIC_NO_GUI                    KC_LGUI
+#endif
+/* swap esc and grave */
+#ifndef BOOTMAGIC_SWAP_GRAVE_ESC
+#define BOOTMAGIC_SWAP_GRAVE_ESC            KC_GRAVE
+#endif
+/* swap backslash and backspace */
+#ifndef BOOTMAGIC_SWAP_BACKSLASH_BACKSPACE
+#define BOOTMAGIC_SWAP_BACKSLASH_BACKSPACE  KC_BSLASH
+#endif
+
+
+/*
+ * change default layer
+ */
 #ifndef BOOTMAGIC_DEFAULT_LAYER_0_KEY
 #define BOOTMAGIC_DEFAULT_LAYER_0_KEY   KC_0
 #endif
@@ -33,6 +68,7 @@
 #define BOOTMAGIC_DEFAULT_LAYER_3_KEY   KC_3
 #endif
 
+
 void bootmagic(void);
 bool bootmagic_scan_keycode(uint8_t keycode);
 
index b82d1884cec5648a5d81c275080b661716fb04d1..cf8d969f8175cfa1ae789c7b0cf0e654fd17514c 100644 (file)
@@ -133,8 +133,8 @@ static void print_eeprom_config(void)
     eebyte = eeconfig_read_defalt_layer();
     print("defalt_layer: "); print_hex8(eebyte); print("\n");
 
-    eebyte = eeconfig_read_modifier();
-    print("modifiers: "); print_hex8(eebyte); print("\n");
+    eebyte = eeconfig_read_keyconf();
+    print("keyconf: "); print_hex8(eebyte); print("\n");
 }
 
 static bool command_common(uint8_t code)
index a5834aa2c7cc813c9887c23304a7f80cd0e9d859..f536dc06c922dda1df337439c02f9553f8c37561 100644 (file)
@@ -6,11 +6,11 @@
 
 void eeconfig_init(void)
 {
-    eeprom_write_word(EECONFIG_MAGIC,               EECONFIG_MAGIC_NUMBER);
-    eeprom_write_byte(EECONFIG_DEBUG,               0);
-    eeprom_write_byte(EECONFIG_DEFAULT_LAYER,       0);
-    eeprom_write_byte(EECONFIG_MODIFIER,            0);
-    eeprom_write_byte(EECONFIG_MOUSEKEY_ACCEL,      0);
+    eeprom_write_word(EECONFIG_MAGIC,          EECONFIG_MAGIC_NUMBER);
+    eeprom_write_byte(EECONFIG_DEBUG,          0);
+    eeprom_write_byte(EECONFIG_DEFAULT_LAYER,  0);
+    eeprom_write_byte(EECONFIG_KEYCONF,        0);
+    eeprom_write_byte(EECONFIG_MOUSEKEY_ACCEL, 0);
 }
 
 bool eeconfig_initialized(void)
@@ -18,12 +18,11 @@ bool eeconfig_initialized(void)
     return (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER);
 }
 
-uint8_t eeconfig_read_debug(void) { return eeprom_read_byte(EECONFIG_DEBUG); }
+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); }
+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_modifier(void) { return eeprom_read_byte(EECONFIG_MODIFIER); }
-void eeconfig_write_modifier(uint8_t val) { eeprom_write_byte(EECONFIG_MODIFIER, val); }
-
+uint8_t eeconfig_read_keyconf(void)      { return eeprom_read_byte(EECONFIG_KEYCONF); }
+void eeconfig_write_keyconf(uint8_t val) { eeprom_write_byte(EECONFIG_KEYCONF, val); }
index 088171f575ac47f1a8d2e430db3764d6f3398c4e..9cf2ff6802666394566b0948235600f10f4e0f76 100644 (file)
@@ -26,21 +26,24 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define EECONFIG_MAGIC                          (uint16_t *)0
 #define EECONFIG_DEBUG                          (uint8_t *)2
 #define EECONFIG_DEFAULT_LAYER                  (uint8_t *)3
-#define EECONFIG_MODIFIER                       (uint8_t *)4
+#define EECONFIG_KEYCONF                        (uint8_t *)4
 #define EECONFIG_MOUSEKEY_ACCEL                 (uint8_t *)5
 
 
-/* config bit */
+/* debug bit */
 #define EECONFIG_DEBUG_ENABLE                   (1<<0)
 #define EECONFIG_DEBUG_MATRIX                   (1<<1)
 #define EECONFIG_DEBUG_KEYBOARD                 (1<<2)
 #define EECONFIG_DEBUG_MOUSE                    (1<<3)
 
-#define EECONFIG_MODIFIER_CONTROL_CAPSLOCK      (1<<0)
-#define EECONFIG_MODIFIER_ALT_GUI               (1<<1)
-#define EECONFIG_MODIFIER_ESC_GRAVE             (1<<2)
-#define EECONFIG_MODIFIER_BACKSPACE_BACKSLASH   (1<<3)
-#define EECONFIG_MODIFIER_NO_GUI                (1<<4)
+/* keyconf bit */
+#define EECONFIG_KEYCONF_SWAP_CONTROL_CAPSLOCK     (1<<0)
+#define EECONFIG_KEYCONF_CAPSLOCK_TO_CONTROL       (1<<1)
+#define EECONFIG_KEYCONF_SWAP_LALT_LGUI            (1<<2)
+#define EECONFIG_KEYCONF_SWAP_RALT_RGUI            (1<<3)
+#define EECONFIG_KEYCONF_NO_GUI                    (1<<4)
+#define EECONFIG_KEYCONF_SWAP_GRAVE_ESC            (1<<5)
+#define EECONFIG_KEYCONF_SWAP_BACKSLASH_BACKSPACE  (1<<6)
 
 
 bool eeconfig_initialized(void);
@@ -53,7 +56,7 @@ 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_modifier(void);
-void eeconfig_write_modifier(uint8_t val);
+uint8_t eeconfig_read_keyconf(void);
+void eeconfig_write_keyconf(uint8_t val);
 
 #endif