logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

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