qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

keymap.c (1598B)


      1 /* Copyright 2023 Brandon Lu
      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 #include QMK_KEYBOARD_H
     17 
     18 enum layer_names {
     19     _VC,
     20     _VIM
     21 };
     22 
     23 enum my_keycodes {
     24     USER_CLUTCH = QK_USER
     25 };
     26 
     27 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     28     /* Base */
     29     [_VC] = LAYOUT(
     30         TO(_VC),    TO(_VIM),  KC_F13
     31     ),
     32 
     33     [_VIM] = LAYOUT(
     34         TO(_VC),    TO(_VIM),  USER_CLUTCH
     35     )
     36 };
     37 
     38 /* Layer-specific lighting */
     39 layer_state_t layer_state_set_user(layer_state_t state) {
     40     gpio_write_pin(F4, !layer_state_cmp(state, _VC));
     41     gpio_write_pin(F5, !layer_state_cmp(state, _VIM));
     42     return state;
     43 };
     44 
     45 /* Define vim-clutching */
     46 bool process_record_user(uint16_t keycode, keyrecord_t *record) {
     47     switch (keycode) {
     48     case USER_CLUTCH:
     49         if (record->event.pressed) {
     50             tap_code_delay(KC_ESC, 50); 
     51             tap_code_delay(KC_A, 50); 
     52         } else {
     53             tap_code_delay(KC_ESC, 50); 
     54         }
     55         break;
     56     }
     57     return true;
     58 };