Created
July 25, 2019 08:19
-
-
Save burakcan/3e47589414ab8e734dc7cdafea494e64 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include QMK_KEYBOARD_H | |
enum custom_keycoodes { | |
GIT_PULL = SAFE_RANGE, | |
GIT_CHECKOUT_MASTER, | |
GIT_CHECKOUT_B, | |
GIT_PULL_REBASE_MASTER, | |
GIT_ADD_ALL, | |
GIT_COMMIT, | |
GIT_AMEND, | |
GIT_PUSH_U, | |
GIT_PUSH, | |
GIT_PUSH_FORCE, | |
GIT_STATUS, | |
VIM_WQ, | |
VIM_Q | |
}; | |
#define SHF_A LSFT_T(KC_A) | |
#define SHF_ENT RSFT_T(KC_ENT) | |
#define L_1_SPC LT(1, KC_SPC) | |
#define L_2_SPC LT(2, KC_SPC) | |
#define L_3_Z LT(3, KC_Z) | |
#define L_4_S LT(4, KC_S) | |
#define L_5_BS LT(5, KC_BSPC) | |
#define L_6_P LT(6, KC_P) | |
#define CTL_X LCTL_T(KC_X) | |
#define ALT_C LALT_T(KC_C) | |
#define GUI_V LGUI_T(KC_V) | |
#define GUI_B LGUI_T(KC_B) | |
#define ALT_N RALT_T(KC_N) | |
#define GUI_1 LGUI(KC_1) | |
#define GUI_2 LGUI(KC_2) | |
#define GUI_3 LGUI(KC_3) | |
#define GUI_4 LGUI(KC_4) | |
#define GUI_5 LGUI(KC_5) | |
#define GUI_6 LGUI(KC_6) | |
#define GUI_7 LGUI(KC_7) | |
#define GUI_8 LGUI(KC_8) | |
#define GUI_9 LGUI(KC_9) | |
#define GUI_0 LGUI(KC_0) | |
#define GUI_LFT LGUI(KC_LEFT) | |
#define GUI_RGHT LGUI(KC_RGHT) | |
#define GUI_UP LGUI(KC_UP) | |
#define GUI_DWN LGUI(KC_DOWN) | |
#define ALT_LFT LALT(KC_LEFT) | |
#define ALT_RGHT LALT(KC_RGHT) | |
#define ALT_UP LALT(KC_UP) | |
#define ALT_DWN LALT(KC_DOWN) | |
#define _NORMAL 0 | |
#define _LOWER 1 | |
#define _RAISE 2 | |
#define _COMMAND 3 | |
#define _ALT 4 | |
#define _GENERIC_MACROS 5 | |
#define _ADJUST 6 | |
//Tap Dance Declarations | |
enum { | |
TD_Q_ESC = 0 | |
}; | |
//Tap Dance Definitions | |
qk_tap_dance_action_t tap_dance_actions[] = { | |
//Tap once for Q, twice for ESC Lock | |
[TD_Q_ESC] = ACTION_TAP_DANCE_DOUBLE(KC_Q, KC_ESC) | |
// Other declarations would go here, separated by commas, if you have them | |
}; | |
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |
[_NORMAL] = LAYOUT_ortho_3x11( \ | |
TD(TD_Q_ESC), KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, L_6_P, L_5_BS, \ | |
SHF_A, L_4_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, SHF_ENT, \ | |
L_3_Z, CTL_X, ALT_C, GUI_V, L_1_SPC, L_2_SPC, GUI_B, ALT_N, KC_M, KC_COMM, KC_DOT \ | |
), | |
[_RAISE] = LAYOUT_ortho_3x11( \ | |
KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, \ | |
_______, _______, _______, _______, KC_QUES, KC_PIPE, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, _______, \ | |
_______, _______, _______, _______, KC_TAB, _______, _______, _______, _______, _______, _______ \ | |
), | |
[_LOWER] = LAYOUT_ortho_3x11( \ | |
KC_GESC, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_QUOT, \ | |
_______, _______, _______, _______, KC_SLSH, KC_BSLS, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, _______, \ | |
_______, _______, _______, _______, _______, KC_TAB, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \ | |
), | |
[_COMMAND] = LAYOUT_ortho_3x11( \ | |
KC_TILD, GUI_1 , GUI_2 , GUI_3 , GUI_4 , GUI_5 , GUI_6 , GUI_7 , GUI_8 , GUI_9 , GUI_0 , \ | |
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | |
_______, _______, _______, _______, _______, _______, _______, GUI_LFT, GUI_DWN, GUI_UP , GUI_RGHT \ | |
), | |
[_ALT] = LAYOUT_ortho_3x11( \ | |
KC_TILD, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | |
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \ | |
_______, _______, _______, _______, _______, _______, _______, ALT_LFT, ALT_DWN, ALT_UP , ALT_RGHT \ | |
), | |
[_GENERIC_MACROS] = LAYOUT_ortho_3x11( \ | |
VIM_Q, VIM_WQ, _______, GIT_PULL_REBASE_MASTER, _______, _______, GIT_PUSH_U, _______, GIT_PUSH, GIT_PULL, _______, \ | |
GIT_ADD_ALL, GIT_AMEND, _______, GIT_PUSH_FORCE, _______, _______, _______, _______, _______, _______, _______, \ | |
_______, GIT_STATUS, GIT_COMMIT, _______, _______, _______, GIT_CHECKOUT_B, _______, GIT_CHECKOUT_MASTER, _______, _______ \ | |
), | |
[_ADJUST] = LAYOUT_ortho_3x11( \ | |
RESET, EEP_RST, DEBUG, _______, _______, _______, _______, _______, _______, _______, _______, \ | |
RGB_TOG, RGB_MOD, RGB_RMOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, _______, _______, \ | |
_______, KC_VOLD, KC_VOLU, KC__MUTE, _______, _______, _______, _______, _______, _______, _______ \ | |
), | |
}; | |
enum combo_events { | |
FU_FUNCTION, | |
IM_IMPORT | |
}; | |
const uint16_t PROGMEM function_combo[] = {KC_F, KC_U, COMBO_END}; | |
const uint16_t PROGMEM import_combo[] = {KC_I, KC_M, COMBO_END}; | |
combo_t key_combos[COMBO_COUNT] = { | |
[FU_FUNCTION] = COMBO_ACTION(function_combo), | |
[IM_IMPORT] = COMBO_ACTION(import_combo), | |
}; | |
void process_combo_event(uint8_t combo_index, bool pressed) { | |
switch(combo_index) { | |
case FU_FUNCTION: | |
if (pressed) { | |
SEND_STRING("function"); | |
} | |
break; | |
case IM_IMPORT: | |
if (pressed) { | |
SEND_STRING("import"); | |
} | |
break; | |
} | |
} | |
void process_record_macros_user(uint16_t keycode, keyrecord_t *record) { | |
if (record->event.pressed) { | |
switch (keycode) { | |
case GIT_PULL: | |
SEND_STRING("git pull"SS_TAP(X_ENTER)); | |
break; | |
case GIT_CHECKOUT_MASTER: | |
SEND_STRING("git checkout master"SS_TAP(X_ENTER)); | |
break; | |
case GIT_CHECKOUT_B: | |
SEND_STRING("git checkout -b "); | |
break; | |
case GIT_PULL_REBASE_MASTER: | |
SEND_STRING("git pull --rebase origin master"SS_TAP(X_ENTER)); | |
break; | |
case GIT_ADD_ALL: | |
SEND_STRING("git add --all"SS_TAP(X_ENTER)); | |
break; | |
case GIT_COMMIT: | |
SEND_STRING("git commit -m \"\""SS_TAP(X_LEFT)); | |
break; | |
case GIT_AMEND: | |
SEND_STRING("git commit --amend"SS_TAP(X_ENTER)); | |
break; | |
case GIT_PUSH_U: | |
SEND_STRING("git push -u origin $(git rev-parse --abbrev-ref HEAD)"SS_TAP(X_ENTER)); | |
break; | |
case GIT_PUSH: | |
SEND_STRING("git push"SS_TAP(X_ENTER)); | |
break; | |
case GIT_PUSH_FORCE: | |
SEND_STRING("git push --force"SS_TAP(X_ENTER)); | |
break; | |
case GIT_STATUS: | |
SEND_STRING("git status"SS_TAP(X_ENTER)); | |
break; | |
case VIM_WQ: | |
SEND_STRING(SS_TAP(X_ESCAPE)":wq"SS_TAP(X_ENTER)); | |
break; | |
case VIM_Q: | |
SEND_STRING(SS_TAP(X_ESCAPE)":q"SS_TAP(X_ENTER)); | |
break; | |
} | |
} | |
} | |
uint16_t last_keycode = _______; | |
bool check_follower_key( | |
uint16_t keycode, | |
keyrecord_t *record, | |
uint16_t followed, | |
uint16_t replacement, | |
uint16_t modifier | |
) { | |
if (last_keycode == followed && record -> event.pressed) { | |
register_code(modifier); | |
register_code(replacement); | |
return true; | |
} else if (last_keycode == followed && !(record -> event.pressed)) { | |
unregister_code(replacement); | |
unregister_code(modifier); | |
last_keycode = replacement; | |
return true; | |
} | |
return false; | |
} | |
bool process_record_follower_keys_user(uint16_t keycode, keyrecord_t *record) { | |
switch (keycode) { | |
case KC_COMM: | |
if (check_follower_key(keycode, record, KC_DOT, KC_SLSH, _______)) { | |
return true; | |
} | |
case KC_MINS: | |
if (check_follower_key(keycode, record, KC_EQL, KC_DOT, KC_LSFT)) { | |
return true; | |
} | |
default: | |
last_keycode = keycode; | |
return false; | |
} | |
} | |
bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |
process_record_macros_user(keycode, record); | |
if (process_record_follower_keys_user(keycode, record)) { | |
return false; | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment