From e4bbe057f2620ee24c3a78cb758cdfa7c4bd7abf Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Wed, 29 Aug 2018 10:42:15 -0700 Subject: Yet another update to drashna keymaps and userspace (#3787) * Make tap function inline * Use better makefile keyboard detection * Remove Copy-Paste macro * Add F11/F12 to Iris * Minor tweaks to userspace config * Set audio clicky randomness to 1.5 * Set NO_DEBUG to only be set if console is not enabled * Move NO_MUSIC_MODE to userspace config.h * Reduce Ergodox Debounce * Add Planck Light config * Use OSM for ortho 4x12 * Music Mode changes for planck light * Cleanup do to shutdown user and other fixes in Master * Add and use 'shutdown_user' fzunction * Remove global NO_MUSIC_MODE define * Add NO_MUSIC_MODE to individual keymaps * Change layer colors * Remove NO_PRINT and NO_DEBUG from userspace config.h Since these are automatically disabled if the console isn't enabled. * Remove backlight code if backlight isn't enabled * Remove Twinkle from Ergodox * Disable RGB twinkling and enable PSM * Clean up RGB matrix code * Clean up planck light indicators * Clean up tap code * Rules cleanup for ortho 4x12 * Fix up userspace template * Revert "Clean up tap code" This reverts commit 09f64d6d67aa021c3b5ac86a9a739a5ca2b9c1ec. * Organize includes * userspace cleanup * Fix modifier spelling error * Fix userspace rules * Disable Permissive Hold again * Minor clean up * Fix Tap stuff * Viterbi Updates for file size --- users/drashna/config.h | 16 +++----- users/drashna/drashna.c | 75 ++++++++++++++---------------------- users/drashna/drashna.h | 22 +++++++---- users/drashna/rgb_stuff.c | 6 +-- users/drashna/rgb_stuff.h | 1 - users/drashna/template.c | 97 +++++++++++++++++++++++++++++++++-------------- users/drashna/template.h | 4 +- 7 files changed, 124 insertions(+), 97 deletions(-) (limited to 'users') diff --git a/users/drashna/config.h b/users/drashna/config.h index 87050fbcc7..dd6875ceb1 100644 --- a/users/drashna/config.h +++ b/users/drashna/config.h @@ -11,8 +11,10 @@ SONG(OVERWATCH_THEME) \ } -#define AUDIO_CLICKY_FREQ_RANDOMNESS 1.0f - +#define AUDIO_CLICKY_FREQ_RANDOMNESS 1.5f +// #ifdef RGBLIGHT_ENABLE +// #define NO_MUSIC_MODE +// #endif //RGBLIGHT_ENABLE #endif #ifdef RGBLIGHT_ENABLE @@ -40,8 +42,8 @@ // and when this option isn't enabled, z rapidly followed by x // actually sends Ctrl-x. That's bad.) #define IGNORE_MOD_TAP_INTERRUPT -#undef PERMISSIVE_HOLD -#undef PREVENT_STUCK_MODIFIERS +#undef PERMISSIVE_HOLD +#define PREVENT_STUCK_MODIFIERS // #define TAPPING_FORCE_HOLD //#define RETRO_TAPPING @@ -59,12 +61,6 @@ // Disable action_get_macro and fn_actions, since we don't use these // and it saves on space in the firmware. -#ifndef NO_DEBUG -#define NO_DEBUG -#endif // !NO_DEBUG -#if !defined(NO_PRINT) && !defined(CONSOLE_ENABLE) -#define NO_PRINT -#endif // !NO_PRINT #define NO_ACTION_MACRO #define NO_ACTION_FUNCTION diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c index f72902f0b0..20df2f4de6 100644 --- a/users/drashna/drashna.c +++ b/users/drashna/drashna.c @@ -16,16 +16,9 @@ along with this program. If not, see . */ #include "drashna.h" -#include "version.h" -#include "eeprom.h" #include "tap_dances.h" #include "rgb_stuff.h" - -float tone_copy[][2] = SONG(SCROLL_LOCK_ON_SOUND); -float tone_paste[][2] = SONG(SCROLL_LOCK_OFF_SOUND); - -static uint16_t copy_paste_timer; userspace_config_t userspace_config; // Helper Functions @@ -35,8 +28,14 @@ userspace_config_t userspace_config; // 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; + } clear_keyboard(); - tap(userspace_config.is_overwatch ? KC_BSPC : KC_ENTER); + tap(keycode); wait_ms(50); send_string_with_delay(str, MACRO_TIMER); wait_ms(50); @@ -46,8 +45,6 @@ bool send_game_macro(const char *str, keyrecord_t *record, bool override) { return false; } -void tap(uint16_t keycode){ register_code(keycode); unregister_code(keycode); }; - bool mod_key_press_timer (uint16_t code, uint16_t mod_code, bool pressed) { static uint16_t this_timer; if(pressed) { @@ -93,6 +90,9 @@ void matrix_init_keymap(void) {} __attribute__ ((weak)) void startup_keymap(void) {} +__attribute__ ((weak)) +void shutdown_keymap(void) {} + __attribute__ ((weak)) void suspend_power_down_keymap(void) {} @@ -127,6 +127,7 @@ __attribute__ ((weak)) void led_set_keymap(uint8_t usb_led) {} + // Call user matrix init, set default RGB colors and then // call the keymap's init function void matrix_init_user(void) { @@ -158,6 +159,24 @@ void startup_user (void) { startup_keymap(); } +void shutdown_user (void) { +#ifdef RGBLIGHT_ENABLE + rgblight_enable_noeeprom(); + rgblight_mode_noeeprom(1); + rgblight_setrgb_red(); +#endif // RGBLIGHT_ENABLE +#ifdef RGB_MATRIX_ENABLE + rgb_led led; + for (int i = 0; i < DRIVER_LED_TOTAL; i++) { + led = g_rgb_leds[i]; + if (led.matrix_co.raw < 0xFF) { + rgb_matrix_set_color( i, 0xFF, 0x00, 0x00 ); + } + } +#endif //RGB_MATRIX_ENABLE + shutdown_keymap(); +} + void suspend_power_down_user(void) { suspend_power_down_keymap(); @@ -246,20 +265,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { return false; break; - - case KC_RESET: // Custom RESET code that sets RGBLights to RED - if (!record->event.pressed) { -#ifdef RGBLIGHT_ENABLE - rgblight_enable_noeeprom(); - rgblight_mode_noeeprom(1); - rgblight_setrgb_red(); -#endif // RGBLIGHT_ENABLE - reset_keyboard(); - } - return false; - break; - - case EPRM: // Resets EEPROM if (record->event.pressed) { eeconfig_init(); @@ -333,28 +338,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { return false; 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(KC_C); - unregister_code(KC_LCTL); -#ifdef AUDIO_ENABLE - PLAY_SONG(tone_copy); -#endif - } else { // Tap, paste - register_code(KC_LCTL); - tap(KC_V); - unregister_code(KC_LCTL); -#ifdef AUDIO_ENABLE - PLAY_SONG(tone_paste); -#endif - } - } - return false; - break; case CLICKY_TOGGLE: #ifdef AUDIO_CLICKY userspace_config.clicky_enable = clicky_enable; diff --git a/users/drashna/drashna.h b/users/drashna/drashna.h index 3efef57046..dd0d1c0d7e 100644 --- a/users/drashna/drashna.h +++ b/users/drashna/drashna.h @@ -15,11 +15,13 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef USERSPACE -#define USERSPACE +#pragma once #include "quantum.h" - - +#include "version.h" +#include "eeprom.h" +#ifdef RGB_MATRIX_ENABLE +#include "rgb_matrix.h" +#endif // Define layer names enum userspace_layers { _QWERTY = 0, @@ -53,7 +55,7 @@ extern bool clicky_enable; void rgblight_sethsv_default_helper(uint8_t index); #endif // RGBLIGHT_ENABLE -void tap(uint16_t keycode); +inline void tap(uint16_t keycode){ register_code(keycode); unregister_code(keycode); }; 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); @@ -90,7 +92,6 @@ enum userspace_custom_keycodes { KC_C9, KC_GGEZ, KC_MAKE, // Run keyboard's customized make command - KC_RESET, // Resets keyboard, with red underglow KC_RGB_T, // Toggles RGB Layer Indication mode KC_SECRET_1, // test1 KC_SECRET_2, // test2 @@ -123,6 +124,7 @@ enum userspace_custom_keycodes { #define COLEMAK KC_COLEMAK #define WORKMAN KC_WORKMAN +#define KC_RESET RESET #define KC_RST KC_RESET #ifdef SWAP_HANDS_ENABLE @@ -131,6 +133,11 @@ enum userspace_custom_keycodes { #define KC_C1R3 KC_BSPC #endif // SWAP_HANDS_ENABLE +#define BK_LWER LT(_LOWER, KC_BSPC) +#define SP_LWER LT(_LOWER, KC_SPC) +#define DL_RAIS LT(_RAISE, KC_DEL) +#define ET_RAIS LT(_RAISE, KC_ENTER) + // OSM keycodes, to keep things clean and easy to change #define KC_MLSF OSM(MOD_LSFT) #define KC_MRSF OSM(MOD_RSFT) @@ -325,7 +332,7 @@ enum { #define _________________ADJUST_L1_________________ RGB_MOD, RGB_HUI, RGB_SAI, RGB_VAI, RGB_TOG -#define _________________ADJUST_L2_________________ _______, CK_TOGG, AU_ON, AU_OFF, AG_NORM +#define _________________ADJUST_L2_________________ MU_TOG , CK_TOGG, AU_ON, AU_OFF, AG_NORM #define _________________ADJUST_L3_________________ RGB_RMOD,RGB_HUD,RGB_SAD, RGB_VAD, KC_RGB_T #define _________________ADJUST_R1_________________ KC_SEC1, KC_SEC2, KC_SEC3, KC_SEC4, KC_SEC5 @@ -350,4 +357,3 @@ enum { LT(_LOWER, KC_SPACE),KC_BSPC, KC_END, KC_PGDN, KC_DEL, LT(_RAISE, KC_ENTER) -#endif // !USERSPACE diff --git a/users/drashna/rgb_stuff.c b/users/drashna/rgb_stuff.c index f2a9a47a90..03c55b1323 100644 --- a/users/drashna/rgb_stuff.c +++ b/users/drashna/rgb_stuff.c @@ -267,7 +267,7 @@ void matrix_init_rgb(void) { case _COLEMAK: rgblight_sethsv_noeeprom_magenta(); break; case _DVORAK: - rgblight_sethsv_noeeprom_green(); break; + rgblight_sethsv_noeeprom_springgreen(); break; case _WORKMAN: rgblight_sethsv_noeeprom_goldenrod(); break; default: @@ -313,7 +313,7 @@ uint32_t layer_state_set_rgb(uint32_t state) { rgblight_mode_noeeprom(5); break; case _LOWER: - rgblight_sethsv_noeeprom_orange(); + rgblight_sethsv_noeeprom_green(); rgblight_mode_noeeprom(5); break; case _ADJUST: @@ -325,7 +325,7 @@ uint32_t layer_state_set_rgb(uint32_t state) { case _COLEMAK: rgblight_sethsv_noeeprom_magenta(); break; case _DVORAK: - rgblight_sethsv_noeeprom_green(); break; + rgblight_sethsv_noeeprom_springgreen(); break; case _WORKMAN: rgblight_sethsv_noeeprom_goldenrod(); break; default: diff --git a/users/drashna/rgb_stuff.h b/users/drashna/rgb_stuff.h index 6426ea266f..50c75c8c3c 100644 --- a/users/drashna/rgb_stuff.h +++ b/users/drashna/rgb_stuff.h @@ -13,4 +13,3 @@ void matrix_init_rgb(void); void matrix_scan_rgb(void); uint32_t layer_state_set_rgb(uint32_t state); - diff --git a/users/drashna/template.c b/users/drashna/template.c index 20dbb96d7f..e6b50c961b 100644 --- a/users/drashna/template.c +++ b/users/drashna/template.c @@ -1,7 +1,5 @@ -#include "drashna.h" -#include "quantum.h" -#include "action.h" -#include "version.h" +#include "template.h" + // Add reconfigurable functions here, for keymap customization // This allows for a global, userspace functions, and continued @@ -10,25 +8,15 @@ __attribute__ ((weak)) void matrix_init_keymap(void) {} -__attribute__ ((weak)) -void matrix_scan_keymap(void) {} - -__attribute__ ((weak)) -bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { - return true; -} -__attribute__ ((weak)) -uint32_t layer_state_set_keymap (uint32_t state) { - return state; -} -__attribute__ ((weak)) -void led_set_keymap(uint8_t usb_led) {} - // Call user matrix init, then call the keymap's init function void matrix_init_user(void) { matrix_init_keymap(); } + +__attribute__ ((weak)) +void matrix_scan_keymap(void) {} + // No global matrix scan code, so just run keymap's matix // scan function void matrix_scan_user(void) { @@ -36,11 +24,16 @@ void matrix_scan_user(void) { } +__attribute__ ((weak)) +bool process_record_keymap(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 recod handier if not processed here, // And use "NEWPLACEHOLDER" for new safe range bool process_record_user(uint16_t keycode, keyrecord_t *record) { - + switch (keycode) { case KC_MAKE: if (!record->event.pressed) { @@ -56,12 +49,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } return false; break; - case KC_RESET: - if (!record->event.pressed) { - reset_keyboard(); - } - return false; - break; + case EPRM: if (record->event.pressed) { eeconfig_init(); @@ -78,13 +66,66 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { return process_record_keymap(keycode, record); } -// Runs state check and changes underglow color and animation -// on layer change, no matter where the change was initiated -// Then runs keymap's layer change check + +__attribute__ ((weak)) +uint32_t layer_state_set_keymap (uint32_t state) { + return state; +} + uint32_t layer_state_set_user (uint32_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(); + #ifdef KEYBOARD_ergodox_ez + wait_ms(10); + #endif +} + + + +__attribute__ ((weak)) +void startup_keymap(void) {} + +void startup_user (void) { + #ifdef RGBLIGHT_ENABLE + matrix_init_rgb(); + #endif //RGBLIGHT_ENABLE + startup_keymap(); +} + + + +__attribute__ ((weak)) +void shutdown_keymap(void) {} + +void shutdown_user (void) { + shutdown_keymap(); +} + diff --git a/users/drashna/template.h b/users/drashna/template.h index d1251462b2..5b3a93de5f 100644 --- a/users/drashna/template.h +++ b/users/drashna/template.h @@ -2,8 +2,10 @@ #define USERSPACE #include "quantum.h" +#include "version.h" +#include "eeprom.h" -// Define layer names +// Define layer names #define BASE 0 enum custom_keycodes { -- cgit v1.2.3 From 2fcfd5cff7089338385c40a630315939a7a9ebbc Mon Sep 17 00:00:00 2001 From: wanleg <32079073+wanleg@users.noreply.github.com> Date: Thu, 30 Aug 2018 09:34:14 -0700 Subject: Keymap: Wanleg updates (#3794) * various edits and minor additions * updates * updates * updates * lets_split LEDs off instructions * lets_split LEDs off instructions * turn off lets_split LEDs in userspace * one-hand setup for right side --- users/wanleg/wanleg.c | 21 +++++++++++++++++++++ users/wanleg/wanleg.h | 7 ++++--- 2 files changed, 25 insertions(+), 3 deletions(-) (limited to 'users') diff --git a/users/wanleg/wanleg.c b/users/wanleg/wanleg.c index 0175ae2010..931546c153 100644 --- a/users/wanleg/wanleg.c +++ b/users/wanleg/wanleg.c @@ -156,3 +156,24 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } return true; } + +/// Turn off LEDs on ProMicros of Let's Split /// +// LEDs only on by default on Let's Split +// Add reconfigurable functions here, for keymap customization +// This allows for a global, userspace functions, and continued +// customization of the keymap. Use _keymap instead of _user +// functions in the keymaps +__attribute__ ((weak)) +void matrix_init_keymap(void) {} + +// Call user matrix init, then call the keymap's init function +void matrix_init_user(void) { +#if defined(KEYBOARD_lets_split_rev2) + DDRD &= ~(1<<5); + PORTD &= ~(1<<5); + + DDRB &= ~(1<<0); + PORTB &= ~(1<<0); +#endif + matrix_init_keymap(); +} \ No newline at end of file diff --git a/users/wanleg/wanleg.h b/users/wanleg/wanleg.h index da14dcdf5a..5cec82e605 100644 --- a/users/wanleg/wanleg.h +++ b/users/wanleg/wanleg.h @@ -119,6 +119,7 @@ enum { #define KEYMAP_wrapper(...) LAYOUT(__VA_ARGS__) #define LAYOUT_wrapper(...) LAYOUT(__VA_ARGS__) #define LAYOUT_ortho_3x10_wrapper(...) LAYOUT_ortho_3x10(__VA_ARGS__) +#define LAYOUT_ortho_5x10_wrapper(...) LAYOUT_ortho_5x10(__VA_ARGS__) #define LAYOUT_ortho_4x12_wrapper(...) LAYOUT_ortho_4x12(__VA_ARGS__) #define LAYOUT_ortho_5x15_wrapper(...) LAYOUT_ortho_5x15(__VA_ARGS__) @@ -204,7 +205,7 @@ enum { #define _______________GherkinLike_1_______________ KC_TAB, _______________Gherkin_Row_1_______________, KC_QUOT #define _______________GherkinLike_2_______________ TD(TD_SFT_CAPS), SFT_T(KC_Z), KC_X, KC_C, LT(NUM, KC_V),LT(ETC, KC_B),KC_N, LT(DIR, KC_M), GUI_T(KC_COMM), ALT_T(KC_DOT), CTL_T(KC_BSPC), SFT_T(KC_ENT) #define _______________GherkinLike_3_______________ KC_LCTL, KC_LGUI, KC_LALT, KC_LALT, NUMBER, ETCETERA, KC_SPC,DIRECTION, KC_RGUI, KC_RALT, KC_DEL, KC_RCTL -#define _______________GherkinLike_3_OneHand_______ KC_LCTL, KC_LGUI, KC_LALT, ONEHAND, NUMBER, ETCETERA, KC_SPC,DIRECTION, KC_RGUI, KC_RALT, KC_DEL, KC_RCTL +#define _______________GherkinLike_3_OneHand_______ KC_LCTL, KC_LGUI, KC_LALT, ONEHAND, NUMBER, ETCETERA, KC_SPC,DIRECTION, KC_RGUI, KC_RALT, ONEHAND, KC_RCTL /* Qwerty * .-------------------------------------------------------------------------------------. @@ -257,7 +258,7 @@ enum { /* Gherkin Numbers * .-----------------------------------------------------------------------------------------------------------. - * | | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | DEL | + * | | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | BACKSP | * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------| * | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | | * |--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------+--------| @@ -267,7 +268,7 @@ enum { * | | | | | | | ENTER | SHIFT | RGUI | | | | * '-----------------------------------------------------------------------------------------------------------' */ -#define _______________NUMBERS_Row_0_______________ _______, _______________Gherkin_NUM_0_______________, KC_DEL +#define _______________NUMBERS_Row_0_______________ _______, _______________Gherkin_NUM_0_______________, KC_BSPC #define _______________NUMBERS_Row_1_______________ _______, _______________Gherkin_NUM_1_______________, _______ #define _______________NUMBERS_Row_2_______________ _______, _______________Gherkin_NUM_2_______________, _______ #define _______________NUMBERS_Row_3_______________ _______, _______, _______, _______, _______, _______, KC_ENT, KC_RSFT, KC_RGUI, _______, _______, _______ -- cgit v1.2.3 From 78ef62764bfba2b7cb1fb34e477953c16c7a926d Mon Sep 17 00:00:00 2001 From: Christon DeWan Date: Fri, 31 Aug 2018 11:28:14 -0400 Subject: Keymap: I got my intern a KBParadise V60 Type R... (#3813) * new mode for v60 xtonhasvim. still working on it: - need to get indicator lights going - and fun layer properly fleshed out. * status lighting, proper fun layer copied fun layout from keycaps to maximize accessibility * enable power return * support brightness adjustment for indicators * refined brightness setting. is saved in eeprom now * readme. and fixed tilde * more modifiers fall through fun layer * i mean, this kinda works.. * much more reliable way of restoring lights * responded to feedback --- users/xtonhasvim/fancylighting.c | 7 ++++++- users/xtonhasvim/fancylighting.h | 9 +++++---- users/xtonhasvim/xtonhasvim.h | 6 ++---- 3 files changed, 13 insertions(+), 9 deletions(-) (limited to 'users') diff --git a/users/xtonhasvim/fancylighting.c b/users/xtonhasvim/fancylighting.c index f4af5ec55d..dc13df03f7 100644 --- a/users/xtonhasvim/fancylighting.c +++ b/users/xtonhasvim/fancylighting.c @@ -34,9 +34,14 @@ void matrix_scan_keymap(void) { #define FADE_BACK_TIME 500 #define BREATH_FIRE_TIME 1000 #define ANIMATION_STEP_INTERVAL 20 + +#if RGBLED_NUM >= 2 #define POWER_KEY_OFFSET (RGBLED_NUM / 2) #define SPACE_OFFSET_MAX (RGBLED_NUM / 2) - +#else +#define POWER_KEY_OFFSET 1 +#define SPACE_OFFSET_MAX 1 +#endif uint16_t effect_start_timer = 0; uint8_t user_rgb_mode = 0; diff --git a/users/xtonhasvim/fancylighting.h b/users/xtonhasvim/fancylighting.h index 982010d3d5..02fb58b84a 100644 --- a/users/xtonhasvim/fancylighting.h +++ b/users/xtonhasvim/fancylighting.h @@ -1,4 +1,4 @@ -p /* Copyright 2015-2017 Christon DeWan +/* Copyright 2015-2017 Christon DeWan * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,16 +20,17 @@ p /* Copyright 2015-2017 Christon DeWan #include "xtonhasvim.h" + extern uint8_t user_rgb_mode; extern LED_TYPE shadowed_led[]; -void start_firey_return(void); -#endif //_fancy_lighting_h +#endif //RGBLIGHT_ENABLE +void start_firey_return(void); enum xtonhasvim_rgbmodes { BREATH_FIRE = 1, FADE_BACK }; -#endif //RGBLIGHT_ENABLE +#endif //_fancy_lighting_h diff --git a/users/xtonhasvim/xtonhasvim.h b/users/xtonhasvim/xtonhasvim.h index 5ff4932a48..2d6670a5e6 100644 --- a/users/xtonhasvim/xtonhasvim.h +++ b/users/xtonhasvim/xtonhasvim.h @@ -22,11 +22,9 @@ #define X_____X KC_NO -bool process_record_xtonhasvim(uint16_t keycode, keyrecord_t *record); - enum xtonhasvim_keycodes { - DUMMY = SAFE_RANGE, - FIREY_RETURN, // kick off special effects + // 20: give keyboard-specific codes some room + FIREY_RETURN = SAFE_RANGE + 20, // kick off special effects VIM_START, // bookend for vim states VIM_A, VIM_B, -- cgit v1.2.3 From fb79015049ebd1309cd4f69a7584db614f50d1db Mon Sep 17 00:00:00 2001 From: MechMerlin <30334081+mechmerlin@users.noreply.github.com> Date: Fri, 31 Aug 2018 14:49:18 -0700 Subject: Keymap: Merlin Learns to QMK (#3820) * Fix up my keymaps to use more QMK features * update 60_ansi readme * add the start of my userspace * begin to use my new userspace * use more of my userspace * spread userspace love to my clueboard * spread userspace love to 75 layout * add a fairly vanilla readme * put the FNX into a userspace incase I ever want to use it for something else * respond to drashna's code review comments --- users/mechmerlin/mechmerlin.c | 20 ++++++++++++++++++++ users/mechmerlin/mechmerlin.h | 17 +++++++++++++++++ users/mechmerlin/readme.md | 3 +++ users/mechmerlin/rules.mk | 1 + 4 files changed, 41 insertions(+) create mode 100644 users/mechmerlin/mechmerlin.c create mode 100644 users/mechmerlin/mechmerlin.h create mode 100644 users/mechmerlin/readme.md create mode 100644 users/mechmerlin/rules.mk (limited to 'users') diff --git a/users/mechmerlin/mechmerlin.c b/users/mechmerlin/mechmerlin.c new file mode 100644 index 0000000000..8d6cecd18b --- /dev/null +++ b/users/mechmerlin/mechmerlin.c @@ -0,0 +1,20 @@ +#include "mechmerlin.h" + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + static uint16_t fnx_layer_timer; + + switch (keycode){ + case KC_FNX: + if(record->event.pressed){ + fnx_layer_timer = timer_read(); + layer_on(_FL); + } else { + layer_off(_FL); + if (timer_elapsed(fnx_layer_timer) < 150) { + layer_invert(_AL); + } + } + return false; + } + return true; +} \ No newline at end of file diff --git a/users/mechmerlin/mechmerlin.h b/users/mechmerlin/mechmerlin.h new file mode 100644 index 0000000000..c140ac70c9 --- /dev/null +++ b/users/mechmerlin/mechmerlin.h @@ -0,0 +1,17 @@ +#pragma once + +#include "quantum.h" + +enum userspace_layers { + _BL = 0, // Base Layer + _FL, // Function Layer + _AL // Arrow Layer +}; + +// Enum of custom keycodes defined in process_record_user +enum keycodes { + KC_FNX, // Hold for FN layer, tap to toggle ARROWS layer. +}; + +// Custom #defined keycodes +#define KC_CTCP MT(KC_LCTL, KC_CAPS) diff --git a/users/mechmerlin/readme.md b/users/mechmerlin/readme.md new file mode 100644 index 0000000000..6a76dd2a9d --- /dev/null +++ b/users/mechmerlin/readme.md @@ -0,0 +1,3 @@ +# MechMerlin's Userspace + +This is a collection of my most commonly used QMK functions diff --git a/users/mechmerlin/rules.mk b/users/mechmerlin/rules.mk new file mode 100644 index 0000000000..70c20ec71e --- /dev/null +++ b/users/mechmerlin/rules.mk @@ -0,0 +1 @@ +SRC += mechmerlin.c \ No newline at end of file -- cgit v1.2.3 From aa795dc33ee1c854a3ea5a3cb3d15e7e68be89d6 Mon Sep 17 00:00:00 2001 From: Xin-Xin Wang Date: Mon, 3 Sep 2018 19:55:06 -0400 Subject: Keymap: Fix missing braces around initializer error on older gcc (#3840) --- users/xtonhasvim/fancylighting.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'users') diff --git a/users/xtonhasvim/fancylighting.c b/users/xtonhasvim/fancylighting.c index dc13df03f7..a88ca4beb3 100644 --- a/users/xtonhasvim/fancylighting.c +++ b/users/xtonhasvim/fancylighting.c @@ -45,7 +45,7 @@ void matrix_scan_keymap(void) { uint16_t effect_start_timer = 0; uint8_t user_rgb_mode = 0; -LED_TYPE shadowed_led[RGBLED_NUM] = {0}; +LED_TYPE shadowed_led[RGBLED_NUM] = {{0}}; void start_firey_return(void) { user_rgb_mode = BREATH_FIRE; @@ -79,7 +79,7 @@ void set_color_for_offsets(uint16_t time_offset, uint16_t space_offset, uint8_t float alpha = (time_progress + 0.1) * 7.0 - space_progress; alpha = fmin(1.0, alpha*alpha); - LED_TYPE px[1] = {0}; + LED_TYPE px[1] = {{0}}; sethsv((uint16_t)(fmod(time_progress * 1.5 + space_progress,1.0)*360), 255, (uint8_t)(progress*255),&px[0]); led[idx].r = alpha * px[0].r + ( 1.0 - alpha) * shadowed_led[idx].r; led[idx].g = alpha * px[0].g + ( 1.0 - alpha) * shadowed_led[idx].g; -- cgit v1.2.3 From 743449472e58651ec8111e6f70811103fb0a28bd Mon Sep 17 00:00:00 2001 From: Joe Wasson Date: Mon, 17 Sep 2018 10:48:02 -0700 Subject: Make `PREVENT_STUCK_MODIFIERS` the default (#3107) * Remove chording as it is not documented, not used, and needs work. * Make Leader Key an optional feature. * Switch from `PREVENT_STUCK_MODIFIERS` to `STRICT_LAYER_RELEASE` * Remove `#define PREVENT_STUCK_MODIFIERS` from keymaps. --- users/333fred/333fred_config.h | 1 - users/bocaj/config.h | 1 - users/drashna/config.h | 5 ----- users/ishtob/config.h | 3 +-- users/replicaJunction/config.h | 6 ------ users/talljoe/config.h | 1 - users/wanleg/config.h | 2 -- users/zer09/config.h | 2 +- 8 files changed, 2 insertions(+), 19 deletions(-) (limited to 'users') diff --git a/users/333fred/333fred_config.h b/users/333fred/333fred_config.h index 7c637d8d36..b158e2d5a2 100644 --- a/users/333fred/333fred_config.h +++ b/users/333fred/333fred_config.h @@ -1,4 +1,3 @@ #pragma once -#define PREVENT_STUCK_MODIFIERS #define PERMISSIVE_HOLD diff --git a/users/bocaj/config.h b/users/bocaj/config.h index ce5ec65d62..0e726598cd 100644 --- a/users/bocaj/config.h +++ b/users/bocaj/config.h @@ -10,7 +10,6 @@ // actually sends Ctrl-x. That's bad.) #define IGNORE_MOD_TAP_INTERRUPT #undef PERMISSIVE_HOLD -#define PREVENT_STUCK_MODIFIERS #ifdef TAPPING_TERM #undef TAPPING_TERM diff --git a/users/drashna/config.h b/users/drashna/config.h index dd6875ceb1..92efcc5c74 100644 --- a/users/drashna/config.h +++ b/users/drashna/config.h @@ -43,7 +43,6 @@ // actually sends Ctrl-x. That's bad.) #define IGNORE_MOD_TAP_INTERRUPT #undef PERMISSIVE_HOLD -#define PREVENT_STUCK_MODIFIERS // #define TAPPING_FORCE_HOLD //#define RETRO_TAPPING @@ -64,8 +63,4 @@ #define NO_ACTION_MACRO #define NO_ACTION_FUNCTION -#define DISABLE_LEADER - #define MACRO_TIMER 5 - - diff --git a/users/ishtob/config.h b/users/ishtob/config.h index 9c4a7ed8dd..1f567f4a5b 100755 --- a/users/ishtob/config.h +++ b/users/ishtob/config.h @@ -15,7 +15,6 @@ //#define LEADER_TIMEOUT 300 //#define BACKLIGHT_BREATHING -#define PREVENT_STUCK_MODIFIERS //#define PERMISSIVE_HOLD // #define QMK_KEYS_PER_SCAN 4 @@ -72,5 +71,5 @@ // Most tactile encoders have detents every 4 stages #define ENCODER_RESOLUTION 4 - + #endif diff --git a/users/replicaJunction/config.h b/users/replicaJunction/config.h index f3556c87ed..4b58b579f8 100644 --- a/users/replicaJunction/config.h +++ b/users/replicaJunction/config.h @@ -6,12 +6,6 @@ // https://docs.qmk.fm/reference/config-options#features-that-can-be-enabled //////////////////////////////////////////////////////////////////////////////// -// Prevent modifiers from sticking when switching layers -// Uses 5 bytes of memory per 8 keys, but makes sure modifiers don't get "stuck" switching layers -#define PREVENT_STUCK_MODIFIERS - - - //////////////////////////////////////////////////////////////////////////////// // Behaviors That Can Be Configured // https://docs.qmk.fm/reference/config-options#behaviors-that-can-be-configured diff --git a/users/talljoe/config.h b/users/talljoe/config.h index 15bbde6bcd..1cdbb5a412 100644 --- a/users/talljoe/config.h +++ b/users/talljoe/config.h @@ -1,7 +1,6 @@ #ifndef USERSPACE_CONFIG_H #define USERSPACE_CONFIG_H -#define PREVENT_STUCK_MODIFIERS #define IGNORE_MOD_TAP_INTERRUPT #define RESET_LAYER 15 diff --git a/users/wanleg/config.h b/users/wanleg/config.h index 22073449b2..28e7690e65 100644 --- a/users/wanleg/config.h +++ b/users/wanleg/config.h @@ -1,8 +1,6 @@ #ifndef USERSPACE_CONFIG_H #define USERSPACE_CONFIG_H -#define PREVENT_STUCK_MODIFIERS - //TAPPING_TERM #ifdef TAP_DANCE_ENABLE #define TAPPING_TERM 200 diff --git a/users/zer09/config.h b/users/zer09/config.h index 7668064622..4cb65c258f 100644 --- a/users/zer09/config.h +++ b/users/zer09/config.h @@ -11,7 +11,7 @@ // actually sends Ctrl-x. That's bad.) #define IGNORE_MOD_TAP_INTERRUPT #undef PERMISSIVE_HOLD -#undef PREVENT_STUCK_MODIFIERS +#define STRICT_LAYER_RELEASE #define FORCE_NKRO -- cgit v1.2.3 From fe3bfd91c1a085716baa2b4396709ad5d77c7c75 Mon Sep 17 00:00:00 2001 From: wanleg <32079073+wanleg@users.noreply.github.com> Date: Mon, 17 Sep 2018 13:41:59 -0700 Subject: Keymap: Big switch config (#3904) * bigswitch keymap * bigswitch keymap * bigswitch keymap * bigswitch keymap * recommended edits made * forgot to revert this change with the others --- users/wanleg/tapdances.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ users/wanleg/wanleg.h | 1 + 2 files changed, 60 insertions(+) (limited to 'users') diff --git a/users/wanleg/tapdances.c b/users/wanleg/tapdances.c index 318810b1b2..6a98b896a5 100644 --- a/users/wanleg/tapdances.c +++ b/users/wanleg/tapdances.c @@ -94,6 +94,64 @@ void DEL_reset (qk_tap_dance_state_t *state, void *user_data) { } DELtap_state.state = 0; } + +//instantialize an instance of 'tap' for the 'CAD' tap dance. +static tap CADtap_state = { + .is_press_action = true, + .state = 0 +}; + +void CAD_finished (qk_tap_dance_state_t *state, void *user_data) { + CADtap_state.state = cur_dance(state); + switch (CADtap_state.state) { + case SINGLE_TAP: + //register_code(KC_SPC); + SEND_STRING(SS_LGUI("l")); + backlight_set(3); + break; + case SINGLE_HOLD: + //register_code(KC_NO); + //take a screenshot of a single window, open Paint and paste + SEND_STRING(SS_LALT(SS_TAP(X_PSCREEN)) SS_LGUI("r")); + _delay_ms(500); + SEND_STRING("mspaint" SS_TAP(X_ENTER)); + _delay_ms(700); + SEND_STRING(SS_LCTRL("v")); + break; //register this keycode when button is held + case DOUBLE_TAP: + //register_code(KC_ENT); + SEND_STRING(SS_LCTRL(SS_LALT(SS_TAP(X_DELETE)))); + backlight_set(0); + break; + //case DOUBLE_HOLD: register_code(KC_NO); break; //register this keycode when button is tapped and then held + case DOUBLE_HOLD: + reset_keyboard(); + break; //register this keycode when button is tapped and then held + case DOUBLE_SINGLE_TAP: register_code(KC_NO); unregister_code(KC_NO); register_code(KC_NO); + } +} + +void CAD_reset (qk_tap_dance_state_t *state, void *user_data) { + switch (CADtap_state.state) { + case SINGLE_TAP: + //unregister_code(KC_SPC); + SEND_STRING(SS_LGUI("l")); + backlight_set(3); + break; + case SINGLE_HOLD: + register_code(KC_NO); //(un)register this keycode when button is held and then released + //SEND_STRING(SS_LCTRL("v")); + break; + case DOUBLE_TAP: + //register_code(KC_ENT); + SEND_STRING(SS_LCTRL(SS_LALT(SS_TAP(X_DELETE)))); + backlight_set(0); + break; + case DOUBLE_HOLD: register_code(KC_NO); //(un)register this keycode when button is tapped and then held, and then released + case DOUBLE_SINGLE_TAP: unregister_code(KC_NO); + } + CADtap_state.state = 0; +} ///// QUAD FUNCTION TAP DANCE PERSONALIZATION SECTION END ///// //Tap Dance Definitions @@ -104,6 +162,7 @@ qk_tap_dance_action_t tap_dance_actions[] = { ,[TD_Q_ESC] = ACTION_TAP_DANCE_DOUBLE(KC_Q, KC_ESC) ,[ENT_TAP_DANCE] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, ENT_finished, ENT_reset) ,[DEL_TAP_DANCE] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, DEL_finished, DEL_reset) + ,[CAD_TD] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, CAD_finished, CAD_reset) }; //In Layer declaration, add tap dance item in place of a key code diff --git a/users/wanleg/wanleg.h b/users/wanleg/wanleg.h index 5cec82e605..8b98ec7ddf 100644 --- a/users/wanleg/wanleg.h +++ b/users/wanleg/wanleg.h @@ -106,6 +106,7 @@ enum { ,TD_Q_ESC ,ENT_TAP_DANCE ,DEL_TAP_DANCE + ,CAD_TD }; #endif -- cgit v1.2.3 From c23233f41ab9221577fc83bbae0a230452a38231 Mon Sep 17 00:00:00 2001 From: Joe Wasson Date: Wed, 19 Sep 2018 16:13:58 -0700 Subject: Keymap: Talljoe's keymap for oddball keyboards (#3910) * Create layout for JD45 * Tweak layout to better support JD45 and add more tap dancing. * Add Maltron and tweak layout for 40% enter compatibility. * Switch back to `BL_TOGGLE` for backlight. * More tweaks * Rename talljoe_gherkin to talljoe-gherkin * Make NAV layer tab C_S_T also. * Add missing RESET key. * Add Talljoe layout for minivan. * MTI is not for me * Tweak keymap. * Add talljoe keymap to Atreus. * Minor tweaks. * Fix talljoe keymaps to work with new Zeal60 commit. --- users/talljoe/config.h | 2 +- users/talljoe/talljoe.c | 53 +++++++++-------- users/talljoe/talljoe.h | 76 ++++++++++++++++++++---- users/talljoe/tapdance.c | 148 +++++++++++++++++++++++++++++++++++++++++------ 4 files changed, 225 insertions(+), 54 deletions(-) (limited to 'users') diff --git a/users/talljoe/config.h b/users/talljoe/config.h index 1cdbb5a412..0d06a0b12d 100644 --- a/users/talljoe/config.h +++ b/users/talljoe/config.h @@ -1,7 +1,7 @@ #ifndef USERSPACE_CONFIG_H #define USERSPACE_CONFIG_H -#define IGNORE_MOD_TAP_INTERRUPT +#define PERMISSIVE_HOLD #define RESET_LAYER 15 diff --git a/users/talljoe/talljoe.c b/users/talljoe/talljoe.c index e9c69b016a..7a343e7768 100644 --- a/users/talljoe/talljoe.c +++ b/users/talljoe/talljoe.c @@ -5,10 +5,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_BASE] = TEMPLATE_TKL( KC_ESC, KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , KC_F12 , KC_PSCR, KC_SLCK, MO_ADJ , - KC_GRV , KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 , KC_MINS, KC_EQL , KC_BSLS, KC_INS , KC_HOME, KC_PGUP, - KC_TAB , KC_Q, KC_W, KC_E, KC_R, KC_T , KC_Y, KC_U, KC_I, KC_O, KC_P , KC_LBRC, KC_RBRC, KC_BSPC, KC_DEL , KC_END , KC_PGDN, - US_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G , KC_H, KC_J, KC_K, KC_L, US_SCLN, US_QUOT, US_ENT , - KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B , KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP , + US_GRV , KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 , KC_MINS, KC_EQL , US_BSLS, KC_INS , KC_HOME, KC_PGUP, + US_TAB , KC_Q, KC_W, KC_E, KC_R, KC_T , KC_Y, KC_U, KC_I, KC_O, KC_P , KC_LBRC, KC_RBRC, KC_BSPC, KC_DEL , KC_END , KC_PGDN, + CTL_ESC, KC_A, KC_S, KC_D, KC_F, KC_G , KC_H, KC_J, KC_K, KC_L, US_SCLN, US_QUOT, US_ENT , + SH_LBRC, KC_Z, KC_X, KC_C, KC_V, KC_B , KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, SH_RBRC, KC_UP , KC_LCTL, KC_LGUI, KC_LALT, KC_SPC2, KC_SPC1, KC_SPC3, KC_RALT, KC_RGUI, KC_RCTL, KC_PTT , KC_LEFT, KC_DOWN, KC_RGHT), [_WORKMAN] = TEMPLATE( _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, @@ -34,41 +34,44 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, KC_A, KC_R, KC_S, KC_T, KC_D , KC_H, KC_N, KC_E, KC_I, KC_O , _______, _______, _______, KC_Z, KC_X, KC_C, KC_V, KC_B , KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), - +#if (SPACE_COUNT > 1) + // A tweaked version of the Maltron layout + [_MALTROFF] = TEMPLATE( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, KC_Q, KC_P, KC_Y, KC_G, KC_B , KC_J, KC_M, KC_U, KC_K, KC_L, _______, _______, _______, + _______, KC_A, KC_N, KC_I, KC_S, KC_F , KC_D, KC_T, KC_H, KC_O, KC_R , US_ENT , KC_BSPC, + _______, KC_Z, KC_X, KC_C, KC_V, US_QUOT, KC_SCLN, KC_W, KC_COMM, KC_DOT, KC_SLSH, _______, _______, + _______, _______, _______, MLT_E , _______, _______, _______, _______, _______, _______), +#endif #ifdef ENABLE_GAME_LAYER [_GAME] = TEMPLATE( KC_ESC , KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 , KC_MINS, KC_EQL , KC_BSLS, KC_GRV, KC_TAB , KC_Q , KC_W , KC_E , KC_R , KC_T , KC_Y , KC_U , KC_I , KC_O , KC_P , KC_LBRC, KC_RBRC, KC_BSPC, MO_NAV , KC_A , KC_S , KC_D , KC_F , KC_G , KC_H , KC_J , KC_K , KC_L , KC_SCLN, KC_QUOT, KC_ENT , KC_LSFT, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_N , KC_M , KC_COMM, KC_DOT , KC_SLSH, KC_RSFT, MO_ADJ , - KC_LCTL, KC_PTT , KC_PGDN, KC_SPC , KC_SPC , KC_SPC , KC_RALT, KC_APP , KC_RCTL, KC_PTT ), + KC_LCTL, KC_PTT , KC_PGDN, KC_SPC , KC_SPC , KC_SPC , KC_RALT, KC_APP , KC_RCTL, KC_PTT ), #endif - [_NAV] = TEMPLATE( + [_NAV] = TEMPLATE_NAV( KC_GRV , XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, - KC_TAB , KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_VOLU, KC_INS , KC_PGUP, KC_UP , KC_PGDN, KC_BTN1, KC_BTN2, KC_BTN3, KC_DEL , - US_CAPS, KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_MUTE, KC_HOME, KC_LEFT, KC_DOWN, KC_RGHT, KC_END , KC_RCTL, TG_ADJ , - KC_LSFT, KC_F9 , KC_F10 , KC_F11 , KC_F12 , KC_VOLD, KC_END , KC_PGDN, KC_WBAK, KC_WFWD, KC_WREF, KC_RSFT, KC_APP , + US_TAB , KC_EXLM, KC_AT , KC_HASH, KC_DLR , KC_PERC, KC_INS , KC_PGUP, KC_UP , KC_PGDN, KC_BTN1, KC_BTN3, KC_BTN2, KC_DEL , + CTL_ESC, KC_LCBR, KC_RCBR, KC_LPRN, KC_RPRN, KC_AMPR, KC_HOME, KC_LEFT, KC_DOWN, KC_RGHT, KC_END , US_QUOT, TG_ADJ , + KC_LSFT, KC_EQL, KC_PLUS, KC_MINS, KC_UNDS, KC_ASTR, KC_CALC, US_GRV , KC_WBAK, KC_WFWD, KC_WREF, KC_RSFT, KC_APP , KC_LCTL, KC_LGUI, KC_LALT, NV_SPC2, NV_SPC1, NV_SPC3, KC_RALT, KC_RGUI, KC_RCTL, KC_PTT ), - [_NUM] = TEMPLATE( + [_NUM] = TEMPLATE_NUM( XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, - KC_GRV , KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, XXXXXXX, KC_DEL , - US_CAPS, KC_LCBR, KC_RCBR, KC_LPRN, KC_RPRN, KC_LBRC, KC_RBRC, KC_4, KC_5, KC_6, KC_PPLS, KC_PENT, XXXXXXX, - KC_LSFT, KC_EQL, KC_PLUS, KC_BSLS, KC_PIPE, KC_SCLN, XXXXXXX, KC_1, KC_2, KC_3, KC_PAST, KC_PSLS, XXXXXXX, + KC_GRV , KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_VOLU, KC_CIRC, KC_7, KC_8, KC_9, KC_PMNS, XXXXXXX, XXXXXXX, KC_DEL , + CTL_ESC, KC_F5 , KC_F6 , KC_F7 , KC_F8 , KC_MUTE, KC_PENT, KC_4, KC_5, KC_6, KC_PPLS, XXXXXXX, KC_ENT , + KC_LSFT, KC_F9 , KC_F10 , KC_F11 , KC_F12 , KC_VOLD, KC_PIPE, KC_1, KC_2, KC_3, KC_PAST, KC_PSLS, TG_NUM , KC_LCTL, KC_LGUI, KC_LALT, NM_SPC2, NM_SPC1, NM_SPC3, KC_PDOT, KC_PCMM, KC_RCTL, KC_PTT ), // Adjust layer is on the split-shift key; or NAV+Enter (for non-split keyboards) - [_ADJUST] = TEMPLATE( - MO_RST , FX(1) , FX(2) , FX(3) , FX(4) , FX(5) , FX(6) , FX(7) , FX(8) , FX(9) , FX(10) , BR_DEC , BR_INC , XXXXXXX, MO_RST , - XXXXXXX, H1_INC , S1_INC , H2_INC , S2_INC , EF_INC , RGB_HUI, RGB_SAI, RGB_MOD, RGB_M_P, DFAULTS, RGB_VAD, RGB_VAI, KC_DEL , + [_ADJUST] = TEMPLATE_ADJUST( + MO_RST , FX(1) , FX(2) , FX(3) , FX(4) , FX(5) , FX(8) , FX(9) , FX(10) , FX(20) , FX(0) , BR_DEC , BR_INC , XXXXXXX, MO_RST , + MO_RST , H1_INC , S1_INC , H2_INC , S2_INC , EF_INC , RGB_HUI, RGB_SAI, RGB_MOD, RGB_M_P, DFAULTS, RGB_VAD, RGB_VAI, MO_RST , XXXXXXX, H1_DEC , S1_DEC , H2_DEC , S2_DEC , EF_DEC , RGB_HUD, RGB_SAD, RGB_RMOD,RGB_M_K, RGB_M_B, RGB_M_G, TG_ADJ , - TG_NKRO, LY_QWER, LY_WORK, LY_NRMN, LY_DVRK, LY_CLMK, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_MAKE, KC_CAPS, XXXXXXX, - MO_RST , AG_NORM, AG_SWAP, XXXXXXX, BL_STEP, XXXXXXX, RGB_TOG, XXXXXXX, XXXXXXX, TG_GAME), + TG_NKRO, LY_QWER, LY_WORK, LY_NRMN, LY_DVRK, LY_CLMK, XXXXXXX, LY_MALT, XXXXXXX, XXXXXXX, KC_MAKE, KC_CAPS, XXXXXXX, + MO_RST , AG_SWAP, AG_NORM, XXXXXXX, BL_TOGG, XXXXXXX, RGB_TOG, XXXXXXX, XXXXXXX, TG_GAME), // To Reset hit FN + ` + Esc - [_RESET] = TEMPLATE( - RESET , XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, RESET , - XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, - XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, - XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, - RESET , XXXXXXX, XXXXXXX, XXXXXXX, KC_SLEP, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX), + [_RESET] = TEMPLATE_RESET, }; void matrix_scan_user(void) { diff --git a/users/talljoe/talljoe.h b/users/talljoe/talljoe.h index 7c34cd41ff..4436c0a044 100644 --- a/users/talljoe/talljoe.h +++ b/users/talljoe/talljoe.h @@ -8,7 +8,7 @@ enum userspace_custom_keycodes { DFAULTS, TOGGLE_BACKLIGHT, EFFECT, - EFFECT_END = EFFECT + 10 + EFFECT_END = EFFECT + 20 }; #ifndef RESET_LAYER @@ -21,6 +21,7 @@ enum layers { _NORMAN, _DVORAK, _COLMAK, + _MALTROFF, _GAME, _NAV, _NUM, @@ -29,7 +30,9 @@ enum layers { }; enum tap_dancers { - TD_SEMICOLON + TD_SEMICOLON, + TD_GRAVE, + TD_QUOTE, }; #define _______ KC_TRNS @@ -39,6 +42,7 @@ enum tap_dancers { #define MO_ADJ MO(_ADJUST) #define MO_RST MO(_RESET) #define TG_ADJ TG(_ADJUST) +#define TG_NUM TG(_NUM) #ifdef ENABLE_GAME_LAYER #define TG_GAME TG(_GAME) #else @@ -49,16 +53,28 @@ enum tap_dancers { #define LY_NRMN DF(_NORMAN) #define LY_DVRK DF(_DVORAK) #define LY_CLMK DF(_COLMAK) +#if SPACE_COUNT >= 2 + #define LY_MALT DF(_MALTROFF) +#else + #define LY_MALT KC_NO +#endif #define TG_NKRO MAGIC_TOGGLE_NKRO #define KC_PTT KC_F24 #define MS_MID KC_MS_BTN3 #define FX(x) (EFFECT + x) -#define US_CAPS CTL_T(KC_ESC) -#define US_QUOT RCTL_T(KC_QUOT) +#define CTL_ESC CTL_T(KC_ESC) +#define US_ENT RCTL_T(KC_ENT) #define US_MINS RCTL_T(KC_QUOT) +#define US_BSLS LCA_T(KC_BSLS) #define US_SCLN TD(TD_SEMICOLON) -#define US_ENT LT(_NUM, KC_ENT) +#define US_GRV TD(TD_GRAVE) +#define US_QUOT TD(TD_QUOTE) +#define US_TAB C_S_T(KC_TAB) +#define SH_LBRC LSFT_T(KC_LBRC) +#define SH_RBRC RSFT_T(KC_RBRC) + +#define MLT_E LT(_NUM, KC_E) #ifndef SPACE_COUNT #define SPACE_COUNT 1 @@ -75,17 +91,34 @@ enum tap_dancers { #define NM_SPC1 _______ #define NM_SPC2 _______ #define NM_SPC3 _______ +#elif (SPACE_COUNT == 2) + #define KC_SPC1 LT(_NAV,KC_SPC) + #define KC_SPC2 LT(_NUM,KC_ENT) + + #define NV_SPC1 KC_SPC + #define NV_SPC2 KC_ENT + + #define NM_SPC1 KC_0 + #define NM_SPC2 KC_SPC + + #define KC_SPC3 XXXXXXX + #define NV_SPC3 XXXXXXX + #define NM_SPC3 XXXXXXX #elif (SPACE_COUNT == 3) - #define KC_SPC1 KC_BSPC + #ifdef SWAP_HANDS_ENABLE + #define KC_SPC1 SH_T(KC_BSPC) + #else + #define KC_SPC1 KC_BSPC + #endif #define KC_SPC2 LT(_NUM,KC_ENT) #define KC_SPC3 LT(_NAV,KC_SPC) #define NV_SPC1 KC_SPC - #define NV_SPC2 C_S_T(KC_ENT) + #define NV_SPC2 KC_ENT #define NV_SPC3 KC_SPC - #define NM_SPC2 XXXXXXX #define NM_SPC1 KC_SPC + #define NM_SPC2 XXXXXXX #define NM_SPC3 KC_0 #else #error "Unsupported space count:" SPACE_COUNT @@ -110,7 +143,7 @@ enum tap_dancers { #define FN_MO2 KC_NO #endif -#ifdef TEMPLATE_TKL +#ifndef TEMPLATE #define _X_ KC_NO #define TEMPLATE( \ KJ4, KJ7, KI7, KH7, KG7, KG4, KF4, KF7, KE7, KD7, KR7, KR4, KE4, KB2, KJ6, \ @@ -126,7 +159,8 @@ enum tap_dancers { KN2, KJ1, KI1, KH1, KG1, KG0, KF0, KF1, KE1, KD1, KR0, KN3, _X_, \ KA4, KP2, KC6, KX1, KK6, KX2, KC0, KM3, KD0, KA1, _X_, _X_, _X_ \ ) -#else +#endif +#ifndef TEMPLATE_TKL #define TEMPLATE_TKL( \ KJ6, KI4, KH4, KH2, KH6, KA7, KE6, KD2, KD4, KB4, KB7, KB6, KB0, KC7, KC5, KA5, \ KJ4, KJ7, KI7, KH7, KG7, KG4, KF4, KF7, KE7, KD7, KR7, KR4, KE4, KB2, KL4, KO4, KQ4, \ @@ -143,4 +177,26 @@ enum tap_dancers { ) #endif +#ifndef TEMPLATE_ALT + #define TEMPLATE_ALT TEMPLATE +#endif +#ifndef TEMPLATE_NUM + #define TEMPLATE_NUM TEMPLATE_ALT +#endif +#ifndef TEMPLATE_NAV + #define TEMPLATE_NAV TEMPLATE_ALT +#endif +#ifndef TEMPLATE_ADJUST + #define TEMPLATE_ADJUST TEMPLATE_ALT +#endif + +#ifndef TEMPLATE_RESET + #define TEMPLATE_RESET TEMPLATE_ALT( \ + RESET , XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, RESET , \ + RESET , XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, RESET , \ + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \ + XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \ + RESET , XXXXXXX, XXXXXXX, XXXXXXX, RESET , XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX) +#endif + #endif diff --git a/users/talljoe/tapdance.c b/users/talljoe/tapdance.c index 3198fc67f0..c4d6025f0f 100644 --- a/users/talljoe/tapdance.c +++ b/users/talljoe/tapdance.c @@ -1,34 +1,146 @@ //Tap Dance #include "talljoe.h" -// Send semin-colon + enter on two taps -void tap_dance_semicolon(qk_tap_dance_state_t *state, void *user_data) { +enum { + SINGLE_TAP = 1, + SINGLE_HOLD = 2, + DOUBLE_TAP = 3, + DOUBLE_HOLD = 4, + DOUBLE_SINGLE_TAP = 5, //send two single taps + TRIPLE_TAP = 6, + TRIPLE_HOLD = 7, + SPECIAL = 8 +}; + +static struct { + int quote; + int semicolon; +} tap_state = {0}; + +int cur_dance (qk_tap_dance_state_t *state) { + if (state->count == 1) { + //If count = 1, and it has been interrupted - it doesn't matter if it is pressed or not: Send SINGLE_TAP + if (state->interrupted) { + // if (!state->pressed) return SINGLE_TAP; + //need "permissive hold" here. + // else return SINGLE_HOLD; + //If the interrupting key is released before the tap-dance key, then it is a single HOLD + //However, if the tap-dance key is released first, then it is a single TAP + //But how to get access to the state of the interrupting key???? + return SINGLE_TAP; + } + else { + if (!state->pressed) return SINGLE_TAP; + else return SINGLE_HOLD; + } + } + //If count = 2, and it has been interrupted - assume that user is trying to type the letter associated + //with single tap. + else if (state->count == 2) { + if (state->interrupted) return DOUBLE_SINGLE_TAP; + else if (state->pressed) return DOUBLE_HOLD; + else return DOUBLE_TAP; + } + else if ((state->count == 3) && ((state->interrupted) || (!state->pressed))) return TRIPLE_TAP; + else if (state->count == 3) return TRIPLE_HOLD; + else return SPECIAL; +} + +int hold_cur_dance (qk_tap_dance_state_t *state) { + if (state->count == 1) { + if (state->interrupted) { + if (!state->pressed) return SINGLE_TAP; + else return SINGLE_HOLD; + } + else { + if (!state->pressed) return SINGLE_TAP; + else return SINGLE_HOLD; + } + } + //If count = 2, and it has been interrupted - assume that user is trying to type the letter associated + //with single tap. + else if (state->count == 2) { + if (state->pressed) return DOUBLE_HOLD; + else return DOUBLE_TAP; + } + else if (state->count == 3) { + if (!state->pressed) return TRIPLE_TAP; + else return TRIPLE_HOLD; + } + else return SPECIAL; +} + +// Send semi-colon + enter on two taps +void tap_dance_semicolon_finished(qk_tap_dance_state_t *state, void *user_data) { + tap_state.semicolon = hold_cur_dance(state); + switch (tap_state.semicolon) { + case SINGLE_TAP: case DOUBLE_HOLD: register_code(KC_SCLN); break; + case SINGLE_HOLD: layer_on(_NUM); break; + } +} + +void tap_dance_semicolon_reset(qk_tap_dance_state_t *state, void *user_data) { + switch (tap_state.semicolon) { + case SINGLE_TAP: case DOUBLE_HOLD: unregister_code(KC_SCLN); break; + case DOUBLE_TAP: { + if (get_mods()) { + SEND_STRING(";;"); // send normal when mods are pressed + } + else { + SEND_STRING(";\n"); + } + break; + } + case TRIPLE_TAP: { + SEND_STRING(";\n\n"); + } + case SPECIAL: layer_invert(_NUM); break; + case SINGLE_HOLD: layer_off(_NUM); break; + } + tap_state.semicolon = 0; +} + +// Send `. ~. ``` +void tap_dance_grave_finished(qk_tap_dance_state_t *state, void *user_data) { switch(state->count) { case 1: - register_code(KC_SCLN); - unregister_code(KC_SCLN); + SEND_STRING("`"); break; case 2: - register_code(KC_SCLN); - unregister_code(KC_SCLN); + SEND_STRING("~"); + break; + } +} - uint8_t mods = get_mods(); - if (mods) { - clear_mods(); - } +void tap_dance_grave_each(qk_tap_dance_state_t *state, void *user_data) { + if(state->count == 3) { + SEND_STRING("```"); + } else if (state->count > 3) { + SEND_STRING("`"); + } +} - register_code(KC_ENT); - unregister_code(KC_ENT); - if (mods) { - set_mods(mods); - } +void tap_dance_quote_finished(qk_tap_dance_state_t *state, void *user_data) { + tap_state.quote = hold_cur_dance(state); + switch (tap_state.quote) { + case SINGLE_TAP: case DOUBLE_HOLD: register_code(KC_QUOT); break; + case SINGLE_HOLD: layer_on(_NAV); break; + } +} - reset_tap_dance(state); - break; +void tap_dance_quote_reset(qk_tap_dance_state_t *state, void *user_data) { + switch (tap_state.quote) { + case SINGLE_TAP: case DOUBLE_HOLD: unregister_code(KC_QUOTE); break; + case DOUBLE_TAP: SEND_STRING("\""); break; + case TRIPLE_TAP: layer_invert(_NAV); break; + case SINGLE_HOLD: layer_off(_NAV); break; } + tap_state.quote = 0; } qk_tap_dance_action_t tap_dance_actions[] = { - [TD_SEMICOLON] = ACTION_TAP_DANCE_FN(tap_dance_semicolon), + [TD_SEMICOLON] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, tap_dance_semicolon_finished, tap_dance_semicolon_reset), + [TD_GRAVE] = ACTION_TAP_DANCE_FN_ADVANCED(tap_dance_grave_each, tap_dance_grave_finished, NULL), + [TD_QUOTE] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, tap_dance_quote_finished, tap_dance_quote_reset), }; -- cgit v1.2.3 From 35e76539e7257a1932ec76882892b999e21c9d4f Mon Sep 17 00:00:00 2001 From: Alexander Kagno Date: Sat, 22 Sep 2018 09:43:28 -0600 Subject: Keymap: Arkag Userspace and MechMini2 Layout (#3958) * deleting arkag branch, forcibly moving changes over to master * fade_color function added, not tested * added half functions some stuff * surround_type function implemented and working. * added flashing function and removed fading, flashing supports infinite flashing along with controlled number flashes * added a fade state machine and functionality * build optimizations, changed fade to bounce between bounds rather than roll over, added a HALMAK layout * changes to sleep breath function, changed how I will switch to HALMAK * support for halmak added * support for activity detection added, condensed fading and flashing state machines, removed support for HALMAK and COLEMAK because arkag is stupid * changed sleep and inactive behaviors, now the color shifting reverses on state change, yay! save_color and reset_color are made to enable layer color changing to look cooler. * reformatted some if statements in state detection * changes to force fade to pause on boot, or plug in. * Attempting to move over to userspace, pushing to repository for help * userspace stuff.... * userspace stuff.... * layout changes, working userspace, Removed left side shift and replaced it with a MT() for LSFT and SPC. Userspace seems to be working properly now! HURRAY * Layout change Removed space/shift and reset modifiers to what they were originally. Added homerow modifiers. * Removed excessive tabs in files * Moved mods on homerow around... * changes recommended by @drashna --- users/arkag/arkag.c | 573 ++++++++++++++++++++++++++++++++++++++++++++++++++ users/arkag/arkag.h | 161 ++++++++++++++ users/arkag/config.h | 5 + users/arkag/readme.md | 14 ++ users/arkag/rules.mk | 1 + 5 files changed, 754 insertions(+) create mode 100644 users/arkag/arkag.c create mode 100644 users/arkag/arkag.h create mode 100644 users/arkag/config.h create mode 100644 users/arkag/readme.md create mode 100644 users/arkag/rules.mk (limited to 'users') diff --git a/users/arkag/arkag.c b/users/arkag/arkag.c new file mode 100644 index 0000000000..c716b5e93f --- /dev/null +++ b/users/arkag/arkag.c @@ -0,0 +1,573 @@ +#include "arkag.h" + +// Start: Written by konstantin: vomindoraan +#include +#include +#include + +void send_unicode_hex_string(const char *str) { + if (!str) { return; } // Saftey net + while (*str) { + // Find the next code point (token) in the string + for (; *str == ' '; str++); + size_t n = strcspn(str, " "); // Length of the current token + char code_point[n+1]; + strncpy(code_point, str, n); + code_point[n] = '\0'; // Make sure it's null-terminated + + // Normalize the code point: make all hex digits lowercase + for (char *p = code_point; *p; p++) { + *p = tolower(*p); + } + + // Send the code point as a Unicode input string + unicode_input_start(); + send_string(code_point); + unicode_input_finish(); + str += n; // Move to the first ' ' (or '\0') after the current token + } +} +// End: Written by konstantin: vomindoraan + +uint8_t current_os, mod_primary_mask, fade_delay; +uint16_t flash_timer_one, flash_timer_two, + fade_timer_one, fade_timer_two, + active_timer_one, active_timer_two, + elapsed = 0, + num_extra_flashes_off = 0; +Color underglow, + flash_color, + saved_color, + hsv_none = {0,0,0}, + hsv_white = {0,0,127}; +flashState flash_state = no_flash; +fadeState fade_state = add_fade; +activityState state = boot; + +void set_color (Color new, bool update) { + rgblight_sethsv_eeprom_helper(new.h, new.s, new.v, update); +} + +void save_color(Color to_save) { + saved_color = to_save; +} + +void reset_color(void) { + underglow = saved_color; +} + +Color mod_color(Color current_color, bool should_add, uint8_t change_amount) { + save_color(underglow); + int addlim = 359 - change_amount; + int sublim = change_amount; + int leftovers; + if (should_add) { + if (current_color.h <= addlim) { + current_color.h += change_amount; + } else { + leftovers = (359 + change_amount) % 359; + current_color.h = 0 + leftovers; + } + } else { + if (current_color.h >= sublim) { + current_color.h -= change_amount; + } else { + leftovers = change_amount - current_color.h; + current_color.h = 359 - leftovers; + } + } + return current_color; +} + +void reverse_fade (void) { + if (fade_state == add_fade){ + fade_state = sub_fade; + } else { + fade_state = add_fade; + } +} + +void check_state (void) { + static bool activated, deactivated, slept; + switch (state) { + case active: + if (!activated) { + fade_delay = LED_FADE_DELAY; + reverse_fade(); + activated = true; + deactivated = false; + } + active_timer_two = timer_read(); + elapsed = active_timer_two - active_timer_one; + if (elapsed < INACTIVE_DELAY) {return;} + state = inactive; + return; + + case inactive: + if (!deactivated) { + fade_delay = LED_FADE_DELAY * 2; + reverse_fade(); + deactivated = true; + slept = false; + activated = false; + } + active_timer_two = timer_read(); + elapsed = active_timer_two - active_timer_one; + if (elapsed < SLEEP_DELAY) {return;} + state = sleeping; + return; + + case sleeping: + if (!slept) { + fade_delay = LED_FADE_DELAY * 6; + reverse_fade(); + slept = true; + deactivated = false; + activated = false; + } + return; + + case boot: + return; + } +} + +void fade_rgb (void) { + static bool ran_once; + if (flash_state != no_flash) {return;} + if (state == boot) {return;} + switch (fade_state) { + case add_fade: + if (!ran_once) { + fade_timer_one = timer_read(); + ran_once = true; + } + fade_timer_two = timer_read(); + elapsed = fade_timer_two - fade_timer_one; + if (elapsed < fade_delay) {return;} + if (underglow.h == 359) { + fade_state = sub_fade; + return; + } + underglow.h = underglow.h + 1; + set_color(underglow, false); + // set_color_at(underglow, 0); + fade_timer_one = fade_timer_two; + return; + + case sub_fade: + fade_timer_two = timer_read(); + elapsed = fade_timer_two - fade_timer_one; + if (elapsed < fade_delay) {return;} + if (underglow.h == 0) { + fade_state = add_fade; + return; + } + underglow.h = underglow.h - 1; + set_color(underglow, false); + // set_color_at(underglow, 0); + fade_timer_one = fade_timer_two; + return; + } +} + +void flash_rgb (void) { + static bool ran_once; + switch(flash_state) { + case no_flash: + return; + + case flash_off: + if (!ran_once) { + set_color(hsv_none, false); + flash_timer_one = timer_read(); + ran_once = true; + flash_state = flash_on; + return; + } + flash_timer_two = timer_read(); + elapsed = flash_timer_two - flash_timer_one; + if (elapsed >= LED_FLASH_DELAY) { + set_color(hsv_none, false); + flash_timer_one = timer_read(); + flash_state = flash_on; + } + return; + + case flash_on: + flash_timer_two = timer_read(); + elapsed = flash_timer_two - flash_timer_one; + if (elapsed >= LED_FLASH_DELAY) { + set_color(flash_color, false); + flash_timer_one = timer_read(); + if (num_extra_flashes_off > 0) { + flash_state = flash_off; + num_extra_flashes_off--; + } else { + set_color(underglow, false); + flash_state = no_flash; + ran_once = false; + } + } + return; + } +} + +void set_os (uint8_t os, bool update) { + current_os = os; + if (update) { + eeprom_update_byte(EECONFIG_USERSPACE, current_os); + } + switch (os) { + case OS_MAC: + set_unicode_input_mode(UC_OSX); + underglow = (Color){ 300, 255, 255 }; + mod_primary_mask = MOD_GUI_MASK; + break; + case OS_WIN: + set_unicode_input_mode(UC_WINC); + underglow = (Color){ 180, 255, 255 }; + mod_primary_mask = MOD_CTL_MASK; + break; + case OS_NIX: + set_unicode_input_mode(UC_LNX); + underglow = (Color){ 60, 255, 255 }; + mod_primary_mask = MOD_CTL_MASK; + break; + default: + underglow = (Color){ 0, 0, 255 }; + mod_primary_mask = MOD_CTL_MASK; + } + set_color(underglow, update); + flash_color = underglow; + flash_state = flash_off; + num_extra_flashes_off = 1; +} + +void tap_key(uint8_t keycode) { + register_code(keycode); + unregister_code(keycode); +} + +// register GUI if Mac or Ctrl if other +void pri_mod(bool press) { + if (press) { + if (current_os == OS_MAC) { + register_code(KC_LGUI); + } else { + register_code(KC_LCTL); + } + } else { + if (current_os == OS_MAC) { + unregister_code(KC_LGUI); + } else { + unregister_code(KC_LCTL); + } + } +} + +// register Ctrl if Mac or GUI if other +void sec_mod(bool press) { + if (press) { + if (current_os == OS_MAC) { + register_code(KC_LCTL); + } else { + register_code(KC_LGUI); + } + } else { + if (current_os == OS_MAC) { + unregister_code(KC_LCTL); + } else { + unregister_code(KC_LGUI); + } + } +} + +void surround_type(uint8_t num_of_chars, uint16_t keycode, bool use_shift) { + if (use_shift) { + register_code(KC_LSFT); + } + for (int i = 0; i < num_of_chars; i++) { + tap_key(keycode); + } + if (use_shift) { + unregister_code(KC_LSFT); + } + for (int i = 0; i < (num_of_chars/2); i++) { + tap_key(KC_LEFT); + } +} + +void long_keystroke(size_t num_of_keys, uint16_t keys[]) { + for (int i = 0; i < num_of_keys-1; i++) { + register_code(keys[i]); + } + tap_key(keys[num_of_keys-1]); + for (int i = 0; i < num_of_keys-1; i++) { + unregister_code(keys[i]); + } +} + +void dance_grv (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + tap_key(KC_GRV); + } else if (state->count == 2) { + surround_type(2, KC_GRAVE, false); + } else { + surround_type(6, KC_GRAVE, false); + } +} + +void dance_quot (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + tap_key(KC_QUOT); + } else if (state->count == 2) { + surround_type(2, KC_QUOTE, false); + } else if (state->count == 3) { + surround_type(2, KC_QUOTE, true); + } +} + +void dance_strk (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + surround_type(4, KC_TILDE, true);