diff options
author | Drashna Jaelre <drashna@live.com> | 2019-07-22 20:22:33 -0700 |
---|---|---|
committer | MechMerlin <30334081+mechmerlin@users.noreply.github.com> | 2019-07-22 20:22:33 -0700 |
commit | d41961c9eddb78591d3b55ea65e6e0baff4bdd69 (patch) | |
tree | a2e03c31b93dc35fbdb539c59de0d2f7c655f02f /users/drashna | |
parent | 840b9090a0fd4faf070d9bbb9039337ecdb82de4 (diff) |
[Keymap] Drashna's Feature madness (#6128)
* Fix my Tap Dance issues after I broke them
* Cleanup and organization of userspace documentation
As well as some additional cleanup of functions due to review of documentation.
* Enable Tapdance on Glow and remove more animations
* Revert to Eager PR debouncing
* Add better check for startup animation
* Move where RGB Matrix defines are listed
* Limit RGB Matrix max val
* Update keyboard for Iris Rev 3 conflicts
* Enable encoder support on planck ez
* Remove is_master check from corne\'s OLED code
* Overhaul OLED screens for my Corne
* One last removal
* Show RGB valu On both sides
* Updates for OLED display info
* Fix compile issues for rgb config
* Disabled Space Cadet for all drashna keymaps
* Fix OLED Screen configs
* Minor OLED Tweaks
* Revert some Iris changes
* Fix song include
* Handle MAKE macro for the Corne boards better
* Add super hacky-hack for eeconfig initialization
* Add audio support for Fractal since Elite Cs support it
* Add defines for keycode steps
* Add White layout
* Update Corne RGB info
* Add fun effects to layer indication for RGB Matrix enabled boards
* Use proper define for product name detection
* Update formatting
* Use custom timeout mechanism for OLED timeout
* Fix up OLED screen HSV code for new HSV structure
* Better handle turning off RGB Matrix when sleeping
* Disable MultiSplash Animation
* Change Iris back to using serial
* Why was RGB disabled?!?!?!
* Limit val in rgb_matrix_layer_helper function
* Remove EECONFIG setting for RGB matrix
Diffstat (limited to 'users/drashna')
-rw-r--r-- | users/drashna/config.h | 131 | ||||
-rw-r--r-- | users/drashna/drashna.c | 138 | ||||
-rw-r--r-- | users/drashna/drashna.h | 69 | ||||
-rw-r--r-- | users/drashna/process_records.c | 257 | ||||
-rw-r--r-- | users/drashna/process_records.h | 66 | ||||
-rw-r--r-- | users/drashna/readme.md | 192 | ||||
-rw-r--r-- | users/drashna/readme_handlers.md | 97 | ||||
-rw-r--r-- | users/drashna/readme_keycodes.md | 10 | ||||
-rw-r--r-- | users/drashna/readme_rgb.md | 43 | ||||
-rw-r--r-- | users/drashna/readme_secrets.md | 123 | ||||
-rw-r--r-- | users/drashna/readme_tap_dance.md | 119 | ||||
-rw-r--r-- | users/drashna/readme_wrappers.md | 11 | ||||
-rw-r--r-- | users/drashna/rgb_stuff.c | 302 | ||||
-rw-r--r-- | users/drashna/rgb_stuff.h | 22 | ||||
-rw-r--r-- | users/drashna/rules.mk | 1 | ||||
-rw-r--r-- | users/drashna/send_unicode.h | 71 | ||||
-rw-r--r-- | users/drashna/tap_dances.c | 77 | ||||
-rw-r--r-- | users/drashna/tap_dances.h | 16 | ||||
-rw-r--r-- | users/drashna/wrappers.h | 14 |
19 files changed, 996 insertions, 763 deletions
diff --git a/users/drashna/config.h b/users/drashna/config.h index a6d8e75263..8f6e700d2b 100644 --- a/users/drashna/config.h +++ b/users/drashna/config.h @@ -1,47 +1,95 @@ #pragma once - #ifdef AUDIO_ENABLE -# define AUDIO_CLICKY -# define STARTUP_SONG SONG(RICK_ROLL) -# define GOODBYE_SONG SONG(SONIC_RING) -# define DEFAULT_LAYER_SONGS { SONG(QWERTY_SOUND), \ - SONG(COLEMAK_SOUND), \ - SONG(DVORAK_SOUND), \ - SONG(OVERWATCH_THEME) \ - } - -# define AUDIO_CLICKY_FREQ_RANDOMNESS 1.5f - -# define UNICODE_SONG_OSX SONG(RICK_ROLL) -# define UNICODE_SONG_LNX SONG(RICK_ROLL) -# define UNICODE_SONG_WIN SONG(RICK_ROLL) -# define UNICODE_SONG_BSD SONG(RICK_ROLL) -# define UNICODE_SONG_WINC SONG(RICK_ROLL) - -#endif // !AUDIO_ENABLE +# if __GNUC__ > 7 +# if __has_include("drashna_song_list.h") +# include "drashna_song_list.h" +# endif // if file exists +# endif // __GNUC__ + +# define AUDIO_CLICKY +# define STARTUP_SONG SONG(RICK_ROLL) +# define GOODBYE_SONG SONG(SONIC_RING) +# define DEFAULT_LAYER_SONGS \ + { SONG(QWERTY_SOUND), SONG(COLEMAK_SOUND), SONG(DVORAK_SOUND), SONG(OVERWATCH_THEME) } + +# define AUDIO_CLICKY_FREQ_RANDOMNESS 1.5f + +# define UNICODE_SONG_OSX SONG(RICK_ROLL) +# define UNICODE_SONG_LNX SONG(RICK_ROLL) +# define UNICODE_SONG_WIN SONG(RICK_ROLL) +# define UNICODE_SONG_BSD SONG(RICK_ROLL) +# define UNICODE_SONG_WINC SONG(RICK_ROLL) +#endif // !AUDIO_ENABLE #ifdef RGBLIGHT_ENABLE -# define RGBLIGHT_SLEEP -# undef RGBLIGHT_ANIMATIONS -# define RGBLIGHT_EFFECT_BREATHING -# define RGBLIGHT_EFFECT_SNAKE -# define RGBLIGHT_EFFECT_KNIGHT -#endif // RGBLIGHT_ENABLE +# define RGBLIGHT_SLEEP +# undef RGBLIGHT_ANIMATIONS +# define RGBLIGHT_EFFECT_BREATHING +# define RGBLIGHT_EFFECT_SNAKE +# define RGBLIGHT_EFFECT_KNIGHT +#endif // RGBLIGHT_ENABLE + +#ifdef RGB_MATRIX_ENABLE +# define RGB_MATRIX_KEYPRESSES // reacts to keypresses (will slow down matrix scan by a lot) +// # define RGB_MATRIX_KEYRELEASES // reacts to keyreleases (not recommened) +# define RGB_MATRIX_FRAMEBUFFER_EFFECTS +// # define RGB_DISABLE_AFTER_TIMEOUT 0 // number of ticks to wait until disabling effects +# define RGB_DISABLE_WHEN_USB_SUSPENDED true // turn off effects when suspended +// # define RGB_MATRIX_MAXIMUM_BRIGHTNESS 200 // limits maximum brightness of LEDs to 200 out of 255. If not defined maximum brightness is set to 255 +// # define EECONFIG_RGB_MATRIX (uint32_t *)16 + +# if defined(__AVR__) && !defined(__AVR_AT90USB1286__) +# define DISABLE_RGB_MATRIX_ALPHAS_MODS +# define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN +# define DISABLE_RGB_MATRIX_BREATHING +# define DISABLE_RGB_MATRIX_BAND_SAT +# define DISABLE_RGB_MATRIX_BAND_VAL +# define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT +# define DISABLE_RGB_MATRIX_BAND_PINWHEEL_VAL +# define DISABLE_RGB_MATRIX_BAND_SPIRAL_SAT +# define DISABLE_RGB_MATRIX_BAND_SPIRAL_VAL +# define DISABLE_RGB_MATRIX_CYCLE_ALL +# define DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT +# define DISABLE_RGB_MATRIX_CYCLE_UP_DOWN +# define DISABLE_RGB_MATRIX_CYCLE_OUT_IN +// # define DISABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL +# define DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON +# define DISABLE_RGB_MATRIX_DUAL_BEACON +# define DISABLE_RGB_MATRIX_CYCLE_PINWHEEL +# define DISABLE_RGB_MATRIX_CYCLE_SPIRAL +# define DISABLE_RGB_MATRIX_RAINBOW_BEACON +# define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS +# define DISABLE_RGB_MATRIX_RAINDROPS +# define DISABLE_RGB_MATRIX_JELLYBEAN_RAINDROPS +// # define DISABLE_RGB_MATRIX_TYPING_HEATMAP +# define DISABLE_RGB_MATRIX_DIGITAL_RAIN +# define DISABLE_RGB_MATRIX_SOLID_REACTIVE +# define DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE +# define DISABLE_RGB_MATRIX_SOLID_REACTIVE_WIDE +# define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTIWIDE +# define DISABLE_RGB_MATRIX_SOLID_REACTIVE_CROSS +# define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTICROSS +# define DISABLE_RGB_MATRIX_SOLID_REACTIVE_NEXUS +# define DISABLE_RGB_MATRIX_SOLID_REACTIVE_MULTINEXUS +# define DISABLE_RGB_MATRIX_SPLASH +# define DISABLE_RGB_MATRIX_MULTISPLASH +# define DISABLE_RGB_MATRIX_SOLID_SPLASH +# define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH +# endif // AVR +#endif // RGB_MATRIX_ENABLE #ifndef ONESHOT_TAP_TOGGLE -# define ONESHOT_TAP_TOGGLE 2 -#endif // !ONESHOT_TAP_TOGGLE +# define ONESHOT_TAP_TOGGLE 2 +#endif // !ONESHOT_TAP_TOGGLE #ifndef ONESHOT_TIMEOUT -# define ONESHOT_TIMEOUT 3000 -#endif// !ONESHOT_TIMEOUT +# define ONESHOT_TIMEOUT 3000 +#endif // !ONESHOT_TIMEOUT #ifndef QMK_KEYS_PER_SCAN -# define QMK_KEYS_PER_SCAN 4 -#endif // !QMK_KEYS_PER_SCAN - - +# define QMK_KEYS_PER_SCAN 4 +#endif // !QMK_KEYS_PER_SCAN // this makes it possible to do rolling combos (zx) with keys that // convert to other keys on hold (z becomes ctrl when you hold it, @@ -55,27 +103,26 @@ #define FORCE_NKRO #ifndef TAPPING_TOGGLE -# define TAPPING_TOGGLE 1 +# define TAPPING_TOGGLE 1 #endif #ifdef TAPPING_TERM -# undef TAPPING_TERM -#endif // TAPPING_TERM +# undef TAPPING_TERM +#endif // TAPPING_TERM #if defined(KEYBOARD_ergodox_ez) -# define TAPPING_TERM 185 +# define TAPPING_TERM 185 #elif defined(KEYBOARD_crkbd) -# define TAPPING_TERM 200 +# define TAPPING_TERM 200 #else -# define TAPPING_TERM 175 +# define TAPPING_TERM 175 #endif - #define TAP_CODE_DELAY 5 /* Disable unused and unneeded features to reduce on firmware size */ #ifdef LOCKING_SUPPORT_ENABLE -# undef LOCKING_SUPPORT_ENABLE +# undef LOCKING_SUPPORT_ENABLE #endif #ifdef LOCKING_RESYNC_ENABLE -# undef LOCKING_RESYNC_ENABLE +# undef LOCKING_RESYNC_ENABLE #endif diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c index acc6b9f9ed..c1809dad0a 100644 --- a/users/drashna/drashna.c +++ b/users/drashna/drashna.c @@ -19,22 +19,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. userspace_config_t userspace_config; #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) - #define DRASHNA_UNICODE_MODE UC_WIN +# define DRASHNA_UNICODE_MODE UC_WIN #else - // set to 2 for UC_WIN, set to 4 for UC_WINC - #define DRASHNA_UNICODE_MODE 2 +// set to 2 for UC_WIN, set to 4 for UC_WINC +# define DRASHNA_UNICODE_MODE 2 #endif - // This block is for all of the gaming macros, as they were all doing // the same thing, but with differring text sent. bool send_game_macro(const char *str, keyrecord_t *record, bool override) { if (!record->event.pressed || override) { uint16_t keycode; if (userspace_config.is_overwatch) { - keycode = KC_BSPC; + keycode = KC_BSPC; } else { - keycode = KC_ENTER; + keycode = KC_ENTER; } clear_keyboard(); tap_code(keycode); @@ -47,12 +46,12 @@ bool send_game_macro(const char *str, keyrecord_t *record, bool override) { return false; } -bool mod_key_press_timer (uint16_t code, uint16_t mod_code, bool pressed) { +bool mod_key_press_timer(uint16_t code, uint16_t mod_code, bool pressed) { static uint16_t this_timer; - if(pressed) { - this_timer= timer_read(); + if (pressed) { + this_timer = timer_read(); } else { - if (timer_elapsed(this_timer) < TAPPING_TERM){ + if (timer_elapsed(this_timer) < TAPPING_TERM) { tap_code(code); } else { register_code(mod_code); @@ -63,11 +62,11 @@ bool mod_key_press_timer (uint16_t code, uint16_t mod_code, bool pressed) { return false; } -bool mod_key_press (uint16_t code, uint16_t mod_code, bool pressed, uint16_t this_timer) { - if(pressed) { - this_timer= timer_read(); +bool mod_key_press(uint16_t code, uint16_t mod_code, bool pressed, uint16_t this_timer) { + if (pressed) { + this_timer = timer_read(); } else { - if (timer_elapsed(this_timer) < TAPPING_TERM){ + if (timer_elapsed(this_timer) < TAPPING_TERM) { tap_code(code); } else { register_code(mod_code); @@ -80,13 +79,13 @@ bool mod_key_press (uint16_t code, uint16_t mod_code, bool pressed, uint16_t thi void bootmagic_lite(void) { matrix_scan(); - #if defined(DEBOUNCING_DELAY) && DEBOUNCING_DELAY > 0 - wait_ms(DEBOUNCING_DELAY * 2); - #elif defined(DEBOUNCE) && DEBOUNCE > 0 - wait_ms(DEBOUNCE * 2); - #else - wait_ms(30); - #endif +#if defined(DEBOUNCING_DELAY) && DEBOUNCING_DELAY > 0 + wait_ms(DEBOUNCING_DELAY * 2); +#elif defined(DEBOUNCE) && DEBOUNCE > 0 + wait_ms(DEBOUNCE * 2); +#else + wait_ms(30); +#endif matrix_scan(); if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) { bootloader_jump(); @@ -97,7 +96,7 @@ void bootmagic_lite(void) { // This allows for a global, userspace functions, and continued // customization of the keymap. Use _keymap instead of _user // functions in the keymaps -__attribute__ ((weak)) +__attribute__((weak)) void matrix_init_keymap(void) {} // Call user matrix init, set default RGB colors and then @@ -105,64 +104,63 @@ void matrix_init_keymap(void) {} void matrix_init_user(void) { userspace_config.raw = eeconfig_read_user(); - #ifdef BOOTLOADER_CATERINA - DDRD &= ~(1<<5); - PORTD &= ~(1<<5); +#ifdef BOOTLOADER_CATERINA + DDRD &= ~(1 << 5); + PORTD &= ~(1 << 5); - DDRB &= ~(1<<0); - PORTB &= ~(1<<0); - #endif + DDRB &= ~(1 << 0); + PORTB &= ~(1 << 0); +#endif - #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) - set_unicode_input_mode(DRASHNA_UNICODE_MODE); - get_unicode_input_mode(); - #endif //UNICODE_ENABLE +#if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) + set_unicode_input_mode(DRASHNA_UNICODE_MODE); + get_unicode_input_mode(); +#endif // UNICODE_ENABLE matrix_init_keymap(); } __attribute__((weak)) -void keyboard_post_init_keymap(void){ } +void keyboard_post_init_keymap(void) {} -void keyboard_post_init_user(void){ +void keyboard_post_init_user(void) { #ifdef RGBLIGHT_ENABLE keyboard_post_init_rgb(); #endif keyboard_post_init_keymap(); } -__attribute__ ((weak)) +__attribute__((weak)) void shutdown_keymap(void) {} -void shutdown_user (void) { - #ifdef RGBLIGHT_ENABLE - rgblight_enable_noeeprom(); - rgblight_mode_noeeprom(1); - rgblight_setrgb_red(); - #endif // RGBLIGHT_ENABLE - #ifdef RGB_MATRIX_ENABLE - // uint16_t timer_start = timer_read(); - // rgb_matrix_set_color_all( 0xFF, 0x00, 0x00 ); - // while(timer_elapsed(timer_start) < 250) { wait_ms(1); } - #endif //RGB_MATRIX_ENABLE +void shutdown_user(void) { +#ifdef RGBLIGHT_ENABLE + rgblight_enable_noeeprom(); + rgblight_mode_noeeprom(1); + rgblight_setrgb_red(); +#endif // RGBLIGHT_ENABLE +#ifdef RGB_MATRIX_ENABLE + // uint16_t timer_start = timer_read(); + // rgb_matrix_set_color_all( 0xFF, 0x00, 0x00 ); + // while(timer_elapsed(timer_start) < 250) { wait_ms(1); } +#endif // RGB_MATRIX_ENABLE shutdown_keymap(); } -__attribute__ ((weak)) +__attribute__((weak)) void suspend_power_down_keymap(void) {} void suspend_power_down_user(void) { suspend_power_down_keymap(); } -__attribute__ ((weak)) +__attribute__((weak)) void suspend_wakeup_init_keymap(void) {} void suspend_wakeup_init_user(void) { suspend_wakeup_init_keymap(); } - -__attribute__ ((weak)) +__attribute__((weak)) void matrix_scan_keymap(void) {} // No global matrix scan code, so just run keymap's matrix @@ -176,20 +174,17 @@ void matrix_scan_user(void) { #ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code. run_diablo_macro_check(); -#endif // TAP_DANCE_ENABLE +#endif // TAP_DANCE_ENABLE #ifdef RGBLIGHT_ENABLE matrix_scan_rgb(); -#endif // RGBLIGHT_ENABLE +#endif // RGBLIGHT_ENABLE matrix_scan_keymap(); } - -__attribute__ ((weak)) -layer_state_t layer_state_set_keymap (layer_state_t state) { - return state; -} +__attribute__((weak)) +layer_state_t layer_state_set_keymap(layer_state_t state) { return state; } // on layer change, no matter where the change was initiated // Then runs keymap's layer change check @@ -197,28 +192,25 @@ layer_state_t layer_state_set_user(layer_state_t state) { state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST); #ifdef RGBLIGHT_ENABLE state = layer_state_set_rgb(state); -#endif // RGBLIGHT_ENABLE - return layer_state_set_keymap (state); +#endif // RGBLIGHT_ENABLE + return layer_state_set_keymap(state); } - -__attribute__ ((weak)) -layer_state_t default_layer_state_set_keymap (layer_state_t state) { - return state; -} +__attribute__((weak)) +layer_state_t default_layer_state_set_keymap(layer_state_t state) { return state; } // Runs state check and changes underglow color and animation layer_state_t default_layer_state_set_user(layer_state_t state) { state = default_layer_state_set_keymap(state); #if 0 -#ifdef RGBLIGHT_ENABLE +# ifdef RGBLIGHT_ENABLE state = default_layer_state_set_rgb(state); -#endif // RGBLIGHT_ENABLE +# endif // RGBLIGHT_ENABLE #endif return state; } -__attribute__ ((weak)) +__attribute__((weak)) void led_set_keymap(uint8_t usb_led) {} // Any custom LED code goes here. @@ -228,17 +220,19 @@ void led_set_user(uint8_t usb_led) { led_set_keymap(usb_led); } -__attribute__ ((weak)) +__attribute__((weak)) void eeconfig_init_keymap(void) {} void eeconfig_init_user(void) { - userspace_config.raw = 0; + userspace_config.raw = 0; userspace_config.rgb_layer_change = true; eeconfig_update_user(userspace_config.raw); - #if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) +#if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) set_unicode_input_mode(DRASHNA_UNICODE_MODE); get_unicode_input_mode(); - #else +#else eeprom_update_byte(EECONFIG_UNICODEMODE, DRASHNA_UNICODE_MODE); - #endif +#endif + eeconfig_init_keymap(); + keyboard_init(); } diff --git a/users/drashna/drashna.h b/users/drashna/drashna.h index 507504f04e..0d6dac380b 100644 --- a/users/drashna/drashna.h +++ b/users/drashna/drashna.h @@ -22,20 +22,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "wrappers.h" #include "process_records.h" #ifdef TAP_DANCE_ENABLE -# include "tap_dances.h" -#endif // TAP_DANCE_ENABLE +# include "tap_dances.h" +#endif // TAP_DANCE_ENABLE #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) -# include "rgb_stuff.h" -#endif -#if defined(AUDIO_ENABLE) && __GNUC__ > 7 -# if __has_include("drashna_song_list.h") -# include "drashna_song_list.h" -# endif +# include "rgb_stuff.h" #endif /* Define layer names */ enum userspace_layers { - _QWERTY = 0, + _QWERTY = 0, _NUMLOCK = 0, _COLEMAK, _DVORAK, @@ -58,47 +53,45 @@ enum userspace_layers { define modifiers here, since MOD_* doesn't seem to work for these */ - -bool mod_key_press_timer (uint16_t code, uint16_t mod_code, bool pressed); -bool mod_key_press (uint16_t code, uint16_t mod_code, bool pressed, uint16_t this_timer); -bool send_game_macro(const char *str, keyrecord_t *record, bool override); -void matrix_init_keymap(void); -void shutdown_keymap(void); -void suspend_power_down_keymap(void); -void suspend_wakeup_init_keymap(void); -void matrix_scan_keymap(void); -layer_state_t layer_state_set_keymap (layer_state_t state); -layer_state_t default_layer_state_set_keymap (layer_state_t state); -void led_set_keymap(uint8_t usb_led); -void eeconfig_init_keymap(void); +bool mod_key_press_timer(uint16_t code, uint16_t mod_code, bool pressed); +bool mod_key_press(uint16_t code, uint16_t mod_code, bool pressed, uint16_t this_timer); +bool send_game_macro(const char *str, keyrecord_t *record, bool override); +void matrix_init_keymap(void); +void shutdown_keymap(void); +void suspend_power_down_keymap(void); +void suspend_wakeup_init_keymap(void); +void matrix_scan_keymap(void); +layer_state_t layer_state_set_keymap(layer_state_t state); +layer_state_t default_layer_state_set_keymap(layer_state_t state); +void led_set_keymap(uint8_t usb_led); +void eeconfig_init_keymap(void); typedef union { uint32_t raw; struct { - bool rgb_layer_change :1; - bool is_overwatch :1; - bool nuke_switch :1; - uint8_t unicode_mod :4; - bool swapped_numbers :1; + bool rgb_layer_change :1; + bool is_overwatch :1; + bool nuke_switch :1; + uint8_t unicode_mod :4; + bool swapped_numbers :1; }; } userspace_config_t; extern userspace_config_t userspace_config; - /* Custom Keycodes for Diablo 3 layer But since TD() doesn't work when tap dance is disabled We use custom codes here, so we can substitute the right stuff */ #ifdef TAP_DANCE_ENABLE -# define KC_D3_1 TD(TD_D3_1) -# define KC_D3_2 TD(TD_D3_2) -# define KC_D3_3 TD(TD_D3_3) -# define KC_D3_4 TD(TD_D3_4) -#else // TAP_DANCE_ENABLE -# define KC_D3_1 KC_1 -# define KC_D3_2 KC_2 -# define KC_D3_3 KC_3 -# define KC_D3_4 KC_4 -#endif // TAP_DANCE_ENABLE +# define KC_D3_1 TD(TD_D3_1) +# define KC_D3_2 TD(TD_D3_2) +# define KC_D3_3 TD(TD_D3_3) +# define KC_D3_4 TD(TD_D3_4) +#else // TAP_DANCE_ENABLE +# define KC_D3_1 KC_1 +# define KC_D3_2 KC_2 +# define KC_D3_3 KC_3 +# define KC_D3_4 KC_4 +#endif // TAP_DANCE_ENABLE diff --git a/users/drashna/process_records.c b/users/drashna/process_records.c index 770219917e..5666d052dc 100644 --- a/users/drashna/process_records.c +++ b/users/drashna/process_records.c @@ -2,160 +2,161 @@ uint16_t copy_paste_timer; -__attribute__ ((weak)) -bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { - return true; -} +__attribute__((weak)) +bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; } -__attribute__ ((weak)) -bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { - return true; -} +__attribute__((weak)) +bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { return true; } // Defines actions tor my global custom keycodes. Defined in drashna.h file // Then runs the _keymap's record handier if not processed here bool process_record_user(uint16_t keycode, keyrecord_t *record) { - - // If console is enabled, it will print the matrix position and status of each key pressed + // If console is enabled, it will print the matrix position and status of each key pressed #ifdef KEYLOGGER_ENABLE -# if defined(KEYBOARD_ergodox_ez) || defined(KEYBOARD_keebio_iris_rev2) - xprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.row, record->event.key.col, record->event.pressed); -# else - xprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed); -# endif -#endif //KEYLOGGER_ENABLE +# if defined(KEYBOARD_ergodox_ez) || defined(KEYBOARD_keebio_iris_rev2) + xprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.row, record->event.key.col, record->event.pressed); +# else + xprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed); +# endif +#endif // KEYLOGGER_ENABLE switch (keycode) { - case KC_QWERTY ... KC_CARPLAX: - if (record->event.pressed) { - set_single_persistent_default_layer(keycode - KC_QWERTY); - } - break; + case KC_QWERTY ... KC_CARPLAX: + if (record->event.pressed) { + set_single_persistent_default_layer(keycode - KC_QWERTY); + } + break; - case KC_MAKE: // Compiles the firmware, and adds the flash command based on keyboard bootloader - if (!record->event.pressed) { - uint8_t temp_mod = get_mods(); - uint8_t temp_osm = get_oneshot_mods(); - clear_mods(); clear_oneshot_mods(); - send_string_with_delay_P(PSTR("make " QMK_KEYBOARD ":" QMK_KEYMAP), TAP_CODE_DELAY); + case KC_MAKE: // Compiles the firmware, and adds the flash command based on keyboard bootloader + if (!record->event.pressed) { + uint8_t temp_mod = get_mods(); + uint8_t temp_osm = get_oneshot_mods(); + clear_mods(); + clear_oneshot_mods(); + send_string_with_delay_P(PSTR("make " QMK_KEYBOARD ":" QMK_KEYMAP), TAP_CODE_DELAY); #ifndef MAKE_BOOTLOADER - if ( ( temp_mod | temp_osm ) & MOD_MASK_SHIFT ) + if ((temp_mod | temp_osm) & MOD_MASK_SHIFT) #endif - { - #if defined(__arm__) - send_string_with_delay_P(PSTR(":dfu-util"), TAP_CODE_DELAY); - #elif defined(BOOTLOADER_DFU) - send_string_with_delay_P(PSTR(":dfu"), TAP_CODE_DELAY); - #elif defined(BOOTLOADER_HALFKAY) - send_string_with_delay_P(PSTR(":teensy"), TAP_CODE_DELAY); - #elif defined(BOOTLOADER_CATERINA) - send_string_with_delay_P(PSTR(":avrdude"), TAP_CODE_DELAY); - #endif // bootloader options - } - if ( ( temp_mod | temp_osm ) & MOD_MASK_CTRL) { send_string_with_delay_P(PSTR(" -j8 --output-sync"), TAP_CODE_DELAY); } + { +#if defined(__arm__) + send_string_with_delay_P(PSTR(":dfu-util"), TAP_CODE_DELAY); +#elif defined(BOOTLOADER_DFU) + send_string_with_delay_P(PSTR(":dfu"), TAP_CODE_DELAY); +#elif defined(BOOTLOADER_HALFKAY) + send_string_with_delay_P(PSTR(":teensy"), TAP_CODE_DELAY); +#elif defined(BOOTLOADER_CATERINA) + send_string_with_delay_P(PSTR(":avrdude"), TAP_CODE_DELAY); +#endif // bootloader options + } + if ((temp_mod | temp_osm) & MOD_MASK_CTRL) { + send_string_with_delay_P(PSTR(" -j8 --output-sync"), TAP_CODE_DELAY); + } #ifdef RGB_MATRIX_SPLIT_RIGHT - send_string_with_delay_P(PSTR(" RGB_MATRIX_SPLIT_RIGHT=yes OLED_DRIVER_ENABLE=no"), TAP_CODE_DELAY); + send_string_with_delay_P(PSTR(" RGB_MATRIX_SPLIT_RIGHT=yes"), TAP_CODE_DELAY); +# ifndef OLED_DRIVER_ENABLE + send_string_with_delay_P(PSTR(" OLED_DRIVER_ENABLE=no"), TAP_CODE_DELAY); +# endif #endif - send_string_with_delay_P(PSTR(SS_TAP(X_ENTER)), TAP_CODE_DELAY); - } + send_string_with_delay_P(PSTR(SS_TAP(X_ENTER)), TAP_CODE_DELAY); + } - break; + break; - case VRSN: // Prints firmware version - if (record->event.pressed) { - send_string_with_delay_P(PSTR(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION ", Built on: " QMK_BUILDDATE), TAP_CODE_DELAY); - } - break; + case VRSN: // Prints firmware version + if (record->event.pressed) { + send_string_with_delay_P(PSTR(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION ", Built on: " QMK_BUILDDATE), TAP_CODE_DELAY); + } + break; - // These are a serious of gaming macros. - // Only enables for the viterbi, basically, - // to save on firmware space, since it's limited. + // These are a serious of gaming macros. + // Only enables for the viterbi, basically, + // to save on firmware space, since it's limited. #ifdef MACROS_ENABLED - case KC_OVERWATCH: // Toggle's if we hit "ENTER" or "BACKSPACE" to input macros - if (record->event.pressed) { userspace_config.is_overwatch ^= 1; eeconfig_update_user(userspace_config.raw); } -#ifdef RGBLIGHT_ENABLE - userspace_config.is_overwatch ? rgblight_mode_noeeprom(17) : rgblight_mode_noeeprom(18); -#endif //RGBLIGHT_ENABLE - break; - case KC_SALT: - return send_game_macro("Salt, salt, salt...", record, false); - case KC_MORESALT: - return send_game_macro("Please sir, can I have some more salt?!", record, false); - case KC_SALTHARD: - return send_game_macro("Your salt only makes me harder, and even more aggressive!", record, false); - case KC_GOODGAME: - return send_game_macro("Good game, everyone!", record, false); - case KC_GLHF: - return send_game_macro("Good luck, have fun!!!", record, false); - case KC_SYMM: - return send_game_macro("Left click to win!", record, false); - case KC_JUSTGAME: - return send_game_macro("It may be a game, but if you don't want to actually try, please go play AI, so that people that actually want to take the game seriously and \"get good\" have a place to do so without trolls like you throwing games.", record, false); - case KC_TORB: - return send_game_macro("That was positively riveting!", record, false); - case KC_AIM: - send_game_macro("That aim is absolutely amazing. It's almost like you're a machine!", record, true); - return send_game_macro("Wait! That aim is TOO good! You're clearly using an aim hack! CHEATER!", record, false); - case KC_C9: - return send_game_macro("OMG!!! C9!!!", record, false); - case KC_GGEZ: - return send_game_macro("That was a fantastic game, though it was a bit easy. Try harder next time!", record, false); -#endif // MACROS_ENABLED - + case KC_OVERWATCH: // Toggle's if we hit "ENTER" or "BACKSPACE" to input macros + if (record->event.pressed) { + userspace_config.is_overwatch ^= 1; + eeconfig_update_user(userspace_config.raw); + } +# ifdef RGBLIGHT_ENABLE + userspace_config.is_overwatch ? rgblight_mode_noeeprom(17) : rgblight_mode_noeeprom(18); +# endif // RGBLIGHT_ENABLE + break; + case KC_SALT: + return send_game_macro("Salt, salt, salt...", record, false); + case KC_MORESALT: + return send_game_macro("Please sir, can I have some more salt?!", record, false); + case KC_SALTHARD: + return send_game_macro("Your salt only makes me harder, and even more aggressive!", record, false); + case KC_GOODGAME: + return send_game_macro("Good game, everyone!", record, false); + case KC_GLHF: + return send_game_macro("Good luck, have fun!!!", record, false); + case KC_SYMM: + return send_game_macro("Left click to win!", record, false); + case KC_JUSTGAME: + return send_game_macro("It may be a game, but if you don't want to actually try, please go play AI, so that people that actually want to take the game seriously and \"get good\" have a place to do so without trolls like you throwing games.", record, false); + case KC_TORB: + return send_game_macro("That was positively riveting!", record, false); + case KC_AIM: + send_game_macro("That aim is absolutely amazing. It's almost like you're a machine!", record, true); + return send_game_macro("Wait! That aim is TOO good! You're clearly using an aim hack! CHEATER!", record, false); + case KC_C9: + return send_game_macro("OMG!!! C9!!!", record, false); + case KC_GGEZ: + return send_game_macro("That was a fantastic game, though it was a bit easy. Try harder next time!", record, false); +#endif // MACROS_ENABLED - case KC_DIABLO_CLEAR: // reset all Diablo timers, disabling them + case KC_DIABLO_CLEAR: // reset all Diablo timers, disabling them #ifdef TAP_DANCE_ENABLE - if (record->event.pressed) { - uint8_t dtime; - for (dtime = 0; dtime < 4; dtime++) { - diablo_timer[dtime].key_time = diablo_times[0]; + if (record->event.pressed) { + for (uint8_t index = 0; index < 4; index++) { + diablo_timer[index].key_interval = 0; + } } - } -#endif // TAP_DANCE_ENABLE - break; +#endif // TAP_DANCE_ENABLE + break; - - case KC_CCCV: // One key copy/paste - if(record->event.pressed){ - copy_paste_timer = timer_read(); + case KC_CCCV: // One key copy/paste + if (record->event.pressed) { + 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); - } else { // Tap, paste - register_code(KC_LCTL); - tap_code(KC_V); - unregister_code(KC_LCTL); + if (timer_elapsed(copy_paste_timer) > TAPPING_TERM) { // Hold, copy + register_code(KC_LCTL); + tap_code(KC_C); + unregister_code(KC_LCTL); + } else { // Tap, paste + register_code(KC_LCTL); + tap_code(KC_V); + unregister_code(KC_LCTL); + } } - } - break; + break; #ifdef UNICODE_ENABLE - case UC_FLIP: // (ノಠ痊ಠ)ノ彡┻━┻ - if (record->event.pressed) { - send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B"); - } - break; - case UC_TABL: // ┬─┬ノ( º _ ºノ) - if (record->event.pressed) { - send_unicode_hex_string("252C 2500 252C 30CE 0028 0020 00BA 0020 005F 0020 00BA 30CE 0029"); - } - break; - case UC_SHRG: // ¯\_(ツ)_/¯ - if (record->event.pressed) { - send_unicode_hex_string("00AF 005C 005F 0028 30C4 0029 005F 002F 00AF"); - } - break; - case UC_DISA: // ಠ_ಠ - if (record->event.pressed) { - send_unicode_hex_string("0CA0 005F 0CA0"); - } - break; + case UC_FLIP: // (ノಠ痊ಠ)ノ彡┻━┻ + if (record->event.pressed) { + send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B"); + } + break; + case UC_TABL: // ┬─┬ノ( º _ ºノ) + if (record->event.pressed) { + send_unicode_hex_string("252C 2500 252C 30CE 0028 0020 00BA 0020 005F 0020 00BA 30CE 0029"); + } + break; + case UC_SHRG: // ¯\_(ツ)_/¯ + if (record->event.pressed) { + send_unicode_hex_string("00AF 005C 005F 0028 30C4 0029 005F 002F 00AF"); + } + break; + case UC_DISA: // ಠ_ಠ + if (record->event.pressed) { + send_unicode_hex_string("0CA0 005F 0CA0"); + } + break; #endif } return process_record_keymap(keycode, record) && #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) - process_record_user_rgb(keycode, record) && -#endif // RGBLIGHT_ENABLE - process_record_secrets(keycode, record); + process_record_user_rgb(keycode, record) && +#endif // RGBLIGHT_ENABLE + process_record_secrets(keycode, record); } diff --git a/users/drashna/process_records.h b/users/drashna/process_records.h index 35adec84cc..8901a6f91c 100644 --- a/users/drashna/process_records.h +++ b/users/drashna/process_records.h @@ -2,24 +2,24 @@ #include "drashna.h" #if defined(KEYMAP_SAFE_RANGE) -# define PLACEHOLDER_SAFE_RANGE KEYMAP_SAFE_RANGE +# define PLACEHOLDER_SAFE_RANGE KEYMAP_SAFE_RANGE #else -# define PLACEHOLDER_SAFE_RANGE SAFE_RANGE +# define PLACEHOLDER_SAFE_RANGE SAFE_RANGE #endif enum userspace_custom_keycodes { - VRSN = PLACEHOLDER_SAFE_RANGE, // Prints QMK Firmware and board info - KC_QWERTY, // Sets default layer to QWERTY - KC_COLEMAK, // Sets default layer to COLEMAK - KC_DVORAK, // Sets default layer to DVORAK - KC_WORKMAN, // Sets default layer to WORKMAN - KC_NORMAN, // Sets default layer to NORMAN - KC_MALTRON, // Sets default layer to MALTRON - KC_EUCALYN, // Sets default layer to EUCALYN - KC_CARPLAX, // Sets default layer to CARPLAX - KC_DIABLO_CLEAR, // Clears all Diablo Timers - KC_OVERWATCH, // Toggles game macro input mode (so in OW, it defaults to game chat) - KC_SALT, // See drashna.c for details + VRSN = PLACEHOLDER_SAFE_RANGE, // Prints QMK Firmware and board info + KC_QWERTY, // Sets default layer to QWERTY + KC_COLEMAK, // Sets default layer to COLEMAK + KC_DVORAK, // Sets default layer to DVORAK + KC_WORKMAN, // Sets default layer to WORKMAN + KC_NORMAN, // Sets default layer to NORMAN + KC_MALTRON, // Sets default layer to MALTRON + KC_EUCALYN, // Sets default layer to EUCALYN + KC_CARPLAX, // Sets default layer to CARPLAX + KC_DIABLO_CLEAR, // Clears all Diablo Timers + KC_OVERWATCH, // Toggles game macro input mode (so in OW, it defaults to game chat) + KC_SALT, // See drashna.c for details KC_MORESALT, KC_SALTHARD, KC_GOODGAME, @@ -30,27 +30,25 @@ enum userspace_custom_keycodes { KC_AIM, KC_C9, KC_GGEZ, - KC_MAKE, // Run keyboard's customized make command - KC_RGB_T, // Toggles RGB Layer Indication mode - KC_SECRET_1, // test1 - KC_SECRET_2, // test2 - KC_SECRET_3, // test3 - KC_SECRET_4, // test4 - KC_SECRET_5, // test5 - KC_CCCV, // Hold to copy, tap to paste - KC_NUKE, // NUCLEAR LAUNCH DETECTED!!! - UC_FLIP, // (ಠ痊ಠ)┻━┻ - UC_TABL, // ┬─┬ノ( º _ ºノ) - UC_SHRG, // ¯\_(ツ)_/¯ - UC_DISA, // ಠ_ಠ - NEW_SAFE_RANGE //use "NEWPLACEHOLDER for keymap specific codes + KC_MAKE, // Run keyboard's customized make command + KC_RGB_T, // Toggles RGB Layer Indication mode + KC_SECRET_1, // test1 + KC_SECRET_2, // test2 + KC_SECRET_3, // test3 + KC_SECRET_4, // test4 + KC_SECRET_5, // test5 + KC_CCCV, // Hold to copy, tap to paste + KC_NUKE, // NUCLEAR LAUNCH DETECTED!!! + UC_FLIP, // (ಠ痊ಠ)┻━┻ + UC_TABL, // ┬─┬ノ( º _ ºノ) + UC_SHRG, // ¯\_(ツ)_/¯ + UC_DISA, // ಠ_ಠ + NEW_SAFE_RANGE // use "NEWPLACEHOLDER for keymap specific codes }; bool process_record_secrets(uint16_t keycode, keyrecord_t *record); bool process_record_keymap(uint16_t keycode, keyrecord_t *record); - - #define LOWER MO(_LOWER) #define RAISE MO(_RAISE) #define ADJUST MO(_ADJUST) @@ -74,10 +72,10 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record); #define KC_RST KC_RESET #ifdef SWAP_HANDS_ENABLE -#define KC_C1R3 SH_TT -#else // SWAP_HANDS_ENABLE -#define KC_C1R3 KC_BSPC -#endif // SWAP_HANDS_ENABLE +# define KC_C1R3 SH_TT +#else // SWAP_HANDS_ENABLE +# define KC_C1R3 KC_BSPC +#endif // SWAP_HANDS_ENABLE #define BK_LWER LT(_LOWER, KC_BSPC) #define SP_LWER LT(_LOWER, KC_SPC) diff --git a/users/drashna/readme.md b/users/drashna/readme.md index ffc60060f4..d98d1d0a6b 100644 --- a/users/drashna/readme.md +++ b/users/drashna/readme.md @@ -2,192 +2,14 @@ This is my personal userspace file. Most of my code exists here, as it's heavily shared. -## Custom userspace handlers +* [RGB Customization](readme_rgb.md) +* [Diablo Tap Dancing](readme_tap_dance.md) +* [Keymap Wrappers](readme_wrappers.md) +* [Custom Function Handlers](readme_handlers.md) +* [Secret Macros](readme_secrets.md) +* [Custom Keycodes](readme_keycodes.md) -Specifically QMK works by using customized handlers for everything. This allows for multiple levels of customization. - -`matrix_scan` calls `matrix_scan_quantum`, which alls `matrix_scan_kb`, which calls `matrix_scan_user`. -`process_record` calls a bunch of stuff, but eventually calls `process_record_kb` which calls `process_record_user` -The same goes for `matrix_init`, `layer_state_set`, `led_set`, and a few other functions. - -All (most) `_user` functions are handled here instead. To allow keyboard specific configuration, I've created `_keymap` functions that can be called by the keymap.c files instead. - -This allows for keyboard specific configuration while maintaining the ability to customize the board. - -My [Ergodox EZ Keymap](https://github.com/qmk/qmk_firmware/blob/master/layouts/community/ergodox/drashna/keymap.c#L297) is a good example of this, as it uses the LEDs as modifier indicators. - -## Keyboard Layout Templates - -This borrows from @jola5's "Not quite neo" code. This allows me to maintain blocks of keymaps in the userspace, so that I can modify the userspace, and this is reflected in all of the keyboards that use it, at once. - -This makes adding tap/hold mods, or other special keycodes or functions to all keyboards super easy, as it's done to all of them at once. - -The caveat here is that the keymap needs a processor/wrapper, as it doesn't like the substitutions. However, this is as simple as just pushing it through a define. For instance: - -`#define LAYOUT_ergodox_wrapper(...) LAYOUT_ergodox(__VA_ARGS__)` - -Once that's been done and you've switched the keymaps to use the "wrapper", it will read the substitution blocks just fine. - -Credit goes to @jola5 for first implementing this awesome idea. - - -## Custom Keycodes - -Keycodes are defined in the drashna.h file and need to be included in the keymap.c files, so that they can be used there. - -A bunch of macros are present and are only included on boards that are not the Ergodox EZ or Orthodox, as they are not needed for those boards. - -Included is a custom macro for compiling my keyboards. This includes the bootloader target (`:teensy`, `:avrdude`, or `:dfu`), and keeps RGBLIGHT, AUDIO and/or FAUXCLICKY enabled, if it previously was (regardless of the rules file). - -This also includes a modified RESET keycode as well, that sets the underglow to red. - -## Layer Indication - -This uses the `layer_state_set_*` command to change the layer color, to indicate which layer it is on. This includes the default keymap, as well. - -Since this is done via userspace, it is the same between all systems. - -Additionally, there is a custom keycode to toggle layer indication. And all RGB keycodes disable layer indication by default, as well. This way, I can leave special effects doing when I want. - -Also. I use `rgblight_sethsv` since it works with animation modes (that support it). - -## Diablo Layer - -This layer has some special handling. - -When Tap Dances are enabled, this layer has the ability to "spam" keypresses. - -For instance, tapping the TD "1" twice causes the layer to hit "1" ever 1 second (appoximately). This is useful for auto-hotkeying skills (such as bone armor or devour). - -Tappind once disables this, and switching layers temporarily disables this, until you switch back to the layer. - -For critics that think this is cheating, search "diablo 3 num lock auto cast". This is just a simpler method, since I no longer own a normal (non QMK) numpad. - -## Secret Macros - -With help from gitter and Colinta, this adds the ability to add hidden macros from other users. - -First, I have several files that are hidden/excluded from Git/GitHub. These contain everything needed for the macros. To hide these files, open `.git/info/exclude` and add `secrets.c` and `secrets.h` to that file, below the comments. - -And this requires `KC_SECRET_1` through `KC_SECRET_5` to be defined in your `<name>.h` file to define the keycodes for the new macros. - - -### .git/info/exclude - -``` -# git ls-files --others --exclude-from=.git/info/exclude -# Lines that start with '#' are comments. -# For a project mostly in C, the following would be a good set of -# exclude patterns (uncomment them if you want to use them): -# *.[oa] -# *~ -/users/drashna/secrets.c -/users/drashna/secrets.h -``` - -Then you can create these files: - -### secrets.c - -```c -#include "drashna.h" // replace with your keymap's "h" file, or whatever file stores the keycodes - -#if (__has_include("secrets.h") && !defined(NO_SECRETS)) -#include "secrets.h" -#else -// `PROGMEM const char secret[][x]` may work better, but it takes up more space in the firmware -// And I'm not familiar enough to know which is better or why... -static const char * const secret[] = { - "test1", - "test2", - "test3", - "test4", - "test5" -}; -#endif - -bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { - switch (keycode) { - case KC_SECRET_1 ... KC_SECRET_5: // Secrets! Externally defined strings, not stored in repo - if (!record->event.pressed) { - clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); - send_string_with_delay(secret[keycode - KC_SECRET_1], MACRO_TIMER); - } - return false; - break; - } - return true; -} -``` - -### secrets.h - -```c -static const char * const secrets[] = { - "secret1", - "secret2", - "secret3", - "secret4", - "secret5" -}; -``` - -Replacing the strings with the codes that you need. - -### name.c - -In the `<name>.c` file, you will want to add this to the top: - -```c -__attribute__ ((weak)) -bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { - return true; -} -``` - -This is so that the function can be called here, and replaced in the `secrets.c` file, and so it won't error out if it doesn't exist. - -And then, in the `process_record_user` function, assuming you have `return process_record_keymap(keycode, record)` here, you'll want to replace the "final" return with the following. Otherwise, you want to replace the `return true;` with `return process_record_secrets(keycode, record);` - -```c - return process_record_keymap(keycode, record) && process_record_secrets(keycode, record); -} -``` - -### rules.mk - -Here, you want your `/users/<name>/rules.mk` file to "detect" the existence of the `secrets.c` file, and only add it if the file exists. To do so, add this block: - -```make -ifneq ("$(wildcard $(USER_PATH)/secrets.c)","") - SRC += secrets.c -endif -``` - -Additionally, if you want to make sure that you can disable the function without messing with the file, you need to add this to your `/users/<name>/rules.mk`, so that it catches the flag: - -```make -ifeq ($(strip $(NO_SECRETS)), yes) - OPT_DEFS += -DNO_SECRETS -endif -``` - -Then, if you run `make keyboard:name NO_SECRETS=yes`, it will default to the test strings in your `<name>.c` file, rather than reading from your file. ## Pro Micro Hacking -Well, you can get the QMK DFU bootloader working on the ProMicro. But you need to change fuses. - -What worked to get into the firmware properly was: - -``` -Low: 0x5E High: 0xD9 Extended: 0xC3 Lock: 0x3F -``` - -The reason that there was some issues before, is that JTAG was still enabled, and using some of the pins that the keyboard uses. Disabling JTAG (either by fuse, or modifying the matrix code for splits fixes the issue). - -And for reference, if you want to go back to caterina, the default fuse settings I believe were: - -``` -Low: 0xFF High: 0xD8 Extended: 0xC3 Lock: 0x3F -``` +See [this thread](https://www.reddit.com/r/olkb/comments/8sxgzb/replace_pro_micro_bootloader_with_qmk_dfu/) for details on how to flash QMK DFU to Pro Micros. diff --git a/users/drashna/readme_handlers.md b/users/drashna/readme_handlers.md new file mode 100644 index 0000000000..4abaf51473 --- /dev/null +++ b/users/drashna/readme_handlers.md @@ -0,0 +1,97 @@ +# Custom Userspace Function handlers + +Specifically QMK works by using customized handlers for everything. This allows for multiple levels of customization. + +`matrix_scan` calls `matrix_scan_quantum`, which calls `matrix_scan_kb`, which calls `matrix_scan_user`. +`process_record` calls a bunch of stuff, but eventually calls `process_record_kb` which calls `process_record_user` +The same goes for `matrix_init`, `layer_state_set`, `led_set`, and a few other functions. + +All (most) `_user` functions are handled here, in the userspace instead. To allow keyboard specific configuration, I've created `_keymap` functions that can be called by the keymap.c files instead. + +This allows for keyboard specific configuration while maintaining the ability to customize the board. + +My [Ergodox EZ Keymap](https://github.com/qmk/qmk_firmware/blob/master/layouts/community/ergodox/drashna/keymap.c) is a good example of this, as it uses the LEDs as modifier indicators. + +But for a list: + +```c +__attribute__ ((weak)) +void matrix_init_keymap(void) {} + +void matrix_init_user(void) { + matrix_init_keymap(); +} + +__attribute__((weak)) +void keyboard_post_init_keymap(void){ } + +void keyboard_post_init_user(void){ + keyboard_post_init_keymap(); +} + +__attribute__ ((weak)) +void matrix_scan_keymap(void) {} + +void matrix_scan_user(void) { + matrix_scan_keymap(); +} + + +__attribute__ ((weak)) +bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { + return true; +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + return process_record_keymap(keycode, record); +} + + +__attribute__ ((weak)) +layer_state_t layer_state_set_keymap (layer_state_t state) { + return state; +} + +layer_state_t layer_state_set_user (layer_state_t state) { + return layer_state_set_keymap (state); +} + + +__attribute__ ((weak)) +void led_set_keymap(uint8_t usb_led) {} + +void led_set_user(uint8_t usb_led) { + led_set_keymap(usb_led); +} + + +__attribute__ ((weak)) +void suspend_power_down_keymap(void) {} + +void suspend_power_down_user(void) { + suspend_power_down_keymap(); +} + + +__attribute__ ((weak)) +void suspend_wakeup_init_keymap(void) {} + +void suspend_wakeup_init_user(void) { + suspend_wakeup_init_keymap(); +} + + +__attribute__ ((weak)) +void shutdown_keymap(void) {} + +void shutdown_user (void) { + shutdown_keymap(); +} + +__attribute__ ((weak)) +void eeconfig_init_keymap(void) {} + +void eeconfig_init_user(void) { + eeconfig_init_keymap(); +} +``` diff --git a/users/drashna/readme_keycodes.md b/users/drashna/readme_keycodes.md new file mode 100644 index 0000000000..f5e6fb271e --- /dev/null +++ b/users/drashna/readme_keycodes.md @@ -0,0 +1,10 @@ + +# Custom Keycodes + +Keycodes are defined in the drashna.h file and need to be included in the keymap.c files, so that they can be used there. + +A bunch of macros are present and are only included on boards that are not the Ergodox EZ or Orthodox, as they are not needed for those boards. + +Included is a custom macro for compiling my keyboards. This includes the bootloader target (`:teensy`, `:avrdude`, or `:dfu`), and keeps RGBLIGHT, AUDIO and/or FAUXCLICKY enabled, if it previously was (regardless of the rules file). + +This also includes a modified RESET keycode as well, that sets the underglow to red. diff --git a/users/drashna/readme_rgb.md b/users/drashna/readme_rgb.md new file mode 100644 index 0000000000..acf01b051e --- /dev/null +++ b/users/drashna/readme_rgb.md @@ -0,0 +1,43 @@ +# Layer Indication Code + +At least for RGB Light, the `layer_state_set` function is used to detect the current highest layer, and change the underglow based on that layer. + +This works for both the regular layers, and for the default layers, too. + +I use the sethsv variants of the commands, so that different modes can be used, as well. + +RGB Matrix uses a custom, per board implementation, at the moment. + +# RGB Light Startup Animation + +On startup, if enabled, the board will cycle through the entire hue wheel, starting and ending on the default layer color. + +```c +void keyboard_post_init_rgb(void) { +#if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_STARTUP_ANIMATION) + if (userspace_config.rgb_layer_change) { rgblight_enable_noeeprom(); } + if (rgblight_config.enable) { + layer_state_set_user(layer_state); + uint16_t old_hue = rgblight_config.hue; + rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); + for (uint16_t i = 255; i > 0; i--) { + rgblight_sethsv_noeeprom( ( i + old_hue) % 255, 255, 255); + matrix_scan(); + wait_ms(10); + } + } +#endif + layer_state_set_user(layer_state); +} +``` + +This could probably benefit from some cleanup and better handling. + + +# RGB Light Twinkling + +This enables random twinkling of the LEDs when typing. + +# RGB Light Mod Indicators + +Allows feedback of which mods (oneshot or otherwise) are enabled. diff --git a/users/drashna/readme_secrets.md b/users/drashna/readme_secrets.md new file mode 100644 index 0000000000..a9408dc2ef --- /dev/null +++ b/users/drashna/readme_secrets.md @@ -0,0 +1,123 @@ +# Secret Macros + +With help from gitter and Colinta, this adds the ability to add hidden macros from other users. + +First, I have several files that are hidden/excluded from Git/GitHub. These contain everything needed for the macros. To hide these files, open `.git/info/exclude` and add `secrets.c` and `secrets.h` to that file, below the comments. + +And this requires `KC_SECRET_1` through `KC_SECRET_5` to be added in your keycode enum (usually in your `<name>.h` file) the keycodes for the new macros. + +## Git Exclusion + +To prevent `git` from seeing, or committing the secret files, you can exclude them. What's the point of having secrets if they're posted on GitHub for everyone to see!?! + +You can do this with the `.git/info/exclude` file, so that it's only ignored locally. Unfortunately, that means it's not consistently handled on each system. + +However, if you create a `.gitignore` file in the same folder, you keep things consistent between every system that the code is checked out on. + +```c +secrets.c +secrets.h +``` + +## secrets.c + +Here is the magic. This handles including the "secrets", and adding the custom macros to send them. + +```c +#include "drashna.h" // replace with your keymap's "h" file, or whatever file stores the keycodes + +#if (__has_include("secrets.h") && !defined(NO_SECRETS)) +#include "secrets.h" +#else +// `PROGMEM const char secret[][x]` may work better, but it takes up more space in the firmware +// And I'm not familiar enough to know which is better or why... +static const char * const secret[] = { + "test1", + "test2", + "test3", + "test4", + "test5" +}; +#endif + +bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case KC_SECRET_1 ... KC_SECRET_5: // Secrets! Externally defined strings, not stored in repo + if (!record->event.pressed) { + clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); + send_string_with_delay(secret[keycode - KC_SECRET_1], MACRO_TIMER); + } + return false; + break; + } + return true; +} +``` + +## secrets.h + +Now, for the actual secrets! The file needs to look like + +```c +static const char * secrets[] = { + "secret1", + "secret2", + "secret3", + "secret4", + "secret5" +}; +``` + +Replacing the strings with the codes that you need. + +## Process Record + +In whichever file you have your `process_record_*` function in, you will want to add this to the top: + +```c +__attribute__ ((weak)) +bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { + return true; +} +``` + +This is so that the function can be called here, and replaced in the `secrets.c` file, and so it won't error out if it doesn't exist. + +And then, in the `process_record_user` function, assuming you have `return process_record_keymap(keycode, record)` here, you'll want to replace the "final" return with the following. Otherwise, you want to replace the `return true;` with `return process_record_secrets(keycode, record);` + +```c +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + // your existing macro code here. + return process_record_keymap(keycode, record) && process_record_secrets(keycode, record); +} +``` + +## rules.mk + +Here, you want your `/users/<name>/rules.mk` file to "detect" the existence of the `secrets.c` file, and only add it if the file exists. + +Additionally, to ensure that it's not added or processed in any way, it checks to see if `NO_SECRETS` is set. This way, if you run `make keyboard:name NO_SECRETS=yes`, it will remove the feature altogether. + +```make +ifneq ($(strip $(NO_SECRETS)), yes) + ifneq ("$(wildcard $(USER_PATH)/secrets.c)","") + SRC += secrets.c + endif +endif +``` + +Alternately, if you want to make sure that you can disable the function without messing with the file, you need to add this to your `/users/<name>/rules.mk`, so that it catches the flag: + +```make +ifneq ("$(wildcard $(USER_PATH)/secrets.c)","") + SRC += secrets.c +endif + +ifeq ($(strip $(NO_SECRETS)), yes) + OPT_DEFS += -DNO_SECRETS +endif +``` + +## Extras + +Additionally, because this file isn't present in the repo at all, you could add additional functionality that nobody else will see. diff --git a/users/drashna/readme_tap_dance.md b/users/drashna/readme_tap_dance.md new file mode 100644 index 0000000000..a61dd1f2b0 --- /dev/null +++ b/users/drashna/readme_tap_dance.md @@ -0,0 +1,119 @@ +# Diablo Tap Dances + +My [Tap Dance](https://github.com/qmk/qmk_firmware/blob/master/users/drashna/tap_dances.c) file includes the tap dance declarations, and everything needed for them. + +This is used for making Diablo 3 much easier to plan, especially at high rift levels. + +This works by using Tap Dances. The taps don't actually "do anything". Instead, it sets up the interval for how often to send specific keypresses. As you can tell, this makes automating things very easy. + +For critics that think this is cheating, just search "[diablo 3 num lock auto cast](http://lmgtfy.com/?q=diablo+3+numlock+autocast)". This is just a simpler method, that doesn't require a numpad. + + +## Custom Tap Dance Type +The real fun here is that the tap dances use a custom defined Tap Dance type: + +```c +#define ACTION_TAP_DANCE_DIABLO(index, keycode) { \ + .fn = { NULL, (void *)diablo_tapdance_master, NULL }, \ + .user_data = (void *)&((diable_keys_t) { index, keycode }), \ + } +``` +This lets me set an index and keycode for the tap dance. This isn't the cool part yet, but this allows for the really cool stuff. + +The Index is needed because I don't know how to handle it otherwise. + +## The Actual Dances + +These are the custom defined dances that I'm using. It sets up everything for later, using the above custom dance type. + +```c +//Tap Dance Definitions, sets the index and the keycode. +qk_tap_dance_action_t tap_dance_actions[] = { + // tap once to disable, and more to enable timed micros + [TD_D3_1] = ACTION_TAP_DANCE_DIABLO(0, KC_1), + [TD_D3_2] = ACTION_TAP_DANCE_DIABLO(1, KC_2), + [TD_D3_3] = ACTION_TAP_DANCE_DIABLO(2, KC_3), + [TD_D3_4] = ACTION_TAP_DANCE_DIABLO(3, KC_4), +}; +``` + +## Custom Data Structures + +First, to get this all working, there are a couple of things that need to be set up. In a header file (or you could put it into the keymap), you need to create a couple of custom structures: + +```c +typedef struct { + uint16_t timer; + uint8_t key_interval; + uint8_t keycode; +} diablo_timer_t; + +typedef struct { + uint8_t index; + uint8_t keycode; +} diable_keys_t; +``` + +The first structure is for tracking each key that is being used. The second is to pass data from the Tap Dance action array to the actual function that we will need. + + +## Custom Arrays + +To facilitate things, you will need a couple of arrays in your `c` file. + +```c +//define diablo macro timer variables +diablo_timer_t diablo_timer[4]; + +// Set the default intervals. Always start with 0 so that it will disable on first hit. +// Otherwise, you will need to hit a bunch of times, or hit the "clear" command +uint8_t diablo_times[] = { 0, 1, 3, 5, 10, 30 }; +``` + +The first one (`diablo_timer`) is what keeps track of the timer used for the keys, the interval that it uses, and the actual keycode. This makes managing it a lot easier. + +The second array is a list of predefined intervals, in seconds. You can add more here, or remove entries. It doesn't matter how long the array is, as this is computed automatically. + +## The Magic - Part 1: Master function + +The first part of the magic here is the `diablo_tapdance_master` function. The Tap Dance feature calls this function, directly, and passes some data to the function. Namely, it passes the array of the index and the keycode (`diablo_keys_t` from above). This sets the keycode and the interval for the specific index of `diabolo_timer` based on the number of taps. If you hit it more than the number of items in the array, then it zeroes out the interval, disabling it. + +```c +// Cycle through the times for the macro, starting at 0, for disabled. +void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data) { + diable_keys_t *diablo_keys = (diable_keys_t *)user_data; + // Sets the keycode based on the index + diablo_timer[diablo_keys->index].keycode = diablo_keys->keycode; + + // if the tapdance is hit more than the number of elemints in the array, reset + if (state->count >= (sizeof(diablo_times) / sizeof(uint8_t) ) ) { + diablo_timer[diablo_keys->index].key_interval = 0; + reset_tap_dance(state); + } else { // else set the interval (tapdance count starts at 1, array starts at 0, so offset by one) + diablo_timer[diablo_keys->index].key_interval = diablo_times[state->count - 1]; + } +} +``` + +## The Magic - Part 2: The Coup de Grace + +The real core here is the `run_diablo_macro_check()` function. You need to call this from `matrix_scan_user`, as this handles the timer check. + +Specifically, it runs a check for each index of the timer. It checks to see if it's enabled, and if enough time has passed. If enough time has passed, it resets the timer, and will tap the keycode that you set for that index, but only if the Diablo layer is enabled. + +```c +// Checks each of the 4 timers/keys to see if enough time has elapsed +void run_diablo_macro_check(void) { + for (uint8_t index = 0; index < NUM_OF_DIABLO_KEYS; index++) { + // if key_interval is 0, it's disabled, so only run if it's set. If it's set, check the timer. + if ( diablo_timer[index].key_interval && timer_elapsed( diablo_timer[index].timer ) > ( diablo_timer[index].key_interval * 1000 ) ) { + // reset the timer, since enough time has passed + diablo_timer[index].timer = timer_read(); + // send keycode ONLY if we're on the diablo layer. + if (IS_LAYER_ON(_DIABLO)) { + tap_code(diablo_timer[index].keycode); + } + } + } +} +``` diff --git a/users/drashna/readme_wrappers.md b/users/drashna/readme_wrappers.md new file mode 100644 index 0000000000..fd62ff1609 --- /dev/null +++ b/users/drashna/readme_wrappers.md @@ -0,0 +1,11 @@ +## Keyboard Layout Templates + +This borrows from @jola5's "Not quite neo" code. This allows me to maintain blocks of keymaps in the userspace, so that I can modify the userspace, and this is reflected in all of the keyboards that use it, at once. + +This makes adding tap/hold mods, or other special keycodes or functions to all keyboards super easy, as it's done to all of them at once. + +The caveat here is that the keymap needs a processor/wrapper, as it doesn't like the substitutions. However, this is as simple as just pushing it through a define. For instance: + +`#define LAYOUT_ergodox_wrapper(...) LAYOUT_ergodox(__VA_ARGS__)` + +Once that's been done and you've switched the keymaps to use the "wrapper", it will read the substitution blocks just fine. diff --git a/users/drashna/rgb_stuff.c b/users/drashna/rgb_stuff.c index 7d364fa686..12851e2616 100644 --- a/users/drashna/rgb_stuff.c +++ b/users/drashna/rgb_stuff.c @@ -4,77 +4,75 @@ #if defined(RGBLIGHT_ENABLE) extern rgblight_config_t rgblight_config; -bool has_initialized; +bool has_initialized; #endif #ifdef RGBLIGHT_ENABLE -void rgblight_sethsv_default_helper(uint8_t index) { - rgblight_sethsv_at(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, index); -} -#endif // RGBLIGHT_ENABLE +void rgblight_sethsv_default_helper(uint8_t index) { rgblight_sethsv_at(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, index); } +#endif // RGBLIGHT_ENABLE #ifdef INDICATOR_LIGHTS void set_rgb_indicators(uint8_t this_mod, uint8_t this_led, uint8_t this_osm) { if (userspace_config.rgb_layer_change && biton32(layer_state) == 0) { - if ( (this_mod | this_osm) & MOD_MASK_SHIFT || this_led & (1<<USB_LED_CAPS_LOCK) ) { - #ifdef SHFT_LED1 + if ((this_mod | this_osm) & MOD_MASK_SHIFT || this_led & (1 << USB_LED_CAPS_LOCK)) { +# ifdef SHFT_LED1 rgblight_sethsv_at(120, 255, 255, SHFT_LED1); - #endif // SHFT_LED1 - #ifdef SHFT_LED2 +# endif // SHFT_LED1 +# ifdef SHFT_LED2 rgblight_sethsv_at(120, 255, 255, SHFT_LED2); - #endif // SHFT_LED2 +# endif // SHFT_LED2 } else { - #ifdef SHFT_LED1 +# ifdef SHFT_LED1 rgblight_sethsv_default_helper(SHFT_LED1); - #endif // SHFT_LED1 - #ifdef SHFT_LED2 +# endif // SHFT_LED1 +# ifdef SHFT_LED2 rgblight_sethsv_default_helper(SHFT_LED2); - #endif // SHFT_LED2 +# endif // SHFT_LED2 } - if ( (this_mod | this_osm) & MOD_MASK_CTRL) { - #ifdef CTRL_LED1 + if ((this_mod | this_osm) & MOD_MASK_CTRL) { +# ifdef CTRL_LED1 rgblight_sethsv_at(0, 255, 255, CTRL_LED1); - #endif // CTRL_LED1 - #ifdef CTRL_LED2 +# endif // CTRL_LED1 +# ifdef CTRL_LED2 rgblight_sethsv_at(0, 255, 255, CTRL_LED2); - #endif // CTRL_LED2 +# endif // CTRL_LED2 } else { - #ifdef CTRL_LED1 +# ifdef CTRL_LED1 rgblight_sethsv_default_helper(CTRL_LED1); - #endif // CTRL_LED1 - #ifdef CTRL_LED2 +# endif // CTRL_LED1 +# ifdef CTRL_LED2 rgblight_sethsv_default_helper(CTRL_LED2); - #endif // CTRL_LED2 +# endif // CTRL_LED2 } - if ( (this_mod | this_osm) & MOD_MASK_GUI) { - #ifdef GUI_LED1 + if ((this_mod | this_osm) & MOD_MASK_GUI) { +# ifdef GUI_LED1 rgblight_sethsv_at(51, 255, 255, GUI_LED1); - #endif // GUI_LED1 - #ifdef GUI_LED2 +# endif // GUI_LED1 +# ifdef GUI_LED2 rgblight_sethsv_at(51, 255, 255, GUI_LED2); - #endif // GUI_LED2 +# endif // GUI_LED2 } else { - #ifdef GUI_LED1 +# ifdef GUI_LED1 rgblight_sethsv_default_helper(GUI_LED1); - #endif // GUI_LED1 - #ifdef GUI_LED2 +# endif // GUI_LED1 +# ifdef GUI_LED2 rgblight_sethsv_default_helper(GUI_LED2); - #endif // GUI_LED2 +# endif // GUI_LED2 } - if ( (this_mod | this_osm) & MOD_MASK_ALT) { - #ifdef ALT_LED1 + if ((this_mod | this_osm) & MOD_MASK_ALT) { +# ifdef ALT_LED1 rgblight_sethsv_at(240, 255, 255, ALT_LED1); - #endif // ALT_LED1 - #ifdef GUI_LED2 +# endif // ALT_LED1 +# ifdef GUI_LED2 rgblight_sethsv_at(240, 255, 255, ALT_LED2); - #endif // GUI_LED2 +# endif // GUI_LED2 } else { - #ifdef GUI_LED1 +# ifdef GUI_LED1 rgblight_sethsv_default_helper(ALT_LED1); - #endif // GUI_LED1 - #ifdef GUI_LED2 +# endif // GUI_LED1 +# ifdef GUI_LED2 rgblight_sethsv_default_helper(ALT_LED2); - #endif // GUI_LED2 +# endif // GUI_LED2 } } } @@ -84,75 +82,73 @@ void matrix_scan_indicator(void) { set_rgb_indicators(get_mods(), host_keyboard_leds(), get_oneshot_mods()); } } -#endif //INDICATOR_LIGHTS +#endif // INDICATOR_LIGHTS #ifdef RGBLIGHT_TWINKLE static rgblight_fadeout lights[RGBLED_NUM]; -__attribute__ ((weak)) -bool rgblight_twinkle_is_led_used_keymap(uint8_t index) { return false; } +__attribute__((weak)) bool rgblight_twinkle_is_led_used_keymap(uint8_t index) { return false; } bool rgblight_twinkle_is_led_used(uint8_t index) { switch (index) { -#ifdef INDICATOR_LIGHTS -#ifdef SHFT_LED1 +# ifdef INDICATOR_LIGHTS +# ifdef SHFT_LED1 case SHFT_LED1: return true; -#endif //SHFT_LED1 -#ifdef SHFT_LED2 +# endif // SHFT_LED1 +# ifdef SHFT_LED2 case SHFT_LED2: return true; -#endif //SHFT_LED2 -#ifdef CTRL_LED1 +# endif // SHFT_LED2 +# ifdef CTRL_LED1 case CTRL_LED1: return true; -#endif //CTRL_LED1 -#ifdef CTRL_LED2 +# endif // CTRL_LED1 +# ifdef CTRL_LED2 case CTRL_LED2: return true; -#endif //CTRL_LED2 -#ifdef GUI_LED1 +# endif // CTRL_LED2 +# ifdef GUI_LED1 case GUI_LED1: return true; -#endif //GUI_LED1 -#ifdef GUI_LED2 +# endif // GUI_LED1 +# ifdef GUI_LED2 case GUI_LED2: return true; -#endif //GUI_LED2 -#ifdef ALT_LED1 +# endif // GUI_LED2 +# ifdef ALT_LED1 case ALT_LED1: return true; -#endif //ALT_LED1 -#ifdef ALT_LED2 +# endif // ALT_LED1 +# ifdef ALT_LED2 case ALT_LED2: return true; -#endif //ALT_LED2 -#endif //INDICATOR_LIGHTS +# endif // ALT_LED2 +# endif // INDICATOR_LIGHTS default: return rgblight_twinkle_is_led_used_keymap(index); - } + } } -void scan_rgblight_fadeout(void) { // Don't effing change this function .... rgblight_sethsv is supppppper intensive +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 ) { + 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]; - litup = true; + rgblight_fadeout *light = &lights[light_index]; + litup = true; - if (light->life) { - light->life -= 1; - if (biton32(layer_state) == 0) { - sethsv(light->hue + rand() % 0xF, 255, light->life, (LED_TYPE *)&led[light_index]); - } - light->timer = timer_read(); - } - else { - if (light->enabled && biton32(layer_state) == 0) { - rgblight_sethsv_default_helper(light_index); + if (light->life) { + light->life -= 1; + if (biton32(layer_state) == 0) { + sethsv(light->hue + rand() % 0xF, 255, light->life, (LED_TYPE *)&led[light_index]); + } + light->timer = timer_read(); + } else { + if (light->enabled && biton32(layer_state) == 0) { + rgblight_sethsv_default_helper(light_index); + } + litup = light->enabled = false; } - litup = light->enabled = false; - } } } if (litup && biton32(layer_state) == 0) { @@ -161,39 +157,37 @@ void scan_rgblight_fadeout(void) { // Don't effing change this function .... rgb } void start_rgb_light(void) { - uint8_t indices[RGBLED_NUM]; - uint8_t indices_count = 0; - uint8_t min_life = 0xFF; + 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; } - if (lights[index].enabled) { - if (min_life_index == -1 || - lights[index].life < min_life) - { - min_life = lights[index].life; - min_life_index = index; + for (uint8_t index = 0; index < RGBLED_NUM; ++index) { + if (rgblight_twinkle_is_led_used(index)) { + continue; + } + if (lights[index].enabled) { + if (min_life_index == -1 || lights[index].life < min_life) { + min_life = lights[index].life; + min_life_index = index; + } + continue; } - continue; - } - indices[indices_count] = index; - ++indices_count; + indices[indices_count] = index; + ++indices_count; } uint8_t light_index; if (!indices_count) { light_index = min_life_index; - } - else { - light_index = indices[rand() % indices_count]; + } else { + light_index = indices[rand() % indices_count]; } rgblight_fadeout *light = &lights[light_index]; - light->enabled = true; - light->timer = timer_read(); - light->life = 0xC0 + rand() % 0x40; + light->enabled = true; + light->timer = timer_read(); + light->life = 0xC0 + rand() % 0x40; light->hue = rgblight_config.hue + (rand() % 0xB4) - 0x54; @@ -201,7 +195,6 @@ void start_rgb_light(void) { } #endif - bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) { if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) { keycode = keycode & 0xFF; @@ -214,9 +207,12 @@ bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) { case KC_KP_SLASH ... KC_KP_DOT: case KC_F13 ... KC_F24: case KC_AUDIO_MUTE ... KC_MEDIA_REWIND: - if (record->event.pressed) { start_rgb_light(); } - return true; break; -#endif // RGBLIGHT_TWINKLE + if (record->event.pressed) { + start_rgb_light(); + } + return true; + break; +#endif // RGBLIGHT_TWINKLE case KC_RGB_T: // This allows me to use underglow as layer indication, or as normal #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) if (record->event.pressed) { @@ -224,41 +220,48 @@ bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) { xprintf("rgblight layer change [EEPROM]: %u\n", userspace_config.rgb_layer_change); eeconfig_update_user(userspace_config.raw); if (userspace_config.rgb_layer_change) { - layer_state_set(layer_state); // This is needed to immediately set the layer color (looks better) + layer_state_set(layer_state); // This is needed to immediately set the layer color (looks better) } } -#endif // RGBLIGHT_ENABLE - return false; break; +#endif // RGBLIGHT_ENABLE + return false; + break; #ifdef RGBLIGHT_ENABLE - case RGB_MODE_FORWARD ... RGB_MODE_GRADIENT: // quantum_keycodes.h L400 for definitions - if (record->event.pressed) { //This disables layer indication, as it's assumed that if you're changing this ... you want that disabled + case RGB_MODE_FORWARD ... RGB_MODE_GRADIENT: // quantum_keycodes.h L400 for definitions + if (record->event.pressed) { // 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; xprintf("rgblight layer change [EEPROM]: %u\n", userspace_config.rgb_layer_change); eeconfig_update_user(userspace_config.raw); } } - return true; break; -#endif // RGBLIGHT_ENABLE - } + return true; + break; +#endif // RGBLIGHT_ENABLE + } return true; } - - void keyboard_post_init_rgb(void) { #if defined(RGBLIGHT_ENABLE) && defined(RGBLIGHT_STARTUP_ANIMATION) - if (userspace_config.rgb_layer_change) { rgblight_enable_noeeprom(); } + bool is_enabled = rgblight_config.enable; + if (userspace_config.rgb_layer_change) { + rgblight_enable_noeeprom(); + } if (rgblight_config.enable) { layer_state_set_user(layer_state); uint16_t old_hue = rgblight_config.hue; rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); for (uint16_t i = 255; i > 0; i--) { - rgblight_sethsv_noeeprom( ( i + old_hue) % 255, 255, 255); + rgblight_sethsv_noeeprom((i + old_hue) % 255, 255, 255); matrix_scan(); wait_ms(10); } } + if (!is_enabled) { + rgblight_disable_noeeprom(); + } + #endif layer_state_set_user(layer_state); } @@ -266,15 +269,13 @@ void keyboard_post_init_rgb(void) { void matrix_scan_rgb(void) { #ifdef RGBLIGHT_TWINKLE scan_rgblight_fadeout(); -#endif // RGBLIGHT_ENABLE +#endif // RGBLIGHT_ENABLE #ifdef INDICATOR_LIGHTS matrix_scan_indicator(); #endif - } - layer_state_t layer_state_set_rgb(layer_state_t state) { #ifdef RGBLIGHT_ENABLE if (userspace_config.rgb_layer_change) { @@ -307,40 +308,73 @@ layer_state_t layer_state_set_rgb(layer_state_t state) { rgblight_sethsv_noeeprom_red(); rgblight_mode_noeeprom(RGBLIGHT_MODE_KNIGHT + 2); break; - default: // for any other layers, or the default layer + default: // for any other layers, or the default layer switch (biton32(default_layer_state)) { case _COLEMAK: - rgblight_sethsv_noeeprom_magenta(); break; + rgblight_sethsv_noeeprom_magenta(); + break; case _DVORAK: - rgblight_sethsv_noeeprom_springgreen(); break; + rgblight_sethsv_noeeprom_springgreen(); + break; case _WORKMAN: - rgblight_sethsv_noeeprom_goldenrod(); break; + rgblight_sethsv_noeeprom_goldenrod(); + break; case _NORMAN: - rgblight_sethsv_noeeprom_coral(); break; + rgblight_sethsv_noeeprom_coral(); + break; case _MALTRON: - rgblight_sethsv_noeeprom_yellow(); break; + rgblight_sethsv_noeeprom_yellow(); + break; case _EUCALYN: - rgblight_sethsv_noeeprom_pink(); break; + rgblight_sethsv_noeeprom_pink(); + break; case _CARPLAX: - rgblight_sethsv_noeeprom_blue(); break; + rgblight_sethsv_noeeprom_blue(); + break; default: - rgblight_sethsv_noeeprom_cyan(); break; + rgblight_sethsv_noeeprom_cyan(); + break; } - biton32(state) == _MODS ? rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING) : rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); // if _MODS layer is on, then breath to denote it + biton32(state) == _MODS ? rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING) : rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); // if _MODS layer is on, then breath to denote it break; } } -#endif // RGBLIGHT_ENABLE +#endif // RGBLIGHT_ENABLE return state; } #ifdef RGB_MATRIX_ENABLE +# include "lib/lib8tion/lib8tion.h" extern led_config_t g_led_config; -void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue, uint8_t led_type) { - for (int i = 0; i < DRIVER_LED_TOTAL; i++) { - if (HAS_FLAGS(g_led_config.flags[i], led_type)) { - rgb_matrix_set_color( i, red, green, blue ); +void rgb_matrix_layer_helper(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode, uint8_t speed, uint8_t led_type) { + HSV hsv = {hue, sat, val}; + if (hsv.v > rgb_matrix_config.hsv.v) { + hsv.v = rgb_matrix_config.hsv.v; + } + + switch (mode) { + case 1: // breathing + { + uint16_t time = scale16by8(g_rgb_counters.tick, speed / 8); + hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v); + RGB rgb = hsv_to_rgb(hsv); + for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { + if (HAS_FLAGS(g_led_config.flags[i], led_type)) { + rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); + } + } + break; + } + default: // Solid Color + { + RGB rgb = hsv_to_rgb(hsv); + for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) { + if (HAS_FLAGS(g_led_config.flags[i], led_type)) { + rgb_matrix_set_color(i, rgb.r, rgb.g, rgb.b); + } + } + break; } } } diff --git a/users/drashna/rgb_stuff.h b/users/drashna/rgb_stuff.h index f5bbd0f3b5..ce45d6a00b 100644 --- a/users/drashna/rgb_stuff.h +++ b/users/drashna/rgb_stuff.h @@ -1,23 +1,23 @@ #pragma once #include "quantum.h" #ifdef RGB_MATRIX_ENABLE - #include "rgb_matrix.h" +# include "rgb_matrix.h" #endif typedef struct { - bool enabled; - uint8_t hue; + bool enabled; + uint8_t hue; uint16_t timer; - uint8_t life; + uint8_t life; } rgblight_fadeout; -bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record); -void scan_rgblight_fadeout(void); -void keyboard_post_init_rgb(void); -void matrix_scan_rgb(void); +bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record); +void scan_rgblight_fadeout(void); +void keyboard_post_init_rgb(void); +void matrix_scan_rgb(void); layer_state_t layer_state_set_rgb(layer_state_t state); layer_state_t default_layer_state_set_rgb(layer_state_t state); -void rgblight_sethsv_default_helper(uint8_t index); -void rgb_matrix_set_color_all( uint8_t red, uint8_t green, uint8_t blue ); +void rgblight_sethsv_default_helper(uint8_t index); +void rgb_matrix_set_color_all(uint8_t red, uint8_t green, uint8_t blue); -void rgb_matrix_layer_helper (uint8_t red, uint8_t green, uint8_t blue, uint8_t led_type); +void rgb_matrix_layer_helper(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode, uint8_t speed, uint8_t led_type); diff --git a/users/drashna/rules.mk b/users/drashna/rules.mk index cdb9e54360..b414036a47 100644 --- a/users/drashna/rules.mk +++ b/users/drashna/rules.mk @@ -2,6 +2,7 @@ SRC += drashna.c \ process_records.c LINK_TIME_OPTIMIZATION_ENABLE = yes +SPACE_CADET_ENABLE = no ifneq ("$(wildcard $(USER_PATH)/secrets.c)","") SRC += secrets.c diff --git a/users/drashna/send_unicode.h b/users/drashna/send_unicode.h deleted file mode 100644 index 743abc58b4..0000000000 --- a/users/drashna/send_unicode.h +++ /dev/null @@ -1,71 +0,0 @@ -#pragma once - -#include "quantum.h" - -void send_unicode_hex_string(const char* str); - -/* use X(n) to call the */ -#ifdef UNICODEMAP_ENABLE -enum unicode_name { - THINK, // thinking face 🤔 - GRIN, // grinning face 😊 - SMRK, // smirk 😏 - WEARY, // good shit 😩 - UNAMU, // unamused 😒 - - SNEK, // snke 🐍 - PENGUIN, // 🐧 - DRAGON, // 🐉 - MONKEY, // 🐒 - CHICK, // 🐥 - BOAR, // 🐗 - - OKOK, // 👌 - EFFU, // 🖕 - INUP, // 👆 - THUP, // 👍 - THDN, // 👎 - - BBB, // dat B 🅱 - POO, // poop 💩 - HUNDR, // 100 💯 - EGGPL, // EGGPLANT 🍆 - WATER, // wet 💦 - TUMBLER, // 🥃 - - LIT, // fire 🔥 - BANG, // ‽ - IRONY, // ⸮ - DEGREE // ° -}; - - -const uint32_t PROGMEM unicode_map[] = { - [THINK] = 0x1F914, - [GRIN] = 0x1F600, - [BBB] = 0x1F171, - [POO] = 0x1F4A9, - [HUNDR] = 0x1F4AF, - [SMRK] = 0x1F60F, - [WEARY] = 0x1F629, - [EGGPL] = 0x1F346, - [WATER] = 0x1F4A6, - [LIT] = 0x1F525, - [UNAMU] = 0x1F612, - [SNEK] = 0x1F40D, - [PENGUIN] = 0x1F427, - [BOAR] = 0x1F417, - [MONKEY] = 0x1F412, - [CHICK] = 0x1F425, - [DRAGON] = 0x1F409, - [OKOK] = 0x1F44C, - [EFFU] = 0x1F595, - [INUP] = 0x1F446, - [THDN] = 0x1F44E, - [THUP] = 0x1F44D, - [TUMBLER] = 0x1F943, - [BANG] = 0x0203D, - [IRONY] = 0x02E2E, - [DEGREE] = 0x000B0 - }; -#endif // UNICODEMAP_ENABLE diff --git a/users/drashna/tap_dances.c b/users/drashna/tap_dances.c index 18ca96e187..65019ab751 100644 --- a/users/drashna/tap_dances.c +++ b/users/drashna/tap_dances.c @@ -1,65 +1,56 @@ #include "tap_dances.h" +#define NUM_OF_DIABLO_KEYS 4 +// define diablo macro timer variables +diablo_timer_t diablo_timer[NUM_OF_DIABLO_KEYS]; -//define diablo macro timer variables -diablo_timer_t diablo_timer[4]; - -uint8_t diablo_times[] = { 0, 0, 1, 3, 5, 10, 30 }; - -// has the correct number of seconds elapsed (as defined by diablo_times) -bool check_dtimer(uint8_t dtimer) { return (timer_elapsed(diablo_timer[dtimer].key_time) < (diablo_timer[dtimer].timer * 1000)) ? false : true; }; +// Set the default intervals. Always start with 0 so that it will disable on first hit. +// Otherwise, you will need to hit a bunch of times, or hit the "clear" command +uint8_t diablo_times[] = {0, 1, 3, 5, 10, 30}; // Cycle through the times for the macro, starting at 0, for disabled. -// Max of six values, so don't exceed void diablo_tapdance_master(qk_tap_dance_state_t *state, void *user_data) { - int index = (int)user_data; - if (state->count >= 7) { - diablo_timer[index].key_time = diablo_times[0]; + diable_keys_t *diablo_keys = (diable_keys_t *)user_data; + // Sets the keycode based on the index + diablo_timer[diablo_keys->index].keycode = diablo_keys->keycode; + + // if the tapdance is hit more than the number of elemints in the array, reset + if (state->count >= (sizeof(diablo_times) / sizeof(uint8_t))) { + diablo_timer[diablo_keys->index].key_interval = 0; reset_tap_dance(state); - } else { - diablo_timer[index].key_time = diablo_times[state->count]; + } else { // else set the interval (tapdance count starts at 1, array starts at 0, so offset by one) + diablo_timer[diablo_keys->index].key_interval = diablo_times[state->count - 1]; } } -// One funtion to rule them all!! -#define ACTION_TAP_DANCE_DIABLO(arg) { \ +// clang-format off +// One function to rule them all!! Where the Magic Sauce lies +#define ACTION_TAP_DANCE_DIABLO(index, keycode) { \ .fn = { NULL, (void *)diablo_tapdance_master, NULL }, \ - .user_data = (void *)arg, \ + .user_data = (void *)&((diable_keys_t) { index, keycode }), \ } +// clang-format on -//Tap Dance Definitions +// Tap Dance Definitions, sets the index and the keycode. qk_tap_dance_action_t tap_dance_actions[] = { // tap once to disable, and more to enable timed micros - [TD_D3_1] = ACTION_TAP_DANCE_DIABLO(0), - [TD_D3_2] = ACTION_TAP_DANCE_DIABLO(1), - [TD_D3_3] = ACTION_TAP_DANCE_DIABLO(2), - [TD_D3_4] = ACTION_TAP_DANCE_DIABLO(3), + [TD_D3_1] = ACTION_TAP_DANCE_DIABLO(0, KC_1), + [TD_D3_2] = ACTION_TAP_DANCE_DIABLO(1, KC_2), + [TD_D3_3] = ACTION_TAP_DANCE_DIABLO(2, KC_3), + [TD_D3_4] = ACTION_TAP_DANCE_DIABLO(3, KC_4), }; -// Sends the key press to system, but only if on the Diablo layer -void send_diablo_keystroke(uint8_t diablo_key) { - if (IS_LAYER_ON(_DIABLO)) { - switch (diablo_key) { - case 0: - tap_code(KC_1); break; - case 1: - tap_code(KC_2); break; - case 2: - tap_code(KC_3); break; - case 3: - tap_code(KC_4); break; - } - } -} - // Checks each of the 4 timers/keys to see if enough time has elapsed -// Runs the "send string" command if enough time has passed, and resets the timer. void run_diablo_macro_check(void) { - uint8_t dtime; - for (dtime = 0; dtime < 4; dtime++) { - if (check_dtimer(dtime) && diablo_timer[dtime].key_time) { - diablo_timer[dtime].timer = timer_read(); - send_diablo_keystroke(dtime); + for (uint8_t index = 0; index < NUM_OF_DIABLO_KEYS; index++) { + // if key_interval is 0, it's disabled, so only run if it's set. If it's set, check the timer. + if (diablo_timer[index].key_interval && timer_elapsed(diablo_timer[index].timer) > (diablo_timer[index].key_interval * 1000)) { + // reset the timer, since enough time has passed + diablo_timer[index].timer = timer_read(); + // send keycode ONLY if we're on the diablo layer. + if (IS_LAYER_ON(_DIABLO)) { + tap_code(diablo_timer[index].keycode); + } } } } diff --git a/users/drashna/tap_dances.h b/users/drashna/tap_dances.h index 4a293b2582..44fa0b9348 100644 --- a/users/drashna/tap_dances.h +++ b/users/drashna/tap_dances.h @@ -1,22 +1,30 @@ #pragma once #include "drashna.h" -//define diablo macro timer variables +// define diablo macro timer variables extern uint8_t diablo_times[]; typedef struct { uint16_t timer; - uint8_t key_time; + uint8_t key_interval; + uint8_t keycode; } diablo_timer_t; -extern diablo_timer_t diablo_timer[4]; +typedef struct { + uint8_t index; + uint8_t keycode; +} diable_keys_t; + +extern diablo_timer_t diablo_timer[]; void run_diablo_macro_check(void); #ifdef TAP_DANCE_ENABLE +// clang-format off enum { TD_D3_1 = 0, TD_D3_2, TD_D3_3, TD_D3_4 }; -#endif // TAP_DANCE_ENABLE +// clang-format on +#endif // TAP_DANCE_ENABLE diff --git a/users/drashna/wrappers.h b/users/drashna/wrappers.h index 93f842f4b2..a87247071f 100644 --- a/users/drashna/wrappers.h +++ b/users/drashna/wrappers.h @@ -6,9 +6,10 @@ arguments, we need a wrapper in order for these definitions to be expanded before being used as arguments to the LAYOUT_xxx macro. */ #if (!defined(LAYOUT) && defined(KEYMAP)) -# define LAYOUT KEYMAP +# define LAYOUT KEYMAP #endif +// clang-format off #define LAYOUT_ergodox_wrapper(...) LAYOUT_ergodox(__VA_ARGS__) #define LAYOUT_ergodox_pretty_wrapper(...) LAYOUT_ergodox_pretty(__VA_ARGS__) #define KEYMAP_wrapper(...) LAYOUT(__VA_ARGS__) @@ -135,6 +136,15 @@ NOTE: These are all the same length. If you do a search/replace #define _____________CARPLAX_QGMLWY_R3_____________ KC_K, KC_P, KC_COMM, KC_DOT, KC_SLSH +#define _________________WHITE_R1__________________ KC_V, KC_Y, KC_D, KC_COMM, KC_QUOT +#define _________________WHITE_R2__________________ KC_A, KC_T, KC_H, KC_E, KC_B +#define _________________WHITE_R3__________________ KC_P, KC_K, KC_G, KC_W, KC_Q + +#define _________________WHITE_L1__________________ KC_INT1, KC_J, KC_M, KC_L, KC_U +#define _________________WHITE_L2__________________ KC_MINS, KC_C, KC_S, KC_N, KC_O // KC_I +#define _________________WHITE_L3__________________ KC_X, KC_R, KC_F, KC_DOT, KC_Z + + #define ________________NUMBER_LEFT________________ KC_1, KC_2, KC_3, KC_4, KC_5 #define ________________NUMBER_RIGHT_______________ KC_6, KC_7, KC_8, KC_9, KC_0 #define _________________FUNC_LEFT_________________ KC_F1, KC_F2, KC_F3, KC_F4, KC_F5 @@ -170,3 +180,5 @@ NOTE: These are all the same length. If you do a search/replace #define _________________ADJUST_R1_________________ KC_SEC1, KC_SEC2, KC_SEC3, KC_SEC4, KC_SEC5 #define _________________ADJUST_R2_________________ AG_SWAP, QWERTY, COLEMAK, DVORAK, WORKMAN #define _________________ADJUST_R3_________________ MG_NKRO, KC_MUTE, KC_VOLD, KC_VOLU, KC_MNXT + +// clang-format on |