summaryrefslogtreecommitdiff
path: root/tmk_core/common/bootmagic.c
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/common/bootmagic.c')
-rw-r--r--tmk_core/common/bootmagic.c50
1 files changed, 33 insertions, 17 deletions
diff --git a/tmk_core/common/bootmagic.c b/tmk_core/common/bootmagic.c
index cc780d17ab..09b1664c90 100644
--- a/tmk_core/common/bootmagic.c
+++ b/tmk_core/common/bootmagic.c
@@ -16,8 +16,7 @@ keymap_config_t keymap_config;
*
* FIXME: needs doc
*/
-void bootmagic(void)
-{
+void bootmagic(void) {
/* check signature */
if (!eeconfig_is_enabled()) {
eeconfig_init();
@@ -26,7 +25,10 @@ void bootmagic(void)
/* do scans in case of bounce */
print("bootmagic scan: ... ");
uint8_t scan = 100;
- while (scan--) { matrix_scan(); wait_ms(10); }
+ while (scan--) {
+ matrix_scan();
+ wait_ms(10);
+ }
print("done.\n");
/* bootmagic skip */
@@ -89,14 +91,30 @@ void bootmagic(void)
/* 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 (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_update_default_layer(default_layer);
default_layer_set((layer_state_t)default_layer);
@@ -110,13 +128,12 @@ void bootmagic(void)
*
* FIXME: needs doc
*/
-static bool scan_keycode(uint8_t keycode)
-{
+static bool scan_keycode(uint8_t keycode) {
for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
matrix_row_t matrix_row = matrix_get_row(r);
for (uint8_t c = 0; c < MATRIX_COLS; c++) {
- if (matrix_row & ((matrix_row_t)1<<c)) {
- if (keycode == keymap_key_to_keycode(0, (keypos_t){ .row = r, .col = c })) {
+ if (matrix_row & ((matrix_row_t)1 << c)) {
+ if (keycode == keymap_key_to_keycode(0, (keypos_t){.row = r, .col = c})) {
return true;
}
}
@@ -129,8 +146,7 @@ static bool scan_keycode(uint8_t keycode)
*
* FIXME: needs doc
*/
-bool bootmagic_scan_keycode(uint8_t keycode)
-{
+bool bootmagic_scan_keycode(uint8_t keycode) {
if (!scan_keycode(BOOTMAGIC_KEY_SALT)) return false;
return scan_keycode(keycode);