aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/bootmagic.c22
-rw-r--r--common/bootmagic.h40
-rw-r--r--common/command.c4
-rw-r--r--common/eeconfig.c19
-rw-r--r--common/eeconfig.h21
5 files changed, 83 insertions, 23 deletions
diff --git a/common/bootmagic.c b/common/bootmagic.c
index 31b8ae5e6..46fbc180a 100644
--- a/common/bootmagic.c
+++ b/common/bootmagic.c
@@ -27,6 +27,28 @@ void bootmagic(void)
27 if (bootmagic_scan_keycode(BOOTMAGIC_EEPROM_CLEAR_KEY)) { 27 if (bootmagic_scan_keycode(BOOTMAGIC_EEPROM_CLEAR_KEY)) {
28 eeconfig_init(); 28 eeconfig_init();
29 } 29 }
30
31 if (bootmagic_scan_keycode(BOOTMAGIC_SWAP_CONTROL_CPASLOCK)) {
32 eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_SWAP_CONTROL_CAPSLOCK);
33 }
34 if (bootmagic_scan_keycode(BOOTMAGIC_CAPSLOCK_TO_CONTROL)) {
35 eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_CAPSLOCK_TO_CONTROL);
36 }
37 if (bootmagic_scan_keycode(BOOTMAGIC_SWAP_LALT_LGUI)) {
38 eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_SWAP_LALT_LGUI);
39 }
40 if (bootmagic_scan_keycode(BOOTMAGIC_SWAP_RALT_RGUI)) {
41 eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_SWAP_RALT_RGUI);
42 }
43 if (bootmagic_scan_keycode(BOOTMAGIC_NO_GUI)) {
44 eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_NO_GUI);
45 }
46 if (bootmagic_scan_keycode(BOOTMAGIC_SWAP_GRAVE_ESC)) {
47 eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_SWAP_GRAVE_ESC);
48 }
49 if (bootmagic_scan_keycode(BOOTMAGIC_SWAP_BACKSLASH_BACKSPACE)) {
50 eeconfig_write_keyconf(eeconfig_read_keyconf() ^ EECONFIG_KEYCONF_SWAP_BACKSLASH_BACKSPACE);
51 }
30} 52}
31 53
32bool bootmagic_scan_keycode(uint8_t keycode) 54bool bootmagic_scan_keycode(uint8_t keycode)
diff --git a/common/bootmagic.h b/common/bootmagic.h
index 7aa224def..d32a5bef8 100644
--- a/common/bootmagic.h
+++ b/common/bootmagic.h
@@ -6,7 +6,7 @@
6#define BOOTMAGIC_IS_ENABLE() true 6#define BOOTMAGIC_IS_ENABLE() true
7#endif 7#endif
8 8
9/* bootloader */ 9/* kick up bootloader */
10#ifndef BOOTMAGIC_BOOTLOADER_KEY 10#ifndef BOOTMAGIC_BOOTLOADER_KEY
11#define BOOTMAGIC_BOOTLOADER_KEY KC_B 11#define BOOTMAGIC_BOOTLOADER_KEY KC_B
12#endif 12#endif
@@ -19,7 +19,42 @@
19#define BOOTMAGIC_EEPROM_CLEAR_KEY KC_BSPACE 19#define BOOTMAGIC_EEPROM_CLEAR_KEY KC_BSPACE
20#endif 20#endif
21 21
22/* change default layer */ 22/*
23 * key configure
24 */
25/* swap control and capslock */
26#ifndef BOOTMAGIC_SWAP_CONTROL_CPASLOCK
27#define BOOTMAGIC_SWAP_CONTROL_CPASLOCK KC_LCTRL
28#endif
29/* capslock to control */
30#ifndef BOOTMAGIC_CAPSLOCK_TO_CONTROL
31#define BOOTMAGIC_CAPSLOCK_TO_CONTROL KC_CAPSLOCK
32#endif
33/* swap alt and gui */
34#ifndef BOOTMAGIC_SWAP_LALT_LGUI
35#define BOOTMAGIC_SWAP_LALT_LGUI KC_LALT
36#endif
37/* swap alt and gui */
38#ifndef BOOTMAGIC_SWAP_RALT_RGUI
39#define BOOTMAGIC_SWAP_RALT_RGUI KC_RALT
40#endif
41/* no gui */
42#ifndef BOOTMAGIC_NO_GUI
43#define BOOTMAGIC_NO_GUI KC_LGUI
44#endif
45/* swap esc and grave */
46#ifndef BOOTMAGIC_SWAP_GRAVE_ESC
47#define BOOTMAGIC_SWAP_GRAVE_ESC KC_GRAVE
48#endif
49/* swap backslash and backspace */
50#ifndef BOOTMAGIC_SWAP_BACKSLASH_BACKSPACE
51#define BOOTMAGIC_SWAP_BACKSLASH_BACKSPACE KC_BSLASH
52#endif
53
54
55/*
56 * change default layer
57 */
23#ifndef BOOTMAGIC_DEFAULT_LAYER_0_KEY 58#ifndef BOOTMAGIC_DEFAULT_LAYER_0_KEY
24#define BOOTMAGIC_DEFAULT_LAYER_0_KEY KC_0 59#define BOOTMAGIC_DEFAULT_LAYER_0_KEY KC_0
25#endif 60#endif
@@ -33,6 +68,7 @@
33#define BOOTMAGIC_DEFAULT_LAYER_3_KEY KC_3 68#define BOOTMAGIC_DEFAULT_LAYER_3_KEY KC_3
34#endif 69#endif
35 70
71
36void bootmagic(void); 72void bootmagic(void);
37bool bootmagic_scan_keycode(uint8_t keycode); 73bool bootmagic_scan_keycode(uint8_t keycode);
38 74
diff --git a/common/command.c b/common/command.c
index b82d1884c..cf8d969f8 100644
--- a/common/command.c
+++ b/common/command.c
@@ -133,8 +133,8 @@ static void print_eeprom_config(void)
133 eebyte = eeconfig_read_defalt_layer(); 133 eebyte = eeconfig_read_defalt_layer();
134 print("defalt_layer: "); print_hex8(eebyte); print("\n"); 134 print("defalt_layer: "); print_hex8(eebyte); print("\n");
135 135
136 eebyte = eeconfig_read_modifier(); 136 eebyte = eeconfig_read_keyconf();
137 print("modifiers: "); print_hex8(eebyte); print("\n"); 137 print("keyconf: "); print_hex8(eebyte); print("\n");
138} 138}
139 139
140static bool command_common(uint8_t code) 140static bool command_common(uint8_t code)
diff --git a/common/eeconfig.c b/common/eeconfig.c
index a5834aa2c..f536dc06c 100644
--- a/common/eeconfig.c
+++ b/common/eeconfig.c
@@ -6,11 +6,11 @@
6 6
7void eeconfig_init(void) 7void eeconfig_init(void)
8{ 8{
9 eeprom_write_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER); 9 eeprom_write_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
10 eeprom_write_byte(EECONFIG_DEBUG, 0); 10 eeprom_write_byte(EECONFIG_DEBUG, 0);
11 eeprom_write_byte(EECONFIG_DEFAULT_LAYER, 0); 11 eeprom_write_byte(EECONFIG_DEFAULT_LAYER, 0);
12 eeprom_write_byte(EECONFIG_MODIFIER, 0); 12 eeprom_write_byte(EECONFIG_KEYCONF, 0);
13 eeprom_write_byte(EECONFIG_MOUSEKEY_ACCEL, 0); 13 eeprom_write_byte(EECONFIG_MOUSEKEY_ACCEL, 0);
14} 14}
15 15
16bool eeconfig_initialized(void) 16bool eeconfig_initialized(void)
@@ -18,12 +18,11 @@ bool eeconfig_initialized(void)
18 return (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER); 18 return (eeprom_read_word(EECONFIG_MAGIC) == EECONFIG_MAGIC_NUMBER);
19} 19}
20 20
21uint8_t eeconfig_read_debug(void) { return eeprom_read_byte(EECONFIG_DEBUG); } 21uint8_t eeconfig_read_debug(void) { return eeprom_read_byte(EECONFIG_DEBUG); }
22void eeconfig_write_debug(uint8_t val) { eeprom_write_byte(EECONFIG_DEBUG, val); } 22void eeconfig_write_debug(uint8_t val) { eeprom_write_byte(EECONFIG_DEBUG, val); }
23 23
24uint8_t eeconfig_read_defalt_layer(void) { return eeprom_read_byte(EECONFIG_DEFAULT_LAYER); } 24uint8_t eeconfig_read_defalt_layer(void) { return eeprom_read_byte(EECONFIG_DEFAULT_LAYER); }
25void eeconfig_write_defalt_layer(uint8_t val) { eeprom_write_byte(EECONFIG_DEFAULT_LAYER, val); } 25void eeconfig_write_defalt_layer(uint8_t val) { eeprom_write_byte(EECONFIG_DEFAULT_LAYER, val); }
26 26
27uint8_t eeconfig_read_modifier(void) { return eeprom_read_byte(EECONFIG_MODIFIER); } 27uint8_t eeconfig_read_keyconf(void) { return eeprom_read_byte(EECONFIG_KEYCONF); }
28void eeconfig_write_modifier(uint8_t val) { eeprom_write_byte(EECONFIG_MODIFIER, val); } 28void eeconfig_write_keyconf(uint8_t val) { eeprom_write_byte(EECONFIG_KEYCONF, val); }
29
diff --git a/common/eeconfig.h b/common/eeconfig.h
index 088171f57..9cf2ff680 100644
--- a/common/eeconfig.h
+++ b/common/eeconfig.h
@@ -26,21 +26,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
26#define EECONFIG_MAGIC (uint16_t *)0 26#define EECONFIG_MAGIC (uint16_t *)0
27#define EECONFIG_DEBUG (uint8_t *)2 27#define EECONFIG_DEBUG (uint8_t *)2
28#define EECONFIG_DEFAULT_LAYER (uint8_t *)3 28#define EECONFIG_DEFAULT_LAYER (uint8_t *)3
29#define EECONFIG_MODIFIER (uint8_t *)4 29#define EECONFIG_KEYCONF (uint8_t *)4
30#define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)5 30#define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)5
31 31
32 32
33/* config bit */ 33/* debug bit */
34#define EECONFIG_DEBUG_ENABLE (1<<0) 34#define EECONFIG_DEBUG_ENABLE (1<<0)
35#define EECONFIG_DEBUG_MATRIX (1<<1) 35#define EECONFIG_DEBUG_MATRIX (1<<1)
36#define EECONFIG_DEBUG_KEYBOARD (1<<2) 36#define EECONFIG_DEBUG_KEYBOARD (1<<2)
37#define EECONFIG_DEBUG_MOUSE (1<<3) 37#define EECONFIG_DEBUG_MOUSE (1<<3)
38 38
39#define EECONFIG_MODIFIER_CONTROL_CAPSLOCK (1<<0) 39/* keyconf bit */
40#define EECONFIG_MODIFIER_ALT_GUI (1<<1) 40#define EECONFIG_KEYCONF_SWAP_CONTROL_CAPSLOCK (1<<0)
41#define EECONFIG_MODIFIER_ESC_GRAVE (1<<2) 41#define EECONFIG_KEYCONF_CAPSLOCK_TO_CONTROL (1<<1)
42#define EECONFIG_MODIFIER_BACKSPACE_BACKSLASH (1<<3) 42#define EECONFIG_KEYCONF_SWAP_LALT_LGUI (1<<2)
43#define EECONFIG_MODIFIER_NO_GUI (1<<4) 43#define EECONFIG_KEYCONF_SWAP_RALT_RGUI (1<<3)
44#define EECONFIG_KEYCONF_NO_GUI (1<<4)
45#define EECONFIG_KEYCONF_SWAP_GRAVE_ESC (1<<5)
46#define EECONFIG_KEYCONF_SWAP_BACKSLASH_BACKSPACE (1<<6)
44 47
45 48
46bool eeconfig_initialized(void); 49bool eeconfig_initialized(void);
@@ -53,7 +56,7 @@ void eeconfig_write_debug(uint8_t val);
53uint8_t eeconfig_read_defalt_layer(void); 56uint8_t eeconfig_read_defalt_layer(void);
54void eeconfig_write_defalt_layer(uint8_t val); 57void eeconfig_write_defalt_layer(uint8_t val);
55 58
56uint8_t eeconfig_read_modifier(void); 59uint8_t eeconfig_read_keyconf(void);
57void eeconfig_write_modifier(uint8_t val); 60void eeconfig_write_keyconf(uint8_t val);
58 61
59#endif 62#endif