keymap.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. /* Copyright 2020
  2. Sergi Meseguer <zigotica@gmail.com>
  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. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include "zigotica.h"
  15. #include "raw_hid.h"
  16. #ifdef RAW_ENABLE
  17. void raw_hid_receive(uint8_t* data, uint8_t length) {
  18. layer_clear();
  19. if (data[0] == 99) {
  20. layer_on(_BASE);
  21. }
  22. else {
  23. layer_on(data[0]);
  24. }
  25. }
  26. #endif
  27. // Custom Keycodes
  28. #define MODE_1 TO(_BASE)
  29. #define MODE_2 TO(_FIGMA)
  30. #define MODE_3 TO(_BROWSER)
  31. #define MODE_4 TO(_VIM)
  32. enum custom_keycodes {
  33. VIM_SIF = SAFE_RANGE,
  34. VIM_SIP,
  35. VIM_RIF,
  36. VIM_RIP,
  37. VIM_NEW
  38. };
  39. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  40. switch (keycode) {
  41. case VIM_SIF:// Search in File
  42. if (record->event.pressed) {
  43. register_code(KC_ESC);
  44. tap_code(KC_SLASH);
  45. } else { // released
  46. unregister_code(KC_ESC);
  47. }
  48. break;
  49. case VIM_SIP:// Search in Project
  50. if (record->event.pressed) {
  51. register_code(KC_ESC);
  52. SEND_STRING(":Ag ");
  53. } else { // released
  54. unregister_code(KC_ESC);
  55. }
  56. break;
  57. case VIM_RIF:// Replace in File
  58. if (record->event.pressed) {
  59. register_code(KC_ESC);
  60. SEND_STRING(":%s/a/b/g");
  61. } else { // released
  62. unregister_code(KC_ESC);
  63. }
  64. break;
  65. case VIM_RIP:// Replace in Project
  66. if (record->event.pressed) {
  67. register_code(KC_ESC);
  68. SEND_STRING(":cdo %s/a/b/g");
  69. } else { // released
  70. unregister_code(KC_ESC);
  71. }
  72. break;
  73. case VIM_NEW:// New buffer
  74. if (record->event.pressed) {
  75. SEND_STRING("\e:vnew\n");
  76. } else { // released
  77. unregister_code(KC_ENT);
  78. unregister_code(KC_ESC);
  79. }
  80. break;
  81. }
  82. return true;
  83. };
  84. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  85. /*
  86. * BASE Layer
  87. *
  88. * ,-----------------------------.
  89. * | | BASE | FIGM | |
  90. * |-------+------+------+-------|
  91. * |VOL/PLY| BROW | VIM | SCROLL|
  92. * |-------+------+------+-------|
  93. * |-------+-------+-------|
  94. * | o | o | o |
  95. * |-------+-------+-------|
  96. * | o | o | o |
  97. * |-------+-------+-------|
  98. */
  99. [_BASE] = LAYOUT(
  100. MODE_1, MODE_2,
  101. ZK_MEDIA, MODE_3, MODE_4, _______,
  102. _______, _______, _______,
  103. _______, _______, _______
  104. ),
  105. /*
  106. * FIGMA Layer
  107. *
  108. * ,-----------------------------.
  109. * | | BASE | FIGM | |
  110. * |-------+------+------+-------|
  111. * | TABS | BROW | VIM | ZOOM |
  112. * |-------+------+------+-------|
  113. * |-------+-------+-------|
  114. * |ZOOMFIT| GRIDS | FULL |
  115. * |-------+-------+-------|
  116. * |ZOOM100| NEXT | COLOR |
  117. * |-------+-------+-------|
  118. */
  119. [_FIGMA] = LAYOUT(
  120. _______, _______,
  121. _______, _______, _______, _______,
  122. LSFT(KC_1), LCTL(KC_G), LGUI(KC_BSLS),
  123. LSFT(KC_0), KC_N, LCTL(KC_C)
  124. ),
  125. /*
  126. * BROWSER Layer
  127. *
  128. * ,-----------------------------.
  129. * | | BASE | FIGM | |
  130. * |-------+------+------+-------|
  131. * | TABS | BROW | VIM | SCROLL|
  132. * |-------+------+------+-------|
  133. * |-------+-------+-------|
  134. * |SEARCH | BOOKM | DEVTL |
  135. * |-------+-------+-------|
  136. * |ZOOM100| MUTE | READ |
  137. * |-------+-------+-------|
  138. */
  139. [_BROWSER] = LAYOUT(
  140. _______, _______,
  141. _______, _______, _______, _______,
  142. G(KC_F), G(KC_D), G(A(KC_I)),
  143. G(KC_0), C(KC_M), G(A(KC_R))
  144. ),
  145. /*
  146. * VIM Layer
  147. *
  148. * ,-----------------------------.
  149. * | | BASE | FIGM | |
  150. * |-------+------+------+-------|
  151. * |BUFFER | BROW | VIM | SCROLL|
  152. * |-------+------+------+-------|
  153. * |-------+-------+-------|
  154. * |SRCH FL|REPL FL|NEW BUF|
  155. * |-------+-------+-------|
  156. * |SRCH PR|REPL PR| o |
  157. * |-------+-------+-------|
  158. */
  159. [_VIM] = LAYOUT(
  160. _______, _______,
  161. _______, _______, _______, _______,
  162. VIM_SIF, VIM_RIF, VIM_NEW,
  163. VIM_SIP, VIM_RIP, _______
  164. ),
  165. };