diff options
Diffstat (limited to 'keyboards/anavi/macropad8/keymaps/git/keymap.c')
| -rw-r--r-- | keyboards/anavi/macropad8/keymaps/git/keymap.c | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/keyboards/anavi/macropad8/keymaps/git/keymap.c b/keyboards/anavi/macropad8/keymaps/git/keymap.c new file mode 100644 index 000000000..0b0099fd5 --- /dev/null +++ b/keyboards/anavi/macropad8/keymaps/git/keymap.c | |||
| @@ -0,0 +1,144 @@ | |||
| 1 | /* Copyright 2021 Leon Anavi <leon@anavi.org> | ||
| 2 | * | ||
| 3 | * This program is free software: you can redistribute it and/or modify | ||
| 4 | * it under the terms of the GNU General Public License as published by | ||
| 5 | * the Free Software Foundation, either version 2 of the License, or | ||
| 6 | * (at your option) any later version. | ||
| 7 | * | ||
| 8 | * This program is distributed in the hope that it will be useful, | ||
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 11 | * GNU General Public License for more details. | ||
| 12 | * | ||
| 13 | * You should have received a copy of the GNU General Public License | ||
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include QMK_KEYBOARD_H | ||
| 18 | |||
| 19 | #define _MAIN 0 | ||
| 20 | #define _FN 1 | ||
| 21 | |||
| 22 | /* | ||
| 23 | * This keymap contains the following shortcuts for Git. On the | ||
| 24 | * first row from left to right: | ||
| 25 | * | ||
| 26 | * git status | ||
| 27 | * git log | ||
| 28 | * git pull | ||
| 29 | * git push | ||
| 30 | * | ||
| 31 | * On the second row from left to right: | ||
| 32 | * | ||
| 33 | * git diff | ||
| 34 | * git add | ||
| 35 | * git commit | ||
| 36 | * FN key to switch to the 2nd layout and control lights | ||
| 37 | * | ||
| 38 | */ | ||
| 39 | |||
| 40 | enum custom_keycodes { | ||
| 41 | GITCOMMIT = SAFE_RANGE, | ||
| 42 | GITPUSH, | ||
| 43 | GITPULL, | ||
| 44 | GITSTATUS, | ||
| 45 | GITDIFF, | ||
| 46 | GITLOG, | ||
| 47 | GITADD | ||
| 48 | }; | ||
| 49 | |||
| 50 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 51 | switch (keycode) { | ||
| 52 | case GITCOMMIT: | ||
| 53 | if (record->event.pressed) { | ||
| 54 | SEND_STRING("git commit -s\n"); | ||
| 55 | } | ||
| 56 | break; | ||
| 57 | case GITPUSH: | ||
| 58 | if (record->event.pressed) { | ||
| 59 | SEND_STRING("git push\n"); | ||
| 60 | } | ||
| 61 | break; | ||
| 62 | case GITPULL: | ||
| 63 | if (record->event.pressed) { | ||
| 64 | SEND_STRING("git pull\n"); | ||
| 65 | } | ||
| 66 | break; | ||
| 67 | case GITSTATUS: | ||
| 68 | if (record->event.pressed) { | ||
| 69 | SEND_STRING("git status\n"); | ||
| 70 | } | ||
| 71 | break; | ||
| 72 | case GITDIFF: | ||
| 73 | if (record->event.pressed) { | ||
| 74 | SEND_STRING("git diff "); | ||
| 75 | } | ||
| 76 | break; | ||
| 77 | case GITLOG: | ||
| 78 | if (record->event.pressed) { | ||
| 79 | SEND_STRING("git log\n"); | ||
| 80 | } | ||
| 81 | break; | ||
| 82 | case GITADD: | ||
| 83 | if (record->event.pressed) { | ||
| 84 | SEND_STRING("git add "); | ||
| 85 | } | ||
| 86 | break; | ||
| 87 | } | ||
| 88 | return true; | ||
| 89 | }; | ||
| 90 | |||
| 91 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 92 | [_MAIN] = LAYOUT_ortho_2x4( | ||
| 93 | GITSTATUS, GITLOG, GITPULL, GITPUSH, | ||
| 94 | GITDIFF, GITADD, GITCOMMIT, MO(_FN) | ||
| 95 | ), | ||
| 96 | |||
| 97 | [_FN] = LAYOUT_ortho_2x4( | ||
| 98 | RGB_TOG, RGB_MOD, RGB_M_R, RGB_M_SN, | ||
| 99 | BL_TOGG, BL_STEP, BL_BRTG, _______ | ||
| 100 | ) | ||
| 101 | }; | ||
| 102 | |||
| 103 | #ifdef OLED_DRIVER_ENABLE | ||
| 104 | oled_rotation_t oled_init_user(oled_rotation_t rotation) { | ||
| 105 | return OLED_ROTATION_180; // flips the display 180 degrees if offhand | ||
| 106 | } | ||
| 107 | |||
| 108 | void oled_task_user(void) { | ||
| 109 | // Host Keyboard Layer Status | ||
| 110 | oled_write_ln_P(PSTR("ANAVI Macro Pad 8"), false); | ||
| 111 | oled_write_P(PSTR("Active layer: "), false); | ||
| 112 | |||
| 113 | switch (get_highest_layer(layer_state)) { | ||
| 114 | case _MAIN: | ||
| 115 | oled_write_ln_P(PSTR("Git"), false); | ||
| 116 | break; | ||
| 117 | case _FN: | ||
| 118 | oled_write_ln_P(PSTR("FN"), false); | ||
| 119 | break; | ||
| 120 | default: | ||
| 121 | // Or use the write_ln shortcut over adding '\n' to the end of your string | ||
| 122 | oled_write_ln_P(PSTR("N/A"), false); | ||
| 123 | } | ||
| 124 | |||
| 125 | // Host Keyboard LED Status | ||
| 126 | led_t led_state = host_keyboard_led_state(); | ||
| 127 | oled_write_P(PSTR("Num Lock: "), false); | ||
| 128 | oled_write_ln_P(led_state.num_lock ? PSTR("On") : PSTR("Off"), false); | ||
| 129 | oled_write_P(PSTR("Caps Lock: "), false); | ||
| 130 | oled_write_ln_P(led_state.caps_lock ? PSTR("On") : PSTR("Off"), false); | ||
| 131 | oled_write_P(PSTR("Scroll Lock: "), false); | ||
| 132 | oled_write_ln_P(led_state.scroll_lock ? PSTR("On") : PSTR("Off"), false); | ||
| 133 | oled_write_P(PSTR("Backlit: "), false); | ||
| 134 | oled_write_ln_P(is_backlight_enabled() ? PSTR("On") : PSTR("Off"), false); | ||
| 135 | #ifdef RGBLIGHT_ENABLE | ||
| 136 | static char rgbStatusLine1[26] = {0}; | ||
| 137 | snprintf(rgbStatusLine1, sizeof(rgbStatusLine1), "RGB Mode: %d", rgblight_get_mode()); | ||
| 138 | oled_write_ln(rgbStatusLine1, false); | ||
| 139 | static char rgbStatusLine2[26] = {0}; | ||
| 140 | snprintf(rgbStatusLine2, sizeof(rgbStatusLine2), "h:%d s:%d v:%d", rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val()); | ||
| 141 | oled_write_ln(rgbStatusLine2, false); | ||
| 142 | #endif | ||
| 143 | } | ||
| 144 | #endif | ||
