clean up quantum.c (#7485)

* idea

* progress

* more stuff

* wip

* wip

* last couple of keycodes you can move safely

* Update quantum/quantum.c

Co-Authored-By: fauxpark <fauxpark@gmail.com>

* Put back RGB_MODE_BREATHE
This commit is contained in:
Yan-Fa Li 2019-11-27 14:00:23 -08:00 committed by GitHub
parent 265c415f5e
commit 1604f79623
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -276,259 +276,181 @@ bool process_record_quantum(keyrecord_t *record) {
return false; return false;
} }
// Shift / paren setup if (record->event.pressed) {
switch (keycode) {
switch (keycode) { case RESET:
case RESET:
if (record->event.pressed) {
reset_keyboard(); reset_keyboard();
} return false;
return false; case DEBUG:
case DEBUG:
if (record->event.pressed) {
debug_enable ^= 1; debug_enable ^= 1;
if (debug_enable) { if (debug_enable) {
print("DEBUG: enabled.\n"); print("DEBUG: enabled.\n");
} else { } else {
print("DEBUG: disabled.\n"); print("DEBUG: disabled.\n");
} }
} return false;
return false; case EEPROM_RESET:
case EEPROM_RESET:
if (record->event.pressed) {
eeconfig_init(); eeconfig_init();
} return false;
return false;
#ifdef FAUXCLICKY_ENABLE #ifdef FAUXCLICKY_ENABLE
case FC_TOG: case FC_TOG:
if (record->event.pressed) {
FAUXCLICKY_TOGGLE; FAUXCLICKY_TOGGLE;
} return false;
return false; case FC_ON:
case FC_ON:
if (record->event.pressed) {
FAUXCLICKY_ON; FAUXCLICKY_ON;
} return false;
return false; case FC_OFF:
case FC_OFF:
if (record->event.pressed) {
FAUXCLICKY_OFF; FAUXCLICKY_OFF;
} return false;
return false;
#endif #endif
#ifdef VELOCIKEY_ENABLE
case VLK_TOG:
velocikey_toggle();
return false;
#endif
#ifdef PROTOCOL_LUFA
case OUT_AUTO:
set_output(OUTPUT_AUTO);
return false;
case OUT_USB:
set_output(OUTPUT_USB);
return false;
# ifdef BLUETOOTH_ENABLE
case OUT_BT:
set_output(OUTPUT_BLUETOOTH);
return false;
# endif
#endif
}
}
#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
case RGB_TOG:
// Split keyboards need to trigger on key-up for edge-case issue
# ifndef SPLIT_KEYBOARD # ifndef SPLIT_KEYBOARD
if (record->event.pressed) { if (record->event.pressed) {
# else # else
if (!record->event.pressed) { // Split keyboards need to trigger on key-up for edge-case issue
if (!record->event.pressed) {
# endif # endif
uint8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT));
switch (keycode) {
case RGB_TOG:
rgblight_toggle(); rgblight_toggle();
} return false;
return false; case RGB_MODE_FORWARD:
case RGB_MODE_FORWARD:
if (record->event.pressed) {
uint8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT));
if (shifted) { if (shifted) {
rgblight_step_reverse(); rgblight_step_reverse();
} else { } else {
rgblight_step(); rgblight_step();
} }
} return false;
return false; case RGB_MODE_REVERSE:
case RGB_MODE_REVERSE:
if (record->event.pressed) {
uint8_t shifted = get_mods() & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT));
if (shifted) { if (shifted) {
rgblight_step(); rgblight_step();
} else { } else {
rgblight_step_reverse(); rgblight_step_reverse();
} }
} return false;
return false; case RGB_HUI:
case RGB_HUI:
// Split keyboards need to trigger on key-up for edge-case issue
# ifndef SPLIT_KEYBOARD
if (record->event.pressed) {
# else
if (!record->event.pressed) {
# endif
rgblight_increase_hue(); rgblight_increase_hue();
} return false;
return false; case RGB_HUD:
case RGB_HUD:
// Split keyboards need to trigger on key-up for edge-case issue
# ifndef SPLIT_KEYBOARD
if (record->event.pressed) {
# else
if (!record->event.pressed) {
# endif
rgblight_decrease_hue(); rgblight_decrease_hue();
} return false;
return false; case RGB_SAI:
case RGB_SAI:
// Split keyboards need to trigger on key-up for edge-case issue
# ifndef SPLIT_KEYBOARD
if (record->event.pressed) {
# else
if (!record->event.pressed) {
# endif
rgblight_increase_sat(); rgblight_increase_sat();
} return false;
return false; case RGB_SAD:
case RGB_SAD:
// Split keyboards need to trigger on key-up for edge-case issue
# ifndef SPLIT_KEYBOARD
if (record->event.pressed) {
# else
if (!record->event.pressed) {
# endif
rgblight_decrease_sat(); rgblight_decrease_sat();
} return false;
return false; case RGB_VAI:
case RGB_VAI:
// Split keyboards need to trigger on key-up for edge-case issue
# ifndef SPLIT_KEYBOARD
if (record->event.pressed) {
# else
if (!record->event.pressed) {
# endif
rgblight_increase_val(); rgblight_increase_val();
} return false;
return false; case RGB_VAD:
case RGB_VAD:
// Split keyboards need to trigger on key-up for edge-case issue
# ifndef SPLIT_KEYBOARD
if (record->event.pressed) {
# else
if (!record->event.pressed) {
# endif
rgblight_decrease_val(); rgblight_decrease_val();
} return false;
return false; case RGB_SPI:
case RGB_SPI:
if (record->event.pressed) {
rgblight_increase_speed(); rgblight_increase_speed();
} return false;
return false; case RGB_SPD:
case RGB_SPD:
if (record->event.pressed) {
rgblight_decrease_speed(); rgblight_decrease_speed();
} return false;
return false; case RGB_MODE_PLAIN:
case RGB_MODE_PLAIN:
if (record->event.pressed) {
rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT); rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT);
} return false;
return false; case RGB_MODE_BREATHE:
case RGB_MODE_BREATHE:
# ifdef RGBLIGHT_EFFECT_BREATHING # ifdef RGBLIGHT_EFFECT_BREATHING
if (record->event.pressed) {
if ((RGBLIGHT_MODE_BREATHING <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_BREATHING_end)) { if ((RGBLIGHT_MODE_BREATHING <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_BREATHING_end)) {
rgblight_step(); rgblight_step();
} else { } else {
rgblight_mode(RGBLIGHT_MODE_BREATHING); rgblight_mode(RGBLIGHT_MODE_BREATHING);
} }
}
# endif # endif
return false; return false;
case RGB_MODE_RAINBOW: case RGB_MODE_RAINBOW:
# ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD # ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD
if (record->event.pressed) {
if ((RGBLIGHT_MODE_RAINBOW_MOOD <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_RAINBOW_MOOD_end)) { if ((RGBLIGHT_MODE_RAINBOW_MOOD <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_RAINBOW_MOOD_end)) {
rgblight_step(); rgblight_step();
} else { } else {
rgblight_mode(RGBLIGHT_MODE_RAINBOW_MOOD); rgblight_mode(RGBLIGHT_MODE_RAINBOW_MOOD);
} }
}
# endif # endif
return false; case RGB_MODE_SWIRL:
case RGB_MODE_SWIRL:
# ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL # ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL
if (record->event.pressed) {
if ((RGBLIGHT_MODE_RAINBOW_SWIRL <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_RAINBOW_SWIRL_end)) { if ((RGBLIGHT_MODE_RAINBOW_SWIRL <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_RAINBOW_SWIRL_end)) {
rgblight_step(); rgblight_step();
} else { } else {
rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL); rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL);
} }
}
# endif # endif
return false; return false;
case RGB_MODE_SNAKE: case RGB_MODE_SNAKE:
# ifdef RGBLIGHT_EFFECT_SNAKE # ifdef RGBLIGHT_EFFECT_SNAKE
if (record->event.pressed) {
if ((RGBLIGHT_MODE_SNAKE <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_SNAKE_end)) { if ((RGBLIGHT_MODE_SNAKE <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_SNAKE_end)) {
rgblight_step(); rgblight_step();
} else { } else {
rgblight_mode(RGBLIGHT_MODE_SNAKE); rgblight_mode(RGBLIGHT_MODE_SNAKE);
} }
}
# endif # endif
return false; return false;
case RGB_MODE_KNIGHT: case RGB_MODE_KNIGHT:
# ifdef RGBLIGHT_EFFECT_KNIGHT # ifdef RGBLIGHT_EFFECT_KNIGHT
if (record->event.pressed) {
if ((RGBLIGHT_MODE_KNIGHT <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_KNIGHT_end)) { if ((RGBLIGHT_MODE_KNIGHT <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_KNIGHT_end)) {
rgblight_step(); rgblight_step();
} else { } else {
rgblight_mode(RGBLIGHT_MODE_KNIGHT); rgblight_mode(RGBLIGHT_MODE_KNIGHT);
} }
}
# endif # endif
return false; return false;
case RGB_MODE_XMAS: case RGB_MODE_XMAS:
# ifdef RGBLIGHT_EFFECT_CHRISTMAS # ifdef RGBLIGHT_EFFECT_CHRISTMAS
if (record->event.pressed) {
rgblight_mode(RGBLIGHT_MODE_CHRISTMAS); rgblight_mode(RGBLIGHT_MODE_CHRISTMAS);
}
# endif # endif
return false; return false;
case RGB_MODE_GRADIENT: case RGB_MODE_GRADIENT:
# ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT # ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT
if (record->event.pressed) {
if ((RGBLIGHT_MODE_STATIC_GRADIENT <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_STATIC_GRADIENT_end)) { if ((RGBLIGHT_MODE_STATIC_GRADIENT <= rgblight_get_mode()) && (rgblight_get_mode() < RGBLIGHT_MODE_STATIC_GRADIENT_end)) {
rgblight_step(); rgblight_step();
} else { } else {
rgblight_mode(RGBLIGHT_MODE_STATIC_GRADIENT); rgblight_mode(RGBLIGHT_MODE_STATIC_GRADIENT);
} }
}
# endif # endif
return false; return false;
case RGB_MODE_RGBTEST: case RGB_MODE_RGBTEST:
# ifdef RGBLIGHT_EFFECT_RGB_TEST # ifdef RGBLIGHT_EFFECT_RGB_TEST
if (record->event.pressed) {
rgblight_mode(RGBLIGHT_MODE_RGB_TEST); rgblight_mode(RGBLIGHT_MODE_RGB_TEST);
}
# endif # endif
return false; return false;
#endif // defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) #if defined(BACKLIGHT_ENABLE) && defined(BACKLIGHT_BREATHING)
#ifdef VELOCIKEY_ENABLE case BL_BRTG:
case VLK_TOG: backlight_toggle_breathing();
if (record->event.pressed) { return false;
velocikey_toggle();
}
return false;
#endif #endif
#ifdef PROTOCOL_LUFA }
case OUT_AUTO: }
if (record->event.pressed) {
set_output(OUTPUT_AUTO);
}
return false;
case OUT_USB:
if (record->event.pressed) {
set_output(OUTPUT_USB);
}
return false;
# ifdef BLUETOOTH_ENABLE
case OUT_BT:
if (record->event.pressed) {
set_output(OUTPUT_BLUETOOTH);
}
return false;
# endif
#endif #endif
// keycodes that depend on both pressed and non-pressed state
switch (keycode) {
case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_ALT_GUI: case MAGIC_SWAP_CONTROL_CAPSLOCK ... MAGIC_TOGGLE_ALT_GUI:
case MAGIC_SWAP_LCTL_LGUI ... MAGIC_EE_HANDS_RIGHT: case MAGIC_SWAP_LCTL_LGUI ... MAGIC_EE_HANDS_RIGHT:
if (record->event.pressed) { if (record->event.pressed) {
@ -711,14 +633,6 @@ bool process_record_quantum(keyrecord_t *record) {
return false; return false;
} }
#if defined(BACKLIGHT_ENABLE) && defined(BACKLIGHT_BREATHING)
case BL_BRTG: {
if (record->event.pressed) {
backlight_toggle_breathing();
}
return false;
}
#endif
} }
return process_action_kb(record); return process_action_kb(record);