diff options
Diffstat (limited to 'users')
42 files changed, 4243 insertions, 440 deletions
diff --git a/users/bbaserdem/README.md b/users/bbaserdem/README.md new file mode 100644 index 000000000..2011e74b6 --- /dev/null +++ b/users/bbaserdem/README.md @@ -0,0 +1,49 @@ +# Overview + +I have mostly ortholinear keyboards, which share a lot of functions. +For this purpose, I collected them here. + +I have the following keymaps: + +* Gherkin (Does not use the user space) +* Let's Split +* Let's Split It Up +* Planck + +# Layout + +I use DVORAK with an unorthodox Turkish layout. +If you wanna grab my code, andused a previous layout with a persistent base +layer change, change it to layer 0 before proceeding. + +# Layers + +* **Dvorak**: Base layer,withdvorak layout. +* **Alternative**: Has alternate characters. +* **Game**: Toggled from *Function*, comfortable for gaming use. +* **Numeric**: Has numericals and symbols. Can be locked. +* **Function**: Layer has media and function keys. +* **Mouse**: Manipulates mouse. Can be locked. +* **Music** Allows playing sounds like a keyboard. + +# Functionality + +* **RGB Backlight**: With layer indication, and ability to change base layer lighting mode. +* **Secrets**: By placing a secrets.h, and not tracking it, you can store passwords etc. +* **Mouse**: Mouse emulation, complete with diagonal keys. +* **Turkish**: An AltGr-like overlay that allows some non-common letters, in unicode. + +I suggest checking out how I enabled shifting for Turkish layer, +how I planned out RGB lighting, and my mouse implementation; they might offer +some insight into fringe user cases. + +# Issues + +All features are too big for the 32kB bootloader. +Offenders are audio and rgb lights; it comes down to one or the other. +~The Proton board, and rev 6 should fix that.~ + +# Credits + +I have previously written my keymap by myself before, but I rewrote it here, +heavily inspired by @drashna's user folder. diff --git a/users/bbaserdem/bbaserdem.c b/users/bbaserdem/bbaserdem.c new file mode 100644 index 000000000..59e5d4ba7 --- /dev/null +++ b/users/bbaserdem/bbaserdem.c @@ -0,0 +1,651 @@ +#include "bbaserdem.h" + +/*---------------*\ +|*-----MOUSE-----*| +\*---------------*/ +#ifdef MOUSEKEY_ENABLE +#include "mousekey.h" +#endif + +/*-------------*\ +|*-----RGB-----*| +\*-------------*/ +#ifdef RGBLIGHT_ENABLE +#include "rgblight.h" +#endif + +/*-----------------*\ +|*-----SECRETS-----*| +\*-----------------*/ +// Enabled by adding a non-tracked secrets.h to this dir. +#if (__has_include("secrets.h")) +#include "secrets.h" +#endif + +/*---------------*\ +|*-----MUSIC-----*| +\*---------------*/ +#ifdef AUDIO_ENABLE +float tone_game[][2] = SONG(ZELDA_PUZZLE); +float tone_return[][2] = SONG(ZELDA_TREASURE); +float tone_linux[][2] = SONG(UNICODE_LINUX); +float tone_windows[][2] = SONG(UNICODE_WINDOWS); +#endif + +/*-------------------*\ +|*-----TAP-DANCE-----*| +\*-------------------*/ +#ifdef TAP_DANCE_ENABLE +qk_tap_dance_action_t tap_dance_actions[] = { + // Shift on double tap of semicolon + [SCL] = ACTION_TAP_DANCE_DOUBLE( KC_SCLN, KC_COLN ) +}; +#endif + +/* In keymaps, instead of writing _user functions, write _keymap functions + * The __attribute__((weak)) allows for empty definitions here, and during + * compilation, if these functions are defined elsewhere, they are written + * over. This allows to include custom code from keymaps in the generic code + * in this file. + */ +__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) { } + +/* ----------------------- *\ + * -----RGB Functions----- * +\* ----------------------- */ + + +#ifdef RGBLIGHT_ENABLE +// Storage variables +extern rgblight_config_t rgblight_config; +bool base_sta; // Keeps track if in saveable state +bool base_tog; // Whether base state is active or not +int base_hue; // Hue value of base state +int base_sat; // Saturation value of base state +int base_val; // Brightness value of base state +uint8_t base_mod; // Animation mode of the base state + +// Save the current state of the rgb mode +void rgblight_saveBase(void) { + base_hue = rgblight_config.hue; + base_sat = rgblight_config.sat; + base_val = rgblight_config.val; + base_mod = rgblight_config.mode; + base_tog = rgblight_config.enable; + base_sta = false; // If saving, that means base layer is being left +} + +// Load the base state back +void rgblight_loadBase(void) { + // Don't do anything if not enabled + if ( !base_sta ) { + if ( base_tog ) { + rgblight_enable(); + rgblight_mode( base_mod ); + rgblight_sethsv( base_hue, base_sat, base_val ); + } else { + rgblight_disable(); + } + } + // Mark that base is loaded, and to be saved before leaving + base_sta = true; +} + +// Set to plain HSV color +void rgblight_colorStatic( int hu, int sa, int va ) { + // First, it must be enabled or color change is not written + rgblight_enable(); + rgblight_mode(1); + rgblight_sethsv(hu,sa,va); +} +/* HSV values, thank you @drashna! + * white ( 0, 0, 255) + * red ( 0, 255, 255) + * coral ( 16, 176, 255) + * orange ( 39, 255, 255) + * goldenrod ( 43, 218, 218) + * gold ( 51, 255, 255) + * yellow ( 60, 255, 255) + * chartreuse ( 90, 255, 255) + * green (120, 255, 255) + * springgreen (150, 255, 255) + * turquoise (174, 90, 112) + * teal (180, 255, 128) + * cyan (180, 255, 255) + * azure (186, 102, 255) + * blue (240, 255, 255) + * purple (270, 255, 255) + * magenta (300, 255, 255) + * pink (330, 128, 255) + */ +// Set RGBLIGHT state depending on layer +void rgblight_change( uint8_t last_layer ) { + // Save state, if saving is requested + /* + if ( base_sta ) { + rgblight_saveBase(); + } + */ + // Change RGB light + switch ( last_layer ) { + case _DV: + // Load base layer + rgblight_loadBase(); + break; + case _AL: + // Do yellow for alternate + rgblight_colorStatic( 60,255,255); + break; + case _GA: + // Do purple for game + rgblight_colorStatic(285,255,255); + break; + case _NU: + // Do azure for number + rgblight_colorStatic(186,200,255); + break; + case _SE: + // Do red for settings + rgblight_colorStatic( 16,255,255); + break; + case _MO: + // Do green for mouse + rgblight_colorStatic(120,255,255); + break; +#ifdef AUDIO_ENABLE + case _MU: + // Do orange for music + rgblight_colorStatic( 39,255,255); + break; +#endif + default: + // Something went wrong + rgblight_colorStatic( 0,255,255); + break; + } +} + +#endif + +/*---------------------*\ +|*-----MATRIX INIT-----*| +\*---------------------*/ +void matrix_init_user (void) { + + // Keymap specific things, do it first thing to allow for delays etc + matrix_init_keymap(); + + // Correct unicode + set_unicode_input_mode(UC_LNX); + + // Make beginning layer DVORAK + set_single_persistent_default_layer(_DV); + +//--RGB light initialize base layer +#ifdef RGBLIGHT_ENABLE + // Base hue is white, and RGB disabled + base_hue = 100; + base_sat = 0; + base_val = 255; + base_mod = 2; + base_tog = false; + rgblight_enable(); + rgblight_mode(base_mod); + rgblight_sethsv(base_hue,base_sat,base_val); + rgblight_disable(); + rgblight_loadBase(); +#endif + +} + +/*---------------------*\ +|*-----MATRIX SCAN-----*| +\*---------------------*/ +void matrix_scan_user (void) { + // Keymap specific, do it first + matrix_scan_keymap(); + // Moved RGB check to layer_state_set_user +} + +/*------------------*\ +|*-----KEYCODES-----*| +\*------------------*/ +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + + // Shift check + bool is_capital = ( keyboard_report->mods & (MOD_BIT(KC_LSFT)|MOD_BIT(KC_RSFT)) ); + static bool lock_flag = false; + uint8_t layer = biton32 (layer_state); + + switch (keycode) { + // Secrets implementation + case SECRET1 ... SECRET3: +#if (__has_include("secrets.h")) + if( !record->event.pressed ) { + send_string_P( secret[ keycode - SECRET1 ] ); + } +#endif + return false; + break; + // If these keys are pressed, load base layer config, and mark saving + case RGB_TOG: + case RGB_MOD: + case RGB_VAI: + case RGB_VAD: + case RGB_SAI: + case RGB_SAD: + case RGB_HUI: + case RGB_HUD: +#ifdef RGBLIGHT_ENABLE + if ( !base_sta ) { + rgblight_loadBase(); + } +#endif + return true; + break; + + // Lock functionality: These layers are locked if the LOCKED buttons are + // pressed. Otherwise, they are momentary toggles + case K_LOCK: + if (record->event.pressed) { + lock_flag = !lock_flag; + } + return false; + break; + case K_MOUSE: +#ifdef MOUSEKEY_ENABLE + if (record->event.pressed) { + layer_on(_MO); + lock_flag = false; + } else { + if ( lock_flag ) { + lock_flag = false; + } else { + layer_off(_MO); + } + } +#endif + return false; + break; + case K_NUMBR: + if (record->event.pressed) { + layer_on(_NU); + lock_flag = false; + } else { + if ( lock_flag ) { + lock_flag = false; + } else { + layer_off(_NU); + } + } + return false; + break; + + // Layer switches with sound + case K_GAMES: + if (record->event.pressed) { + // On press, turn off layer if active + if ( layer == _GA ) { +#ifdef AUDIO_ENABLE + stop_all_notes(); + PLAY_SONG(tone_return); +#endif + layer_off(_GA); + } + } else { + // After click, turn on layer if accessed from setting + if ( layer == _SE ) { +#ifdef AUDIO_ENABLE + stop_all_notes(); + PLAY_SONG(tone_game); +#endif + layer_on(_GA); + layer_off(_SE); + } + } + return false; + break; + case MU_TOG: +#ifdef AUDIO_ENABLE + if (record->event.pressed) { + // On press, turn off layer if active + if ( layer == _SE ) { + layer_off(_SE); + layer_on(_MU); + } else { + layer_off(_MU); + } + } +#endif + return true; + break; + +//------UNICODE + // Unicode switches with sound + case UNI_LI: +#ifdef UNICODE_ENABLE + if (record->event.pressed) { +#ifdef AUDIO_ENABLE + stop_all_notes(); + PLAY_SONG(tone_linux); +#endif + set_unicode_input_mode(UC_LNX); + } +#endif + return false; + break; + case UNI_WN: +#ifdef UNICODE_ENABLE + if (record->event.pressed) { +#ifdef AUDIO_ENABLE + stop_all_notes(); + PLAY_SONG(tone_windows); +#endif + set_unicode_input_mode(UC_WIN); + } +#endif + return false; + break; + + // Turkish letters, with capital functionality + case TUR_A: +#ifdef UNICODE_ENABLE + if (record->event.pressed) { + if ( is_capital ) { + unicode_input_start(); + register_hex(0x00c2); + unicode_input_finish(); + } else { + unicode_input_start(); + register_hex(0x00e2); + unicode_input_finish(); + } + } +#endif + return false; + break; + case TUR_O: +#ifdef UNICODE_ENABLE + if (record->event.pressed) { + if ( is_capital ) { + unicode_input_start(); + register_hex(0x00d6); + unicode_input_finish(); + } else { + unicode_input_start(); + register_hex(0x00f6); + unicode_input_finish(); + } + } +#endif + return false; + break; + case TUR_U: +#ifdef UNICODE_ENABLE + if (record->event.pressed) { + if ( is_capital ) { + unicode_input_start(); + register_hex(0x00dc); + unicode_input_finish(); + } else { + unicode_input_start(); + register_hex(0x00fc); + unicode_input_finish(); + } + } +#endif + return false; + break; + case TUR_I: +#ifdef UNICODE_ENABLE + if (record->event.pressed) { + if ( is_capital ) { + unicode_input_start(); + register_hex(0x0130); + unicode_input_finish(); + } else { + unicode_input_start(); + register_hex(0x0131); + unicode_input_finish(); + } + } +#endif + return false; + break; + case TUR_G: +#ifdef UNICODE_ENABLE + if (record->event.pressed) { + if ( is_capital ) { + unicode_input_start(); + register_hex(0x011e); + unicode_input_finish(); + } else { + unicode_input_start(); + register_hex(0x011f); + unicode_input_finish(); + } + } +#endif + return false; + break; + case TUR_C: +#ifdef UNICODE_ENABLE + if (record->event.pressed) { + if ( is_capital ) { + unicode_input_start(); + register_hex(0x00c7); + unicode_input_finish(); + } else { + unicode_input_start(); + register_hex(0x00e7); + unicode_input_finish(); + } + } +#endif + return false; + break; + case TUR_S: +#ifdef UNICODE_ENABLE + if (record->event.pressed) { + if ( is_capital ) { + unicode_input_start(); + register_hex(0x015e); + unicode_input_finish(); + } else { + unicode_input_start(); + register_hex(0x015f); + unicode_input_finish(); + } + } +#endif + return false; + break; + +//-------Diagonal mouse movements + case MO_NE: +#ifdef MOUSEKEY_ENABLE + if( record->event.pressed ) { + mousekey_on(MO_N); + mousekey_on(MO_E); + mousekey_send(); + } else { + mousekey_off(MO_N); + mousekey_off(MO_E); + mousekey_send(); + } +#endif + return false; + break; + case MO_NW: +#ifdef MOUSEKEY_ENABLE + if( record->event.pressed ) { + mousekey_on(MO_N); + mousekey_on(MO_W); + mousekey_send(); + } else { + mousekey_off(MO_N); + mousekey_off(MO_W); + mousekey_send(); + } +#endif + return false; + break; + case MO_SE: +#ifdef MOUSEKEY_ENABLE + if( record->event.pressed ) { + mousekey_on(MO_S); + mousekey_on(MO_E); + mousekey_send(); + } else { + mousekey_off(MO_S); + mousekey_off(MO_E); + mousekey_send(); + } +#endif + return false; + break; + case MO_SW: +#ifdef MOUSEKEY_ENABLE + if( record->event.pressed ) { + mousekey_on(MO_S); + mousekey_on(MO_W); + mousekey_send(); + } else { + mousekey_off(MO_S); + mousekey_off(MO_W); + mousekey_send(); + } +#endif + return false; + break; + case MO_S_NE: +#ifdef MOUSEKEY_ENABLE + if( record->event.pressed ) { + mousekey_on(MO_S_N); + mousekey_on(MO_S_E); + mousekey_send(); + } else { + mousekey_off(MO_S_N); + mousekey_off(MO_S_E); + mousekey_send(); + } +#endif + return false; + break; + case MO_S_NW: +#ifdef MOUSEKEY_ENABLE + if( record->event.pressed ) { + mousekey_on(MO_S_N); + mousekey_on(MO_S_W); + mousekey_send(); + } else { + mousekey_off(MO_S_N); + mousekey_off(MO_S_W); + mousekey_send(); + } +#endif + return false; + break; + case MO_S_SE: +#ifdef MOUSEKEY_ENABLE + if( record->event.pressed ) { + mousekey_on(MO_S_S); + mousekey_on(MO_S_E); + mousekey_send(); + } else { + mousekey_off(MO_S_S); + mousekey_off(MO_S_E); + mousekey_send(); + } +#endif + return false; + break; + case MO_S_SW: +#ifdef MOUSEKEY_ENABLE + if( record->event.pressed ) { + mousekey_on(MO_S_S); + mousekey_on(MO_S_W); + mousekey_send(); + } else { + mousekey_off(MO_S_S); + mousekey_off(MO_S_W); + mousekey_send(); + } +#endif + return false; + break; +//------DOUBLE PRESS, with added left navigation + case DBL_SPC: + if( record->event.pressed ) { + SEND_STRING(" "SS_TAP(X_LEFT)); + } + return false; + break; + case DBL_ANG: + if( record->event.pressed ) { + SEND_STRING("<>"SS_TAP(X_LEFT)); + } + return false; + break; + case DBL_PAR: + if( record->event.pressed ) { + SEND_STRING("()"SS_TAP(X_LEFT)); + } + return false; + break; + case DBL_SQR: + if( record->event.pressed ) { + SEND_STRING("[]"SS_TAP(X_LEFT)); + } + return false; + break; + case DBL_BRC: + if( record->event.pressed ) { + SEND_STRING("{}"SS_TAP(X_LEFT)); + } + return false; + break; + case DBL_QUO: + if( record->event.pressed ) { + SEND_STRING("\'\'"SS_TAP(X_LEFT)); + } + return false; + break; + case DBL_DQT: + if( record->event.pressed ) { + SEND_STRING("\"\""SS_TAP(X_LEFT)); + } + return false; + break; + case DBL_GRV: + if( record->event.pressed ) { + SEND_STRING("``"SS_TAP(X_LEFT)); + } + return false; + break; +// END OF KEYCODES + } + return process_record_keymap(keycode, record); +} + +/*----------------------*\ +|*-----LAYER CHANGE-----*| +\*----------------------*/ + +uint32_t layer_state_set_user(uint32_t state) { + + state = layer_state_set_keymap (state); +#ifdef RGBLIGHT_ENABLE + // Change RGB lighting depending on the last layer activated + rgblight_change( biton32(state) ); +#endif + return state; +} diff --git a/users/bbaserdem/bbaserdem.h b/users/bbaserdem/bbaserdem.h new file mode 100644 index 000000000..1b1b53710 --- /dev/null +++ b/users/bbaserdem/bbaserdem.h @@ -0,0 +1,279 @@ +#ifndef USERSPACE +#define USERSPACE + +#include "quantum.h" + +// Use 7 wide characters for keymaps +#define _______ KC_TRNS +#define XXX KC_NO + +// Layers +#define _DV 0 // Base layer +#define _AL 1 // Alt char overlay +#define _GA 2 // Game layer +#define _NU 3 // Numbers layer +#define _SE 4 // Settings layer +#define _MO 5 // Mouse emulation +#define _MU 6 // Music mode + +// Define short macros +#define UNDO LCTL(KC_Z) +#define REDO LCTL(KC_Y) +#define COPY LCTL(KC_C) +#define CUT LCTL(KC_X) +#define PASTE LCTL(KC_V) + +// Rename mouse keys +#ifdef MOUSEKEY_ENABLE +#define MO_S_N KC_MS_WH_UP +#define MO_S_S KC_MS_WH_DOWN +#define MO_S_E KC_MS_WH_RIGHT +#define MO_S_W KC_MS_WH_LEFT +#define MO_N KC_MS_UP +#define MO_S KC_MS_DOWN +#define MO_E KC_MS_RIGHT +#define MO_W KC_MS_LEFT +#define MO_CL_L KC_MS_BTN1 +#define MO_CL_R KC_MS_BTN2 +#define MO_CL_M KC_MS_BTN3 +#define MO_CL_4 KC_MS_BTN4 +#define MO_CL_5 KC_MS_BTN5 +#define MO_AC_0 KC_MS_ACCEL0 +#define MO_AC_1 KC_MS_ACCEL1 +#define MO_AC_2 KC_MS_ACCEL2 +#else +#define MO_S_N KC_NO +#define MO_S_S KC_NO +#define MO_S_E KC_NO +#define MO_S_W KC_NO +#define MO_N KC_NO +#define MO_S KC_NO +#define MO_E KC_NO +#define MO_W KC_NO +#define MO_CL_L KC_NO +#define MO_CL_R KC_NO +#define MO_CL_M KC_NO +#define MO_CL_1 KC_NO +#define MO_CL_2 KC_NO +#define MO_AC_0 KC_NO +#define MO_AC_1 KC_NO +#define MO_AC_2 KC_NO +#endif + +// Define non-capitalized UTF shortcuts here +#ifdef UNICODE_ENABLE +#define PHY_HBR UC(0x0127) +#define PHY_DEG UC(0x00b0) +#define CUR_LIR UC(0x20ba) +#define CUR_BIT UC(0x20bf) +#define CUR_EUR UC(0x20ac) +#define CUR_BPN UC(0x00a3) +#define CUR_YEN UC(0x00a5) +#else +#define PHY_HBR KC_NO +#define PHY_DEG KC_NO +#define CUR_LIR KC_NO +#define CUR_BIT KC_NO +#define CUR_EUR KC_NO +#define CUR_BPN KC_NO +#define CUR_YEN KC_NO +#endif + +// Make only KC_NO be grabbed by music mode +#ifdef AUDIO_ENABLE +#define MUSIC_MASK keycode == XXX +#endif + +// Custom keycodes +enum userspace_custom_keycodes { + // Turkish letters, with shifting + TUR_A = SAFE_RANGE, + TUR_C, + TUR_G, + TUR_I, + TUR_O, + TUR_S, + TUR_U, + // Unicode mode switch + UNI_LI, + UNI_WN, + // Double keys + DBL_SPC, + DBL_ANG, + DBL_PAR, + DBL_SQR, + DBL_BRC, + DBL_QUO, + DBL_DQT, + DBL_GRV, + // Diagonal mouse movements + MO_NE, + MO_NW, + MO_SE, + MO_SW, + MO_S_NE, + MO_S_NW, + MO_S_SE, + MO_S_SW, + // Layer switches and lock functionality + K_MOUSE, + K_NUMBR, + K_LOCK, + K_GAMES, + // Secret macros + SECRET1, + SECRET2, + SECRET3 +}; + +// Do tap dancable semicolon key if available +#ifdef TAP_DANCE_ENABLE +#define TAPPING_TERM 300 +#define TAPPING_TOGGLE 1 +enum { + SCL = 0 +}; +#define MY_SCL TD(SCL) +#else +#define MY_SCL KC_SCLN +#endif + +// Shared keymaps +#define KM(...) KEYMAP(__VA_ARGS__) // Required to expand the CSVs + +/* Dvorak + * ,------------------------------------------------------------------------. + * | Esc | ' " | , | . | P | Y || F | G | C | R | L | Bkp | + * |-----+-----+-----+-----+-----+-----++-----+-----+-----+-----+-----+-----| + * | Tab | A | O | E | U | I || D | H | T | N | S | / ? | + * |-----+-----+-----+-----+-----+-----++-----+-----+-----+-----+-----+-----| + * | SYM | ; : | Q | J | K | X || B | M | W | V | Z | SET | + * |-----+-----+-----+-----+-----+-----++-----+-----+-----+-----+-----+-----| + * | TUR | OS | Ctrl| Alt | Shf | Spc || Ent | Lft | Dwn | Up | Rght| MSE | + * `------------------------------------------------------------------------' */ +#define DVORAK_1 \ + KC_ESC, KC_QUOT,KC_COMM,KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC +#define DVORAK_2 \ + KC_TAB, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH +#define DVORAK_3 \ + K_NUMBR,MY_SCL, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, MO(_SE) +#define DVORAK_4 \ + MO(_AL),KC_LGUI,KC_LCTL,KC_LALT,KC_LSFT,KC_SPC, KC_ENT, KC_LEFT,KC_DOWN,KC_RGHT,KC_UP, K_MOUSE +#define DVORAK KM(DVORAK_1,DVORAK_2,DVORAK_3,DVORAK_4) + +/* Alternative character overlay + * ,------------------------------------------------------------------------. + * | | ' ' | Undo| Redo|Pound| Yen || | G | C | |TLira| Del | + * |-----+-----+-----+-----+-----+-----++-----+-----+-----+-----+-----+-----| + * | | A | O | Euro| U | I ||Degre|Plank| | | S | Ins | + * |-----+-----+-----+-----+-----+-----++-----+-----+-----+-----+-----+-----| + * | | " " | Cut | Copy|Paste| || BTC | < > | ( ) | [ ] | { } | PgUp| + * |-----+-----+-----+-----+-----+-----++-----+-----+-----+-----+-----+-----| + * | | | | | | || | Home|PgDwn| PgUp| End | | + * `------------------------------------------------------------------------' */ +#define ALTCHAR_1 \ + _______,DBL_QUO,UNDO, REDO, CUR_BPN,CUR_YEN,_______,TUR_G, TUR_C, _______,CUR_LIR,KC_DEL +#define ALTCHAR_2 \ + _______,TUR_A, TUR_O, CUR_EUR,TUR_U, TUR_I, PHY_DEG,PHY_HBR,_______,_______,TUR_S, KC_INS +#define ALTCHAR_3 \ + _______,DBL_DQT,CUT, COPY, PASTE, _______,CUR_BIT,DBL_ANG,DBL_PAR,DBL_SQR,DBL_BRC,_______ +#define ALTCHAR_4 \ + _______,_______,_______,_______,_______,_______,_______,KC_HOME,KC_PGDN,KC_PGUP,KC_END,_______ +#define ALTCHAR KM(ALTCHAR_1,ALTCHAR_2,ALTCHAR_3,ALTCHAR_4) + +/* Game layer + * ,------------------------------------------------------------------------. + * | OFF | Q | W | E | R | T || Esc | 7 | 8 | 9 |NumLk|Bkspc| + * |-----+-----+-----+-----+-----+-----++-----+-----+-----+-----+-----+-----| + * | Tab | A | S | D | F | G || F1 | 4 | 5 | 6 | \ | Ent | + * |-----+-----+-----+-----+-----+-----++-----+-----+-----+-----+-----+-----| + * | | Z | X | C | V | B || F2 | 1 | 2 | 3 | ^ | | + * |-----+-----+-----+-----+-----+-----++-----+-----+-----+-----+-----+-----| + * | / | ` | | | | Spc || Spc | Ent | 0 | < | v | > | + * `------------------------------------------------------------------------' */ +#define GAME_1 \ + K_GAMES,KC_Q, KC_W, KC_E, KC_R, KC_T, KC_ESC, KC_P7, KC_P8, KC_P9, KC_NLCK,KC_BSPC +#define GAME_2 \ + KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_F1, KC_P4, KC_P5, KC_P6, KC_BSLS,KC_ENT +#define GAME_3 \ + _______,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_F2, KC_P1, KC_P2, KC_P3, KC_UP, _______ +#define GAME_4 \ + KC_SLSH,KC_GRV, _______,_______,_______,KC_SPC, KC_SPC, KC_ENT, KC_P0, KC_LEFT,KC_DOWN,KC_RGHT +#define GAME KM(GAME_1,GAME_2,GAME_3,GAME_4) + +/* Symbols layer + * ,------------------------------------------------------------------------. + * | OFF | ` | ~ | [ | ] | { || } | - | _ | = | + | | + * |-----+-----+-----+-----+-----+-----++-----+-----+-----+-----+-----+-----| + * | | 1 | 2 | 3 | 4 | 5 || 6 | 7 | 8 | 9 | 0 | \ | + * |-----+-----+-----+-----+-----+-----++-----+-----+-----+-----+-----+-----| + * | | ! | @ | # | $ | % || ^ | & | * | ( | ) | LCK | + * |-----+-----+-----+-----+-----+-----++-----+-----+-----+-----+-----+-----| + * | | | | | | | | || | | | | | | + * `------------------------------------------------------------------------' */ +#define NUMBERS_1 \ + K_NUMBR,KC_GRV, KC_TILD,KC_LBRC,KC_RBRC,KC_LCBR,KC_RCBR,KC_MINS,KC_UNDS,KC_EQL, KC_PLUS,_______ +#define NUMBERS_2 \ + _______,KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSLS +#define NUMBERS_3 \ + _______,KC_EXLM,KC_AT, KC_HASH,KC_DLR, KC_PERC,KC_CIRC,KC_AMPR,KC_ASTR,KC_LPRN,KC_RPRN,K_LOCK +#define NUMBERS_4 \ + KC_PIPE,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______ +#define NUMBERS KM(NUMBERS_1,NUMBERS_2,NUMBERS_3,NUMBERS_4) + +/* Settings layer + * ,------------------------------------------------------------------------. + * |BLLed| F1 | F2 | F3 | F4 | Lin || Win | Wake| |Hue -|Hue +|Reset| + * |-----+-----+-----+-----+-----+-----++-----+-----+-----+-----+-----+-----| + * | | F5 | F6 | F7 | F8 | || | |RGBto|Sat -|Sat +| | + * |-----+-----+-----+-----+-----+-----++-----+-----+-----+-----+-----+-----| + * | Game| F9 | F10 | F11 | F12 |Vol 0||PrtSc| |RGBan|Bri -|Bri +| | + * |-----+-----+-----+-----+-----+-----++-----+-----+-----+-----+-----+-----| + * |Musir| | | | |Vol -||Vol +| Prev| Stop|TogMu| Next| | + * `------------------------------------------------------------------------' */ +#define SETTINGS_1 \ + BL_STEP,KC_F1, KC_F2, KC_F3, KC_F4, UNI_LI, UNI_WN, KC_WAKE,_______,RGB_HUD,RGB_HUI,RESET +#define SETTINGS_2 \ + _______,KC_F5, KC_F6, KC_F7, KC_F8, _______,_______,_______,RGB_TOG,RGB_SAD,RGB_SAI,_______ +#define SETTINGS_3 \ + K_GAMES,KC_F9, KC_F10, KC_F11, KC_F12, KC_MUTE,KC_PSCR,_______,RGB_MOD,RGB_VAD,RGB_VAI,_______ +#define SETTINGS_4 \ + MU_TOG, _______,_______,_______,_______,KC_VOLD,KC_VOLU,KC_MPRV,KC_MSTP,KC_MPLY,KC_MNXT,_______ +#define SETTINGS KM(SETTINGS_1,SETTINGS_2,SETTINGS_3,SETTINGS_4) + +/* Mouse layer + * ,------------------------------------------------------------------------. + * |Ulock| \ | ^ | / |.....|.....||.....|.....| |\|.| |^| | |/|.| | + * |-----+-----+-----+-----+-----+-----++-----+-----+-----+-----+-----+-----| + * | | < | Mid | > |Btn 4|.....||.....|Btn 5| <-- | Mid | --> | | + * |-----+-----+-----+-----+-----+-----++-----+-----+-----+-----+-----+-----| + * | | / | v | \ |.....|.....||.....|.....| |/| | |v| | |\| | LCK | + * |-----+-----+-----+-----+-----+-----++-----+-----+-----+-----+-----+-----| + * | | | | | | Left||Right| | |Accl0|Accl1|Accl2| + * `------------------------------------------------------------------------' */ +#define MOUSE_1 \ + K_MOUSE,MO_NW, MO_N, MO_NE, XXX, XXX ,XXX, XXX, MO_S_NW,MO_S_N, MO_S_NE,_______ +#define MOUSE_2 \ + _______,MO_W, MO_CL_M,MO_E, MO_CL_4,XXX ,XXX, MO_CL_5,MO_S_W, MO_CL_M,MO_S_E, _______ +#define MOUSE_3 \ + _______,MO_SW, MO_S, MO_SE, XXX, XXX ,XXX, XXX, MO_S_SW,MO_S_S, MO_S_SE,K_LOCK +#define MOUSE_4 \ + _______,_______,_______,_______,_______,MO_CL_L,MO_CL_R,_______,MO_AC_0,MO_AC_1,MO_AC_2,_______ +#define MOUSE KM(MOUSE_1,MOUSE_2,MOUSE_3,MOUSE_4) + +/* Music layer + * ,------------------------------------------------------------------------. + * |.....|.....|.....|.....|.....|.....||.....|.....|.....|.....|.....|.....| + * |-----+-----+-----+-----+-----+-----++-----+-----+-----+-----+-----+-----| + * |.....|.....|.....|.....|.....|.....||.....|.....|.....|.....|.....|.....| + * |-----+-----+-----+-----+-----+-----++-----+-----+-----+-----+-----+-----| + * |.....|.....|.....|.....|.....|.....||.....|.....|.....|.....|.....|.....| + * |-----+-----+-----+-----+-----+-----++-----+-----+-----+-----+-----+-----| + * | togg| rec | stop| play| slow| fast||modes|.....|.....|.....|.....|.....| + * `------------------------------------------------------------------------' + */ +#define MASK XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX, XXX +#define MUSIC_4 MU_TOG, KC_LCTL, KC_LALT, KC_LGUI, KC_DOWN, KC_UP, MU_MOD, XXX, XXX, XXX, XXX, XXX +#define MUSIC KM(MASK,MASK,MASK,MUSIC_4) + +#endif diff --git a/users/bbaserdem/rules.mk b/users/bbaserdem/rules.mk new file mode 100644 index 000000000..513ce4fe0 --- /dev/null +++ b/users/bbaserdem/rules.mk @@ -0,0 +1,22 @@ +SRC += bbaserdem.c +EXTRAFLAGS += -flto + +# ENABLE +UNICODE_ENABLE = yes # Used for unicode character emulation +EXTRAKEY_ENABLE = yes # OS signals like volume control + +# DISABLE +BLUETOOTH_ENABLE = no # No bluetooth +COMMAND_ENABLE = no # Some bootmagic thing +BOOTMAGIC_ENABLE = no # Access to EEPROM settings, not needed +CONSOLE_ENABLE = no # Allows console output with a command +SLEEP_LED_ENABLE = no # Breathes LED's when computer is asleep. Untested. +NKRO_ENABLE = no # Default is 6KRO which is plenty +MIDI_ENABLE = no # Untested feature +FAUXCLICKY_ENABLE = no # Emulates clicks using speaker +KEY_LOCK_ENABLE = no # Allows locking any key. Not used +API_SYSEX_ENABLE = no # Allows OS to send signals. +KEY_LOCK_ENABLE = no # Allows locking any key. Not used + +# Disabling this makes it compile, prob bad upstream code +# VARIABLE_TRACE = no # Allows debugging variables diff --git a/users/dhertz/config.h b/users/dhertz/config.h new file mode 100644 index 000000000..3f7762e65 --- /dev/null +++ b/users/dhertz/config.h @@ -0,0 +1,9 @@ +#ifndef USERSPACE_CONFIG_H +#define USERSPACE_CONFIG_H + +#ifdef TAPPING_TERM +#undef TAPPING_TERM +#endif // TAPPING_TERM +#define TAPPING_TERM 200 + +#endif // !USERSPACE_CONFIG_H diff --git a/users/dhertz/dhertz.c b/users/dhertz/dhertz.c new file mode 100644 index 000000000..9aae0125f --- /dev/null +++ b/users/dhertz/dhertz.c @@ -0,0 +1,101 @@ +#include "dhertz.h" + +// 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) {} + +__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) {} + +__attribute__ ((weak)) +void action_function_keymap(keyrecord_t *record, uint8_t id, uint8_t opt) {} + +// Call user matrix init, then call the keymap's init function +void matrix_init_user(void) { + matrix_init_keymap(); +} + +// No global matrix scan code, so just run keymap's matix +// scan function +void matrix_scan_user(void) { + matrix_scan_keymap(); +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch(keycode) { + case CMD_TAB_CMD: + mod_or_mod_with_macro(record, KC_LGUI, SS_TAP(X_TAB)); + return false; + case CMD_GRV_CMD: + mod_or_mod_with_macro(record, KC_RGUI, SS_TAP(X_GRAVE)); + return false; + } + + if (record->event.pressed) { + switch(keycode) { + case HSH_TLD: + if (get_mods()&(MOD_BIT(KC_LSFT)|MOD_BIT(KC_RSFT))) { + SEND_STRING(SS_TAP(X_NONUS_BSLASH)); + } else { + SEND_STRING(SS_LALT("3")); + } + break; + case CTRL_A: + SEND_STRING(SS_LCTRL("a")); + break; + case CMD_ALT_C: + SEND_STRING(SS_LGUI(SS_LALT("c"))); + break; + case CMD_SFT_L: + SEND_STRING(SS_LGUI("L")); + break; + case ISO_COUNTRY_CODE: + SEND_STRING("country_iso_alpha2_code"); + break; + default: + return process_record_keymap(keycode, record); + } + return false; + } + return process_record_keymap(keycode, record); +} + +static uint16_t sunds_timer; + +void mod_or_mod_with_macro(keyrecord_t *record, uint16_t kc_mod, char* macro) { + if (record->event.pressed) { + sunds_timer = timer_read(); + register_code(kc_mod); + } else { + if (timer_elapsed(sunds_timer) < TAPPING_TERM) { + send_string(macro); + } + unregister_code(kc_mod); + } +} + +// 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 +uint32_t layer_state_set_user (uint32_t state) { + return layer_state_set_keymap (state); +} + +void led_set_user(uint8_t usb_led) { + led_set_keymap(usb_led); +} + diff --git a/users/dhertz/dhertz.h b/users/dhertz/dhertz.h new file mode 100644 index 000000000..aef613f55 --- /dev/null +++ b/users/dhertz/dhertz.h @@ -0,0 +1,23 @@ +#ifndef USERSPACE +#define USERSPACE + +#include "quantum.h" + +#define SRCH_CTL CTL_T(KC_F19) +#define LYR_SPC LT(1, KC_SPC) +#define NC_CTL CTL_T(KC_F18) + +enum custom_keycodes { + HSH_TLD = SAFE_RANGE, + CTRL_A, + CMD_ALT_C, + CMD_SFT_L, + ISO_COUNTRY_CODE, + CMD_TAB_CMD, + CMD_GRV_CMD, + NEW_SAFE_RANGE, +}; + +void mod_or_mod_with_macro(keyrecord_t *record, uint16_t kc_mod, char* cmd_or_macro); + +#endif diff --git a/users/dhertz/rules.mk b/users/dhertz/rules.mk new file mode 100644 index 000000000..0643edfad --- /dev/null +++ b/users/dhertz/rules.mk @@ -0,0 +1 @@ +SRC += dhertz.c diff --git a/users/drashna/config.h b/users/drashna/config.h index 0a59ad026..26c989d7f 100644 --- a/users/drashna/config.h +++ b/users/drashna/config.h @@ -4,7 +4,6 @@ #ifdef AUDIO_ENABLE #define AUDIO_CLICKY -#define AUDIO_CLICKY_ON #define STARTUP_SONG SONG(E1M1_DOOM) #define GOODBYE_SONG SONG(SONIC_RING) #define DEFAULT_LAYER_SONGS { SONG(QWERTY_SOUND), \ @@ -12,12 +11,13 @@ SONG(DVORAK_SOUND), \ SONG(OVERWATCH_THEME) \ } + +#define AUDIO_CLICKY_FREQ_RANDOMNESS 1.0f + #endif #ifdef RGBLIGHT_ENABLE - #ifndef KEYBOARD_ergodox_ez - #define RGBLIGHT_SLEEP - #endif // !KEYBOARD_ergodox_ez +#define RGBLIGHT_SLEEP #endif // RGBLIGHT_ENABLE @@ -43,6 +43,8 @@ #define IGNORE_MOD_TAP_INTERRUPT #undef PERMISSIVE_HOLD #undef PREVENT_STUCK_MODIFIERS +// #define TAPPING_FORCE_HOLD +//#define RETRO_TAPPING #define FORCE_NKRO @@ -53,7 +55,7 @@ #ifdef TAPPING_TERM #undef TAPPING_TERM #endif // TAPPING_TERM -#define TAPPING_TERM 176 +#define TAPPING_TERM 175 // Disable action_get_macro and fn_actions, since we don't use these @@ -61,7 +63,7 @@ #ifndef NO_DEBUG #define NO_DEBUG #endif // !NO_DEBUG -#ifndef NO_PRINT +#if !defined(NO_PRINT) && !defined(CONSOLE_ENABLE) #define NO_PRINT #endif // !NO_PRINT #define NO_ACTION_MACRO diff --git a/users/drashna/drashna.c b/users/drashna/drashna.c index 86c16b826..8efd99f80 100644 --- a/users/drashna/drashna.c +++ b/users/drashna/drashna.c @@ -17,123 +17,36 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include "drashna.h" #include "version.h" - -#if (__has_include("secrets.h") && !defined(NO_SECRETS)) -#include "secrets.h" -#else -// `PROGMEM const char secret[][x]` may work better, but it takes up more space in the firmware -// And I'm not familiar enough to know which is better or why... -PROGMEM const char secret[][64] = { - "test1", - "test2", - "test3", - "test4", - "test5" -}; -#endif +#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; -#ifdef RGBLIGHT_ENABLE -bool rgb_layer_change = true; -#endif - userspace_config_t userspace_config; // Helper Functions -void tap(uint16_t keycode){ register_code(keycode); unregister_code(keycode); }; -#ifdef RGBLIGHT_ENABLE -void rgblight_sethsv_default_helper(uint8_t index) { - uint8_t default_layer = eeconfig_read_default_layer(); - if (default_layer & (1UL << _COLEMAK)) { - rgblight_sethsv_at(300, 255, 255, index); - rgblight_sethsv_at(300, 255, 255, index); - } - else if (default_layer & (1UL << _DVORAK)) { - rgblight_sethsv_at(120, 255, 255, index); - rgblight_sethsv_at(120, 255, 255, index); - } - else if (default_layer & (1UL << _WORKMAN)) { - rgblight_sethsv_at(43, 255, 255, index); - rgblight_sethsv_at(43, 255, 255, index); - } - else { - rgblight_sethsv_at(180, 255, 255, index); - rgblight_sethsv_at(180, 255, 255, index); - } -} -#endif // RGBLIGHT_ENABLE - - -// ========================================= TAP DANCE ========================================= -#ifdef TAP_DANCE_ENABLE -//define diablo macro timer variables -static uint16_t diablo_timer[4]; -static uint8_t diablo_times[] = { 0, 1, 3, 5, 10, 30 }; -static uint8_t diablo_key_time[4]; - -// 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; }; - -// 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]; - } -} -// 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); } - -//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), -}; - -// Sends the key press to system, but only if on the Diablo layer -void send_diablo_keystroke(uint8_t diablo_key) { - if (biton32(layer_state) == _DIABLO) { - switch (diablo_key) { - case 0: - tap(KC_1); break; - case 1: - tap(KC_2); break; - case 2: - tap(KC_3); break; - case 3: - tap(KC_4); break; - } +// 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) { + clear_keyboard(); + tap(userspace_config.is_overwatch ? KC_BSPC : KC_ENTER); + wait_ms(50); + send_string(str); + wait_ms(50); + tap(KC_ENTER); } + if (override) wait_ms(3000); + return false; } -// 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); - } - } -} -#endif // TAP_DANCE_ENABLE +void tap(uint16_t keycode){ register_code(keycode); unregister_code(keycode); }; // Add reconfigurable functions here, for keymap customization @@ -152,6 +65,11 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { } __attribute__ ((weak)) +bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { + return true; +} + +__attribute__ ((weak)) uint32_t layer_state_set_keymap (uint32_t state) { return state; } @@ -163,39 +81,29 @@ 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) { - uint8_t default_layer = eeconfig_read_default_layer(); + userspace_config.raw = eeprom_read_byte(EECONFIG_USERSPACE); -#ifdef RGBLIGHT_ENABLE - rgblight_enable(); -#endif // RGBLIGHT_ENABLE +#ifdef AUDIO_CLICKY + clicky_enable = userspace_config.clicky_enable; +#endif - if (default_layer & (1UL << _COLEMAK)) { -#ifdef RGBLIGHT_ENABLE - rgblight_sethsv_magenta(); -#endif // RGBLIGHT_ENABLE - } else if (default_layer & (1UL << _DVORAK)) { -#ifdef RGBLIGHT_ENABLE - rgblight_sethsv_green(); -#endif // RGBLIGHT_ENABLE - } else if (default_layer & (1UL << _WORKMAN)) { -#ifdef RGBLIGHT_ENABLE - rgblight_sethsv_goldenrod(); -#endif // RGBLIGHT_ENABLE - } else { -#ifdef RGBLIGHT_ENABLE - rgblight_sethsv_teal(); -#endif // RGBLIGHT_ENABLE - } +#ifdef BOOTLOADER_CATERINA + DDRD &= ~(1<<5); + PORTD &= ~(1<<5); - userspace_config.raw = eeprom_read_byte(EECONFIG_USERSPACE); - clicky_enable = userspace_config.clicky_enable; + DDRB &= ~(1<<0); + PORTB &= ~(1<<0); +#endif -#if ( defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE) ) + +#if (defined(UNICODE_ENABLE) || defined(UNICODEMAP_ENABLE) || defined(UCIS_ENABLE)) set_unicode_input_mode(UC_WINC); #endif //UNICODE_ENABLE - + matrix_init_rgb(); matrix_init_keymap(); } + + // No global matrix scan code, so just run keymap's matrix // scan function void matrix_scan_user(void) { @@ -204,24 +112,14 @@ void matrix_scan_user(void) { run_diablo_macro_check(); #endif // TAP_DANCE_ENABLE +#ifdef RGBLIGHT_ENABLE + matrix_scan_rgb(); +#endif // RGBLIGHT_ENABLE + matrix_scan_keymap(); } -// 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) { - clear_keyboard(); - tap(userspace_config.is_overwatch ? KC_BSPC : KC_ENTER); - wait_ms(50); - send_string(str); - wait_ms(50); - tap(KC_ENTER); - } - if (override) wait_ms(3000); - return false; -} // Defines actions tor my global custom keycodes. Defined in drashna.h file @@ -229,10 +127,9 @@ bool send_game_macro(const char *str, keyrecord_t *record, bool override) { 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 CONSOLE_ENABLE +#ifdef KEYLOGGER_ENABLE xprintf("KL: row: %u, column: %u, pressed: %u\n", record->event.key.col, record->event.key.row, record->event.pressed); -#endif //CONSOLE_ENABLE - +#endif //KEYLOGGER_ENABLE switch (keycode) { case KC_QWERTY: @@ -280,8 +177,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case KC_RESET: // Custom RESET code that sets RGBLights to RED if (!record->event.pressed) { #ifdef RGBLIGHT_ENABLE - rgblight_enable(); - rgblight_mode(1); + rgblight_enable_noeeprom(); + rgblight_mode_noeeprom(1); rgblight_setrgb_red(); #endif // RGBLIGHT_ENABLE reset_keyboard(); @@ -293,6 +190,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case EPRM: // Resets EEPROM if (record->event.pressed) { eeconfig_init(); + default_layer_set(1UL<<eeconfig_read_default_layer()); + layer_state_set(layer_state); } return false; break; @@ -303,24 +202,24 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { return false; break; - - case KC_SECRET_1 ... KC_SECRET_5: // Secrets! Externally defined strings, not stored in repo - if (!record->event.pressed) { - clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); - send_string_P(secret[keycode - KC_SECRET_1]); - } - return false; - break; - +/* Code has been depreciated + case KC_SECRET_1 ... KC_SECRET_5: // Secrets! Externally defined strings, not stored in repo + if (!record->event.pressed) { + clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); + send_string(decoy_secret[keycode - KC_SECRET_1]); + } + return false; + break; +*/ // These are a serious of gaming macros. // Only enables for the viterbi, basically, // to save on firmware space, since it's limited. -#if !(defined(KEYBOARD_orthodox_rev1) || defined(KEYBOARD_orthodox_rev3) || defined(KEYBOARD_ergodox_ez) || defined(KEYBOARD_iris_rev2)) +#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; eeprom_update_byte(EECONFIG_USERSPACE, userspace_config.raw); } #ifdef RGBLIGHT_ENABLE - userspace_config.is_overwatch ? rgblight_mode(17) : rgblight_mode(18); + userspace_config.is_overwatch ? rgblight_mode_noeeprom(17) : rgblight_mode_noeeprom(18); #endif //RGBLIGHT_ENABLE return false; break; case KC_SALT: @@ -346,38 +245,19 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { 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 // !(defined(KEYBOARD_orthodox_rev1) || defined(KEYBOARD_orthodox_rev3) || defined(KEYBOARD_ergodox_ez)) +#endif // MACROS_ENABLED -#ifdef TAP_DANCE_ENABLE 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]; } } +#endif // TAP_DANCE_ENABLE#endif return false; break; -#endif // TAP_DANCE_ENABLE - - - case KC_RGB_T: // This allows me to use underglow as layer indication, or as normal -#ifdef RGBLIGHT_ENABLE - if (record->event.pressed) { - rgb_layer_change = !rgb_layer_change; - if (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; -#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 - rgb_layer_change = false; - } - return true; break; -#endif // RGBLIGHT_ENABLE case KC_CCCV: // One key copy/paste @@ -403,8 +283,10 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { return false; break; case CLICKY_TOGGLE: +#ifdef AUDIO_CLICKY userspace_config.clicky_enable = clicky_enable; eeprom_update_byte(EECONFIG_USERSPACE, userspace_config.raw); +#endif break; #ifdef UNICODE_ENABLE case UC_FLIP: // (╯°□°)╯ ︵ ┻━┻ @@ -432,7 +314,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { #endif // UNICODE_ENABLE } - return process_record_keymap(keycode, record); + return process_record_keymap(keycode, record) && process_record_secrets(keycode, record) && process_record_user_rgb(keycode, record); } @@ -441,130 +323,10 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { // 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) { - uint8_t default_layer = eeconfig_read_default_layer(); state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST); - - switch (biton32(state)) { - case _NAV: -#ifdef RGBLIGHT_ENABLE - if (rgb_layer_change) { - rgblight_sethsv_blue(); - rgblight_mode(1); - } -#endif // RGBLIGHT_ENABLE - break; - case _SYMB: -#ifdef RGBLIGHT_ENABLE - if (rgb_layer_change) { - rgblight_sethsv_blue(); - rgblight_mode(2); - } -#endif // RGBLIGHT_ENABLE - break; - case _MOUS: -#ifdef RGBLIGHT_ENABLE - if (rgb_layer_change) { - rgblight_sethsv_yellow(); - rgblight_mode(1); - } -#endif // RGBLIGHT_ENABLE - break; - case _MACROS: -#ifdef RGBLIGHT_ENABLE - if (rgb_layer_change) { - rgblight_sethsv_orange(); - userspace_config.is_overwatch ? rgblight_mode(17) : rgblight_mode(18); - } -#endif // RGBLIGHT_ENABLE - break; - case _MEDIA: -#ifdef RGBLIGHT_ENABLE - if (rgb_layer_change) { - rgblight_sethsv_chartreuse(); - rgblight_mode(22); - } -#endif // RGBLIGHT_ENABLE - break; - case _GAMEPAD: #ifdef RGBLIGHT_ENABLE - if (rgb_layer_change) { - rgblight_sethsv_orange(); - rgblight_mode(17); - } -#endif // RGBLIGHT_ENABLE - break; - case _DIABLO: -#ifdef RGBLIGHT_ENABLE - if (rgb_layer_change) { - rgblight_sethsv_red(); - rgblight_mode(5); - } -#endif // RGBLIGHT_ENABLE - break; - case _RAISE: -#ifdef RGBLIGHT_ENABLE - if (rgb_layer_change) { - rgblight_sethsv_yellow(); - rgblight_mode(5); - } -#endif // RGBLIGHT_ENABLE - break; - case _LOWER: -#ifdef RGBLIGHT_ENABLE - if (rgb_layer_change) { - rgblight_sethsv_orange(); - rgblight_mode(5); - } -#endif // RGBLIGHT_ENABLE - break; - case _ADJUST: -#ifdef RGBLIGHT_ENABLE - if (rgb_layer_change) { - rgblight_sethsv_red(); - rgblight_mode(23); - } -#endif // RGBLIGHT_ENABLE - break; - case _COVECUBE: -#ifdef RGBLIGHT_ENABLE - if (rgb_layer_change) { - rgblight_sethsv_green(); - rgblight_mode(2); - } + state = layer_state_set_rgb(state); #endif // RGBLIGHT_ENABLE - break; - default: // for any other layers, or the default layer - if (default_layer & (1UL << _COLEMAK)) { -#ifdef RGBLIGHT_ENABLE - if (rgb_layer_change) { rgblight_sethsv_magenta(); } -#endif // RGBLIGHT_ENABLE - } - else if (default_layer & (1UL << _DVORAK)) { -#ifdef RGBLIGHT_ENABLE - if (rgb_layer_change) { rgblight_sethsv_green(); } -#endif // RGBLIGHT_ENABLE - } - else if (default_layer & (1UL << _WORKMAN)) { -#ifdef RGBLIGHT_ENABLE - if (rgb_layer_change) { rgblight_sethsv_goldenrod(); } -#endif // RGBLIGHT_ENABLE - } - else { -#ifdef RGBLIGHT_ENABLE - if (rgb_layer_change) { rgblight_sethsv_teal(); } -#endif // RGBLIGHT_ENABLE - } - if (biton32(state) == _MODS) { // If the non-OSM layer is enabled, then breathe -#ifdef RGBLIGHT_ENABLE - if (rgb_layer_change) { rgblight_mode(2); } -#endif // RGBLIGHT_ENABLE - } else { // otherwise, stay solid -#ifdef RGBLIGHT_ENABLE - if (rgb_layer_change) { rgblight_mode(1); } -#endif // RGBLIGHT_ENABLE - } - break; - } return layer_state_set_keymap (state); } diff --git a/users/drashna/drashna.h b/users/drashna/drashna.h index 5ef25333b..e035b86fb 100644 --- a/users/drashna/drashna.h +++ b/users/drashna/drashna.h @@ -27,12 +27,8 @@ enum userspace_layers { _DVORAK, _WORKMAN, _MODS, - _NAV, - _COVECUBE, - _SYMB, _GAMEPAD, _DIABLO, - _MOUS, _MACROS, _MEDIA, _LOWER, @@ -46,23 +42,29 @@ enum userspace_layers { #define MODS_ALT_MASK (MOD_BIT(KC_LALT)|MOD_BIT(KC_RALT)) #define MODS_GUI_MASK (MOD_BIT(KC_LGUI)|MOD_BIT(KC_RGUI)) + // RGB color codes are no longer located here anymore. Instead, you will want to // head to https://github.com/qmk/qmk_firmware/blob/master/quantum/rgblight_list.h -extern bool rgb_layer_change; extern bool clicky_enable; #ifdef RGBLIGHT_ENABLE void rgblight_sethsv_default_helper(uint8_t index); #endif // RGBLIGHT_ENABLE -#define EECONFIG_USERSPACE (uint8_t *)20 +void tap(uint16_t keycode); +bool process_record_secrets(uint16_t keycode, keyrecord_t *record); + + +#define EECONFIG_USERSPACE (uint8_t *)19 typedef union { - uint32_t raw; + uint8_t raw; struct { - bool clicky_enable :1; - bool is_overwatch :1; + bool clicky_enable :1; + bool rgb_layer_change :1; + bool is_overwatch :1; + bool nuke_switch :1; }; } userspace_config_t; @@ -95,6 +97,8 @@ enum userspace_custom_keycodes { KC_SECRET_4, KC_SECRET_5, KC_CCCV, + KC_NUKE, + #ifdef UNICODE_ENABLE UC_FLIP, #endif //UNICODE_ENABLE @@ -116,8 +120,8 @@ enum userspace_custom_keycodes { #define DVORAK KC_DVORAK #define COLEMAK KC_COLEMAK #define WORKMAN KC_WORKMAN -#define KC_RST KC_RESET +#define KC_RST KC_RESET #ifdef SWAP_HANDS_ENABLE #define KC_C1R3 SH_TT @@ -129,6 +133,16 @@ enum userspace_custom_keycodes { #define KC_MLSF OSM(MOD_LSFT) #define KC_MRSF OSM(MOD_RSFT) +#define OS_LGUI OSM(MOD_LGUI) +#define OS_RGUI OSM(MOD_RGUI) +#define OS_LSFT OSM(MOD_LSFT) +#define OS_RSFT OSM(MOD_RSFT) +#define OS_LCTL OSM(MOD_LCTL) +#define OS_RCTL OSM(MOD_RCTL) +#define OS_LALT OSM(MOD_LALT) +#define OS_RALT OSM(MOD_RALT) +#define ALT_APP ALT_T(KC_APP) + #define MG_NKRO MAGIC_TOGGLE_NKRO @@ -166,10 +180,10 @@ enum { #define LAYOUT KEYMAP #endif -#define LAYOUT_ergodox_wrapper(...) LAYOUT_ergodox(__VA_ARGS__) +#define LAYOUT_ergodox_wrapper(...) LAYOUT_ergodox(__VA_ARGS__) #define LAYOUT_ergodox_pretty_wrapper(...) LAYOUT_ergodox_pretty(__VA_ARGS__) -#define KEYMAP_wrapper(...) LAYOUT(__VA_ARGS__) -#define LAYOUT_wrapper(...) LAYOUT(__VA_ARGS__) +#define KEYMAP_wrapper(...) LAYOUT(__VA_ARGS__) +#define LAYOUT_wrapper(...) LAYOUT(__VA_ARGS__) // Blocks for each of the four major keyboard layouts @@ -204,8 +218,8 @@ enum { #define ______________COLEMAK_MOD_DH_L3____________ CTL_T(KC_Z), KC_X, KC_C, KC_D, KC_V #define ______________COLEMAK_MOD_DH_R1____________ KC_J, KC_L, KC_U, KC_Y, KC_SCLN -#define ______________COLEMAK_MOD_DH_R2____________ KC_K, KC_N, KC_E, KC_I, KC_O -#define ______________COLEMAK_MOD_DH_R3____________ KC_M, KC_H, KC_COMM, KC_DOT, CTL_T(KC_SLASH) +#define ______________COLEMAK_MOD_DH_R2____________ KC_M, KC_N, KC_E, KC_I, KC_O +#define ______________COLEMAK_MOD_DH_R3____________ KC_K, KC_H, KC_COMM, KC_DOT, CTL_T(KC_SLASH) #define _________________DVORAK_L1_________________ KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y @@ -231,11 +245,13 @@ enum { #define _________________NORMAN_L3_________________ CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B #define _________________NORMAN_R1_________________ KC_J, KC_U, KC_R, KC_L, KC_SCLN -#define _________________NORMAN_R2_________________ KC_J, KC_N, KC_I, KC_O, KC_U +#define _________________NORMAN_R2_________________ KC_Y, KC_N, KC_I, KC_O, KC_U #define _________________NORMAN_R3_________________ KC_P, KC_M, KC_COMM, KC_DOT, CTL_T(KC_SLASH) #define ________________NUMBER_LEFT________________ KC_1, KC_2, KC_3, KC_4, KC_5 #define ________________NUMBER_RIGHT_______________ KC_6, KC_7, KC_8, KC_9, KC_0 +#define _________________FUNC_LEFT_________________ KC_F1, KC_F2, KC_F3, KC_F4, KC_F5 +#define _________________FUNC_RIGHT________________ KC_F6, KC_F7, KC_F8, KC_F9, KC_F10 // Since we have 4 default layouts (QWERTY, DVORAK, COLEMAK and WORKMAN), // this allows us to quickly modify the bottom row for all of the layouts @@ -245,9 +261,9 @@ enum { #define ___________ERGODOX_BOTTOM_RIGHT____________ KC_LEFT, KC_DOWN, KC_UP, KC_RGHT -#define __________________ERGODOX_THUMB_CLUSTER_____________________ ALT_T(KC_APP), KC_LGUI, KC_RGUI, CTL_T(KC_ESCAPE), \ +#define __________________ERGODOX_THUMB_CLUSTER_____________________ ALT_T(KC_APP), OSM(MOD_LGUI), OSM(MOD_RGUI), CTL_T(KC_ESCAPE), \ KC_HOME, KC_PGUP, \ - KC_SPACE,KC_BSPC, KC_END, KC_PGDN, KC_DEL, KC_ENTER + LT(_LOWER, KC_SPACE),KC_BSPC, KC_END, KC_PGDN, KC_DEL, LT(_RAISE, KC_ENTER) #endif // !USERSPACE diff --git a/users/drashna/readme.md b/users/drashna/readme.md index 79758e7e5..0aa73ece9 100644 --- a/users/drashna/readme.md +++ b/users/drashna/readme.md @@ -96,7 +96,7 @@ Then you can create this file and add your macro strings to it: ###### secrets.h ```c -PROGMEM const char secret[][64] = { +static const char * const secrets[] = { "secret1", "secret2", "secret3", @@ -116,7 +116,7 @@ In the `<name>.c` file, you will want to add this to the top: #else // `PROGMEM const char secret[][x]` may work better, but it takes up more space in the firmware // And I'm not familiar enough to know which is better or why... -PROGMEM const char secret[][64] = { +static const char * const secrets[] = { "test1", "test2", "test3", @@ -162,7 +162,7 @@ This tells us where in the EEPROM that the data structure is located, and this s ```c typedef union { - uint32_t raw; + uint8_t raw; struct { bool clicky_enable :1; bool is_overwatch :1; @@ -174,3 +174,23 @@ Then, in your C file, you want to add: `userspace_config_t userspace_config;`, a From there, you'd want to use the data structure (such as `userspace_config.is_overwatch`) when you want to check this value. And if you want to update it, update directly and then use `eeprom_update_byte(EECONFIG_USERSPACE, userspace_config.raw);` to write the value back to the EEPROM. + + +Pro Micro Hacking +----------------- + +Well, you can get the QMK DFU bootloader working on the ProMicro. But you need to change fuses. + +What worked to get into the firmware properly was: + +``` +Low: 0x5E High: 0x99 Extended: 0xF3 Lock: 0xFF +``` + +But some of the columns and rows didn't work, like the pin mapping was wrong. Even when setting the bootloader settings. + + This is here for future reference. And the default fuse settings I believe were: + +``` +Low: 0xFF High: 0xD8 Extended: 0xC3 Lock: 0x3F +``` diff --git a/users/drashna/rgb_stuff.c b/users/drashna/rgb_stuff.c new file mode 100644 index 000000000..af7190cc3 --- /dev/null +++ b/users/drashna/rgb_stuff.c @@ -0,0 +1,261 @@ +#include "drashna.h" +#include "rgb_stuff.h" + +extern rgblight_config_t rgblight_config; +extern userspace_config_t userspace_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); +} +#endif // RGBLIGHT_ENABLE + +#ifdef INDICATOR_LIGHTS +uint8_t last_mod; +uint8_t last_led; +uint8_t last_osm; +uint8_t current_mod; +uint8_t current_led; +uint8_t current_osm; + + +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 & MODS_SHIFT_MASK || this_led & (1<<USB_LED_CAPS_LOCK) || this_osm & MODS_SHIFT_MASK) { + rgblight_sethsv_at(0, 255, 255, SHFT_LED1); + rgblight_sethsv_at(0, 255, 255, SHFT_LED2); + } else { + rgblight_sethsv_default_helper(SHFT_LED1); + rgblight_sethsv_default_helper(SHFT_LED2); + } + if (this_mod & MODS_CTRL_MASK || this_osm & MODS_CTRL_MASK) { + rgblight_sethsv_at(51, 255, 255, CTRL_LED1); + rgblight_sethsv_at(51, 255, 255, CTRL_LED2); + } else { + rgblight_sethsv_default_helper(CTRL_LED1); + rgblight_sethsv_default_helper(CTRL_LED2); + } + if (this_mod & MODS_GUI_MASK || this_osm & MODS_GUI_MASK) { + rgblight_sethsv_at(120, 255, 255, GUI_LED1); + rgblight_sethsv_at(120, 255, 255, GUI_LED2); + } else { + rgblight_sethsv_default_helper(GUI_LED1); + rgblight_sethsv_default_helper(GUI_LED2); + } + } +} + +void matrix_scan_indicator(void) { + current_mod = get_mods(); + current_led = host_keyboard_leds(); + current_osm = get_oneshot_mods(); + + set_rgb_indicators(current_mod, current_led, current_osm); + + last_mod = current_mod; + last_led = current_led; + last_osm = current_osm; + +} +#endif //INDICATOR_LIGHTS + +#ifdef RGBLIGHT_TWINKLE +static rgblight_fadeout lights[RGBLED_NUM]; + +__attribute__ ((weak)) +bool indicator_is_this_led_used(uint8_t index) { return false; } + +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; + + 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; + } + } + } + if (litup && biton32(layer_state) == 0) { + rgblight_set(); + } +} + +void start_rgb_light(void) { + + uint8_t indices[RGBLED_NUM]; + uint8_t indices_count = 0; + uint8_t min_life = 0xFF; + uint8_t min_life_index = -1; + for (uint8_t index = 0 ; index < RGBLED_NUM ; ++index ) { + if (indicator_is_this_led_used(index)) { continue; } + if (lights[index].enabled) { + if (min_life_index == -1 || + lights[index].life < min_life) + { + min_life = lights[index].life; + min_life_index = index; + } + continue; + } + + indices[indices_count] = index; + ++indices_count; + } + + uint8_t light_index; + if (!indices_count) { + light_index = min_life_index; + } + else { + light_index = indices[rand() % indices_count]; + } + + rgblight_fadeout *light = &lights[light_index]; + light->enabled = true; + light->timer = timer_read(); + light->life = 0xC0 + rand() % 0x40; + + light->hue = rgblight_config.hue + (rand() % 0xB4) - 0x54; + + rgblight_sethsv_at(light->hue, 255, light->life, light_index); +} +#endif + + +bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record) { + 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; +#endif // RGBLIGHT_TWINKLE + case KC_RGB_T: // This allows me to use underglow as layer indication, or as normal +#ifdef RGBLIGHT_ENABLE + if (record->event.pressed) { + userspace_config.rgb_layer_change ^= 1; + xprintf("rgblight layer change [EEPROM]: %u\n", userspace_config.rgb_layer_change); + eeprom_update_byte(EECONFIG_USERSPACE, 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; +#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); + eeprom_update_byte(EECONFIG_USERSPACE, userspace_config.raw); + } + } + return true; break; +#endif // RGBLIGHT_ENABLE + } + return true; +} + + + +void matrix_init_rgb(void) { +#ifdef INDICATOR_LIGHTS + current_mod = last_mod = get_mods(); + current_led = last_led = host_keyboard_leds(); + current_osm = last_osm = get_oneshot_mods(); +#endif + + if (userspace_config.rgb_layer_change) { + uint8_t default_layer = eeconfig_read_default_layer(); + rgblight_enable_noeeprom(); + if (default_layer & (1UL << _COLEMAK)) { + rgblight_sethsv_magenta(); + } else if (default_layer & (1UL << _DVORAK)) { + rgblight_sethsv_green(); + } else if (default_layer & (1UL << _WORKMAN)) { + rgblight_sethsv_goldenrod(); + } else { + rgblight_sethsv_cyan(); + } + } +} + +void matrix_scan_rgb(void) { +#ifdef RGBLIGHT_TWINKLE + scan_rgblight_fadeout(); +#endif // RGBLIGHT_ENABLE + +#ifdef INDICATOR_LIGHTS + matrix_scan_indicator(); +#endif + +} + + +uint32_t layer_state_set_rgb(uint32_t state) { +#ifdef RGBLIGHT_ENABLE + uint8_t default_layer = eeconfig_read_default_layer(); + if (userspace_config.rgb_layer_change) { + switch (biton32(state)) { + case _MACROS: + rgblight_sethsv_noeeprom_orange(); + userspace_config.is_overwatch ? rgblight_mode_noeeprom(17) : rgblight_mode_noeeprom(18); + break; + case _MEDIA: + rgblight_sethsv_noeeprom_chartreuse(); + rgblight_mode_noeeprom(22); + break; + case _GAMEPAD: + rgblight_sethsv_noeeprom_orange(); + rgblight_mode_noeeprom(17); + break; + case _DIABLO: + rgblight_sethsv_noeeprom_red(); + rgblight_mode_noeeprom(5); + break; + case _RAISE: + rgblight_sethsv_noeeprom_yellow(); + rgblight_mode_noeeprom(5); + break; + case _LOWER: + rgblight_sethsv_noeeprom_orange(); + rgblight_mode_noeeprom(5); + break; + case _ADJUST: + rgblight_sethsv_noeeprom_red(); + rgblight_mode_noeeprom(23); + break; + default: // for any other layers, or the default layer + if (default_layer & (1UL << _COLEMAK)) { + rgblight_sethsv_noeeprom_magenta(); + } else if (default_layer & (1UL << _DVORAK)) { + rgblight_sethsv_noeeprom_green(); + } else if (default_layer & (1UL << _WORKMAN)) { + rgblight_sethsv_noeeprom_goldenrod(); + } else { + rgblight_sethsv_noeeprom_cyan(); + } + biton32(state) == _MODS ? rgblight_mode_noeeprom(2) : rgblight_mode_noeeprom(1); // 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; +} diff --git a/users/drashna/rgb_stuff.h b/users/drashna/rgb_stuff.h new file mode 100644 index 000000000..6426ea266 --- /dev/null +++ b/users/drashna/rgb_stuff.h @@ -0,0 +1,16 @@ +#include "quantum.h" + +typedef struct { + bool enabled; + uint8_t hue; + uint16_t timer; + uint8_t life; +} rgblight_fadeout; + +bool process_record_user_rgb(uint16_t keycode, keyrecord_t *record); +void scan_rgblight_fadeout(void); +void matrix_init_rgb(void); +void matrix_scan_rgb(void); +uint32_t layer_state_set_rgb(uint32_t state); + + diff --git a/users/drashna/rules.mk b/users/drashna/rules.mk index 123c0cc70..18df665c0 100644 --- a/users/drashna/rules.mk +++ b/users/drashna/rules.mk @@ -1,7 +1,34 @@ -SRC += drashna.c +SRC += drashna.c secrets.c rgb_stuff.c + +ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) + SRC += tap_dances.c +endif + EXTRAFLAGS += -flto ifeq ($(strip $(NO_SECRETS)), yes) OPT_DEFS += -DNO_SECRETS endif + +ifdef RGBLIGHT_ENABLE + 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 +endif + +ifeq ($(strip $(MACROS_ENABLED)), yes) + OPT_DEFS += -DMACROS_ENABLED +endif + +ifdef CONSOLE_ENABLE + ifeq ($(strip $(KEYLOGGER_ENABLE)), yes) + OPT_DEFS += -DKEYLOGGER_ENABLE + endif +endif diff --git a/users/drashna/tap_dances.c b/users/drashna/tap_dances.c new file mode 100644 index 000000000..c9e4b1d0f --- /dev/null +++ b/users/drashna/tap_dances.c @@ -0,0 +1,65 @@ +#include "drashna.h" +#include "tap_dances.h" + + +//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]; + +// 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; }; + +// 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]; + } +} + +// 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); } + +//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), +}; + +// Sends the key press to system, but only if on the Diablo layer +void send_diablo_keystroke(uint8_t diablo_key) { + if (biton32(layer_state) == _DIABLO) { + switch (diablo_key) { + case 0: + tap(KC_1); break; + case 1: + tap(KC_2); break; + case 2: + tap(KC_3); break; + case 3: + tap(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); + } + } +} diff --git a/users/drashna/tap_dances.h b/users/drashna/tap_dances.h new file mode 100644 index 000000000..8935753f6 --- /dev/null +++ b/users/drashna/tap_dances.h @@ -0,0 +1,7 @@ +//define diablo macro timer variables +extern uint16_t diablo_timer[4]; +extern uint8_t diablo_times[]; +extern uint8_t diablo_key_time[4]; + + +void run_diablo_macro_check(void); diff --git a/users/edvorakjp/edvorakjp.c b/users/edvorakjp/edvorakjp.c new file mode 100644 index 000000000..cff1a123e --- /dev/null +++ b/users/edvorakjp/edvorakjp.c @@ -0,0 +1,246 @@ +#include "eeprom.h" +#include "edvorakjp.h" + +bool japanese_mode; +uint16_t time_on_pressed; + +edvorakjp_config_t edvorakjp_config; + +uint8_t eeconfig_read_edvorakjp(void) { + return eeprom_read_byte(EECONFIG_EDVORAK); +} + +void eeconfig_update_edvorakjp(uint8_t val) { + eeprom_update_byte(EECONFIG_EDVORAK, val); +} + +void dvorakj_layer_off(void) { + layer_off(_EDVORAKJ1); + layer_off(_EDVORAKJ2); +} + +void update_japanese_mode(bool new_state) { + japanese_mode = new_state; + if (japanese_mode) { + if (edvorakjp_config.enable_kc_lang) { + SEND_STRING(SS_TAP(X_LANG1)); + } else { + SEND_STRING(SS_LALT("`")); + } + } else { + dvorakj_layer_off(); + if (edvorakjp_config.enable_kc_lang) { + SEND_STRING(SS_TAP(X_LANG2)); + } else { + SEND_STRING(SS_LALT("`")); + } + } +} + +void matrix_init_user(void) { + japanese_mode = false; + time_on_pressed = 0; + edvorakjp_config.raw = eeconfig_read_edvorakjp(); + + matrix_init_keymap(); +} + +__attribute__ ((weak)) +void matrix_init_keymap() {} + +uint32_t layer_state_set_user(uint32_t state) { + state = update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST); + return layer_state_set_keymap(state); +} + +__attribute__ ((weak)) +uint32_t layer_state_set_keymap(uint32_t state) { + return state; +} + +/* + * Each process_record_* methods defined here are + * return false if handle edvorak_keycodes, or return true others. + */ +__attribute__ ((weak)) +bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { + return true; +} + +bool process_record_edvorakjp_ext(uint16_t keycode, keyrecord_t *record) { + if (!(edvorakjp_config.enable_jp_extra_layer &&\ + (default_layer_state == 1UL<<_EDVORAK) &&\ + japanese_mode &&\ + record->event.pressed)) { + return true; + } + + // consonant keys + // layer_on(J1) or layer_on(J2) are defined based on key positions. + switch (keycode) { + // right hand's left side w/o N + case KC_F: + case KC_G: + case KC_R: + case KC_D: + case KC_T: + case KC_B: + case KC_H: + case KC_J: + layer_on(_EDVORAKJ1); + register_code(keycode); + unregister_code(keycode); + return false; + + // N: toggle layer + case KC_N: + biton32(layer_state) == _EDVORAK ? layer_on(_EDVORAKJ1) : dvorakj_layer_off(); + register_code(keycode); + unregister_code(keycode); + return false; + + // left hand and right hand's right side + case KC_X: + case KC_C: + case KC_V: + case KC_Z: + case KC_P: + case KC_Y: + case KC_W: + case KC_Q: + case KC_S: + case KC_M: + case KC_K: + case KC_L: + layer_on(_EDVORAKJ2); + register_code(keycode); + unregister_code(keycode); + return false; + } + + // vowel keys, symbol keys and modifier keys + dvorakj_layer_off(); + switch (keycode) { + // combination vowel keys + case KC_AI: + SEND_STRING("ai"); + return false; + case KC_OU: + SEND_STRING("ou"); + return false; + case KC_EI: + SEND_STRING("ei"); + return false; + case KC_ANN: + SEND_STRING("ann"); + return false; + case KC_ONN: + SEND_STRING("onn"); + return false; + case KC_ENN: + SEND_STRING("enn"); + return false; + case KC_INN: + SEND_STRING("inn"); + return false; + case KC_UNN: + SEND_STRING("unn"); + return false; + + // AOEIU and other (symbol, modifier) keys + default: + return true; + } +} + +bool process_record_edvorakjp_config(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case KC_MAC: + edvorakjp_config.enable_kc_lang = true; + eeconfig_update_edvorakjp(edvorakjp_config.raw); + return false; + case KC_WIN: + edvorakjp_config.enable_kc_lang = false; + eeconfig_update_edvorakjp(edvorakjp_config.raw); + return false; + case KC_EXTON: + edvorakjp_config.enable_jp_extra_layer = true; + eeconfig_update_edvorakjp(edvorakjp_config.raw); + return false; + case KC_EXTOFF: + edvorakjp_config.enable_jp_extra_layer = false; + eeconfig_update_edvorakjp(edvorakjp_config.raw); + return false; + } + return true; +} + +bool process_record_layer(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case EDVORAK: + if (record->event.pressed) { + set_single_persistent_default_layer(_EDVORAK); + } + return false; + case QWERTY: + if (record->event.pressed) { + dvorakj_layer_off(); + set_single_persistent_default_layer(_QWERTY); + } + return false; + case LOWER: + if (record->event.pressed) { + layer_on(_LOWER); + time_on_pressed = record->event.time; + } else { + layer_off(_LOWER); + + if (TIMER_DIFF_16(record->event.time, time_on_pressed) < TAPPING_TERM) { + update_japanese_mode(false); + } + time_on_pressed = 0; + } + return false; + case RAISE: + if (record->event.pressed) { + layer_on(_RAISE); + time_on_pressed = record->event.time; + } else { + layer_off(_RAISE); + + if (TIMER_DIFF_16(record->event.time, time_on_pressed) < TAPPING_TERM) { + update_japanese_mode(true); + } + time_on_pressed = 0; + } + return false; + default: + return true; + } +} + +bool process_record_ime(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case KC_JPN: + if (record->event.pressed) { + update_japanese_mode(true); + } + return false; + case KC_ENG: + if (record->event.pressed) { + update_japanese_mode(false); + } + return false; + default: + return true; + } +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + + return process_record_keymap(keycode, record) &&\ + process_record_edvorakjp_ext(keycode, record) &&\ + process_record_edvorakjp_config(keycode, record) &&\ + process_record_layer(keycode, record) &&\ + process_record_ime(keycode, record); +} diff --git a/users/edvorakjp/edvorakjp.h b/users/edvorakjp/edvorakjp.h new file mode 100644 index 000000000..c38a9d1fa --- /dev/null +++ b/users/edvorakjp/edvorakjp.h @@ -0,0 +1,74 @@ +#ifndef USERSPACE +#define USERSPACE + +#include "quantum.h" +#include "action_layer.h" + +#define EECONFIG_EDVORAK (uint8_t *)20 + +extern keymap_config_t keymap_config; + +typedef union { + uint8_t raw; + struct { + bool enable_jp_extra_layer : 1; + bool enable_kc_lang : 1; // for macOS + }; +} edvorakjp_config_t; + +enum edvorakjp_layers { + _EDVORAK = 0, + _EDVORAKJ1, + _EDVORAKJ2, + _QWERTY, + _LOWER, + _RAISE, + _ADJUST, + _EXTRA, +}; + +enum edvorakjp_keycodes { + EDVORAK = SAFE_RANGE, + QWERTY, + LOWER, + RAISE, + KC_MAC, + KC_WIN, + KC_EXTON, + KC_EXTOFF, + KC_JPN, + KC_ENG, + KC_AI, + KC_OU, + KC_EI, + KC_ANN, + KC_ONN, + KC_ENN, + KC_INN, + KC_UNN, + NEW_SAFE_RANGE +}; + +uint8_t eeconfig_read_edvorakjp(void); +void eeconfig_update_edvorakjp(uint8_t val); + +void dvorakj_layer_off(void); +void update_japanese_mode(bool new_state); +void matrix_init_user(void); +void matrix_init_keymap(void); +uint32_t layer_state_set_user(uint32_t state); +uint32_t layer_state_set_keymap(uint32_t state); + +/* + * Each process_record_* methods defined here are + * return false if processed, or return true if not processed. + * You can add your original macros in process_record_keymap() in keymap.c. + */ +bool process_record_keymap(uint16_t keycode, keyrecord_t *record); +bool process_record_edvorakjp_ext(uint16_t keycode, keyrecord_t *record); +bool process_record_edvorakjp_config(uint16_t keycode, keyrecord_t *record); +bool process_record_layer(uint16_t keycode, keyrecord_t *record); +bool process_record_ime(uint16_t keycode, keyrecord_t *record); +bool process_record_user(uint16_t keycode, keyrecord_t *record); + +#endif diff --git a/users/edvorakjp/readme.md b/users/edvorakjp/readme.md new file mode 100644 index 000000000..d7ec74285 --- /dev/null +++ b/users/edvorakjp/readme.md @@ -0,0 +1,103 @@ +# edvorakjp + +epaew's Enhanced Dvorak layout for Japanese Programmer + +## Layout overview +This is a sample. You can swap any symbol keys and modifier keys. + +- Base layer (for ansi layout) +``` + //+----+----+----+----+----+----+----+----+----+----+----+----+----+---------+ + ` , ! , @ , # , $ , % , ^ , & , * , ( , ) , [ , ] , BSPC , + //+----+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+-------+ + TAB , ' , , , . , P , Y , F , G , R , W , Q , / , = , \ , + //+------++---++---++---++---++---++---++---++---++---++---++---++---+-------+ + CAPS , A , O , E , I , U , D , T , N , S , M , - , ENT , + //+-------+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-----------+ + LSFT , ; , X , C , V , Z , B , H , J , K , L , RSFT , + //+------+--+---++----++---+----+----+----+----+-+--+---++----++------+------+ + LCTL , LGUI , LALT , SPACE , RALT , RGUI , MENU , RCTL + //+------+------+------+-------------------------+------+------+------+------+ +``` +- Base layer (for iso layout) + - Two C keys are placed, it's on purpose. +``` + //+----+----+----+----+----+----+----+----+----+----+----+----+----+---------+ + ` , ! , @ , # , $ , % , ^ , & , * , ( , ) , [ , ] , BSPC , + //+----+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+-------+ + TAB , ' , , , . , P , Y , F , G , R , W , C , / , = , + //+------++---++---++---++---++---++---++---++---++---++---++---++---++ + CAPS , A , O , E , I , U , D , T , N , S , M , ; , - , ENT , + //+-------+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+------+ + LSFT , Q , X , C , V , Z , B , H , J , K , L , \ , RSFT , + //+------+--+---++----++---+----+----+----+----+-+--+---++----++---+--+------+ + LCTL , LGUI , LALT , SPACE , RALT , RGUI , MENU , RCTL + //+------+------+------+-------------------------+------+------+------+------+ +``` +- Additional layer (common, blanks are transparent) +``` + //+----+----+----+----+----+----+----+----+----+----+----+----+----+---------+ + , , , , , , , , , , , , , , + //+----+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+-------+ + , AI , OU , EI , , , , , , , , , , , + //+------++---++---++---++---++---++---++---++---++---++---++---++---+-------+ + , A , O , E , I , U , , Y1 , N , Y2 , , , , + //+-------+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-+--+-----------+ + ,ANN ,ONN ,ENN ,INN ,UNN , , , , , , , + //+------+--+---++----++---+----+----+----+----+-+--+---++----++------+------+ + , , , , , , , + //+------+------+------+-------------------------+------+------+------+------+ +``` + + And you can see [my iris keyboard layout](../../keyboards/iris/keymaps/edvorakjp/keymap.c) for sample implementation, too. + +## for Japanese + +- 日本語入力用のキーを追加 + - IME 切り替えキー + - 長押しでレイヤー切り替え、短押しでIME切り替え + - macOS(かな/英数)、Windows(Alt+\`)の両方に対応 + - DvorakJP(<http://www7.plala.or.jp/dvorakjp/>)を参考にした日本語入力用キーの導入 + - 拗音入力用のYキーを追加配置 + - 二重母音入力用のキー(AI, OU, EI) + - 撥音入力用のキー(ANN, ONN, ENN, INN, UNN) + - いずれかの子音を押下することで Additional layer が出現し、いずれかの母音を押下することで Base layer に戻ります(※1※2) + - ※1促音の入力に使うため、また連続で同じ指での打鍵を減らすために、 + FGRDTNBHJ を押下した場合はy1が、それ以外の子音を押下した場合はy2が出現しません + - ※2撥音の入力のため、nを2連打すると、Base layerに戻ります +- Define some custom keys for typing Japanese + - IME switching + - act as LOWER/RAISE when hold, act as IME switching when tapped + - for macOS(かな/英数), for Windows(Alt+\`) + - oneshot combination keys, inspired from DvorakJP (<http://www7.plala.or.jp/dvorakjp/>) + - additional Y key to enter a contracted sound + - diphthong keys (AI, OU, EI) + - syllabic nasal (ANN, ONN, ENN, INN, UNN) + - Additional layer is appeared when you taps any consonant keys, and disappeared when you taps any diphthong keys. + +## for Programmer + +- Dvorak 配列をベースに、ショートカットでよく利用される XCV は QWERTY 配列の位置を維持 +- Vimユーザのために、HJKL キーを横並びで配置 +- デフォルトレイヤーには、数字キーの代わりに記号 `!@#$%^&*()` を配置 + +- mainly based on Dvorak layout, but XCV is available in the same position of QWERTY layout +- HJKL is lining side by side, for Vim users +- we can type `!@#$%^&*()` keys without shift keys in base layer + +## License + +Copyright 2018 Ryo Maeda epaew.333@gmail.com @epaew + +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 +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. diff --git a/users/edvorakjp/rules.mk b/users/edvorakjp/rules.mk new file mode 100644 index 000000000..4fb739186 --- /dev/null +++ b/users/edvorakjp/rules.mk @@ -0,0 +1 @@ +SRC += edvorakjp.c diff --git a/users/ericgebhart/config.h b/users/ericgebhart/config.h new file mode 100755 index 000000000..934c3debb --- /dev/null +++ b/users/ericgebhart/config.h @@ -0,0 +1,33 @@ +#ifndef USERSPACE_CONFIG_H +#define USERSPACE_CONFIG_H + +#include "../../config.h" + +// Sets good default for the speed of the mouse. +#undef MOUSEKEY_INTERVAL +#undef MOUSEKEY_DELAY +#undef MOUSEKEY_TIME_TO_MAX +#undef MOUSEKEY_MAX_SPEED + +#define MOUSEKEY_INTERVAL 20 +#define MOUSEKEY_DELAY 100 +#define MOUSEKEY_TIME_TO_MAX 60 +#define MOUSEKEY_MAX_SPEED 7 + +#undef MOUSEKEY_WHEEL_MAX_SPEED +#undef MOUSEKEY_WHEEL_TIME_TO_MAX +#undef MOUSEKEY_WHEEL_DELAY + +#define MOUSEKEY_WHEEL_MAX_SPEED 5 +#define MOUSEKEY_WHEEL_TIME_TO_MAX 60 +#define MOUSEKEY_WHEEL_DELAY 100 + +#undef TAPPING_TOGGLE +#undef TAPPING_TERM +#undef IGNORE_MOD_TAP_INTERRUPT + +#define TAPPING_TOGGLE 1 +#define TAPPING_TERM 200 +#define IGNORE_MOD_TAP_INTERRUPT + +#endif diff --git a/users/ericgebhart/ericgebhart.c b/users/ericgebhart/ericgebhart.c new file mode 100644 index 000000000..69aa450e0 --- /dev/null +++ b/users/ericgebhart/ericgebhart.c @@ -0,0 +1,637 @@ +/* + Copyright 2018 Eric Gebhart <e.a.gebhart@gmail.com> + + 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 + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ +#include "ericgebhart.h" + +#include "quantum.h" +#include "version.h" +#include "action.h" +#include "action_layer.h" +#include "process_keycode/process_tap_dance.h" +#include "keymap_bepo.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; + +void tap(uint16_t keycode){ register_code(keycode); unregister_code(keycode); }; + + +// 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) {} + +__attribute__ ((weak)) +void matrix_scan_keymap(void) {} + +__attribute__ ((weak)) +bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { + return true; +} + +__attribute__ ((weak)) +bool process_record_secrets(uint16_t keycode, keyrecord_t *record) { + return true; +} + +__attribute__ ((weak)) +uint32_t layer_state_set_keymap (uint32_t state) { + return state; +} + +__attribute__ ((weak)) +void led_set_keymap(uint8_t usb_led) {} + +// Runs just one time when the keyboard initializes. +void matrix_init_user(void) { + //ACTION_DEFAULT_LAYER_SET(DVORAK) ; +} + +// check default layerstate to see which layer we are on. +// if (biton32(layer_state) == _DIABLO) { --- current layer +// if (biton32(default_layer_state) == _DIABLO) { --- current default layer +// check for left shift on. +// if (mods & MOD_BIT(KC_LSFT)) register_code(KC_LSFT); + +static void switch_default_layer(uint8_t layer) { + default_layer_set(1UL<<layer); + clear_keyboard(); +} + +// so the keyboard remembers which layer it's in after power disconnect. +/* + uint32_t default_layer_state_set_kb(uint32_t state) { + eeconfig_update_default_layer(state); + return state; + } +*/ + +// These are the keys for dvorak on bepo. column one is the keycode and mods for +// the unshifted key, the second column is the keycode and mods for the shifted key. +// GR is Good Range. It subtracts SAFE_RANGE from the keycode so we can make a +// reasnably sized array without difficulties. The macro is for the constant declarations +// the function is for when we use it. +const uint8_t key_translations[][2][2] = { + [GR(DB_1)] = {{BP_DQOT, MOD_LSFT}, {BP_DCRC, MOD_LSFT}}, + [GR(DB_2)] = {{BP_LGIL, MOD_LSFT}, {BP_AT, MOD_NONE}}, + [GR(DB_3)] = {{BP_RGIL, MOD_LSFT}, {BP_DLR, MOD_LSFT}}, + [GR(DB_4)] = {{BP_LPRN, MOD_LSFT}, {BP_DLR, MOD_NONE}}, + [GR(DB_5)] = {{BP_RPRN, MOD_LSFT}, {BP_PERC, MOD_NONE}}, + [GR(DB_6)] = {{BP_AT, MOD_LSFT}, {BP_AT, MOD_BIT(KC_RALT)}}, + [GR(DB_7)] = {{BP_PLUS, MOD_LSFT}, {BP_P, MOD_BIT(KC_RALT)}}, + [GR(DB_8)] = {{BP_MINS, MOD_LSFT}, {BP_ASTR, MOD_NONE}}, + [GR(DB_9)] = {{BP_SLASH, MOD_LSFT}, {BP_LPRN, MOD_NONE}}, + [GR(DB_0)] = {{BP_ASTR, MOD_LSFT}, {BP_RPRN, MOD_NONE}}, + [GR(DB_GRV)] = {{BP_PERC, MOD_LSFT}, {BP_K, MOD_BIT(KC_RALT)}}, + [GR(DB_SCOLON)] = {{BP_COMM, MOD_LSFT}, {BP_DOT, MOD_LSFT}}, + [GR(DB_SLASH)] = {{BP_SLASH, MOD_NONE}, {BP_APOS, MOD_LSFT}}, + [GR(DB_BACKSLASH)] = {{BP_AGRV, MOD_BIT(KC_RALT)}, {BP_B, MOD_BIT(KC_RALT)}}, + [GR(DB_EQL)] = {{BP_EQL, MOD_NONE}, {BP_PLUS, MOD_NONE}}, + [GR(DB_COMM)] = {{BP_COMMA, MOD_NONE}, {BP_LGIL, MOD_BIT(KC_RALT)}}, + [GR(DB_DOT)] = {{BP_DOT, MOD_NONE}, {BP_RGIL, MOD_BIT(KC_RALT)}}, + [GR(DB_QUOT)] = {{BP_APOS, MOD_NONE}, {BP_DQOT, MOD_NONE}}, + [GR(DB_MINUS)] = {{BP_MINUS, MOD_NONE}, {KC_SPC, MOD_BIT(KC_RALT)}}, + [GR(DB_LPRN)] = {{BP_LPRN, MOD_NONE}, {BP_LPRN, MOD_BIT(KC_RALT)}}, + [GR(DB_RPRN)] = {{BP_RPRN, MOD_NONE}, {BP_RPRN, MOD_BIT(KC_RALT)}}, + [GR(DB_LBRC)] = {{BP_Y, MOD_BIT(KC_RALT)}, {BP_LPRN, MOD_BIT(KC_RALT)}}, + [GR(DB_RBRC)] = {{BP_X, MOD_BIT(KC_RALT)}, {BP_RPRN, MOD_BIT(KC_RALT)}}, + // For the symbol layer + [GR(DB_HASH)] = {{BP_DLR, MOD_LSFT}, {BP_DLR, MOD_LSFT}}, + [GR(DB_LCBR)] = {{BP_LPRN, MOD_BIT(KC_RALT)}, {BP_LPRN, MOD_BIT(KC_RALT)}}, + [GR(DB_RCBR)] = {{BP_LPRN, MOD_BIT(KC_RALT)}, {BP_RPRN, MOD_BIT(KC_RALT)}}, + [GR(DB_PIPE)] = {{BP_B, MOD_BIT(KC_RALT)}, {BP_B, MOD_BIT(KC_RALT)}}, + [GR(DB_TILD)] = {{BP_K, MOD_BIT(KC_RALT)}, {BP_K, MOD_BIT(KC_RALT)}}, + [GR(DB_CIRC)] = {{BP_AT, MOD_BIT(KC_RALT)}, {BP_AT, MOD_BIT(KC_RALT)}}, + [GR(DB_LESS)] = {{BP_LGIL, MOD_BIT(KC_RALT)}, {BP_LGIL, MOD_BIT(KC_RALT)}}, + [GR(DB_GRTR)] = {{BP_RGIL, MOD_BIT(KC_RALT)}, {BP_RGIL, MOD_BIT(KC_RALT)}}, + + +}; + + +uint8_t gr(uint8_t kc){ + return (kc - SAFE_RANGE); +} +// send the right keycode for the right mod. +// remove the mods we are taking care of, +// send our keycodes then restore them. +// all so we can make dvorak keys from bepo keycodes. +void send_keycode(uint8_t kc){ + uint8_t tmp_mods = get_mods(); + bool is_shifted = ( tmp_mods & (MOD_BIT(KC_LSFT)|MOD_BIT(KC_RSFT)) ); + //uint8_t key[2][2] = key_translations[GR(kc)]; + // need to turn of the shift if it is on. + unregister_mods((MOD_BIT(KC_LSFT)|MOD_BIT(KC_RSFT))); + if(is_shifted){ + register_mods(SHIFTED_MODS(kc)); + register_code(SHIFTED_KEY(kc)); + unregister_code(SHIFTED_KEY(kc)); + unregister_mods(SHIFTED_MODS(kc)); + } else{ + register_mods(UNSHIFTED_MODS(kc)); + register_code(UNSHIFTED_KEY(kc)); + unregister_code(UNSHIFTED_KEY(kc)); + unregister_mods(UNSHIFTED_MODS(kc)); + } + clear_mods(); + register_mods(tmp_mods); +} + + +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 +xprintf("KL: row: %u, column: %u, pressed: %u\n", record->event.key.col, record->event.key.row, record->event.pressed); +#endif //KEYLOGGER_ENABLE + +// still dont know how to make #&_ And RALT is not ALTGR, That isn't working in the bepo keyboard +// either. No {} either probably for the same reasons. ALtGR is the key to some of these. + switch (keycode) { + // Handle the key translations for Dvorak on bepo. It's best if these are the first + // enums after SAFE_RANGE. + case DB_1: + case DB_2: + case DB_3: + case DB_4: + case DB_5: + case DB_6: + case DB_7: + case DB_8: + case DB_9: + case DB_0: + case DB_GRV: + case DB_SCOLON: + case DB_SLASH: + case DB_BACKSLASH: + case DB_EQL: + case DB_DOT: + case DB_COMM: + case DB_QUOT: + case DB_MINUS: + case DB_LPRN: + case DB_RPRN: + case DB_LBRC: + case DB_RBRC: + if(record->event.pressed) + send_keycode(keycode); + unregister_code(keycode); + break; + + case KC_QWERTY: + if (record->event.pressed) { + set_single_persistent_default_layer(QWERTY); + } + return false; + break; + case KC_COLEMAK: + if (record->event.pressed) { + set_single_persistent_default_layer(COLEMAK); + } + return false; + break; + case KC_DVORAK: + if (record->event.pressed) { + set_single_persistent_default_layer(DVORAK); + } + return false; + break; + case KC_WORKMAN: + if (record->event.pressed) { + set_single_persistent_default_layer(WORKMAN); + } + return false; + break; + + case KC_MAKE: // Compiles the firmware, and adds the flash command based on keyboard bootloader + if (!record->event.pressed) { + SEND_STRING("make " QMK_KEYBOARD ":" QMK_KEYMAP +#if (defined(BOOTLOADER_DFU) || defined(BOOTLOADER_LUFA_DFU) || defined(BOOTLOADER_QMK_DFU)) + ":dfu" +#elif defined(BOOTLOADER_HALFKAY) + ":teensy" +#elif defined(BOOTLOADER_CATERINA) + ":avrdude" +#endif // bootloader options + SS_TAP(X_ENTER)); + } + return false; + break; + + + case KC_RESET: // Custom RESET code + if (!record->event.pressed) { + reset_keyboard(); + } + return false; + break; + + + case EPRM: // Resets EEPROM + if (record->event.pressed) { + eeconfig_init(); + default_layer_set(1UL<<eeconfig_read_default_layer()); + layer_state_set(layer_state); + } + return false; + break; + case VRSN: // Prints firmware version + if (record->event.pressed) { + SEND_STRING(QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION ", Built on: " QMK_BUILDDATE); + } + return false; + break; + + /* Code has been depreciated + case KC_SECRET_1 ... KC_SECRET_5: // Secrets! Externally defined strings, not stored in repo + if (!record->event.pressed) { + clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); + send_string(decoy_secret[keycode - KC_SECRET_1]); + } + return false; + break; + */ + + // 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; eeprom_update_byte(EECONFIG_USERSPACE, userspace_config.raw); } + return false; break; +#endif // MACROS_ENABLED + + 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; + eeprom_update_byte(EECONFIG_USERSPACE, userspace_config.raw); +#endif + break; +#ifdef UNICODE_ENABLE + case UC_FLIP: // (╯°□°)╯ ︵ ┻━┻ + if (record->event.pressed) { + register_code(KC_RSFT); + tap(KC_9); + unregister_code(KC_RSFT); + process_unicode((0x256F | QK_UNICODE), record); // Arm + process_unicode((0x00B0 | QK_UNICODE), record); // Eye + process_unicode((0x25A1 | QK_UNICODE), record); // Mouth + process_unicode((0x00B0 | QK_UNICODE), record); // Eye + register_code(KC_RSFT); + tap(KC_0); + unregister_code(KC_RSFT); + process_unicode((0x256F | QK_UNICODE), record); // Arm + tap(KC_SPC); + process_unicode((0x0361 | QK_UNICODE), record); // Flippy + tap(KC_SPC); + process_unicode((0x253B | QK_UNICODE), record); // Table + process_unicode((0x2501 | QK_UNICODE), record); // Table + process_unicode((0x253B | QK_UNICODE), record); // Table + } + return false; + break; +#endif // UNICODE_ENABLE + +} + +return true; + // return process_record_keymap(keycode, record) && process_record_secrets(keycode, record); +} + +void tap_dance_mouse_btns (qk_tap_dance_state_t *state, void *user_data) { + switch(state->count){ + case 1: + register_code(KC_BTN1); + break; + case 2: + register_code(KC_BTN2); + break; + case 3: + register_code(KC_BTN3); + break; + case 4: + register_code(KC_BTN4); + break; + case 5: + register_code(KC_BTN5); + break; + default: + break; + } + reset_tap_dance(state); +} + +// counting on all the qwerty layers to be less than dvorak_on_bepo +int on_qwerty(){ + uint8_t deflayer = (biton32(default_layer_state)); + return (deflayer < DVORAK_ON_BEPO); +} + +void tap_dance_df_bepo_layers_switch (qk_tap_dance_state_t *state, void *user_data) { + switch(state->count){ + case 1: + switch_default_layer(DVORAK_ON_BEPO); + break; + case 2: + switch_default_layer(BEPO); + break; + case 3: + layer_invert(LAYERS); + break; + default: + break; + } + reset_tap_dance(state); +} + +void tap_dance_layer_switch (qk_tap_dance_state_t *state, void *user_data) { + switch(state->count){ + case 1: + if(on_qwerty()) + layer_invert(SYMB); + else + layer_invert(SYMB_ON_BEPO); + break; + case 2: + layer_invert(MDIA); + break; + case 3: + layer_invert(LAYERS); + default: + break; + } + reset_tap_dance(state); +} + +void tap_dance_default_layer_switch (qk_tap_dance_state_t *state, void *user_data) { + switch(state->count){ + case 1: + switch_default_layer(DVORAK); + break; + case 2: + switch_default_layer(DVORAK_ON_BEPO); + break; + case 3: + switch_default_layer(BEPO); + break; + default: + break; + } + reset_tap_dance(state); +} + +// switch the default layer to another qwerty based layer. +void switch_default_layer_on_qwerty(int count) { + switch(count){ + case 1: + switch_default_layer(DVORAK); + break; + case 2: + switch_default_layer(QWERTY); + break; + case 3: + switch_default_layer(COLEMAK); + break; + case 4: + switch_default_layer(WORKMAN); + break; + case 5: + switch_default_layer(NORMAN); + break; + default: + switch_default_layer(DVORAK); + break; + } +} + +// switch the default layer to another bepo based layer. +void switch_default_layer_on_bepo(int count) { + switch(count){ + case 1: + switch_default_layer(DVORAK_ON_BEPO); + break; + case 2: + switch_default_layer(BEPO); + break; + default: + switch_default_layer(DVORAK_ON_BEPO); + break; + } +} + + +// tap to change the default layer. Distinguishes between layers that are based on +// a qwerty software keyboard and a bepo software keyboard. +// if shifted, choose layers based on the other software keyboard, otherwise choose only +// layers that work on the current software keyboard. +void tap_dance_default_os_layer_switch (qk_tap_dance_state_t *state, void *user_data) { + //uint8_t shifted = (get_mods() & MOD_BIT(KC_LSFT|KC_RSFT)); + bool shifted = ( keyboard_report->mods & (MOD_BIT(KC_LSFT)|MOD_BIT(KC_RSFT)) ); + int qwerty = on_qwerty(); + + + // shifted, choose between layers on the other software keyboard + if(shifted){ + if (qwerty) + switch_default_layer_on_bepo(state->count); + else + switch_default_layer_on_qwerty(state->count); + + // not shifted, choose between layers on the same software keyboard + } else { + if (qwerty) + switch_default_layer_on_qwerty(state->count); + else + switch_default_layer_on_bepo(state->count); + } + + reset_tap_dance(state); +} + + +/* Return an integer that corresponds to what kind of tap dance should be executed. + * + * How to figure out tap dance state: interrupted and pressed. + * + * Interrupted: If the state of a dance dance is "interrupted", that means that another key has been hit + * under the tapping term. This is typically indicitive that you are trying to "tap" the key. + * + * Pressed: Whether or not the key is still being pressed. If this value is true, that means the tapping term + * has ended, but the key is still being pressed down. This generally means the key is being "held". + * + * One thing that is currenlty not possible with qmk software in regards to tap dance is to mimic the "permissive hold" + * feature. In general, advanced tap dances do not work well if they are used with commonly typed letters. + * For example "A". Tap dances are best used on non-letter keys that are not hit while typing letters. + * + * Good places to put an advanced tap dance: + * z,q,x,j,k,v,b, any function key, home/end, comma, semi-colon + * + * Criteria for "good placement" of a tap dance key: + * Not a key that is hit frequently in a sentence + * Not a key that is used frequently to double tap, for example 'tab' is often double tapped in a terminal, or + * in a web form. So 'tab' would be a poor choice for a tap dance. + * Letters used in common words as a double. For example 'p' in 'pepper'. If a tap dance function existed on the + * letter 'p', the word 'pepper' would be quite frustating to type. + * + * For the third point, there does exist the 'DOUBLE_SINGLE_TAP', however this is not fully tested + * + */ +int cur_dance (qk_tap_dance_state_t *state) { + if (state->count == 1) { + if (state->interrupted || !state->pressed) return SINGLE_TAP; + //key has not been interrupted, but they key is still held. Means you want to send a 'HOLD'. + else return SINGLE_HOLD; + } + else if (state->count == 2) { + /* + * DOUBLE_SINGLE_TAP is to distinguish between typing "pepper", and actually wanting a double tap + * action when hitting 'pp'. Suggested use case for this return value is when you want to send two + * keystrokes of the key, and not the 'double tap' action/macro. + */ + if (state->interrupted) return DOUBLE_SINGLE_TAP; + else if (state->pressed) return DOUBLE_HOLD; + else return DOUBLE_TAP; + } + //Assumes no one is trying to type the same letter three times (at least not quickly). + //If your tap dance key is 'KC_W', and you want to type "www." quickly - then you will need to add + //an exception here to return a 'TRIPLE_SINGLE_TAP', and define that enum just like 'DOUBLE_SINGLE_TAP' + if (state->count == 3) { + if (state->interrupted || !state->pressed) return TRIPLE_TAP; + else return TRIPLE_HOLD; + } + else return 8; //magic number. At some point this method will expand to work for more presses +} +//instanalize an instance of 'tap' for the 'x' tap dance. +static tdtap xtap_state = { + .is_press_action = true, + .state = 0 +}; +/* + This so I can have a single key that acts like LGUI in DVORAK no + matter which keymap is my current default. + It also allows for the + shift gui and ctl gui, on the same key, So the same key is Escape, + and the mostcommon modifiers in my xmonad control keymap, while also + insuring that dvorak is active for the xmonad command key + Single tap = ESC + tap and hold = dvorak with L_GUI + double tap = One shot dvorak layer with LSFT LGUI mods + double hold = dvorak with LCTL LGUI + double single tap = esc. +*/ +int get_xmonad_layer(){ + int qwerty = on_qwerty(); + + if (qwerty) + return(XMONAD); + else + return(XMONAD_FR); +} + + +void x_finished (qk_tap_dance_state_t *state, void *user_data) { + int xmonad_layer = get_xmonad_layer(); + xtap_state.state = cur_dance(state); + switch (xtap_state.state) { + case SINGLE_TAP: + register_code(KC_ESC); + break; + case SINGLE_HOLD: + layer_on(xmonad_layer); + set_oneshot_mods (MOD_LGUI); + //set_oneshot_layer (DVORAK, ONESHOT_START); + break; + case DOUBLE_TAP: + set_oneshot_mods ((MOD_LCTL | MOD_LGUI)); + layer_on (xmonad_layer); + set_oneshot_layer (xmonad_layer, ONESHOT_START); + break; + case DOUBLE_HOLD: + set_oneshot_mods (MOD_LSFT | MOD_LGUI); + if (xmonad_layer != -1) + layer_on(xmonad_layer); + break; + case DOUBLE_SINGLE_TAP: + register_code(KC_ESC); + unregister_code(KC_ESC); + register_code(KC_ESC); + //Last case is for fast typing. Assuming your key is `f`: + //For example, when typing the word `buffer`, and you want to make sure that you send `ff` and not `Esc`. + //In order to type `ff` when typing fast, the next character will have to be hit within the `TAPPING_TERM`, which by default is 200ms. + } +} + +void x_reset (qk_tap_dance_state_t *state, void *user_data) { + int xmonad_layer = get_xmonad_layer(); + switch (xtap_state.state) { + case SINGLE_TAP: + unregister_code(KC_ESC); + break; + case SINGLE_HOLD: + layer_off(xmonad_layer); + break; + case DOUBLE_TAP: + set_oneshot_layer (xmonad_layer, ONESHOT_PRESSED); + break; + case DOUBLE_HOLD: + layer_off(xmonad_layer); + break; + case DOUBLE_SINGLE_TAP: + unregister_code(KC_ESC); + } + xtap_state.state = 0; +} + +//Tap Dance Definitions +qk_tap_dance_action_t tap_dance_actions[] = { + //Tap once for Esc, twice for Caps Lock + [TD_ESC_CAPS] = ACTION_TAP_DANCE_DOUBLE(KC_ESC, KC_CAPS), + [TD_TAB_BKTAB] = ACTION_TAP_DANCE_DOUBLE(KC_TAB, LSFT(KC_TAB)), + [TD_MDIA_SYMB] = ACTION_TAP_DANCE_FN(tap_dance_layer_switch), + [TD_DVORAK_BEPO] = ACTION_TAP_DANCE_FN(tap_dance_df_bepo_layers_switch), + [TD_DEF_LAYER_SW] = ACTION_TAP_DANCE_FN(tap_dance_default_layer_switch), + [TD_DEF_OS_LAYER_SW] = ACTION_TAP_DANCE_FN(tap_dance_default_os_layer_switch), + [TD_HOME_END] = ACTION_TAP_DANCE_DOUBLE(KC_HOME, KC_END), + [TD_XMONAD_ESC] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, x_finished, x_reset), + [TD_MOUSE_BTNS] = ACTION_TAP_DANCE_FN(tap_dance_mouse_btns) +}; diff --git a/users/ericgebhart/ericgebhart.h b/users/ericgebhart/ericgebhart.h new file mode 100644 index 000000000..6eb11ddfc --- /dev/null +++ b/users/ericgebhart/ericgebhart.h @@ -0,0 +1,429 @@ +/* + Copyright 2018 Eric Gebhart <e.a.gebhart@gmail.com> + + 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 + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ +#include QMK_KEYBOARD_H + +#ifndef ericgebhart +#define ericgebhart + +#include "quantum.h" +#include "process_keycode/process_tap_dance.h" + + +void tap(uint16_t keycode); +bool process_record_secrets(uint16_t keycode, keyrecord_t *record); + + +#define EECONFIG_USERSPACE (uint8_t *)19 + +typedef union { + uint8_t raw; + struct { + bool clicky_enable :1; + bool rgb_layer_change :1; + bool is_overwatch :1; + bool nuke_switch :1; + }; +} userspace_config_t; + +#define ___ KC_TRNS +#define XXX KC_NO + +// The most portable copy/paste keys (windows (mostly), linux, and some terminal emulators). +#define MK_CUT LSFT(KC_DEL) // shift + delete +#define MK_COPY LCTL(KC_INS) // ctrl + insert +#define MK_PASTE LSFT(KC_INS) // shift + insert + + +#define DVORAK 0 // dvorak layout (default) +#define QWERTY 1 +#define COLEMAK 2 +#define WORKMAN 3 +#define NORMAN 4 +// bepo layers +#define DVORAK_ON_BEPO 6 // dvorak layout (default) +#define BEPO 7 // Bepo +// non-default layers +#define SYMB 8 // symbols and numbers +#define SYMB_ON_BEPO 9 // symbols and numbers +#define MDIA 10 // mouse knd media eys +#define LAYERS 11 // layers and right mousekeys. +#define XMONAD 12 // xmonad ie. dvorak. +#define XMONAD_FR 13 // xmonad ie. dvorak. + + +// for the creation of dvorak keys on an Bepo keyboard at the OS layer. + +// so we can create an array of reasonable size +// for our translation keys. We have to create a +// good range of numbers +#define GR(x) (x-SAFE_RANGE) + +uint8_t gr(uint8_t); +void send_keycode(uint8_t); + +#define MOD_NONE 0x00 + +// indexs for the keycode translation table. +#define UNSHIFTED_KEY(key) key_translations[gr(key)][0][0] +#define UNSHIFTED_MODS(key) key_translations[gr(key)][0][1] +#define SHIFTED_KEY(key) key_translations[gr(key)][1][0] +#define SHIFTED_MODS(key) key_translations[gr(key)][1][1] + + +enum userspace_custom_keycodes { + // keep the keycodes using the send_key function close to SAFE_RANGE + // so the array of keycodes remains a reasonbale size. + DB_1 = SAFE_RANGE, // can always be here + DB_2, + DB_3, + DB_4, + DB_5, + DB_6, + DB_7, + DB_8, + DB_9, + DB_0, + DB_GRV, + DB_SCOLON, + DB_SLASH, + DB_BACKSLASH, + DB_EQL, + DB_DOT, + DB_COMM, + DB_QUOT, + DB_MINUS, + DB_RPRN, + DB_LPRN, + DB_RBRC, + DB_LBRC, + // for symbols layer + DB_HASH, + DB_LCBR, + DB_RCBR, + DB_PIPE, + DB_TILD, + DB_CIRC, + DB_LESS, + DB_GRTR, + // End of dvorak on bepo translation keys. + + EPRM, + VRSN, + KC_DVORAK_ON_BEPO, + KC_BEPO, + KC_NORMAN, + KC_QWERTY, + KC_COLEMAK, + KC_DVORAK, + KC_WORKMAN, + KC_MAKE, + KC_RESET, + KC_RGB_T, + KC_SECRET_1, + KC_SECRET_2, + KC_SECRET_3, + KC_SECRET_4, + KC_SECRET_5, + KC_CCCV +}; + +#define SFTGUI_T(kc) { MT(MOD_LGUI | MOD_LSFT, kc) } +#define SFT_GUI_ESC MT(MOD_LSFT | MOD_LGUI, KC_PGDN) // shift LGUI or Escape. +#define ALT_ENT ALT_T(KC_ENT) // Alt or enter +#define CTL_SPC CTL_T(KC_SPC) // ctrl or space +#define CTL_BSPC CTL_T(KC_BSPC) // ctrl or backspace +#define ALT_DEL ALT_T(KC_DEL) // Alt or delete +#define GUI_ESC GUI_T(KC_ESC) // Gui or escape +#define ALGR_SYMB ALGR_T(TG(SYMB)) // Alt gre or toggle symbol layer + +#define KC_SFT_T_U SFT_T(KC_U) +#define KC_SFT_T_H SFT_T(KC_H) +#define KC_LT_SYMB_I LT(SYMB, KC_I) +#define KC_LT_SYMB_D LT(SYMB, KC_D) + +// for dvorak on bepo +#define BP_SFT_T_U SFT_T(BP_U) +#define BP_SFT_T_H SFT_T(BP_H) +#define BP_LT_SYMB_D LT(SYMB, BP_D) + + +// for bepo on bepo +#define BP_SFT_T_T SFT_T(BP_T) +#define BP_LT_SYMB_C LT(SYMB_ON_BEPO, BP_C) +#define BP_LT_SYMB_I LT(SYMB_ON_BEPO, BP_I) +#define BP_SFT_T_E SFT_T(BP_E) +#define BP_SFT_T_ECRC SFT_T(BP_ECRC) +#define BP_SFT_T_CCED SFT_T(BP_CCED) +#define BP_LT_SYMB_COMM LT(SYMB,BP_COMM) + +// OSM keycodes, to keep things clean and easy to change +#define KC_MLSF OSM(MOD_LSFT) +#define KC_MRSF OSM(MOD_RSFT) +#define OS_LGUI OSM(MOD_LGUI) +#define OS_RGUI OSM(MOD_RGUI) +#define OS_LSFT OSM(MOD_LSFT) +#define OS_RSFT OSM(MOD_RSFT) +#define OS_LCTL OSM(MOD_LCTL) +#define OS_RCTL OSM(MOD_RCTL) +#define OS_LALT OSM(MOD_LALT) +#define OS_RALT OSM(MOD_RALT) +#define ALT_APP ALT_T(KC_APP) + +#define MG_NKRO MAGIC_TOGGLE_NKRO + + +//// TAP DANCE + +typedef struct { + bool is_press_action; + int state; +} tdtap; + +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 + }; + + //Tap Dance Declarations + enum { + TD_ESC_CAPS = 0, + TD_TAB_BKTAB = 1, + TD_MDIA_SYMB = 2, + TD_HOME_END = 3, + TD_XMONAD_ESC = 4, + TD_DEF_LAYER_SW = 5, + TD_DEF_OS_LAYER_SW = 6, + TD_MOUSE_BTNS = 7, + TD_DVORAK_BEPO = 8 + }; + + +// Tap dance +#define TAB_BKTAB TD(TD_TAB_BKTAB) // Tab or backtab tapdance. +#define MDIA_SYMB TD(TD_MDIA_SYMB) // MDIA or Symb layer tapdance toggle. +#define DEF_LAYER_SW TD(TD_DEF_LAYER_SW) // dvorak, dvorak_on_bepo, bepo default layer +#define DEF_OS_LAYER_SW TD(TD_DEF_OS_LAYER_SW) // dvorak, dvorak_on_bepo, bepo default layer +#define HOME_END TD(TD_HOME_END) // home or end tapdance. +#define XMONAD_ESC TD(TD_XMONAD_ESC) // Escape, dvorak, media or symb. - tap and hold tap dance. 1-4 +#define DVORAK_ET_BEPO TD(TD_DVORAK_BEPO) // Escape, dvorak, media or symb. - tap and hold tap dance. 1-4 +#define TDMOUSE_BTNS TD(TD_MOUSE_BTNS) // hmmm. 1-5 + + +int on_qwerty(void); +int get_xmonad_layer(void); +int cur_dance (qk_tap_dance_state_t *state); + +//for the x tap dance. Put it here so it can be used in any keymap +void x_finished (qk_tap_dance_state_t *state, void *user_data); +void x_reset (qk_tap_dance_state_t *state, void *user_data); + + +// Blocks for each of the four major keyboard layouts +// Organized so we can quickly adapt and modify all of them +// at once, rather than for each keyboard, one at a time. +// And this allows for much cleaner blocks in the keymaps. +// For instance Tap/Hold for Control on all of the layouts + +// NOTE: These are all the same length. If you do a search/replace +// then you need to add/remove underscores to keep the +// lengths consistent. + +// Since our quirky block definitions are basically a list of comma separated +// 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 +#endif + +#define LAYOUT_ergodox_wrapper(...) LAYOUT_ergodox(__VA_ARGS__) +#define LAYOUT_ergodox_pretty_wrapper(...) LAYOUT_ergodox_pretty(__VA_ARGS__) +#define KEYMAP_wrapper(...) LAYOUT(__VA_ARGS__) +#define LAYOUT_wrapper(...) LAYOUT(__VA_ARGS__) + +//Dvorak on a qwerty software layer in the OS +#define ___DVORAK_L1___ KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y +#define ___DVORAK_L2___ KC_A, KC_O, KC_E, KC_SFT_T_U, KC_LT_SYMB_I +#define ___DVORAK_L3___ KC_SCLN, KC_Q, KC_J, KC_K, KC_X + +#define ___DVORAK_R1___ KC_F, KC_G, KC_C, KC_R, KC_L +#define ___DVORAK_R2___ KC_LT_SYMB_D, KC_SFT_T_H, KC_T, KC_N, KC_S +#define ___DVORAK_R3___ KC_B, KC_M, KC_W, KC_V, KC_Z + + +// Dvorak on fr-bepo software layer in the OS. +// for dvorak and all the other qwerty like keyboards on bepo +#define ___NUMBER_BEPO_L___ DB_1, DB_2, DB_3, DB_4, DB_5 +#define ___NUMBER_BEPO_R___ DB_6, DB_7, DB_8, DB_9, DB_0 + +#define ___DVORAK_FR_L1___ DB_QUOT, DB_COMM, DB_DOT, BP_P, BP_Y +#define ___DVORAK_FR_L2___ BP_A, BP_O, BP_E, BP_SFT_T_U, BP_LT_SYMB_I +#define ___DVORAK_FR_L3___ DB_SCOLON, BP_Q, BP_J, BP_K, BP_X + +#define ___DVORAK_FR_R1___ BP_F, BP_G, BP_C, BP_R, BP_L +#define ___DVORAK_FR_R2___ BP_LT_SYMB_D, BP_SFT_T_H, BP_T, BP_N, BP_S +#define ___DVORAK_FR_R3___ BP_B, BP_M, BP_W, BP_V, BP_Z + + +// Bepo on fr-bepo software layer +// for bepo on bepo +#define ___SYMBOL_BEPO_L___ /* BP_DLR */ BP_DQOT, BP_LGIL, BP_RGIL, BP_LPRN, BP_RPRN +#define ___SYMBOL_BEPO_R___ BP_AT, BP_PLUS, BP_MINS, BP_SLASH, BP_ASTR /* BP_EQL, BP_PERC */ + +#define ___BEPO_FR_L1___ BP_B, BP_ECUT, BP_P, BP_O, BP_EGRV +#define ___BEPO_FR_L2___ BP_A, BP_U, BP_I, BP_SFT_T_E, BP_LT_SYMB_COMM +#define ___BEPO_FR_L3___ /*BP_ECRC*/ BP_AGRV, BP_Y, BP_X, BP_DOT, BP_K + +#define ___BEPO_FR_R1___ /* BP_DCRC*/ BP_V, BP_D, BP_L, BP_J, BP_Z //, BP_W +#define ___BEPO_FR_R2___ /* BP_C */ BP_SFT_T_T, BP_S, BP_R, BP_N, BP_M //BP_CCED +#define ___BEPO_FR_R3___ BP_APOS, BP_Q, BP_G, BP_H, BP_F + +// the bottom rows for keyboards on bepo. +#define ___ERGODOX_BOTTOM_RIGHT_FR___ KC_UP, KC_DOWN, DB_BACKSLASH, LCTL(BP_V), LCTL(BP_C) +#define ___ERGODOX_BOTTOM_LEFT_FR___ LCTL(BP_C), LCTL(BP_V), KC_INS, KC_LEFT, KC_RIGHT + +// Since we have 7 default layouts (QWERTY, DVORAK, COLEMAK and WORKMAN, NORMAN, +// 2 of them based on a Bepo software keyboard, --- DVORAK_ON_BEPO and BEPO), +// this allows us to quickly modify the bottom row for all of the layouts +// so we don't have to alter it 4 times and hope that we haven't missed +// anything +#define ___ERGODOX_BOTTOM_LEFT___ LCTL(KC_C), LCTL(KC_V), KC_INS, KC_LEFT, KC_RIGHT +#define ___ERGODOX_BOTTOM_RIGHT___ KC_UP, KC_DOWN, KC_BSLASH, LCTL(KC_V), LCTL(KC_C) + +#define ___ERGODOX_THUMB_LEFT___ \ + KC_RALT, ALGR_SYMB, \ + HOME_END, \ + CTL_BSPC, ALT_DEL, XMONAD_ESC + +#define ___ERGODOX_THUMB_RIGHT___ \ + ALGR_SYMB, TD_MOUSE_BTNS, \ + KC_PGUP, \ + KC_PGDN, ALT_ENT, CTL_SPC + +#define ___ERGODOX_TRANS_THUMBS___ \ + ___, ___, \ + ___, \ + ___, ___, ___ \ + +#define ___ERGODOX_TRANS_BOTTOM___ \ + ___,___,___,___,___ + +#define ___ERGODOX_TRANS_6_ROW___ \ + ___,___,___,___,___,___ + + + +// Qwerty based layers that I don't really use. +#define ___QWERTY_L1___ KC_Q, KC_W, KC_E, KC_R, KC_T +#define ___QWERTY_L2___ KC_A, KC_S, KC_D, KC_F, KC_G +#define ___QWERTY_L3___ KC_Z, KC_X, KC_C, KC_V, KC_B + +#define ___QWERTY_R1___ KC_Y, KC_U, KC_I, KC_O, KC_P +#define ___QWERTY_R2___ KC_H, KC_J, KC_K, KC_L, KC_SCLN +#define ___QWERTY_R3___ KC_N, KC_M, KC_COMM, KC_DOT, KC_SLASH + + +#define ___COLEMAK_L1___ KC_Q, KC_W, KC_F, KC_P, KC_G +#define ___COLEMAK_L2___ KC_A, KC_R, KC_S, KC_T, KC_D +#define ___COLEMAK_L3___ KC_Z, KC_X, KC_C, KC_V, KC_B + +#define ___COLEMAK_R1___ KC_J, KC_L, KC_U, KC_Y, KC_SCLN +#define ___COLEMAK_R2___ KC_H, KC_N, KC_E, KC_I, KC_O +#define ___COLEMAK_R3___ KC_K, KC_M, KC_COMM, KC_DOT, KC_SLASH + + +#define ___COLEMAK_MOD_DH_L1___ KC_Q, KC_W, KC_F, KC_P, KC_B +#define ___COLEMAK_MOD_DH_L2___ KC_A, KC_R, KC_S, KC_T, KC_G +#define ___COLEMAK_MOD_DH_L3___ CTL_T(KC_Z), KC_X, KC_C, KC_D, KC_V + +#define ___COLEMAK_MOD_DH_R1___ KC_J, KC_L, KC_U, KC_Y, KC_SCLN +#define ___COLEMAK_MOD_DH_R2___ KC_M, KC_N, KC_E, KC_I, KC_O +#define ___COLEMAK_MOD_DH_R3___ KC_K, KC_H, KC_COMM, KC_DOT, KC_SLASH + + +#define ___WORKMAN_L1___ KC_Q, KC_D, KC_R, KC_W, KC_B +#define ___WORKMAN_L2___ KC_A, KC_S, KC_H, KC_T, KC_G +#define ___WORKMAN_L3___ KC_Z, KC_X, KC_M, KC_C, KC_V + +#define ___WORKMAN_R1___ KC_J, KC_F, KC_U, KC_P, KC_SCLN +#define ___WORKMAN_R2___ KC_Y, KC_N, KC_E, KC_O, KC_I +#define ___WORKMAN_R3___ KC_K, KC_L, KC_COMM, KC_DOT, KC_SLASH + + +#define ___NORMAN_L1___ KC_Q, KC_W, KC_D, KC_F, KC_K +#define ___NORMAN_L2___ KC_A, KC_S, KC_E, KC_T, KC_G +#define ___NORMAN_L3___ KC_Z, KC_X, KC_C, KC_V, KC_B + +#define ___NORMAN_R1___ KC_J, KC_U, KC_R, KC_L, KC_SCLN +#define ___NORMAN_R2___ KC_Y, KC_N, KC_I, KC_O, KC_U +#define ___NORMAN_R3___ KC_P, KC_M, KC_COMM, KC_DOT, KC_SLASH + + +// For the top rows. Numbers for most things, symbols for Bepo. + +// for everything on qwerty. +#define ___NUMBER_L___ KC_1, KC_2, KC_3, KC_4, KC_5 +#define ___NUMBER_R___ KC_6, KC_7, KC_8, KC_9, KC_0 + +// function key rows, works for everyone. +#define ___FUNC_L___ KC_F1, KC_F2, KC_F3, KC_F4, KC_F5 +#define ___FUNC_R___ KC_F6, KC_F7, KC_F8, KC_F9, KC_F10 + + +// Rows for the auxillary layers. + +// The symbol layer is for qwerty. I need another one for Bepo... + +// the KC_P? codes don't work for me. I don't use those shifted values anyway. +#define ___KEYPAD_1___ KC_7, KC_8, KC_9, KC_PSLS +#define ___KEYPAD_2___ KC_4, KC_5, KC_6, KC_PAST +#define ___KEYPAD_3___ KC_1, KC_2, KC_3, KC_PMNS +#define ___KEYPAD_4___ KC_0, KC_DOT, KC_PEQL, KC_PPLS + +#define ___KEYPAD_1_BP___ DB_7, DB_8, DB_9, BP_SLASH +#define ___KEYPAD_2_BP___ DB_4, DB_5, DB_6, BP_ASTR +#define ___KEYPAD_3_BP___ DB_1, DB_2, DB_3, DB_MINUS +#define ___KEYPAD_4_BP___ DB_0, DB_DOT, DB_EQL, BP_PLUS + +#define ___SYMBOLS_1___ KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_PIPE +#define ___SYMBOLS_2___ KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_GRV +#define ___SYMBOLS_3___ KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD + +#define ___SYMBOLS_1_BP___ KC_EXLM, BP_AT, DB_LCBR, DB_RCBR, DB_PIPE +#define ___SYMBOLS_2_BP___ DB_HASH, BP_DLR, DB_LPRN, DB_RPRN, DB_GRV +#define ___SYMBOLS_3_BP___ BP_PERC, DB_CIRC, DB_LBRC, DB_RBRC, DB_TILD + +#define ___MOUSE_LDUR___ KC_MS_L, KC_MS_D, KC_MS_U, KC_MS_R +#define ___MWHEEL_LDUR___ KC_WH_L, KC_WH_D, KC_WH_U, KC_WH_R +#define ___MOUSE_BTNS_R___ KC_BTN1, KC_BTN2, KC_BTN3, KC_BTN4, KC_BTN5 +#define ___MOUSE_BTNS_L___ KC_BTN5, KC_BTN4, KC_BTN3, KC_BTN2, KC_BTN1 +#define ___MOUSE_ACCL_012___ KC_ACL0, KC_ACL1, KC_ACL2 + +#define ___MUTE_PLAY_STOP___ KC_MUTE, KC_MPLY, KC_MSTP +#define ___VI_ARROWS___ KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT + +#define ___LAYERS_L1___ DF(BEPO), DF(DVORAK_ON_BEPO) +#define ___LAYERS_L2___ DF(COLEMAK), DF(DVORAK) +#define ___LAYERS_L3___ DF(QWERTY), DF(NORMAN), DF(WORKMAN) +#define ___LAYERS_L4___ TO(MDIA), TO(SYMB_ON_BEPO), TO(SYMB) + + +#endif diff --git a/users/ericgebhart/flash-ergodox b/users/ericgebhart/flash-ergodox new file mode 100755 index 000000000..945b2b605 --- /dev/null +++ b/users/ericgebhart/flash-ergodox @@ -0,0 +1 @@ +teensy-loader-cli -mmcu=atmega32u4 -w $1 diff --git a/users/ericgebhart/readme.md b/users/ericgebhart/readme.md new file mode 100644 index 000000000..cd57735c2 --- /dev/null +++ b/users/ericgebhart/readme.md @@ -0,0 +1,124 @@ +Overview +======== + +This is my personal userspace. Most of my code exists here. I only have one keymap, and that +is for an ergodox_ez. There are a lot of layers, 7 of them are default layers. I primarily use +dvorak and Bepo. I've been using emacs in vi mode for over 23 years. I also us Xmonad as my +window manager, additionally I've been using a Kinesis advantage keyboard in dvorak for over 20 +years. All of those things tend to color the layouts I have. + +The Bepo layer needs some love. It is true to the layout at Bepo.fr, but I find it a little +cumbersome, and I miss some of my favorite keys. + +There are 2 dvorak layers, one for a qwerty OS keyboard, and one for a Bepo OS keyboard. +There is a symbol/keypad layer for bepo and qwerty. And of course there is a mouse/media layer. +There are 2 Xmonad layers one for qwerty and one for Bepo. Layer selection happens automatically +based on your current default layer. I use 2 tap dance keys for layer selection. + +There are also Qwerty, Colemak, Workman and Norman layers for qwerty. + + +Keyboard Layout Templates +------------------------- + +I borrowed the idea for the keyboard defines and some of the definitions from @drashna. +I think it is an awesome idea, It makes consistency between layout definitions so much easier. +@drashna had this to say about it. + + +This borrows from @jola5's "Not quite neo" code. This allows me to maintain blocks of keymaps in the userspace, so that I can modify the userspace, and this is reflected in all of the keyboards that use it, at once. + +This makes adding tap/hold mods, or other special keycodes or functions to all keyboards super easy, as it's done to all of them at once. + +The caveat here is that the keymap needs a processor/wrapper, as it doesn't like the substitutions. However, this is as simple as just pushing it through a define. For instance: + +`#define LAYOUT_ergodox_wrapper(...) LAYOUT_ergodox(__VA_ARGS__)` + +Once that's been done and you've switched the keymaps to use the "wrapper", it will read the substitution blocks just fine. + +Credit goes to @jola5 for first implementing this awesome idea. + + +Custom Keycodes +--------------- + +Keycodes are defined in the ericgebhart.h file and need to be included in the keymap.c files, so that they can be used there. The keymap.c file has very little in it, the most important thing to see there are the keys that are at the ends of each row, ie. the 1st and last key on each row is defined there. +Everything else is in ericgebhart.h. + +Layer Indication +---------------- + +The ergodox_ez only has 3 leds, layer indication is pretty lame. +Currently the first led lights up if the default layer is not qwerty. The symbol and media layers get +the other 2 leds, and all the leds light up if you are on the "layers" layer. +I hope I can figure out how to make it better, but I just don't see a way with 3 leds and 11 layers. + + +BEPO vs Qwerty Layers +--------------------- + +There are 7 base layers. Dvorak, qwerty, Colemak, Workman, and Norman work on a Qwerty software layer on the OS. Dvorak_on_bepo and Bepo both work on a Bepo software layer on the os. +Dvorak on qwerty is the default. There is a function in ericgebhart.c which will allow the keyboard +to persist it's default layer through power down. It is currently commented out. + +I don't actually use Qwerty, but it seemed like I should have it, +@drashna had it along with Colemak, Workman and Norman so I added them +to my existing dvorak and bepo definitions. + +There are two tap dance functions that allow switching the default layers +and the overlay layers. + +The default layers switch according to the current OS keyboard of the current Default layer. +Shifting the key, causes the selection to use the other OS keyboard selections. ie, +if you are on qwerty, you get dvorak, qwerty, colemak, workman and norman. If you shift it you get +dvorak on bepo and bepo. If you are not on qwerty the unshifted taps get dvorak and bepo on bepo. + +The other tap dance for layers is for the symbol, mouse and layers layers. The layers layer is just a +safety layer, knowing I can get to if I screw something up... + +XMonad +--------------------- + +Additionally there is an advanced tap dance called XMONAD_ESC. One tap is Escape, tap and hold is +LGUI with the proper XMONAD layer, it is essentially dvorak, for the +given OS layer. 2 taps is Shift lgui with xmonad, and 2 taps and hold +is Control LGUI with Xmonad. This allows for the finger patterns for +Xmonad to remain the same regarless of the keyboard in use. The hold +versions allow for secondary menu selection in Xmonad, the 2 tap function +must be for a key that is in the top level keymap of Xmonad. This is how +many people use xmonad so it's not a real problem. There are plenty of +keys combinations to choose from with these choices. The function can +be expanded to 3 taps and 3 tap and hold, and on and on.... + +I have a few other special keys, for momentary symbols or shift on the home row of each hand. + +Also, after using a kinesis for many years I'm very accustomed to the +space, enter, backspace and delete keys on the thumbs. I've added control +and alt as a secondary function. These are also the Control and Alt keys +if held down. + +Tap Dance +-------------------- + +Additionally there are other tap dance functions, tab-backtab, home-end as well as I few I'm not actually using. + +Building and flashing +----------------------- + +```make ergodox_z:ericgebhart``` will compile the code. + +I use the teensy-loader cli so that's all I know. There is a script here called flash_ergodox + +Use it like this, + +```flash-ergodox <path to your hex file>``` + +then use a paperclip to push the reset button on your keyboard. + +Switching the OS keyboard +------------------------- + +This varies from system to system. I use Arch Linux, so I use ```setxkbmap```. +I've included a helper script which makes it easy to switch between EN and FR Bepo, +called switch-kbd. + diff --git a/users/ericgebhart/rules.mk b/users/ericgebhart/rules.mk new file mode 100755 index 000000000..2572d2111 --- /dev/null +++ b/users/ericgebhart/rules.mk @@ -0,0 +1,18 @@ +USER_NAME := ericgebhart +SRC += ericgebhart.c + +MOUSEKEY_ENABLE = yes # Mouse keys +EXTRAKEY_ENABLE = yes # Audio control and System control +COMMAND_ENABLE = yes # Commands for debug and configuration +NKRO_ENABLE = yes # USB Nkey Rollover - for issues, see github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +SWAP_HANDS_ENABLE= yes # Allow swapping hands of keyboard +KEY_LOCK_ENABLE = yes # Enable the KC_LOCK key +TAP_DANCE_ENABLE = yes # Enable the tap dance feature. +CONSOLE_ENABLE = yes # Console for debug + +BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration +UNICODE_ENABLE = no +SLEEP_LED_ENABLE = no +API_SYSEX_ENABLE = no +RGBLIGHT_ENABLE = no +RGBLIGHT_ANIMATION = no diff --git a/users/ericgebhart/switch-kbd b/users/ericgebhart/switch-kbd new file mode 100755 index 000000000..4401967a0 --- /dev/null +++ b/users/ericgebhart/switch-kbd @@ -0,0 +1,74 @@ +#!/usr/bin/env zsh + +# Switch the keyboard to en-us by default, bepo, or en-dvorak. + +help(){ + print 'switch-kbd - helper for setxkbmap' + print ' ' + print 'Change the keyboard to en-us, fr-bepo, or en-dvorak.' + print 'Uses setxkbmap, so the change only affects the current' + print 'session. This mainly to avoid using a toggle key.' + print ' ' + print ' -b Bepo' + print ' -d Dvorak' + print ' -n do not execute' + print ' -h help text.' + print ' ' + print ' The default is to set the keyboard to en-us.' + exit +} + +layout="-layout us" +variant="" +let "execute = 1" +let "verose = 0" + +# $opt will hold the current option +local opt +while getopts bdnvh opt; do + # loop continues till options finished + # see which pattern $opt matches... + case $opt in + (b) + layout="-layout fr" + variant="-variant bepo" + ;; + + (d) + layout="-layout en" + variant="-variant dvorak" + ;; + (n) + let "execute = 0" + ;; + (v) + let "verbose = 1" + ;; + (h) + help + ;; + # matches a question mark + # (and nothing else, see text) + (\?) + print "Bad option:" $* + print " " + help + return 1 + ;; + esac +done +(( OPTIND > 1 )) && shift $(( OPTIND - 1 )) +##print Remaining arguments are: $* + +mycommand='setxkbmap '${layout}' '${variant} + +if [[ ( $verbose -ne 0 ) ]]; then; + print "setxkbmap Command:" $mycommand +fi + +if [[ ( $execute -ne 0 ) ]] +then; + eval $mycommand +else; + print "did not execute" +fi diff --git a/users/gordon/gordon.c b/users/gordon/gordon.c index 056012a21..3115e1c32 100644 --- a/users/gordon/gordon.c +++ b/users/gordon/gordon.c @@ -15,20 +15,17 @@ const char secret[][64] = { }; #endif - - - void register_hyper (void) { //Helper function to invoke Hyper register_code (KC_LSFT); - register_code (KC_LCTL); - register_code (KC_LALT); - register_code (KC_LGUI); + register_code (KC_LCTL); + register_code (KC_LALT); + register_code (KC_LGUI); } void unregister_hyper (void) { //Helper function to invoke Hyper unregister_code (KC_LSFT); - unregister_code (KC_LCTL); - unregister_code (KC_LALT); - unregister_code (KC_LGUI); + unregister_code (KC_LCTL); + unregister_code (KC_LALT); + unregister_code (KC_LGUI); } void register_ctrl_a (void) { @@ -41,55 +38,55 @@ void unregister_ctrl_a (void) { unregister_code(KC_A); } -void register_alt_f7 (void) { - register_code (KC_LALT); +void register_alt_f7 (void) { + register_code (KC_LALT); register_code (KC_F7); } -void unregister_alt_f7 (void) { - unregister_code (KC_LALT); +void unregister_alt_f7 (void) { + unregister_code (KC_LALT); unregister_code (KC_F7); } -void register_shift_f6 (void) { - register_code (KC_LSFT); +void register_shift_f6 (void) { + register_code (KC_LSFT); register_code (KC_F6); } -void unregister_shift_f6 (void) { - unregister_code (KC_LSFT); +void unregister_shift_f6 (void) { + unregister_code (KC_LSFT); unregister_code (KC_F6); } -void register_ctrl_shift (void) { - register_code (KC_LSFT); +void register_ctrl_shift (void) { + register_code (KC_LSFT); register_code (KC_LCTRL); } -void unregister_ctrl_shift (void) { - unregister_code (KC_LSFT); +void unregister_ctrl_shift (void) { + unregister_code (KC_LSFT); unregister_code (KC_LCTRL); } -void register_alt_shift (void) { - register_code (KC_LSFT); +void register_alt_shift (void) { + register_code (KC_LSFT); register_code (KC_LALT); } -void unregister_alt_shift (void) { - unregister_code (KC_LSFT); +void unregister_alt_shift (void) { + unregister_code (KC_LSFT); unregister_code (KC_LALT); } -// To activate SINGLE_HOLD, you will need to hold for 200ms first. +// To activate SINGLE_HOLD, you will need to hold for 200ms first. // This tap dance favors keys that are used frequently in typing like 'f' 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; + // if (!state->pressed) return SINGLE_TAP; //need "permissive hold" here. - // else return SINsGLE_HOLD; + // else return SINsGLE_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???? @@ -105,8 +102,8 @@ int cur_dance (qk_tap_dance_state_t *state) { else if (state->count == 2) { if (state->interrupted) return DOUBLE_SINGLE_TAP; else if (state->pressed) return DOUBLE_HOLD; - else return DOUBLE_TAP; - } + 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 8; //magic number. At some point this method will expand to work for more presses @@ -116,8 +113,8 @@ int cur_dance (qk_tap_dance_state_t *state) { 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; + if (!state->pressed) return SINGLE_TAP; + else return SINGLE_HOLD; } else { if (!state->pressed) return SINGLE_TAP; @@ -128,8 +125,8 @@ int hold_cur_dance (qk_tap_dance_state_t *state) { //with single tap. else if (state->count == 2) { if (state->pressed) return DOUBLE_HOLD; - else return DOUBLE_TAP; - } + else return DOUBLE_TAP; + } else if (state->count == 3) { if (!state->pressed) return TRIPLE_TAP; else return TRIPLE_HOLD; @@ -138,7 +135,7 @@ int hold_cur_dance (qk_tap_dance_state_t *state) { } -static xtap htap_state = { +static xtap htap_state = { .is_press_action = true, .state = 0 }; @@ -168,7 +165,7 @@ void h_reset (qk_tap_dance_state_t *state, void *user_data) { /**************** QUAD FUNCTION FOR TAB ****************/ // TAB, ALT + SHIFT, TAB TAB, CTRL + SHIFT -static xtap tab_state = { +static xtap tab_state = { .is_press_action = true, .state = 0 }; @@ -183,7 +180,7 @@ void tab_finished (qk_tap_dance_state_t *state, void *user_data) { case TRIPLE_TAP: register_code(KC_LSHIFT) ;register_code(KC_ESC); break; case TRIPLE_HOLD: register_code(KC_LSHIFT); register_code(KC_LGUI); break; } -} +} void tab_reset (qk_tap_dance_state_t *state, void *user_data) { switch (tab_state.state) { @@ -201,7 +198,7 @@ void tab_reset (qk_tap_dance_state_t *state, void *user_data) { //*************** SUPER COMMA *******************// // Assumption: we don't care about trying to hit ,, quickly //*************** SUPER COMMA *******************// -static xtap comma_state = { +static xtap comma_state = { .is_press_action = true, .state = 0 }; @@ -209,19 +206,19 @@ static xtap comma_state = { void comma_finished (qk_tap_dance_state_t *state, void *user_data) { comma_state.state = hold_cur_dance(state); //Use the dance that favors being held switch (comma_state.state) { - case SINGLE_TAP: register_code(KC_COMMA); break; + case SINGLE_TAP: register_code(KC_COMMA); break; case SINGLE_HOLD: layer_on(1); break; //turn on symbols layer case DOUBLE_TAP: layer_invert(4); break; //toggle numbers layer case DOUBLE_HOLD: layer_on(2); break; case TRIPLE_TAP: register_code(KC_CALCULATOR); break; case TRIPLE_HOLD: layer_on(3); } -} +} void comma_reset (qk_tap_dance_state_t *state, void *user_data) { switch (comma_state.state) { case SINGLE_TAP: unregister_code(KC_COMMA); break; //unregister comma - case SINGLE_HOLD: layer_off(1); break; + case SINGLE_HOLD: layer_off(1); break; case DOUBLE_TAP: ;break; case DOUBLE_HOLD: layer_off(2); break; case TRIPLE_TAP: unregister_code(KC_CALCULATOR); break; @@ -235,7 +232,7 @@ void comma_reset (qk_tap_dance_state_t *state, void *user_data) { //*************** F3 TAP DANCE *******************// //Good example for accessing multiple layers from the same key. -static xtap S1_state = { +static xtap S1_state = { .is_press_action = true, .state = 0 }; @@ -244,17 +241,17 @@ void bt_finished (qk_tap_dance_state_t *state, void *user_data) { S1_state.state = cur_dance(state); switch (S1_state.state) { case SINGLE_TAP: register_code(KC_F3); break; - case SINGLE_HOLD: layer_on(4); break; - case DOUBLE_TAP: layer_invert(4); break; + case SINGLE_HOLD: layer_on(_MACROS); break; + case DOUBLE_TAP: layer_invert(_MACROS); break; case DOUBLE_HOLD: layer_on(5); break; - case DOUBLE_SINGLE_TAP: layer_invert(4); break; + case DOUBLE_SINGLE_TAP: layer_invert(_MACROS); break; } } void bt_reset (qk_tap_dance_state_t *state, void *user_data) { switch (S1_state.state) { case SINGLE_TAP: unregister_code(KC_F3); break; - case SINGLE_HOLD: layer_off(4); break; + case SINGLE_HOLD: layer_off(_MACROS); break; case DOUBLE_TAP: break; //already inverted. Don't do anything. case DOUBLE_HOLD: layer_off(5); break; case DOUBLE_SINGLE_TAP: break; @@ -262,14 +259,152 @@ void bt_reset (qk_tap_dance_state_t *state, void *user_data) { S1_state.state = 0; } +// Tap Dance Definitions +qk_tap_dance_action_t tap_dance_actions[] = { + // simple tap dance + [F12ETAPS] = ACTION_TAP_DANCE_DOUBLE(KC_F12,LSFT(LCTL(KC_F10))), + [REFRESH] = ACTION_TAP_DANCE_DOUBLE(KC_R,LCTL(KC_R)), + [ENDESC] = ACTION_TAP_DANCE_DOUBLE(KC_END, KC_ESC), + [Q_ESCAPE] = ACTION_TAP_DANCE_DOUBLE(KC_Q, KC_ESC), + [ENDHOME] = ACTION_TAP_DANCE_DOUBLE(KC_END, KC_HOME), + [CALCCOMP] = ACTION_TAP_DANCE_DOUBLE(KC_CALCULATOR, KC_MY_COMPUTER), + [ALTF4] = ACTION_TAP_DANCE_DOUBLE(KC_F4,LALT(KC_F4)), + [F6F7] = ACTION_TAP_DANCE_DOUBLE(LSFT(KC_F6), LALT(KC_F7)), + [F1F13] = ACTION_TAP_DANCE_DOUBLE(KC_F1, KC_F13), + [F2F14] = ACTION_TAP_DANCE_DOUBLE(KC_F2, KC_F14), + [F5F15] = ACTION_TAP_DANCE_DOUBLE(KC_F5, KC_F15), + [TABCOMBO] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, tab_finished, tab_reset), + [F3D] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, bt_finished, bt_reset), + [COMMA] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, comma_finished, comma_reset), + [HTAB] = ACTION_TAP_DANCE_FN_ADVANCED(NULL,h_finished, h_reset) +}; + +// bool process_record_user(uint16_t keycode, keyrecord_t *record) { +// if (!record->event.pressed) { +// switch (keycode) { + +// case KC_SECRET_1 ... KC_SECRET_5: +// send_string(secret[keycode - KC_SECRET_1]); +// // clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); +// return true; break; + +// case UP_ENTER_RESET: +// register_code(KC_UP); +// unregister_code(KC_UP); +// register_code(KC_ENTER); +// unregister_code(KC_ENTER); +// reset_keyboard(); +// return false; break; + +// case TIL_SLASH: +// SEND_STRING ("~/."); +// return false; break; + +// case DBMS_OUT: +// SEND_STRING ("dbms_output.put_line('');"); +// SEND_STRING (SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT)); +// return false; break; + +// case ID_MAN_IP: +// SEND_STRING ("http://dev-1967110238.us-east-1.elb.amazonaws.com"); +// return false; break; + +// case MODRESET: +// clear_mods(); +// return false; break; + +// case DEREF: +// SEND_STRING ("->"); +// return false; break; + +// case EQRIGHT: +// SEND_STRING ("=>"); +// return false; break; + +// case TICK3: +// SEND_STRING ("```"); +// return false; break; + +// case TILD3: +// SEND_STRING ("~~~"); +// return false; break; +// } +// } +// return true; +// }; + + + + bool process_record_user(uint16_t keycode, keyrecord_t *record) { - switch (keycode) { - case KC_SECRET_1 ... KC_SECRET_5: - if (!record->event.pressed) { - send_string(secret[keycode - KC_SECRET_1]); + if (!record->event.pressed) { + switch (keycode) { + case KC_SECRET_1 ... KC_SECRET_5: + send_string(secret[keycode - KC_SECRET_1]); + // clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); + return true; break; + case UP_ENTER_RESET: + SEND_STRING("make ergodox_infinity:gordon:dfu-util"); + register_code(KC_ENTER); + unregister_code(KC_ENTER); + reset_keyboard(); + return false; break; + + case TIL_SLASH: + SEND_STRING ("~/."); + return false; break; + + case DBMS_OUT: + SEND_STRING ("dbms_output.put_line('');"); + SEND_STRING (SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT)); + return false; break; + case DIE_1000X_RIGHT: + SEND_STRING (SS_TAP(X_G) SS_TAP(X_G) SS_TAP(X_RIGHT) SS_TAP(X_B) SS_TAP(X_J)); + return false; break; + case DIE_1000X_LEFT: + SEND_STRING (SS_TAP(X_GRAVE) SS_TAP(X_G) SS_TAP(X_LEFT) SS_TAP(X_B) SS_TAP(X_J)); + return false; break; + case ID_MAN_IP: + SEND_STRING ("http://dev-1967110238.us-east-1.elb.amazonaws.com"); + return false; break; + + case MODRESET: + clear_mods(); + return false; break; + + case DEREF: + SEND_STRING ("->"); + return false; break; + + case EQRIGHT: + SEND_STRING ("=>"); + return false; break; + + case TICK3: + SEND_STRING ("```"); + + return false; break; + + case SPRK_TCK: + SEND_STRING ("```"); + SEND_STRING (SS_DOWN(X_LSHIFT) SS_TAP(X_ENTER) SS_UP(X_LSHIFT)); + SEND_STRING (SS_DOWN(X_LSHIFT) SS_TAP(X_ENTER) SS_UP(X_LSHIFT)); + SEND_STRING ("```"); + SEND_STRING (SS_TAP(X_UP)); + return false; break; + + case TILD3: + SEND_STRING ("~~~"); + return false; break; + } + } + else { //On key being pressed + switch (keycode) { + case KC_SECRET_1 ... KC_SECRET_5: + clear_oneshot_layer_state(ONESHOT_OTHER_KEY_PRESSED); + return false; break; } - return false; - break; } return true; -}
\ No newline at end of file +}; + diff --git a/users/gordon/gordon.h b/users/gordon/gordon.h index 548c63049..92641a8aa 100644 --- a/users/gordon/gordon.h +++ b/users/gordon/gordon.h @@ -6,20 +6,21 @@ // Fillers to make layering more clear -#define _______ KC_TRNS -#define ________ KC_TRNS +#define _______ KC_TRNS +#define ________ KC_TRNS #define _________ KC_TRNS -#define XXXXXXX KC_NO +#define _XXXXXX_ KC_TRNS +#define XXXXXXX KC_NO // KC codes that are too long -#define DOLLAR KC_DOLLAR -#define LSQUIGLY KC_LBRACKET -#define RSQUIGLY KC_RBRACKET -#define NUMLOCK KC_NUMLOCK -#define CAPLOCK KC_CAPSLOCK -#define BK_SLASH KC_BSLASH -#define ASTERSK KC_KP_ASTERISK - +#define DOLLAR KC_DOLLAR +#define LSQUIGLY KC_LBRACKET +#define RSQUIGLY KC_RBRACKET +#define NUMLOCK KC_NUMLOCK +#define CAPLOCK KC_CAPSLOCK +#define BK_SLASH KC_BSLASH +#define ASTERSK KC_KP_ASTERISK + // Navigation #define SNAPLEFT LGUI(KC_LEFT) #define SNAPRGHT LGUI(KC_RIGHT) @@ -30,19 +31,28 @@ #define WORKRIGHT LCTL(LGUI(KC_RIGHT)) #define WORKLEFT LCTL(LGUI(KC_LEFT)) +#define APP_1 LCTL(LGUI(KC_1)) +#define APP_2 LCTL(LGUI(KC_2)) +#define APP_3 LCTL(LGUI(KC_3)) +#define APP_4 LCTL(LGUI(KC_4)) +#define APP_5 LCTL(LGUI(KC_5)) +#define APP_6 LCTL(LGUI(KC_6)) +#define APP_7 LCTL(LGUI(KC_7)) +#define APP_8 LCTL(LGUI(KC_8)) + // KC/modifier hold -#define CTRL_F CTL_T(KC_F) -#define CTRL_J CTL_T(KC_J) -#define CTRL_Z CTL_T(KC_Z) -#define ALT_V ALT_T(KC_V) -#define ALT_M ALT_T(KC_M) -#define WIN_G GUI_T(KC_G) -#define WIN_H GUI_T(KC_H) -#define HYPER_X ALL_T(KC_X) -#define HYPE_DOT ALL_T(KC_DOT) -#define MEH_S MEH_T(KC_S) -#define MEH_L MEH_T(KC_L) -#define ALT_HOME ALT_T(KC_HOME) +#define CTRL_F CTL_T(KC_F) +#define CTRL_J CTL_T(KC_J) +#define CTRL_Z CTL_T(KC_Z) +#define ALT_V ALT_T(KC_V) +#define ALT_M ALT_T(KC_M) +#define WIN_G GUI_T(KC_G) +#define WIN_H GUI_T(KC_H) +#define HYPER_X ALL_T(KC_X) +#define HYPE_DOT ALL_T(KC_DOT) +#define MEH_S MEH_T(KC_S) +#define MEH_L MEH_T(KC_L) +#define ALT_HOME ALT_T(KC_HOME) // KC/Layer Hold @@ -52,6 +62,15 @@ #define SYMB_BSP LT(_SYMBOLS,KC_BSPACE) #define COL_MOUS LT(_MOUSE,KC_SCOLON) #define SPAC_SYM LT(_SYMBOLS,KC_SPACE) +#define SPAC_TXT LT(_TEXTNAV,KC_SPACE) + +#define APP_SW_I LT(_APPSWITCH,KC_I) +#define APP_SW_K LT(_APPSWITCH,KC_K) + +// #define TLSLSH TIL_SLASH +// #define TILDA_3x TILD3 +// #define _RESET_ UP_ENTER_RESET + // Double Modifier ONLY hold #define ALT_SHFT LSFT(KC_LALT) @@ -60,6 +79,7 @@ // KC/Double modifier Hold #define CTR_SH_W MT(MOD_LCTL|MOD_LSFT,KC_W) #define CTR_AL_R MT(MOD_LCTL|MOD_LALT,KC_R) +#define ALT_SH_R MT(MOD_LSFT|MOD_LALT,KC_R) //MISC #define PRINTSCR KC_PSCREEN @@ -82,16 +102,77 @@ enum { TRIPLE_HOLD = 7 }; +//Tap dance enums +enum +{ + F12TAP = 0, + F12ETAPS, + CALCCOMP, + REFRESH, //send R, or Control+R if double tapped. + ENDESC, + XESC, //'quad function'. x, control, escape, alt + ALY2, //'quad function': a, Hyper, ctrl+a, layer 2 + PRLOCK, + F6F7, // Shift F6 or Alt F7 + TABCOMBO, + FCTRL, + F3D, + ALTF4, + COMMA, + AT, + HTAB, + F1F13, + F2F14, + F5F15, + ENDHOME, + Q_ESCAPE +}; + +#ifdef TAP_DANCE_ENABLE +#define F1_F13 TD(F1F13) +#define F2_F14 TD(F2F14) +#define F5_F15 TD(F5F15) +#define F4_ALTF4 TD(ALTF4) +#define END_ESC TD(ENDESC) +#define Q_ESC TD(Q_ESCAPE) +#define END_HOME TD(ENDHOME) +#define SHF6_AF7 TD(F6F7) +#define F12_RUN TD(F12ETAPS) +#define COMMA_TD TD(COMMA) +#define CALC_COM TD(CALCCOMP) +#else //just to make things compile +#define F1_F13 KC_1 +#define F2_F14 KC_1 +#define F5_F15 KC_1 +#define F4_ALTF4 KC_1 +#define END_ESC KC_1 +#define END_HOME KC_1 +#define SHF6_AF7 KC_1 +#define F12_RUN KC_1 +#define COMMA_TD KC_1 +#define CALC_COM KC_1 +#endif + enum gordon_layers { _QWERTY = 0, - _SYMBOLS, - _MOUSE, - _NUMPAD, - _NAV, - _MACROS, - _FUNCTION, - _TEXTNAV + _SYMBOLS, // Programming and all other commonlye used symbols + _MOUSE, // Mouse movement and also a few macros + _NUMPAD, // For getting a numpad under the right hand, and a few helpful things under the left + _NAV, // Windows navigation. Windows snapping, changing workspaces, and ARROWS + _MACROS, // Non-text related Macros. + _FUNCTION, // Not sure what I had in mind for this one + _APPSWITCH, // For switching between apps using the `ctrl + Win + [num]` shortcut. + // This allows for toggling windows of the same app with one button. + // Example: Press and hold `I`, then tap `j` multiple times to cycle through all + // Intellij windows (and only Intellij). This requires the app to be pinned to the Windows bar + _ONESHOT, // A layer I use for shortcuts that require multiple modifiers and a button not on my home layer + // Example: If I need to hit `alt + shift + 5` + _TEXTNAV, // Navigate through text + _QWERTY_KIDS, // So my kids can do nothing but type. Could also be a `speed typing` layer with no LT or MTs + _STREET_FIGHTER, // For Street Fighter 5. Die 1000x Deaths!!!! + _DIRNAV, // For navigating to different directories. + _TEXT_MACROS // For text-manipulation macros. Passwords, saved strings, pre-formatting }; @@ -99,23 +180,23 @@ enum gordon_layers void register_hyper (void); void unregister_hyper (void); -void register_ctrl_a (void); -void unregister_ctrl_a (void); +void register_ctrl_a (void); +void unregister_ctrl_a (void); -void register_alt_f7 (void); +void register_alt_f7 (void); void unregister_alt_f7 (void); -void register_shift_f6 (void); -void unregister_shift_f6 (void); +void register_shift_f6 (void); +void unregister_shift_f6 (void); -void register_ctrl_shift (void); -void unregister_ctrl_shift (void); +void register_ctrl_shift (void); +void unregister_ctrl_shift (void); -void register_alt_shift (void); +void register_alt_shift (void); void unregister_alt_shift (void); -int cur_dance (qk_tap_dance_state_t *state); -int hold_cur_dance (qk_tap_dance_state_t *state); +int cur_dance (qk_tap_dance_state_t *state); +int hold_cur_dance (qk_tap_dance_state_t *state); void x_finished (qk_tap_dance_state_t *state, void *user_data); void x_reset (qk_tap_dance_state_t *state, void *user_data); @@ -132,26 +213,37 @@ void comma_reset (qk_tap_dance_state_t *state, void *user_data); void bt_finished (qk_tap_dance_state_t *state, void *user_data); void bt_reset (qk_tap_dance_state_t *state, void *user_data); +enum secret_strings { + KC_SECRET_1 = SAFE_RANGE, + KC_SECRET_2, + KC_SECRET_3, + KC_SECRET_4, + KC_SECRET_5, + END_SECRET_SAFE_RANGE +}; + + // Macro Declarations enum { - INFOQM, + INFOQM = END_SECRET_SAFE_RANGE, + MODRESET, TIL_SLASH, DEREF, EQRIGHT, TILD3, TICK3, + SPRK_TCK, ALTTAB_START, - ALTTAB_END + ALTTAB_END, + UP_ENTER_RESET, + DBMS_OUT, + DIE_1000X_RIGHT, + DIE_1000X_LEFT, + ID_MAN_IP }; -enum secret_strings { - KC_SECRET_1 = SAFE_RANGE, - KC_SECRET_2, - KC_SECRET_3, - KC_SECRET_4, - KC_SECRET_5, -}; + const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt); -#endif
\ No newline at end of file +#endif diff --git a/users/gordon/rules.mk b/users/gordon/rules.mk index 359478912..19e77b01b 100644 --- a/users/gordon/rules.mk +++ b/users/gordon/rules.mk @@ -1,2 +1,4 @@ TAP_DANCE_ENABLE = yes -SRC += gordon.c
\ No newline at end of file +SRC += gordon.c + +# BOOTMAGIC_ENABLE = yes diff --git a/users/kuatsure/kuatsure.c b/users/kuatsure/kuatsure.c new file mode 100644 index 000000000..a18713626 --- /dev/null +++ b/users/kuatsure/kuatsure.c @@ -0,0 +1,111 @@ +#include "kuatsure.h" + +void tmux_prefix(void) { + register_code(KC_LCTL); + register_code(KC_SPC); + + unregister_code(KC_LCTL); + unregister_code(KC_SPC); +} + +void tmux_pane_zoom(void) { + tmux_prefix(); + + register_code(KC_Z); + unregister_code(KC_Z); +} + +void tmux_pane_switch(uint16_t keycode) { + tmux_prefix(); + + register_code(KC_Q); + unregister_code(KC_Q); + + register_code(keycode); + unregister_code(keycode); +} + +void tmux_window_switch(uint16_t keycode) { + tmux_prefix(); + + register_code(keycode); + unregister_code(keycode); +} + +LEADER_EXTERNS(); +void matrix_scan_user(void) { + LEADER_DICTIONARY() { + leading = false; + leader_end(); + + // Available seqs + // SEQ_ONE_KEY, SEQ_TWO_KEYS, SEQ_THREE_KEYS + // anything you can do in a macro https://docs.qmk.fm/macros.html + // https://docs.qmk.fm/feature_leader_key.html + + // Whole Screen Shot + SEQ_ONE_KEY(KC_A) { + register_code(KC_LGUI); + register_code(KC_LSFT); + register_code(KC_3); + + unregister_code(KC_3); + unregister_code(KC_LSFT); + unregister_code(KC_LGUI); + } + + // Selective Screen Shot + SEQ_ONE_KEY(KC_S) { + register_code(KC_LGUI); + register_code(KC_LSFT); + register_code(KC_4); + + unregister_code(KC_4); + unregister_code(KC_LSFT); + unregister_code(KC_LGUI); + } + + // TMUX - shift to pane 1 and zoom + SEQ_ONE_KEY(KC_J) { + tmux_pane_switch(KC_1); + tmux_pane_zoom(); + } + + // TMUX - shift to pane 2 and zoom + SEQ_ONE_KEY(KC_K) { + tmux_pane_switch(KC_2); + tmux_pane_zoom(); + } + + // TMUX - shift to pane 3 and zoom + SEQ_ONE_KEY(KC_L) { + tmux_pane_switch(KC_3); + tmux_pane_zoom(); + } + + // TMUX - shift to last pane and zoom + SEQ_ONE_KEY(KC_SCOLON) { + tmux_prefix(); + + register_code(KC_SCOLON); + unregister_code(KC_SCOLON); + + tmux_pane_zoom(); + } + + // TMUX - shift to first window + SEQ_ONE_KEY(KC_U) { + tmux_window_switch(KC_1); + } + + // TMUX - shift to second window + SEQ_ONE_KEY(KC_I) { + tmux_window_switch(KC_2); + } + + // TMUX - shift to third window + SEQ_ONE_KEY(KC_O) { + tmux_window_switch(KC_3); + } + } +} diff --git a/users/kuatsure/kuatsure.h b/users/kuatsure/kuatsure.h new file mode 100644 index 000000000..56fb684ec --- /dev/null +++ b/users/kuatsure/kuatsure.h @@ -0,0 +1,31 @@ +#ifndef KUATSURE +#define KUATSURE + +#include "quantum.h" + +void tmux_prefix(void); +void tmux_pane_zoom(void); +void tmux_pane_switch(uint16_t keycode); +void tmux_window_switch(uint16_t keycode); + +#undef LEADER_TIMEOUT +#define LEADER_TIMEOUT 300 + +#define LAYOUT_preonic_grid_wrapper(...) LAYOUT_preonic_grid(__VA_ARGS__) + +#define _________________NUMBER_L1_________________ KC_1, KC_2, KC_3, KC_4, KC_5 +#define _________________NUMBER_R1_________________ KC_6, KC_7, KC_8, KC_9, KC_0 + +#define _________________QWERTY_L1_________________ KC_Q, KC_W, KC_E, KC_R, KC_T +#define _________________QWERTY_L2_________________ KC_A, KC_S, KC_D, KC_F, KC_G +#define _________________QWERTY_L3_________________ KC_Z, KC_X, KC_C, KC_V, KC_B + +#define _________________QWERTY_R1_________________ KC_Y, KC_U, KC_I, KC_O, KC_P +#define _________________QWERTY_R2_________________ KC_H, KC_J, KC_K, KC_L, KC_SCLN +#define _________________QWERTY_R3_________________ KC_N, KC_M, KC_COMM, KC_DOT, KC_SLASH + +#define ____________FUNCTION_1____________ KC_F1, KC_F2, KC_F3, KC_F4 +#define ____________FUNCTION_2____________ KC_F5, KC_F6, KC_F7, KC_F8 +#define ____________FUNCTION_3____________ KC_F9, KC_F10, KC_F11, KC_F12 + +#endif diff --git a/users/kuatsure/readme.md b/users/kuatsure/readme.md new file mode 100644 index 000000000..b6d10224f --- /dev/null +++ b/users/kuatsure/readme.md @@ -0,0 +1,14 @@ +Copyright 2018 Jarrett Drouillard jarrett@thestyl.us @kuatsure + +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 +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. diff --git a/users/kuatsure/rules.mk b/users/kuatsure/rules.mk new file mode 100644 index 000000000..11262d0ec --- /dev/null +++ b/users/kuatsure/rules.mk @@ -0,0 +1 @@ +SRC += kuatsure.c diff --git a/users/losinggeneration/losinggeneration-keymap.h b/users/losinggeneration/losinggeneration-keymap.h index 89827bc13..74170dc31 100644 --- a/users/losinggeneration/losinggeneration-keymap.h +++ b/users/losinggeneration/losinggeneration-keymap.h @@ -88,11 +88,22 @@ qk_tap_dance_action_t tap_dance_actions[] = { * |Adjust| Ctrl | Alt | GUI |Lower | Del ||Space |Raise | Left | Down | Up |Right | * `-----------------------------------------'`-----------------------------------------' */ -#define BOTTOM_40_ROW \ +#define BOTTOM_GRID_ROW \ TD_ADJ ,TD_CTL , TD_ALT , TD_GUI , LOWER , KC_DEL , KC_SPC , RAISE , KC_LEFT, KC_DOWN, KC_UP , KC_RGHT /* * ,-----------------------------------------..-----------------------------------------. + * |Adjust| Ctrl | Alt | GUI |Lower |Space ||Space |Raise | Left | Down | Up |Right | + * `-----------------------------------------'`-----------------------------------------' + */ +#define BOTTOM_MIT_ROW \ + TD_ADJ ,TD_CTL , TD_ALT , TD_GUI , LOWER , KC_SPC , KC_SPC , RAISE , KC_LEFT, KC_DOWN, KC_UP , KC_RGHT + +#ifdef USE_MIT_LAYOUT +#define BOTTOM_ROW BOTTOM_MIT_ROW + +/* + * ,-----------------------------------------..-----------------------------------------. * | | F7 | F8 | F9 | F10 | F11 || F12 | PgUp | PgDn | Home | End | ⏹ | * |------+------+------+------+------+------||------+------+------+------+------+------| * | | | | | | || | | Mute | Vol- | Vol+ | ⏯ | @@ -102,6 +113,22 @@ qk_tap_dance_action_t tap_dance_actions[] = { _______, KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , KC_F12 , KC_PGUP, KC_PGDN, KC_HOME, KC_END , KC_MSTP, \ _______, _______, _______, _______, _______, _______, _______, _______, KC_MUTE, KC_VOLD, KC_VOLU, KC_MPLY +#else +#define BOTTOM_ROW BOTTOM_GRID_ROW + +/* + * ,-----------------------------------------..-----------------------------------------. + * | | F7 | F8 | F9 | F10 | F11 || F12 | PgUp | PgDn | Home | End | ⏹ | + * |------+------+------+------+------+------||------+------+------+------+------+------| + * | | | | | | || Bksp | | Mute | Vol- | Vol+ | ⏯ | + * `-----------------------------------------'`-----------------------------------------' + */ +#define BOTTOM_RAISE_LOWER_ROWS \ + _______, KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , KC_F12 , KC_PGUP, KC_PGDN, KC_HOME, KC_END , KC_MSTP, \ + _______, _______, _______, _______, _______, KC_BSPC, _______, _______, KC_MUTE, KC_VOLD, KC_VOLU, KC_MPLY +#endif + + /* * ,-----------------------------------------..-----------------------------------------. * | Tab | || | Bksp | @@ -115,7 +142,7 @@ qk_tap_dance_action_t tap_dance_actions[] = { * `-----------------------------------------'`-----------------------------------------' */ -#define STD_ESC_ROW(...) KC_ESC, __VA_ARGS__ +#define STD_ESC_ROW(...) MT_ESC, __VA_ARGS__ /* * ,-----------------------------------------..-----------------------------------------. @@ -139,7 +166,7 @@ qk_tap_dance_action_t tap_dance_actions[] = { STD_TAB_ROW( KC_Q , KC_W , KC_E , KC_R , KC_T , KC_Y , KC_U , KC_I , KC_O , KC_P ), \ STD_ESC_ROW( KC_A , KC_S , KC_D , KC_F , KC_G , KC_H , KC_J , KC_K , KC_L , KC_SCLN , KC_QUOT), \ STD_LSFT_ROW(KC_Z , KC_X , KC_C , KC_V , KC_B , KC_N , KC_M , KC_COMM, KC_DOT , KC_SLSH), \ - BOTTOM_40_ROW + BOTTOM_ROW /* Colemak * ,-----------------------------------------.,-----------------------------------------. @@ -156,7 +183,7 @@ qk_tap_dance_action_t tap_dance_actions[] = { STD_TAB_ROW( KC_Q , KC_W , KC_F , KC_P , KC_G , KC_J , KC_L , KC_U , KC_Y , KC_SCLN), \ STD_ESC_ROW( KC_A , KC_R , KC_S , KC_T , KC_D , KC_H , KC_N , KC_E , KC_I , KC_O , KC_QUOT), \ STD_LSFT_ROW(KC_Z , KC_X , KC_C , KC_V , KC_B , KC_K , KC_M , KC_COMM, KC_DOT , KC_SLSH), \ - BOTTOM_40_ROW + BOTTOM_ROW /* Workman * ,-----------------------------------------..-----------------------------------------. @@ -173,7 +200,7 @@ qk_tap_dance_action_t tap_dance_actions[] = { STD_TAB_ROW( KC_Q , KC_D , KC_R , KC_W , KC_B , KC_J , KC_F , KC_U , KC_P , KC_SCLN), \ STD_ESC_ROW( KC_A , KC_S , KC_H , KC_T , KC_G , KC_Y , KC_N , KC_E , KC_O , KC_I , KC_QUOT), \ STD_LSFT_ROW(KC_Z , KC_X , KC_M , KC_C , KC_V , KC_K , KC_L , KC_COMM, KC_DOT , KC_SLSH), \ - BOTTOM_40_ROW + BOTTOM_ROW /* Dvorak * ,-----------------------------------------..-----------------------------------------. @@ -190,7 +217,7 @@ qk_tap_dance_action_t tap_dance_actions[] = { STD_TAB_ROW( KC_QUOT, KC_COMM, KC_DOT , KC_P , KC_Y , KC_F , KC_G , KC_C , KC_R , KC_L), \ STD_ESC_ROW( KC_A , KC_O , KC_E , KC_U , KC_I , KC_D , KC_H , KC_T , KC_N , KC_S , KC_SLSH), \ STD_LSFT_ROW(KC_SCLN, KC_Q , KC_J , KC_K , KC_X , KC_B , KC_M , KC_W , KC_V , KC_Z), \ - BOTTOM_40_ROW + BOTTOM_ROW /* Game (Qwerty without one shot modifiers & tap dancing) * ,-----------------------------------------..-----------------------------------------. diff --git a/users/mtdjr/config.h b/users/mtdjr/config.h new file mode 100644 index 000000000..9769ebc18 --- /dev/null +++ b/users/mtdjr/config.h @@ -0,0 +1,7 @@ +#ifndef USERSPACE_CONFIG_H +#define USERSPACE_CONFIG_H + +// Put normal config.h settings here: +#define TAPPING_TERM 250 + +#endif // !USERSPACE_CONFIG_H diff --git a/users/mtdjr/mtdjr.c b/users/mtdjr/mtdjr.c new file mode 100644 index 000000000..da4f57047 --- /dev/null +++ b/users/mtdjr/mtdjr.c @@ -0,0 +1,137 @@ +#include "mtdjr.h" + +#ifdef SOLENOID_ENABLE + #include "solenoid.h" + + void solenoid_buzz_on(void); + void solenoid_buzz_off(void); + void solenoid_dwell_minus(void); + void solenoid_dwell_plus(void); + void solenoid_toggle(void); + void solenoid_stop(void); + void solenoid_fire(void); + void solenoid_check(void); + void solenoid_setup(void); + void matrix_init_user(void); + void matrix_scan_user(void); +#endif + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + #ifdef SOLENOID_ENABLE + if (record->event.pressed) { + solenoid_fire(); + } + #endif + switch (keycode) { + case QWERTY: + if (record->event.pressed) { + set_single_persistent_default_layer(_QWERTY); + } + return false; + break; + case LOWER: + if (record->event.pressed) { + layer_on(_LOWER); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } else { + layer_off(_LOWER); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } + return false; + break; + case RAISE: + if (record->event.pressed) { + layer_on(_RAISE); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } else { + layer_off(_RAISE); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } + return false; + break; + case ADJUST: + if (record->event.pressed) { + layer_on(_ADJUST); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } else { + layer_off(_ADJUST); + update_tri_layer(_LOWER, _RAISE, _ADJUST); + } + return false; + break; + case SOLENOID_TOG: + #ifdef SOLENOID_ENABLE + if (record->event.pressed) { + solenoid_toggle(); + } + #endif + break; + case SOLENOID_DWELL_MINUS: + #ifdef SOLENOID_ENABLE + if (record->event.pressed) { + solenoid_dwell_minus(); + } + #endif + break; + case SOLENOID_DWELL_PLUS: + #ifdef SOLENOID_ENABLE + if (record->event.pressed) { + solenoid_dwell_plus(); + } + #endif + break; + case SOLENOID_BUZZ_ON: + #ifdef SOLENOID_ENABLE + if (record->event.pressed) { + solenoid_buzz_on(); + } + #endif + break; + case SOLENOID_BUZZ_OFF: + #ifdef SOLENOID_ENABLE + if (record->event.pressed) { + solenoid_buzz_off(); + } + #endif + break; + } + return true; +}; + + +//Tap Dance Definitions +qk_tap_dance_action_t tap_dance_actions[] = { + [TD_ESC] = ACTION_TAP_DANCE_DOUBLE(KC_GRV, KC_ESC), + [TD_ALTLOCK] = ACTION_TAP_DANCE_DOUBLE(KC_RALT, LGUI(KC_L)), + [TD_ENDLOCK] = ACTION_TAP_DANCE_DOUBLE(KC_END, LGUI(KC_L)), + //[TD_PRNT] = ACTION_TAP_DANCE_DOUBLE(PRINT, PRINT_SEL) +}; + +const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { + if (record->event.pressed) { + switch(id) { + case 0: + SEND_STRING("sudo su -\n"); + return false; break; + case 1: + SEND_STRING("puppet apply /etc/puppetlabs/code/environments/production/manifests/site.pp\n"); + return false; break; + case 2: + SEND_STRING("ps -ef | grep "); + return false; break; + case 3: // control + insert + return MACRO(D(LCTL), T(INS), U(LCTL), END); + break; + case 4: // shift + insert + return MACRO(D(LSFT), T(INS), U(LSFT), END); + break; + case 5: // control + alt + delete + return MACRO(D(LCTL), D(RALT), T(DEL), U(LCTL), U(LALT), END); + break; + case 6: // lgui + L + return MACRO(D(LGUI), T(L), U(LGUI), END); + break; + } + } + return MACRO_NONE; +}; diff --git a/users/mtdjr/mtdjr.h b/users/mtdjr/mtdjr.h new file mode 100644 index 000000000..012a35610 --- /dev/null +++ b/users/mtdjr/mtdjr.h @@ -0,0 +1,76 @@ +#ifndef USERSPACE +#define USERSPACE + +#include "quantum.h" + +#define _QWERTY 0 +#define _LOWER 1 +#define _RAISE 2 +#define _SUPER 3 +#define _ADJUST 16 + +enum user_layers { + QWERTY = SAFE_RANGE, + LOWER, + RAISE, + SUPER, + ADJUST, +}; + +enum user_tapdance { + TD_ENDLOCK, + TD_ALTLOCK, + TD_ESC, +}; + +enum user_solenoid { + SOLENOID_TOG, + SOLENOID_DWELL_MINUS, + SOLENOID_DWELL_PLUS, + SOLENOID_BUZZ_ON, + SOLENOID_BUZZ_OFF, +}; + +#define KC_STOG SOLENOID_TOG +#define KC_SDM SOLENOID_DWELL_MINUS +#define KC_SDP SOLENOID_DWELL_PLUS +#define KC_SBON SOLENOID_BUZZ_ON +#define KC_SBOF SOLENOID_BUZZ_OFF + +#define KC_ KC_TRNS +#define _______ KC_TRNS +#define XXXXXXX KC_NO +#define KC_xxxx KC_NO + +#define KC_LOWR LOWER +#define KC_RASE RAISE +#define KC_SUPR SUPER +#define KC_RST RESET + +// TapDance Keycodes +#define KC_EXC TD_ESC + +// Macro Declarations +#define KC_ROOT M(0) +#define KC_PPLY M(1) +#define KC_PSEF M(2) +#define KC_XCPY M(3) +#define KC_XINS M(4) +#define KC_CAD M(5) +#define UM_LOCK M(6) + +// RGB and Backlighting +#define KC_RGB RGB_TOG +#define KC_RHUI RGB_HUI +#define KC_RHUD RGB_HUD +#define KC_RSAI RGB_SAI +#define KC_RSAD RGB_SAD +#define KC_RVAI RGB_VAI +#define KC_RVAD RGB_VAD +#define KC_BLT BL_TOGG +#define KC_BLS BL_STEP +#define KC_BLI BL_INC +#define KC_BLD BL_DEC + + +#endif diff --git a/users/mtdjr/readme.md b/users/mtdjr/readme.md new file mode 100644 index 000000000..e795ee23a --- /dev/null +++ b/users/mtdjr/readme.md @@ -0,0 +1,14 @@ +Copyright 2018 @mtdjr + +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 +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. diff --git a/users/mtdjr/rules.mk b/users/mtdjr/rules.mk new file mode 100644 index 000000000..6eec4b5b8 --- /dev/null +++ b/users/mtdjr/rules.mk @@ -0,0 +1,2 @@ +SRC += mtdjr.c +TAP_DANCE_ENABLE = yes diff --git a/users/mtdjr/solenoid.h b/users/mtdjr/solenoid.h new file mode 100644 index 000000000..38066f4c3 --- /dev/null +++ b/users/mtdjr/solenoid.h @@ -0,0 +1,103 @@ +#ifndef SOLENOID_H +#define SOLENOID_H + +#include <timer.h> +#include "pincontrol.h" + +#define SOLENOID_DEFAULT_DWELL 12 +#define SOLENOID_MAX_DWELL 100 +#define SOLENOID_MIN_DWELL 4 +#ifndef SOLENOID_ACTIVE + #define SOLENOID_ACTIVE false +#endif +//#define SOLENOID_PIN F6 + +bool solenoid_enabled = SOLENOID_ACTIVE; +bool solenoid_on = false; +bool solenoid_buzz = false; +bool solenoid_buzzing = false; +uint16_t solenoid_start = 0; +uint8_t solenoid_dwell = SOLENOID_DEFAULT_DWELL; + + +void solenoid_buzz_on(void) { + solenoid_buzz = true; +} + +void solenoid_buzz_off(void) { + solenoid_buzz = false; +} + +void solenoid_dwell_minus(void) { + if (solenoid_dwell > 0) solenoid_dwell--; +} + +void solenoid_dwell_plus(void) { + if (solenoid_dwell < SOLENOID_MAX_DWELL) solenoid_dwell++; +} + +void solenoid_toggle(void) { + solenoid_enabled = !solenoid_enabled; +} + +void solenoid_stop(void) { + digitalWrite(SOLENOID_PIN, PinLevelLow); + solenoid_on = false; + solenoid_buzzing = false; +} + +void solenoid_fire(void) { + if (!solenoid_enabled) return; + + if (!solenoid_buzz && solenoid_on) return; + if (solenoid_buzz && solenoid_buzzing) return; + + solenoid_on = true; + solenoid_buzzing = true; + solenoid_start = timer_read(); + digitalWrite(SOLENOID_PIN, PinLevelHigh); +} + +void solenoid_check(void) { + uint16_t elapsed = 0; + + if (!solenoid_on) return; + + elapsed = timer_elapsed(solenoid_start); + + //Check if it's time to finish this solenoid click cycle + if (elapsed > solenoid_dwell) { + solenoid_stop(); + return; + } + + //Check whether to buzz the solenoid on and off + if (solenoid_buzz) { + if (elapsed / SOLENOID_MIN_DWELL % 2 == 0){ + if (!solenoid_buzzing) { + solenoid_buzzing = true; + digitalWrite(SOLENOID_PIN, PinLevelHigh); + } + } + else { + if (solenoid_buzzing) { + solenoid_buzzing = false; + digitalWrite(SOLENOID_PIN, PinLevelLow); + } + } + } +} + +void solenoid_setup(void) { + pinMode(SOLENOID_PIN, PinDirectionOutput); +} + +void matrix_init_user(void) { + solenoid_setup(); +} + +void matrix_scan_user(void) { + solenoid_check(); +} + +#endif |