diff options
Diffstat (limited to 'users')
-rw-r--r-- | users/drashna/.gitlab-ci.yml | 35 | ||||
-rw-r--r-- | users/drashna/config.h | 72 | ||||
-rw-r--r-- | users/drashna/drashna.c | 198 | ||||
-rw-r--r-- | users/drashna/drashna.h | 76 | ||||
-rw-r--r-- | users/drashna/process_records.c | 232 | ||||
-rw-r--r-- | users/drashna/process_records.h | 76 | ||||
-rw-r--r-- | users/drashna/rgb_stuff.c | 441 | ||||
-rw-r--r-- | users/drashna/rgblight_breathe_table.h | 116 | ||||
-rw-r--r-- | users/drashna/rules.mk | 46 | ||||
-rw-r--r-- | users/drashna/send_unicode.h | 104 | ||||
-rw-r--r-- | users/drashna/tap_dances.c | 77 | ||||
-rw-r--r-- | users/drashna/tap_dances.h | 15 | ||||
-rw-r--r-- | users/drashna/wrappers.h | 3 |
13 files changed, 770 insertions, 721 deletions
diff --git a/users/drashna/.gitlab-ci.yml b/users/drashna/.gitlab-ci.yml index 92813a27d3..679bdf4351 100644 --- a/users/drashna/.gitlab-ci.yml +++ b/users/drashna/.gitlab-ci.yml @@ -1,9 +1,7 @@ stages: - test - - build - - deploy -Preliminary Test: +QMK Firmware: stage: test variables: GIT_SUBMODULE_STRATEGY: recursive @@ -18,36 +16,7 @@ Preliminary Test: script: - make test:all - make planck/rev6:default planck/rev5:default - -QMK Firmware Defaults: - stage: deploy - variables: - GIT_SUBMODULE_STRATEGY: recursive - tags: - - linux - image: ubuntu:18.10 - before_script: - - apt-get update -qy - - apt-get install -y build-essential avr-libc binutils-arm-none-eabi binutils-avr dfu-programmer dfu-util gcc gcc-arm-none-eabi gcc-avr git libnewlib-arm-none-eabi unzip wget zip - - avr-gcc --version - - uname -a - script: - - make test:all - - make all:default -j16 - -Drashna Firmware: - stage: build - variables: - GIT_SUBMODULE_STRATEGY: recursive - tags: - - linux - image: ubuntu:18.10 - before_script: - - apt-get update -qy - - apt-get install -y build-essential avr-libc binutils-arm-none-eabi binutils-avr dfu-programmer dfu-util gcc gcc-arm-none-eabi gcc-avr git libnewlib-arm-none-eabi unzip wget zip - - avr-gcc --version - script: - - make keebio/iris/rev2:drashna keebio/iris/rev2:drashna_old ergodox_ez:drashna ergodox_ez:drashna_glow keebio/viterbi/rev1:drashna orthodox/rev1:drashna orthodox/rev3:drashna crkbd:drashna planck/light:drashna planck/rev6:drashna fractal:drashna primekb/prime_m:drashna -j16 --output-sync + - make keebio/iris/rev2:drashna keebio/iris/rev2:drashna_old ergodox_ez:drashna ergodox_ez:drashna_glow keebio/viterbi/rev1:drashna orthodox/rev1:drashna orthodox/rev3:drashna crkbd:drashna planck/light:drashna planck/rev6:drashna fractal:drashna primekb/prime_m:drashna -j2 --output-sync artifacts: name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG" paths: diff --git a/users/drashna/config.h b/users/drashna/config.h index 1680eb4cb1..a6d8e75263 100644 --- a/users/drashna/config.h +++ b/users/drashna/config.h @@ -2,50 +2,43 @@ #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), \ +# 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 - // #ifdef RGBLIGHT_ENABLE - // #define NO_MUSIC_MODE - // #endif //RGBLIGHT_ENABLE/ - // #ifndef __arm__ - // #undef NOTE_REST - // #define NOTE_REST 1.00f - // #endif // !__arm__ - -#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) + } + +# 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 +# define RGBLIGHT_SLEEP +# undef RGBLIGHT_ANIMATIONS +# define RGBLIGHT_EFFECT_BREATHING +# define RGBLIGHT_EFFECT_SNAKE +# define RGBLIGHT_EFFECT_KNIGHT #endif // RGBLIGHT_ENABLE #ifndef ONESHOT_TAP_TOGGLE - #define ONESHOT_TAP_TOGGLE 2 +# define ONESHOT_TAP_TOGGLE 2 #endif // !ONESHOT_TAP_TOGGLE #ifndef ONESHOT_TIMEOUT - #define ONESHOT_TIMEOUT 3000 +# define ONESHOT_TIMEOUT 3000 #endif// !ONESHOT_TIMEOUT #ifndef QMK_KEYS_PER_SCAN - #define QMK_KEYS_PER_SCAN 4 +# define QMK_KEYS_PER_SCAN 4 #endif // !QMK_KEYS_PER_SCAN @@ -62,24 +55,27 @@ #define FORCE_NKRO #ifndef TAPPING_TOGGLE - #define TAPPING_TOGGLE 1 +# define TAPPING_TOGGLE 1 #endif #ifdef TAPPING_TERM - #undef 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 -// Disable action_get_macro and fn_actions, since we don't use these -// and it saves on space in the firmware. -#define NO_ACTION_MACRO -#define NO_ACTION_FUNCTION - #define TAP_CODE_DELAY 5 + +/* Disable unused and unneeded features to reduce on firmware size */ +#ifdef LOCKING_SUPPORT_ENABLE +# undef LOCKING_SUPPORT_ENABLE +#endif +#ifdef LOCKING_RESYNC_ENABLE +# undef LOCKING_RESYNC_ENABLE +#endif diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c index ec249dd224..7c60a2e4a5 100644 --- a/users/drashna/drashna.c +++ b/users/drashna/drashna.c @@ -19,78 +19,78 @@ 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 + #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; - } else { - keycode = KC_ENTER; + if (!record->event.pressed || override) { + uint16_t keycode; + if (userspace_config.is_overwatch) { + keycode = KC_BSPC; + } else { + keycode = KC_ENTER; + } + clear_keyboard(); + tap_code(keycode); + wait_ms(TAP_CODE_DELAY); + send_string_with_delay(str, TAP_CODE_DELAY); + wait_ms(TAP_CODE_DELAY); + tap_code(KC_ENTER); } - clear_keyboard(); - tap_code(keycode); - wait_ms(TAP_CODE_DELAY); - send_string_with_delay(str, TAP_CODE_DELAY); - wait_ms(TAP_CODE_DELAY); - tap_code(KC_ENTER); - } - if (override) wait_ms(3000); - return false; + if (override) wait_ms(3000); + return false; } 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(); - } else { - if (timer_elapsed(this_timer) < TAPPING_TERM){ - tap_code(code); - } else { - register_code(mod_code); - tap_code(code); - unregister_code(mod_code); - } - } - return false; + static uint16_t this_timer; + if(pressed) { + this_timer= timer_read(); + } else { + if (timer_elapsed(this_timer) < TAPPING_TERM){ + tap_code(code); + } else { + register_code(mod_code); + tap_code(code); + unregister_code(mod_code); + } + } + 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(); - } else { - if (timer_elapsed(this_timer) < TAPPING_TERM){ - tap_code(code); - } else { - register_code(mod_code); - tap_code(code); - unregister_code(mod_code); - } - } - return false; + if(pressed) { + this_timer= timer_read(); + } else { + if (timer_elapsed(this_timer) < TAPPING_TERM){ + tap_code(code); + } else { + register_code(mod_code); + tap_code(code); + unregister_code(mod_code); + } + } + return false; } 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 - matrix_scan(); - if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) { - bootloader_jump(); - } + 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 + matrix_scan(); + if (matrix_get_row(BOOTMAGIC_LITE_ROW) & (1 << BOOTMAGIC_LITE_COLUMN)) { + bootloader_jump(); + } } // Add reconfigurable functions here, for keymap customization @@ -103,21 +103,21 @@ void matrix_init_keymap(void) {} // Call user matrix init, set default RGB colors and then // call the keymap's init function void matrix_init_user(void) { - userspace_config.raw = eeconfig_read_user(); + 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 - matrix_init_keymap(); + #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)) @@ -125,26 +125,26 @@ void keyboard_post_init_keymap(void){ } void keyboard_post_init_user(void){ #ifdef RGBLIGHT_ENABLE - keyboard_post_init_rgb(); + keyboard_post_init_rgb(); #endif - keyboard_post_init_keymap(); + keyboard_post_init_keymap(); } __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 - shutdown_keymap(); + #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)) @@ -158,7 +158,7 @@ __attribute__ ((weak)) void suspend_wakeup_init_keymap(void) {} void suspend_wakeup_init_user(void) { - suspend_wakeup_init_keymap(); + suspend_wakeup_init_keymap(); } @@ -168,54 +168,54 @@ void matrix_scan_keymap(void) {} // No global matrix scan code, so just run keymap's matrix // scan function void matrix_scan_user(void) { - static bool has_ran_yet; - if (!has_ran_yet) { - has_ran_yet = true; - startup_user(); - } + static bool has_ran_yet; + if (!has_ran_yet) { + has_ran_yet = true; + startup_user(); + } #ifdef TAP_DANCE_ENABLE // Run Diablo 3 macro checking code. - run_diablo_macro_check(); + run_diablo_macro_check(); #endif // TAP_DANCE_ENABLE #ifdef RGBLIGHT_ENABLE - matrix_scan_rgb(); + matrix_scan_rgb(); #endif // RGBLIGHT_ENABLE - matrix_scan_keymap(); + matrix_scan_keymap(); } __attribute__ ((weak)) uint32_t layer_state_set_keymap (uint32_t state) { - return state; + return state; } // on layer change, no matter where the change was initiated // Then runs keymap's layer change check uint32_t layer_state_set_user(uint32_t state) { - state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST); + state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST); #ifdef RGBLIGHT_ENABLE - state = layer_state_set_rgb(state); + state = layer_state_set_rgb(state); #endif // RGBLIGHT_ENABLE - return layer_state_set_keymap (state); + return layer_state_set_keymap (state); } __attribute__ ((weak)) uint32_t default_layer_state_set_keymap (uint32_t state) { - return state; + return state; } // Runs state check and changes underglow color and animation uint32_t default_layer_state_set_user(uint32_t state) { - state = default_layer_state_set_keymap(state); + state = default_layer_state_set_keymap(state); #if 0 #ifdef RGBLIGHT_ENABLE state = default_layer_state_set_rgb(state); #endif // RGBLIGHT_ENABLE #endif - return state; + return state; } __attribute__ ((weak)) @@ -225,16 +225,16 @@ void led_set_keymap(uint8_t usb_led) {} // So far, I only have keyboard specific code, // So nothing goes here. void led_set_user(uint8_t usb_led) { - led_set_keymap(usb_led); + led_set_keymap(usb_led); } __attribute__ ((weak)) void eeconfig_init_keymap(void) {} void eeconfig_init_user(void) { - userspace_config.raw = 0; - userspace_config.rgb_layer_change = true; - eeconfig_update_user(userspace_config.raw); + 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)) set_unicode_input_mode(DRASHNA_UNICODE_MODE); get_unicode_input_mode(); diff --git a/users/drashna/drashna.h b/users/drashna/drashna.h index 6645626d98..5df67792a5 100644 --- a/users/drashna/drashna.h +++ b/users/drashna/drashna.h @@ -22,36 +22,36 @@ 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" +# include "tap_dances.h" #endif // TAP_DANCE_ENABLE #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) - #include "rgb_stuff.h" +# include "rgb_stuff.h" #endif #if defined(AUDIO_ENABLE) && __GNUC__ > 7 - #if __has_include("drashna_song_list.h") - #include "drashna_song_list.h" - #endif +# if __has_include("drashna_song_list.h") +# include "drashna_song_list.h" +# endif #endif /* Define layer names */ enum userspace_layers { - _QWERTY = 0, - _NUMLOCK = 0, - _COLEMAK, - _DVORAK, - _WORKMAN, - _NORMAN, - _MALTRON, - _EUCALYN, - _CARPLAX, - _MODS, /* layer 8 */ - _GAMEPAD, - _DIABLO, - _MACROS, - _MEDIA, - _LOWER, - _RAISE, - _ADJUST, + _QWERTY = 0, + _NUMLOCK = 0, + _COLEMAK, + _DVORAK, + _WORKMAN, + _NORMAN, + _MALTRON, + _EUCALYN, + _CARPLAX, + _MODS, /* layer 8 */ + _GAMEPAD, + _DIABLO, + _MACROS, + _MEDIA, + _LOWER, + _RAISE, + _ADJUST, }; /* @@ -73,14 +73,14 @@ 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; - }; + 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; + }; } userspace_config_t; extern userspace_config_t userspace_config; @@ -92,13 +92,13 @@ 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) +# 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 +# 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 2b6ccf510c..a5487b5855 100644 --- a/users/drashna/process_records.c +++ b/users/drashna/process_records.c @@ -4,12 +4,12 @@ uint16_t copy_paste_timer; __attribute__ ((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { - return true; + return true; } __attribute__ ((weak)) bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { - return true; + return true; } // Defines actions tor my global custom keycodes. Defined in drashna.h file @@ -18,140 +18,140 @@ 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 #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 +# 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; + switch (keycode) { + 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); } - send_string_with_delay_P(PSTR(SS_TAP(X_ENTER)), TAP_CODE_DELAY); - } - break; + { + #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); } + send_string_with_delay_P(PSTR(SS_TAP(X_ENTER)), 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; + 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); } + 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); + 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); + 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_key_time[dtime] = diablo_times[0]; - } - } + if (record->event.pressed) { + uint8_t dtime; + for (dtime = 0; dtime < 4; dtime++) { + diablo_timer[dtime].key_time = diablo_times[0]; + } + } #endif // TAP_DANCE_ENABLE - break; + break; 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); - } - } - break; + 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); + } + } + 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) && + } + return process_record_keymap(keycode, record) && #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) - process_record_user_rgb(keycode, record) && + process_record_user_rgb(keycode, record) && #endif // RGBLIGHT_ENABLE - process_record_secrets(keycode, record); + process_record_secrets(keycode, record); } diff --git a/users/drashna/process_records.h b/users/drashna/process_records.h index 5e3374d3f2..35adec84cc 100644 --- a/users/drashna/process_records.h +++ b/users/drashna/process_records.h @@ -2,48 +2,48 @@ #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 - KC_MORESALT, - KC_SALTHARD, - KC_GOODGAME, - KC_SYMM, - KC_JUSTGAME, - KC_GLHF, - KC_TORB, - 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 + 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, + KC_SYMM, + KC_JUSTGAME, + KC_GLHF, + KC_TORB, + 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 }; bool process_record_secrets(uint16_t keycode, keyrecord_t *record); diff --git a/users/drashna/rgb_stuff.c b/users/drashna/rgb_stuff.c index b5e145842f..38e86ae0ea 100644 --- a/users/drashna/rgb_stuff.c +++ b/users/drashna/rgb_stuff.c @@ -11,80 +11,80 @@ extern rgb_config_t rgb_matrix_config; #ifdef RGBLIGHT_ENABLE void rgblight_sethsv_default_helper(uint8_t index) { - rgblight_sethsv_at(rgblight_config.hue, rgblight_config.sat, rgblight_config.val, 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 - rgblight_sethsv_at(120, 255, 255, SHFT_LED1); - #endif // SHFT_LED1 - #ifdef SHFT_LED2 - rgblight_sethsv_at(120, 255, 255, SHFT_LED2); - #endif // SHFT_LED2 - } else { - #ifdef SHFT_LED1 - rgblight_sethsv_default_helper(SHFT_LED1); - #endif // SHFT_LED1 - #ifdef SHFT_LED2 - rgblight_sethsv_default_helper(SHFT_LED2); - #endif // SHFT_LED2 - } - 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 - rgblight_sethsv_at(0, 255, 255, CTRL_LED2); - #endif // CTRL_LED2 - } else { - #ifdef CTRL_LED1 - rgblight_sethsv_default_helper(CTRL_LED1); - #endif // CTRL_LED1 - #ifdef CTRL_LED2 - rgblight_sethsv_default_helper(CTRL_LED2); - #endif // CTRL_LED2 - } - 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 - rgblight_sethsv_at(51, 255, 255, GUI_LED2); - #endif // GUI_LED2 - } else { - #ifdef GUI_LED1 - rgblight_sethsv_default_helper(GUI_LED1); - #endif // GUI_LED1 - #ifdef GUI_LED2 - rgblight_sethsv_default_helper(GUI_LED2); - #endif // GUI_LED2 - } - 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 - rgblight_sethsv_at(240, 255, 255, ALT_LED2); - #endif // GUI_LED2 - } else { - #ifdef GUI_LED1 - rgblight_sethsv_default_helper(ALT_LED1); - #endif // GUI_LED1 - #ifdef GUI_LED2 - rgblight_sethsv_default_helper(ALT_LED2); - #endif // GUI_LED2 + 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 + rgblight_sethsv_at(120, 255, 255, SHFT_LED1); + #endif // SHFT_LED1 + #ifdef SHFT_LED2 + rgblight_sethsv_at(120, 255, 255, SHFT_LED2); + #endif // SHFT_LED2 + } else { + #ifdef SHFT_LED1 + rgblight_sethsv_default_helper(SHFT_LED1); + #endif // SHFT_LED1 + #ifdef SHFT_LED2 + rgblight_sethsv_default_helper(SHFT_LED2); + #endif // SHFT_LED2 + } + 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 + rgblight_sethsv_at(0, 255, 255, CTRL_LED2); + #endif // CTRL_LED2 + } else { + #ifdef CTRL_LED1 + rgblight_sethsv_default_helper(CTRL_LED1); + #endif // CTRL_LED1 + #ifdef CTRL_LED2 + rgblight_sethsv_default_helper(CTRL_LED2); + #endif // CTRL_LED2 + } + 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 + rgblight_sethsv_at(51, 255, 255, GUI_LED2); + #endif // GUI_LED2 + } else { + #ifdef GUI_LED1 + rgblight_sethsv_default_helper(GUI_LED1); + #endif // GUI_LED1 + #ifdef GUI_LED2 + rgblight_sethsv_default_helper(GUI_LED2); + #endif // GUI_LED2 + } + 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 + rgblight_sethsv_at(240, 255, 255, ALT_LED2); + #endif // GUI_LED2 + } else { + #ifdef GUI_LED1 + rgblight_sethsv_default_helper(ALT_LED1); + #endif // GUI_LED1 + #ifdef GUI_LED2 + rgblight_sethsv_default_helper(ALT_LED2); + #endif // GUI_LED2 + } } - } } void matrix_scan_indicator(void) { - if (has_initialized) { - set_rgb_indicators(get_mods(), host_keyboard_leds(), get_oneshot_mods()); - } + if (has_initialized) { + set_rgb_indicators(get_mods(), host_keyboard_leds(), get_oneshot_mods()); + } } #endif //INDICATOR_LIGHTS @@ -95,69 +95,71 @@ __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) { + switch (index) { #ifdef INDICATOR_LIGHTS #ifdef SHFT_LED1 - case SHFT_LED1: - return true; + case SHFT_LED1: + return true; #endif //SHFT_LED1 #ifdef SHFT_LED2 - case SHFT_LED2: - return true; + case SHFT_LED2: + return true; #endif //SHFT_LED2 #ifdef CTRL_LED1 - case CTRL_LED1: - return true; + case CTRL_LED1: + return true; #endif //CTRL_LED1 #ifdef CTRL_LED2 - case CTRL_LED2: - return true; + case CTRL_LED2: + return true; #endif //CTRL_LED2 #ifdef GUI_LED1 - case GUI_LED1: - return true; + case GUI_LED1: + return true; #endif //GUI_LED1 #ifdef GUI_LED2 - case GUI_LED2: - return true; + case GUI_LED2: + return true; #endif //GUI_LED2 #ifdef ALT_LED1 - case ALT_LED1: - return true; + case ALT_LED1: + return true; #endif //ALT_LED1 #ifdef ALT_LED2 - case ALT_LED2: - return true; + case ALT_LED2: + return true; #endif //ALT_LED2 #endif //INDICATOR_LIGHTS - default: - return rgblight_twinkle_is_led_used_keymap(index); + 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 - 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]; - litup = true; + 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]; + 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]); + 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; + } } - light->timer = timer_read(); - } - else { - if (light->enabled && biton32(layer_state) == 0) { rgblight_sethsv_default_helper(light_index); } - litup = light->enabled = false; - } } - } - if (litup && biton32(layer_state) == 0) { - rgblight_set(); - } + if (litup && biton32(layer_state) == 0) { + rgblight_set(); + } } void start_rgb_light(void) { @@ -203,42 +205,42 @@ void start_rgb_light(void) { 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; - } - switch (keycode) { + if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) { + keycode = keycode & 0xFF; + } + switch (keycode) { #ifdef RGBLIGHT_TWINKLE - case KC_A ... KC_SLASH: - case KC_F1 ... KC_F12: - case KC_INSERT ... KC_UP: - 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; + case KC_A ... KC_SLASH: + case KC_F1 ... KC_F12: + case KC_INSERT ... KC_UP: + 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 - case KC_RGB_T: // This allows me to use underglow as layer indication, or as normal + 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) { - userspace_config.rgb_layer_change ^= 1; - 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) - } - } + if (record->event.pressed) { + userspace_config.rgb_layer_change ^= 1; + 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) + } + } #endif // RGBLIGHT_ENABLE - return false; break; + 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 - 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; + 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; @@ -248,28 +250,28 @@ bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) { 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 = 360; i > 0; i--) { - rgblight_sethsv_noeeprom( ( i + old_hue) % 360, 255, 255); - matrix_scan(); - wait_ms(10); + 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); + layer_state_set_user(layer_state); } void matrix_scan_rgb(void) { #ifdef RGBLIGHT_TWINKLE - scan_rgblight_fadeout(); + scan_rgblight_fadeout(); #endif // RGBLIGHT_ENABLE #ifdef INDICATOR_LIGHTS - matrix_scan_indicator(); + matrix_scan_indicator(); #endif } @@ -277,99 +279,60 @@ void matrix_scan_rgb(void) { uint32_t layer_state_set_rgb(uint32_t state) { #ifdef RGBLIGHT_ENABLE - if (userspace_config.rgb_layer_change) { - switch (biton32(state)) { - case _MACROS: - rgblight_sethsv_noeeprom_orange(); - userspace_config.is_overwatch ? rgblight_mode_noeeprom(RGBLIGHT_MODE_SNAKE + 2) : rgblight_mode_noeeprom(RGBLIGHT_MODE_SNAKE + 3); - break; - case _MEDIA: - rgblight_sethsv_noeeprom_chartreuse(); - rgblight_mode_noeeprom(RGBLIGHT_MODE_KNIGHT + 1); - break; - case _GAMEPAD: - rgblight_sethsv_noeeprom_orange(); - rgblight_mode_noeeprom(RGBLIGHT_MODE_SNAKE + 2); - break; - case _DIABLO: - rgblight_sethsv_noeeprom_red(); - rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING + 3); - break; - case _RAISE: - rgblight_sethsv_noeeprom_yellow(); - rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING + 3); - break; - case _LOWER: - rgblight_sethsv_noeeprom_green(); - rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING + 3); - break; - case _ADJUST: - rgblight_sethsv_noeeprom_red(); - rgblight_mode_noeeprom(RGBLIGHT_MODE_KNIGHT + 2); - break; - default: // for any other layers, or the default layer - switch (biton32(default_layer_state)) { - case _COLEMAK: - rgblight_sethsv_noeeprom_magenta(); break; - case _DVORAK: - rgblight_sethsv_noeeprom_springgreen(); break; - case _WORKMAN: - rgblight_sethsv_noeeprom_goldenrod(); break; - case _NORMAN: - rgblight_sethsv_noeeprom_coral(); break; - case _MALTRON: - rgblight_sethsv_noeeprom_yellow(); break; - case _EUCALYN: - rgblight_sethsv_noeeprom_pink(); break; - case _CARPLAX: - rgblight_sethsv_noeeprom_blue(); break; - default: - 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 - break; + if (userspace_config.rgb_layer_change) { + switch (biton32(state)) { + case _MACROS: + rgblight_sethsv_noeeprom_orange(); + userspace_config.is_overwatch ? rgblight_mode_noeeprom(RGBLIGHT_MODE_SNAKE + 2) : rgblight_mode_noeeprom(RGBLIGHT_MODE_SNAKE + 3); + break; + case _MEDIA: + rgblight_sethsv_noeeprom_chartreuse(); + rgblight_mode_noeeprom(RGBLIGHT_MODE_KNIGHT + 1); + break; + case _GAMEPAD: + rgblight_sethsv_noeeprom_orange(); + rgblight_mode_noeeprom(RGBLIGHT_MODE_SNAKE + 2); + break; + case _DIABLO: + rgblight_sethsv_noeeprom_red(); + rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING + 3); + break; + case _RAISE: + rgblight_sethsv_noeeprom_yellow(); + rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING + 3); + break; + case _LOWER: + rgblight_sethsv_noeeprom_green(); + rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING + 3); + break; + case _ADJUST: + rgblight_sethsv_noeeprom_red(); + rgblight_mode_noeeprom(RGBLIGHT_MODE_KNIGHT + 2); + break; + default: // for any other layers, or the default layer + switch (biton32(default_layer_state)) { + case _COLEMAK: + rgblight_sethsv_noeeprom_magenta(); break; + case _DVORAK: + rgblight_sethsv_noeeprom_springgreen(); break; + case _WORKMAN: + rgblight_sethsv_noeeprom_goldenrod(); break; + case _NORMAN: + rgblight_sethsv_noeeprom_coral(); break; + case _MALTRON: + rgblight_sethsv_noeeprom_yellow(); break; + case _EUCALYN: + rgblight_sethsv_noeeprom_pink(); break; + case _CARPLAX: + rgblight_sethsv_noeeprom_blue(); break; + default: + 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 + break; + } } -// layer_state_set_indicator(); // Runs every scan, so need to call this here .... since I can't get it working "right" anyhow - } #endif // RGBLIGHT_ENABLE - return state; -} - -#if 0 -uint32_t default_layer_state_set_rgb(uint32_t state) { -#ifdef RGBLIGHT_ENABLE - if (userspace_config.rgb_layer_change) { - rgblight_config_t temp_rgblight_config = rgblight_config; - switch (biton32(state)) { - case _COLEMAK: - temp_rgblight_config.hue = 300; - temp_rgblight_config.val = 255; - temp_rgblight_config.sat = 255; - temp_rgblight_config.mode = 1; - break; - case _DVORAK: - temp_rgblight_config.hue = 150; - temp_rgblight_config.val = 255; - temp_rgblight_config.sat = 255; - temp_rgblight_config.mode = 1; - case _WORKMAN: - temp_rgblight_config.hue = 43; - temp_rgblight_config.val = 218; - temp_rgblight_config.sat = 218; - temp_rgblight_config.mode = 1; - default: - temp_rgblight_config.hue = 180; - temp_rgblight_config.val = 255; - temp_rgblight_config.sat = 255; - temp_rgblight_config.mode = 1; - } - if (temp_rgblight_config.raw != eeconfig_read_rgblight()) { - xprintf("rgblight set default layer hsv [EEPROM]: %u,%u,%u,%u\n", temp_rgblight_config.hue, temp_rgblight_config.sat, temp_rgblight_config.val, temp_rgblight_config.mode); - eeconfig_update_rgblight(temp_rgblight_config.raw); - } - } -#endif // RGBLIGHT_ENABLE - return state; + return state; } -#endif diff --git a/users/drashna/rgblight_breathe_table.h b/users/drashna/rgblight_breathe_table.h new file mode 100644 index 0000000000..05d347fcd3 --- /dev/null +++ b/users/drashna/rgblight_breathe_table.h @@ -0,0 +1,116 @@ +#ifndef RGBLIGHT_EFFECT_BREATHE_TABLE +#define RGBLIGHT_EFFECT_BREATHE_TABLE + +const uint8_t rgblight_effect_breathe_table[] PROGMEM = { + /* #define RGBLIGHT_EFFECT_BREATHE_CENTER 0.00 */ + /* #define RGBLIGHT_EFFECT_BREATHE_MAX 255 */ + + #if RGBLIGHT_BREATHE_TABLE_SIZE == 256 + 0x44, 0x45, 0x47, 0x48, 0x4a, 0x4b, 0x4c, 0x4e, + 0x4f, 0x51, 0x52, 0x54, 0x55, 0x57, 0x58, 0x5a, + 0x5c, 0x5d, 0x5f, 0x60, 0x62, 0x64, 0x65, 0x67, + 0x69, 0x6a, 0x6c, 0x6e, 0x70, 0x72, 0x73, 0x75, + 0x77, 0x79, 0x7b, 0x7c, 0x7e, 0x80, 0x82, 0x84, + 0x86, 0x88, 0x8a, 0x8b, 0x8d, 0x8f, 0x91, 0x93, + 0x95, 0x97, 0x99, 0x9b, 0x9d, 0x9f, 0xa1, 0xa3, + 0xa5, 0xa7, 0xa9, 0xaa, 0xac, 0xae, 0xb0, 0xb2, + 0xb4, 0xb6, 0xb8, 0xba, 0xbc, 0xbe, 0xbf, 0xc1, + 0xc3, 0xc5, 0xc7, 0xc9, 0xca, 0xcc, 0xce, 0xd0, + 0xd1, 0xd3, 0xd5, 0xd6, 0xd8, 0xda, 0xdb, 0xdd, + 0xde, 0xe0, 0xe1, 0xe3, 0xe4, 0xe5, 0xe7, 0xe8, + 0xe9, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, + 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf8, + 0xf9, 0xfa, 0xfa, 0xfb, 0xfc, 0xfc, 0xfc, 0xfd, + 0xfd, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, + 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfd, + 0xfd, 0xfc, 0xfc, 0xfc, 0xfb, 0xfa, 0xfa, 0xf9, + 0xf8, 0xf8, 0xf7, 0xf6, 0xf5, 0xf4, 0xf3, 0xf2, + 0xf1, 0xf0, 0xef, 0xee, 0xed, 0xec, 0xeb, 0xe9, + 0xe8, 0xe7, 0xe5, 0xe4, 0xe3, 0xe1, 0xe0, 0xde, + 0xdd, 0xdb, 0xda, 0xd8, 0xd6, 0xd5, 0xd3, 0xd1, + 0xd0, 0xce, 0xcc, 0xca, 0xc9, 0xc7, 0xc5, 0xc3, + 0xc1, 0xbf, 0xbe, 0xbc, 0xba, 0xb8, 0xb6, 0xb4, + 0xb2, 0xb0, 0xae, 0xac, 0xaa, 0xa9, 0xa7, 0xa5, + 0xa3, 0xa1, 0x9f, 0x9d, 0x9b, 0x99, 0x97, 0x95, + 0x93, 0x91, 0x8f, 0x8d, 0x8b, 0x8a, 0x88, 0x86, + 0x84, 0x82, 0x80, 0x7e, 0x7c, 0x7b, 0x79, 0x77, + 0x75, 0x73, 0x72, 0x70, 0x6e, 0x6c, 0x6a, 0x69, + 0x67, 0x65, 0x64, 0x62, 0x60, 0x5f, 0x5d, 0x5c, + 0x5a, 0x58, 0x57, 0x55, 0x54, 0x52, 0x51, 0x4f, + 0x4e, 0x4c, 0x4b, 0x4a, 0x48, 0x47, 0x45, 0x44 + #endif /* 256 bytes table */ + + #if RGBLIGHT_BREATHE_TABLE_SIZE == 128 + 0x44, 0x47, 0x4a, 0x4c, + 0x4f, 0x52, 0x55, 0x58, + 0x5c, 0x5f, 0x62, 0x65, + 0x69, 0x6c, 0x70, 0x73, + 0x77, 0x7b, 0x7e, 0x82, + 0x86, 0x8a, 0x8d, 0x91, + 0x95, 0x99, 0x9d, 0xa1, + 0xa5, 0xa9, 0xac, 0xb0, + 0xb4, 0xb8, 0xbc, 0xbf, + 0xc3, 0xc7, 0xca, 0xce, + 0xd1, 0xd5, 0xd8, 0xdb, + 0xde, 0xe1, 0xe4, 0xe7, + 0xe9, 0xec, 0xee, 0xf0, + 0xf2, 0xf4, 0xf6, 0xf8, + 0xf9, 0xfa, 0xfc, 0xfc, + 0xfd, 0xfe, 0xfe, 0xfe, + 0xfe, 0xfe, 0xfe, 0xfe, + 0xfd, 0xfc, 0xfb, 0xfa, + 0xf8, 0xf7, 0xf5, 0xf3, + 0xf1, 0xef, 0xed, 0xeb, + 0xe8, 0xe5, 0xe3, 0xe0, + 0xdd, 0xda, 0xd6, 0xd3, + 0xd0, 0xcc, 0xc9, 0xc5, + 0xc1, 0xbe, 0xba, 0xb6, + 0xb2, 0xae, 0xaa, 0xa7, + 0xa3, 0x9f, 0x9b, 0x97, + 0x93, 0x8f, 0x8b, 0x88, + 0x84, 0x80, 0x7c, 0x79, + 0x75, 0x72, 0x6e, 0x6a, + 0x67, 0x64, 0x60, 0x5d, + 0x5a, 0x57, 0x54, 0x51, + 0x4e, 0x4b, 0x48, 0x45 + #endif /* 128 bytes table */ + + #if RGBLIGHT_BREATHE_TABLE_SIZE == 64 + 0x44, 0x4a, + 0x4f, 0x55, + 0x5c, 0x62, + 0x69, 0x70, + 0x77, 0x7e, + 0x86, 0x8d, + 0x95, 0x9d, + 0xa5, 0xac, + 0xb4, 0xbc, + 0xc3, 0xca, + 0xd1, 0xd8, + 0xde, 0xe4, + 0xe9, 0xee, + 0xf2, 0xf6, + 0xf9, 0xfc, + 0xfd, 0xfe, + 0xfe, 0xfe, + 0xfd, 0xfb, + 0xf8, 0xf5, + 0xf1, 0xed, + 0xe8, 0xe3, + 0xdd, 0xd6, + 0xd0, 0xc9, + 0xc1, 0xba, + 0xb2, 0xaa, + 0xa3, 0x9b, + 0x93, 0x8b, + 0x84, 0x7c, + 0x75, 0x6e, + 0x67, 0x60, + 0x5a, 0x54, + 0x4e, 0x48 + #endif /* 64 bytes table */ +}; + +static const int table_scale = 256/sizeof(rgblight_effect_breathe_table); + +#endif /* RGBLIGHT_EFFECT_BREATHE_TABLE */ diff --git a/users/drashna/rules.mk b/users/drashna/rules.mk index bef25e2594..085840f1cc 100644 --- a/users/drashna/rules.mk +++ b/users/drashna/rules.mk @@ -1,40 +1,40 @@ SRC += drashna.c \ process_records.c +LINK_TIME_OPTIMIZATION_ENABLE = yes + ifneq ("$(wildcard $(USER_PATH)/secrets.c)","") - SRC += secrets.c + SRC += secrets.c endif ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) - SRC += tap_dances.c + SRC += tap_dances.c endif -ifeq ($(PLATFORM),AVR) - EXTRAFLAGS += -flto -endif + ifeq ($(strip $(NO_SECRETS)), yes) OPT_DEFS += -DNO_SECRETS endif ifeq ($(strip $(RGBLIGHT_ENABLE)), yes) - SRC += rgb_stuff.c - ifeq ($(strip $(INDICATOR_LIGHTS)), yes) - OPT_DEFS += -DINDICATOR_LIGHTS - endif - ifeq ($(strip $(RGBLIGHT_TWINKLE)), yes) - OPT_DEFS += -DRGBLIGHT_TWINKLE - endif - ifeq ($(strip $(RGBLIGHT_NOEEPROM)), yes) - OPT_DEFS += -DRGBLIGHT_NOEEPROM - endif - ifeq ($(strip $(RGBLIGHT_STARTUP_ANIMATION)), yes) - OPT_DEFS += -DRGBLIGHT_STARTUP_ANIMATION - endif + SRC += rgb_stuff.c + ifeq ($(strip $(INDICATOR_LIGHTS)), yes) + OPT_DEFS += -DINDICATOR_LIGHTS + endif + ifeq ($(strip $(RGBLIGHT_TWINKLE)), yes) + OPT_DEFS += -DRGBLIGHT_TWINKLE + endif + ifeq ($(strip $(RGBLIGHT_NOEEPROM)), yes) + OPT_DEFS += -DRGBLIGHT_NOEEPROM + endif + ifeq ($(strip $(RGBLIGHT_STARTUP_ANIMATION)), yes) + OPT_DEFS += -DRGBLIGHT_STARTUP_ANIMATION + endif endif -ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes) - SRC += rgb_stuff.c +ifneq ($(strip $(RGB_MATRIX_ENABLE)), no) + SRC += rgb_stuff.c endif @@ -43,9 +43,9 @@ ifeq ($(strip $(MACROS_ENABLED)), yes) endif ifdef CONSOLE_ENABLE - ifeq ($(strip $(KEYLOGGER_ENABLE)), yes) - OPT_DEFS += -DKEYLOGGER_ENABLE - endif + ifeq ($(strip $(KEYLOGGER_ENABLE)), yes) + OPT_DEFS += -DKEYLOGGER_ENABLE + endif endif ifeq ($(strip $(MAKE_BOOTLOADER)), yes) diff --git a/users/drashna/send_unicode.h b/users/drashna/send_unicode.h index 818b6e571b..743abc58b4 100644 --- a/users/drashna/send_unicode.h +++ b/users/drashna/send_unicode.h @@ -7,65 +7,65 @@ 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 😒 + THINK, // thinking face 🤔 + GRIN, // grinning face 😊 + SMRK, // smirk 😏 + WEARY, // good shit 😩 + UNAMU, // unamused 😒 - SNEK, // snke 🐍 - PENGUIN, // 🐧 - DRAGON, // 🐉 - MONKEY, // 🐒 - CHICK, // 🐥 - BOAR, // 🐗 + SNEK, // snke 🐍 + PENGUIN, // 🐧 + DRAGON, // 🐉 + MONKEY, // 🐒 + CHICK, // 🐥 + BOAR, // 🐗 - OKOK, // 👌 - EFFU, // 🖕 - INUP, // 👆 - THUP, // 👍 - THDN, // 👎 + OKOK, // 👌 + EFFU, // 🖕 + INUP, // 👆 + THUP, // 👍 + THDN, // 👎 - BBB, // dat B 🅱 - POO, // poop 💩 - HUNDR, // 100 💯 - EGGPL, // EGGPLANT 🍆 - WATER, // wet 💦 - TUMBLER, // 🥃 + BBB, // dat B 🅱 + POO, // poop 💩 + HUNDR, // 100 💯 + EGGPL, // EGGPLANT 🍆 + WATER, // wet 💦 + TUMBLER, // 🥃 - LIT, // fire 🔥 - BANG, // ‽ - IRONY, // ⸮ - DEGREE // ° + 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 + [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 cbb3cf54ef..18ca96e187 100644 --- a/users/drashna/tap_dances.c +++ b/users/drashna/tap_dances.c @@ -2,63 +2,64 @@ //define diablo macro timer variables -uint16_t diablo_timer[4]; -uint8_t diablo_times[] = { 0, 1, 3, 5, 10, 30 }; -uint8_t diablo_key_time[4]; +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]) < (diablo_key_time[dtimer] * 1000)) ? false : true; }; +bool check_dtimer(uint8_t dtimer) { return (timer_elapsed(diablo_timer[dtimer].key_time) < (diablo_timer[dtimer].timer * 1000)) ? false : true; }; // 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, uint8_t diablo_key) { - if (state->count >= 7) { - diablo_key_time[diablo_key] = diablo_times[0]; - reset_tap_dance(state); - } else { - diablo_key_time[diablo_key] = diablo_times[state->count - 1]; - } +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]; + reset_tap_dance(state); + } else { + diablo_timer[index].key_time = diablo_times[state->count]; + } } -// Would rather have one function for all of this, but no idea how to do that... -void diablo_tapdance1(qk_tap_dance_state_t *state, void *user_data) { diablo_tapdance_master(state, user_data, 0); } -void diablo_tapdance2(qk_tap_dance_state_t *state, void *user_data) { diablo_tapdance_master(state, user_data, 1); } -void diablo_tapdance3(qk_tap_dance_state_t *state, void *user_data) { diablo_tapdance_master(state, user_data, 2); } -void diablo_tapdance4(qk_tap_dance_state_t *state, void *user_data) { diablo_tapdance_master(state, user_data, 3); } +// One funtion to rule them all!! +#define ACTION_TAP_DANCE_DIABLO(arg) { \ + .fn = { NULL, (void *)diablo_tapdance_master, NULL }, \ + .user_data = (void *)arg, \ + } //Tap Dance Definitions qk_tap_dance_action_t tap_dance_actions[] = { - // tap once to disable, and more to enable timed micros - [TD_D3_1] = ACTION_TAP_DANCE_FN(diablo_tapdance1), - [TD_D3_2] = ACTION_TAP_DANCE_FN(diablo_tapdance2), - [TD_D3_3] = ACTION_TAP_DANCE_FN(diablo_tapdance3), - [TD_D3_4] = ACTION_TAP_DANCE_FN(diablo_tapdance4), + // 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), }; // 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; + 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_key_time[dtime]) { - diablo_timer[dtime] = timer_read(); - send_diablo_keystroke(dtime); + 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); + } } - } } diff --git a/users/drashna/tap_dances.h b/users/drashna/tap_dances.h index 41d2bacb7b..4a293b2582 100644 --- a/users/drashna/tap_dances.h +++ b/users/drashna/tap_dances.h @@ -2,18 +2,21 @@ #include "drashna.h" //define diablo macro timer variables -extern uint16_t diablo_timer[4]; extern uint8_t diablo_times[]; -extern uint8_t diablo_key_time[4]; +typedef struct { + uint16_t timer; + uint8_t key_time; +} diablo_timer_t; +extern diablo_timer_t diablo_timer[4]; void run_diablo_macro_check(void); #ifdef TAP_DANCE_ENABLE enum { - TD_D3_1 = 0, - TD_D3_2, - TD_D3_3, - TD_D3_4 + TD_D3_1 = 0, + TD_D3_2, + TD_D3_3, + TD_D3_4 }; #endif // TAP_DANCE_ENABLE diff --git a/users/drashna/wrappers.h b/users/drashna/wrappers.h index 3260c58ae2..93f842f4b2 100644 --- a/users/drashna/wrappers.h +++ b/users/drashna/wrappers.h @@ -6,7 +6,7 @@ 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 #define LAYOUT_ergodox_wrapper(...) LAYOUT_ergodox(__VA_ARGS__) @@ -15,6 +15,7 @@ expanded before being used as arguments to the LAYOUT_xxx macro. #define LAYOUT_wrapper(...) LAYOUT(__VA_ARGS__) #define LAYOUT_ortho_4x12_wrapper(...) LAYOUT_ortho_4x12(__VA_ARGS__) #define LAYOUT_ortho_5x12_wrapper(...) LAYOUT_ortho_5x12(__VA_ARGS__) +#define LAYOUT_gergo_wrapper(...) LAYOUT_gergo(__VA_ARGS__) /* Blocks for each of the four major keyboard layouts |