keymap.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* Copyright 2021 John Mueller
  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. _VIMA,
  19. _VIMI
  20. };
  21. enum my_keycodes {
  22. CLUTCH_A = QK_USER,
  23. CLUTCH_I
  24. };
  25. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  26. /* Base */
  27. [_VIMA] = LAYOUT(
  28. TO(_VIMA), TO(_VIMI), CLUTCH_A
  29. ),
  30. [_VIMI] = LAYOUT(
  31. TO(_VIMA), TO(_VIMI), CLUTCH_I
  32. )
  33. };
  34. /* Layer-specific lighting */
  35. layer_state_t layer_state_set_user(layer_state_t state) {
  36. writePin(F4, !layer_state_cmp(state, _VIMA));
  37. writePin(F5, !layer_state_cmp(state, _VIMI));
  38. return state;
  39. };
  40. /* Define vim-clutching */
  41. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  42. switch (keycode) {
  43. case CLUTCH_A:
  44. if (record->event.pressed) {
  45. tap_code_delay(KC_ESC, 50);
  46. tap_code_delay(KC_A, 50);
  47. } else {
  48. tap_code_delay(KC_ESC, 50);
  49. }
  50. break;
  51. case CLUTCH_I:
  52. if (record->event.pressed) {
  53. tap_code_delay(KC_ESC, 50);
  54. tap_code_delay(KC_I, 50);
  55. } else {
  56. tap_code_delay(KC_ESC, 50);
  57. }
  58. break;
  59. }
  60. return true;
  61. };