diff options
Diffstat (limited to 'keyboards/bobpad/keymaps/via/keymap.c')
| -rw-r--r-- | keyboards/bobpad/keymaps/via/keymap.c | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/keyboards/bobpad/keymaps/via/keymap.c b/keyboards/bobpad/keymaps/via/keymap.c new file mode 100644 index 000000000..e4fb137c4 --- /dev/null +++ b/keyboards/bobpad/keymaps/via/keymap.c | |||
| @@ -0,0 +1,106 @@ | |||
| 1 | /* Copyright 2021 Ananya Kirti | ||
| 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 | |||
| 18 | #include QMK_KEYBOARD_H | ||
| 19 | |||
| 20 | |||
| 21 | bool is_alt_tab_active = false; | ||
| 22 | uint16_t alt_tab_timer = 0; | ||
| 23 | |||
| 24 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 25 | [0] = LAYOUT_ortho_2x3( | ||
| 26 | KC_MEDIA_STOP, KC_MEDIA_PLAY_PAUSE, KC__MUTE, | ||
| 27 | KC_MEDIA_REWIND, KC_MEDIA_FAST_FORWARD, KC_PGDN | ||
| 28 | ), | ||
| 29 | [1] = LAYOUT_ortho_2x3( | ||
| 30 | _______, _______, _______, | ||
| 31 | _______, _______, _______ | ||
| 32 | ), | ||
| 33 | [2] = LAYOUT_ortho_2x3( | ||
| 34 | _______, _______, _______, | ||
| 35 | _______, _______, _______ | ||
| 36 | ), | ||
| 37 | [3] = LAYOUT_ortho_2x3( | ||
| 38 | _______, _______, _______, | ||
| 39 | _______, _______, _______ | ||
| 40 | ), | ||
| 41 | }; | ||
| 42 | |||
| 43 | |||
| 44 | |||
| 45 | // D4 D0 | ||
| 46 | // C6 E6 D7 | ||
| 47 | |||
| 48 | void matrix_scan_user(void) { | ||
| 49 | writePin(C6, layer_state_is(1)); | ||
| 50 | writePin(E6, layer_state_is(2)); | ||
| 51 | writePin(D7, layer_state_is(3)); | ||
| 52 | writePin(D4, layer_state_is(4)); | ||
| 53 | writePin(D0, layer_state_is(5)); | ||
| 54 | if (is_alt_tab_active) { | ||
| 55 | if (timer_elapsed(alt_tab_timer) > 1000) { | ||
| 56 | unregister_code(KC_LWIN); | ||
| 57 | is_alt_tab_active = false; | ||
| 58 | } | ||
| 59 | } | ||
| 60 | } | ||
| 61 | |||
| 62 | bool led_update_user(led_t led_state) { | ||
| 63 | return false; | ||
| 64 | }; | ||
| 65 | |||
| 66 | |||
| 67 | |||
| 68 | bool encoder_update_user(uint8_t index, bool clockwise) { | ||
| 69 | if(IS_LAYER_ON(1)) { // on 1st layer | ||
| 70 | if (clockwise) { | ||
| 71 | if (!is_alt_tab_active) { | ||
| 72 | is_alt_tab_active = true; | ||
| 73 | register_code(KC_LWIN); | ||
| 74 | } | ||
| 75 | alt_tab_timer = timer_read(); | ||
| 76 | tap_code16(KC_TAB); | ||
| 77 | } else { | ||
| 78 | alt_tab_timer = timer_read(); | ||
| 79 | tap_code16(S(KC_TAB)); | ||
| 80 | } | ||
| 81 | } | ||
| 82 | // 2nd layer | ||
| 83 | else if(IS_LAYER_ON(2)) { | ||
| 84 | if (clockwise) { | ||
| 85 | tap_code(KC_DOWN); | ||
| 86 | } else { | ||
| 87 | tap_code(KC_UP); | ||
| 88 | } | ||
| 89 | } | ||
| 90 | else if(IS_LAYER_ON(3)) { | ||
| 91 | if (clockwise) { | ||
| 92 | tap_code(KC_BRIU); | ||
| 93 | } else { | ||
| 94 | tap_code(KC_BRID); | ||
| 95 | } | ||
| 96 | } | ||
| 97 | // default layer | ||
| 98 | else if(IS_LAYER_ON(0)) { | ||
| 99 | if (clockwise) { | ||
| 100 | tap_code(KC_VOLU); | ||
| 101 | } else { | ||
| 102 | tap_code(KC_VOLD); | ||
| 103 | } | ||
| 104 | } | ||
| 105 | return false; | ||
| 106 | } | ||
