From 00d3061e02fa5fedaa6e6cebd310d4e716ffffee Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Mon, 6 Jan 2020 01:49:49 -0800 Subject: [Keymap] Cleanup of Drashna code (#7800) * ifdef rgb stuff like a madman for RGB Coexistance * Re-enable RGB Light on Planck * fix RGB Coexistance issue * Tweak feature settings for Ergodox EZ Glow * Their powers combine, and I am Captain RGB This one is for noroadsleft and yan. * Limit brightness when both RGB features are enabled * Change shutdown method * Add RGB Coexistience stuff to keymap * disable RGBLIGHT_SLEEP until a solution can be found * Disable Unicode on the kyria * Fix up Iris rev defines * Fix up community layouts to compile properly * Cleanup rgb stuff * Merge ergodox keymaps * Update CCCV macro to use tap_code16 * Enable Solenoid on C39 Because josh couldn't * Enable RGB Light, not Matrix on rev6 keymap * Only enable LTO on non-ARM boards * Clean up Bootmagic OLED display * Enable RGBLIGHT_SPLIT on kyria Not that it does anything * Add hotkey for discord --- users/drashna/drashna.c | 6 +- users/drashna/process_records.c | 8 +- users/drashna/rgb_stuff.c | 173 ++++++++++++++++++++++++++++++++++++++-- users/drashna/rules.mk | 6 +- 4 files changed, 179 insertions(+), 14 deletions(-) (limited to 'users') diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c index 71779a6215..1a4ee9b414 100644 --- a/users/drashna/drashna.c +++ b/users/drashna/drashna.c @@ -121,9 +121,13 @@ void shutdown_user(void) { rgblight_setrgb_red(); #endif // RGBLIGHT_ENABLE #ifdef RGB_MATRIX_ENABLE +# ifdef __AVR__ rgb_matrix_set_color_all(0xFF, 0x00, 0x00); rgb_matrix_update_pwm_buffers(); - +# else + rgb_matrix_sethsv_noeeprom(0, 255, 255); + rgb_matrix_mode_noeeprom(1); +# endif #endif // RGB_MATRIX_ENABLE shutdown_keymap(); } diff --git a/users/drashna/process_records.c b/users/drashna/process_records.c index 2f79ad11cc..af3ee9cf05 100644 --- a/users/drashna/process_records.c +++ b/users/drashna/process_records.c @@ -80,13 +80,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { copy_paste_timer = timer_read(); } else { if (timer_elapsed(copy_paste_timer) > TAPPING_TERM) { // Hold, copy - register_code(KC_LCTL); - tap_code(KC_C); - unregister_code(KC_LCTL); + tap_code16(LCTL(KC_C)); } else { // Tap, paste - register_code(KC_LCTL); - tap_code(KC_V); - unregister_code(KC_LCTL); + tap_code16(LCTL(KC_V)); } } break; diff --git a/users/drashna/rgb_stuff.c b/users/drashna/rgb_stuff.c index 52ec61c22d..e7247f754f 100644 --- a/users/drashna/rgb_stuff.c +++ b/users/drashna/rgb_stuff.c @@ -147,6 +147,7 @@ bool rgblight_twinkle_is_led_used(uint8_t index) { /* Handler for fading/twinkling effect */ void scan_rgblight_fadeout(void) { // Don't effing change this function .... rgblight_sethsv is supppppper intensive bool litup = false; + for (uint8_t light_index = 0; light_index < RGBLED_NUM; ++light_index) { if (lights[light_index].enabled && timer_elapsed(lights[light_index].timer) > 10) { rgblight_fadeout *light = &lights[light_index]; @@ -179,6 +180,7 @@ void start_rgb_light(void) { uint8_t indices_count = 0; uint8_t min_life = 0xFF; uint8_t min_life_index = -1; + for (uint8_t index = 0; index < RGBLED_NUM; ++index) { if (rgblight_twinkle_is_led_used(index)) { continue; @@ -248,7 +250,14 @@ bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) { dprintf("rgblight layer change [EEPROM]: %u\n", userspace_config.rgb_layer_change); eeconfig_update_user(userspace_config.raw); if (userspace_config.rgb_layer_change) { +# if defined(RGBLIGHT_ENABLE) && defined(RGB_MATRIX_ENABLE) + rgblight_enable_noeeprom(); +# endif layer_state_set(layer_state); // This is needed to immediately set the layer color (looks better) +# if defined(RGBLIGHT_ENABLE) && defined(RGB_MATRIX_ENABLE) + } else { + rgblight_disable_noeeprom(); +# endif } } #endif // RGBLIGHT_ENABLE @@ -265,28 +274,182 @@ bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) { } #endif break; +#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 + if (record->event.pressed) { +# else + if (!record->event.pressed) { +# endif +# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) + rgblight_toggle(); +# endif +# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + rgb_matrix_toggle(); +# endif + } + return false; + break; case RGB_MODE_FORWARD ... RGB_MODE_GRADIENT: // quantum_keycodes.h L400 for definitions if (record->event.pressed) { - bool is_eeprom_updated = false; -#ifdef RGBLIGHT_ENABLE + bool is_eeprom_updated; +# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) // This disables layer indication, as it's assumed that if you're changing this ... you want that disabled if (userspace_config.rgb_layer_change) { userspace_config.rgb_layer_change = false; dprintf("rgblight layer change [EEPROM]: %u\n", userspace_config.rgb_layer_change); is_eeprom_updated = true; } -#endif -#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) +# endif +# if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS) if (userspace_config.rgb_matrix_idle_anim) { userspace_config.rgb_matrix_idle_anim = false; dprintf("RGB Matrix Idle Animation [EEPROM]: %u\n", userspace_config.rgb_matrix_idle_anim); is_eeprom_updated = true; } -#endif +# endif if (is_eeprom_updated) { eeconfig_update_user(userspace_config.raw); } } + +# if defined(RGBLIGHT_DISABLE_KEYCODES) || defined(RGB_MATRIX_DISABLE_KEYCODES) + if (keycode == RGB_MODE_FORWARD && record->event.pressed) { + uint8_t shifted = get_mods() & (MOD_MASK_SHIFT); + if (shifted) { +# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) + rgblight_step_reverse(); +# endif +# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + rgb_matrix_step_reverse(); +# endif + } else { +# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) + rgblight_step(); +# endif +# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + rgb_matrix_step(); +# endif + } + } else if (keycode == RGB_MODE_REVERSE && record->event.pressed) { + uint8_t shifted = get_mods() & (MOD_MASK_SHIFT); + if (shifted) { +# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) + rgblight_step(); +# endif +# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + rgb_matrix_step(); +# endif + } else { +# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) + rgblight_step_reverse(); +# endif +# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + rgb_matrix_step_reverse(); +# endif + } + } else if (keycode == RGB_HUI) { +# ifndef SPLIT_KEYBOARD + if (record->event.pressed) { +# else + if (!record->event.pressed) { +# endif +# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) + rgblight_increase_hue(); +# endif +# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + rgb_matrix_increase_hue(); +# endif + } + } else if (keycode == RGB_HUD) { +# ifndef SPLIT_KEYBOARD + if (record->event.pressed) { +# else + if (!record->event.pressed) { +# endif +# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) + rgblight_decrease_hue(); +# endif +# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + rgb_matrix_decrease_hue(); +# endif + } + } else if (keycode == RGB_SAI) { +# ifndef SPLIT_KEYBOARD + if (record->event.pressed) { +# else + if (!record->event.pressed) { +# endif +# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) + rgblight_increase_sat(); +# endif +# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + rgb_matrix_increase_sat(); +# endif + } + } else if (keycode == RGB_SAD) { +# ifndef SPLIT_KEYBOARD + if (record->event.pressed) { +# else + if (!record->event.pressed) { +# endif +# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) + rgblight_decrease_sat(); +# endif +# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + rgb_matrix_decrease_sat(); +# endif + } + } else if (keycode == RGB_VAI) { +# ifndef SPLIT_KEYBOARD + if (record->event.pressed) { +# else + if (!record->event.pressed) { +# endif +# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) + rgblight_increase_val(); +# endif +# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + rgb_matrix_increase_val(); +# endif + } + } else if (keycode == RGB_VAD) { +# ifndef SPLIT_KEYBOARD + if (record->event.pressed) { +# else + if (!record->event.pressed) { +# endif +# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) + rgblight_decrease_val(); +# endif +# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + rgb_matrix_decrease_val(); +# endif + } + } else if (keycode == RGB_SPI) { + if (record->event.pressed) { +# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) + rgblight_increase_speed(); +# endif +# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + rgb_matrix_increase_speed(); +# endif + } + } else if (keycode == RGB_SPD) { + if (record->event.pressed) { +# if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) + rgblight_decrease_speed(); +# endif +# if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + rgb_matrix_decrease_speed(); +# endif + } + } + return false; +# endif +#endif + break; } return true; diff --git a/users/drashna/rules.mk b/users/drashna/rules.mk index 882857fc86..4d55da803f 100644 --- a/users/drashna/rules.mk +++ b/users/drashna/rules.mk @@ -1,7 +1,9 @@ SRC += drashna.c \ process_records.c -LTO_ENABLE = yes +ifneq ($(PLATFORM),CHIBIOS) + LTO_ENABLE = yes +endif SPACE_CADET_ENABLE = no ifneq ($(strip $(NO_SECRETS)), yes) @@ -58,4 +60,4 @@ endif # this should be handled per keyboard, but until that happens ... ifeq ($(strip $(PROTOCOL)), VUSB) NKRO_ENABLE = no -endif \ No newline at end of file +endif -- cgit v1.2.3