1
0

Add KEYCONF to eeconfig.c

This commit is contained in:
tmk 2013-03-10 19:22:54 +09:00
parent 51050875b7
commit de8ef18a53
5 changed files with 83 additions and 23 deletions

View File

@ -27,6 +27,28 @@ void bootmagic(void)
if (bootmagic_scan_keycode(BOOTMAGIC_EEPROM_CLEAR_KEY)) { if (bootmagic_scan_keycode(BOOTMAGIC_EEPROM_CLEAR_KEY)) {
eeconfig_init(); 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) bool bootmagic_scan_keycode(uint8_t keycode)

View File

@ -6,7 +6,7 @@
#define BOOTMAGIC_IS_ENABLE() true #define BOOTMAGIC_IS_ENABLE() true
#endif #endif
/* bootloader */ /* kick up bootloader */
#ifndef BOOTMAGIC_BOOTLOADER_KEY #ifndef BOOTMAGIC_BOOTLOADER_KEY
#define BOOTMAGIC_BOOTLOADER_KEY KC_B #define BOOTMAGIC_BOOTLOADER_KEY KC_B
#endif #endif
@ -19,7 +19,42 @@
#define BOOTMAGIC_EEPROM_CLEAR_KEY KC_BSPACE #define BOOTMAGIC_EEPROM_CLEAR_KEY KC_BSPACE
#endif #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 #ifndef BOOTMAGIC_DEFAULT_LAYER_0_KEY
#define BOOTMAGIC_DEFAULT_LAYER_0_KEY KC_0 #define BOOTMAGIC_DEFAULT_LAYER_0_KEY KC_0
#endif #endif
@ -33,6 +68,7 @@
#define BOOTMAGIC_DEFAULT_LAYER_3_KEY KC_3 #define BOOTMAGIC_DEFAULT_LAYER_3_KEY KC_3
#endif #endif
void bootmagic(void); void bootmagic(void);
bool bootmagic_scan_keycode(uint8_t keycode); bool bootmagic_scan_keycode(uint8_t keycode);

View File

@ -133,8 +133,8 @@ static void print_eeprom_config(void)
eebyte = eeconfig_read_defalt_layer(); eebyte = eeconfig_read_defalt_layer();
print("defalt_layer: "); print_hex8(eebyte); print("\n"); print("defalt_layer: "); print_hex8(eebyte); print("\n");
eebyte = eeconfig_read_modifier(); eebyte = eeconfig_read_keyconf();
print("modifiers: "); print_hex8(eebyte); print("\n"); print("keyconf: "); print_hex8(eebyte); print("\n");
} }
static bool command_common(uint8_t code) static bool command_common(uint8_t code)

View File

@ -9,7 +9,7 @@ void eeconfig_init(void)
eeprom_write_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER); eeprom_write_word(EECONFIG_MAGIC, EECONFIG_MAGIC_NUMBER);
eeprom_write_byte(EECONFIG_DEBUG, 0); eeprom_write_byte(EECONFIG_DEBUG, 0);
eeprom_write_byte(EECONFIG_DEFAULT_LAYER, 0); eeprom_write_byte(EECONFIG_DEFAULT_LAYER, 0);
eeprom_write_byte(EECONFIG_MODIFIER, 0); eeprom_write_byte(EECONFIG_KEYCONF, 0);
eeprom_write_byte(EECONFIG_MOUSEKEY_ACCEL, 0); eeprom_write_byte(EECONFIG_MOUSEKEY_ACCEL, 0);
} }
@ -24,6 +24,5 @@ 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); } 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); } uint8_t eeconfig_read_keyconf(void) { return eeprom_read_byte(EECONFIG_KEYCONF); }
void eeconfig_write_modifier(uint8_t val) { eeprom_write_byte(EECONFIG_MODIFIER, val); } void eeconfig_write_keyconf(uint8_t val) { eeprom_write_byte(EECONFIG_KEYCONF, val); }

View 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_MAGIC (uint16_t *)0
#define EECONFIG_DEBUG (uint8_t *)2 #define EECONFIG_DEBUG (uint8_t *)2
#define EECONFIG_DEFAULT_LAYER (uint8_t *)3 #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 #define EECONFIG_MOUSEKEY_ACCEL (uint8_t *)5
/* config bit */ /* debug bit */
#define EECONFIG_DEBUG_ENABLE (1<<0) #define EECONFIG_DEBUG_ENABLE (1<<0)
#define EECONFIG_DEBUG_MATRIX (1<<1) #define EECONFIG_DEBUG_MATRIX (1<<1)
#define EECONFIG_DEBUG_KEYBOARD (1<<2) #define EECONFIG_DEBUG_KEYBOARD (1<<2)
#define EECONFIG_DEBUG_MOUSE (1<<3) #define EECONFIG_DEBUG_MOUSE (1<<3)
#define EECONFIG_MODIFIER_CONTROL_CAPSLOCK (1<<0) /* keyconf bit */
#define EECONFIG_MODIFIER_ALT_GUI (1<<1) #define EECONFIG_KEYCONF_SWAP_CONTROL_CAPSLOCK (1<<0)
#define EECONFIG_MODIFIER_ESC_GRAVE (1<<2) #define EECONFIG_KEYCONF_CAPSLOCK_TO_CONTROL (1<<1)
#define EECONFIG_MODIFIER_BACKSPACE_BACKSLASH (1<<3) #define EECONFIG_KEYCONF_SWAP_LALT_LGUI (1<<2)
#define EECONFIG_MODIFIER_NO_GUI (1<<4) #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); bool eeconfig_initialized(void);
@ -53,7 +56,7 @@ void eeconfig_write_debug(uint8_t val);
uint8_t eeconfig_read_defalt_layer(void); uint8_t eeconfig_read_defalt_layer(void);
void eeconfig_write_defalt_layer(uint8_t val); void eeconfig_write_defalt_layer(uint8_t val);
uint8_t eeconfig_read_modifier(void); uint8_t eeconfig_read_keyconf(void);
void eeconfig_write_modifier(uint8_t val); void eeconfig_write_keyconf(uint8_t val);
#endif #endif