keymap.c 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. /* Copyright 2018 Christon DeWan
  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. #include "xtonhasvim.h"
  18. /************************************
  19. * states
  20. ************************************/
  21. enum layers {
  22. _QWERTY,
  23. _LOWER,
  24. _RAISE,
  25. _ADJUST,
  26. _MOVE,
  27. _MOUSE,
  28. _CMD
  29. };
  30. extern uint8_t vim_cmd_layer(void) { return _CMD; }
  31. enum keymap_keycodes {
  32. RAISE = VIM_SAFE_RANGE,
  33. LOWER
  34. };
  35. /************************************
  36. * keymaps!
  37. ************************************/
  38. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  39. /* Qwerty
  40. * ,-----------------------------------------------------------------------------------.
  41. * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp |
  42. * |------+------+------+------+------+-------------+------+------+------+------+------|
  43. * | Ctrl*| A | S | D | F | G | H | J | K | L | ;* | ' |
  44. * |------+------+------+------+------+------|------+------+------+------+------+------|
  45. * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter |
  46. * |------+------+------+------+------+------+------+------+------+------+------+------|
  47. * | chkwm| | Alt | GUI | Lower* | Raise* | SPC | GUI | | Vim |
  48. * `-----------------------------------------------------------------------------------'
  49. *
  50. * - Ctrl acts as Esc when tapped.
  51. * - Holding ; switches to movement layer.
  52. * - Tapping raise or lower produces space.
  53. */
  54. [_QWERTY] = LAYOUT_ortho_4x12_2x2u( \
  55. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, \
  56. LCTL_T(KC_ESC), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, LT(_MOVE,KC_SCLN), KC_QUOT, \
  57. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_ENT) , \
  58. LSFT(KC_LALT), MO(_MOVE), KC_LALT, KC_LGUI, LT(_LOWER, KC_SPC), LT(_RAISE, KC_SPC), KC_RGUI, KC_RALT, MO(_MOVE), VIM_START \
  59. ),
  60. /* Lower
  61. * ,-----------------------------------------------------------------------------------.
  62. * | ~ | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | { | } | Bksp |
  63. * |------+------+------+------+------+-------------+------+------+------+------+------|
  64. * | Del | ! | @ | # | $ | % | ^ | & | * | ( | ) | | |
  65. * |------+------+------+------+------+------|------+------+------+------+------+------|
  66. * | | F7 | F8 | F9 | F10 | F11 | F12 | | Next | Vol- | Vol+ | Play |
  67. * |------+------+------+------+------+------+------+------+------+------+------+------|
  68. * | | Bail | | | | Raise | | | Bail | |
  69. * `-----------------------------------------------------------------------------------'
  70. */
  71. [_LOWER] = LAYOUT_ortho_4x12_2x2u( \
  72. KC_TILD, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_BSPC, \
  73. KC_DEL, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_PIPE, \
  74. _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, X_____X, X_____X, X_____X, X_____X, FIREY_RETURN, \
  75. RESET, TO(_QWERTY), _______, _______, _______, MO(_RAISE), _______, _______, TO(_QWERTY), X_____X \
  76. ),
  77. /* Raise
  78. * ,-----------------------------------------------------------------------------------.
  79. * | ` | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | Bksp |
  80. * |------+------+------+------+------+-------------+------+------+------+------+------|
  81. * | Del | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | \ |
  82. * |------+------+------+------+------+------|------+------+------+------+------+------|
  83. * | | F7 | F8 | F9 | F10 | F11 | F12 | | Next | Vol- | Vol+ | Play |
  84. * |------+------+------+------+------+------+------+------+------+------+------+------|
  85. * | | Bail | | | Lower | | | | Bail | |
  86. * `-----------------------------------------------------------------------------------'
  87. */
  88. [_RAISE] = LAYOUT_ortho_4x12_2x2u( \
  89. KC_GRV, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSPC, \
  90. KC_DEL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSLS, \
  91. _______, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, FIREY_RETURN, \
  92. X_____X, TO(_QWERTY), _______, _______, MO(_LOWER), _______, _______, _______, TO(_QWERTY), RESET \
  93. ),
  94. /* Adjust (Lower + Raise)
  95. * ,-------------------------------------------------------------------------------------.
  96. * |BL Raise| | | | | | | | | | | |
  97. * |--------+------+------+------+------+-------------+------+------+------+------+------|
  98. * |BL Lower| | | | | | | | | | | |
  99. * |--------+------+------+------+------+------|------+------+------+------+------+------|
  100. * |BL STEP | | | | | | | Next | Vol- | Vol+ | Play | |
  101. * |--------+------+------+------+------+------+------+------+------+------+------+------|
  102. * |Backlite| Mouse| | | | | | | Bail | |
  103. * `-------------------------------------------------------------------------------------'
  104. */
  105. [_ADJUST] = LAYOUT_ortho_4x12_2x2u( \
  106. BL_INC, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, \
  107. BL_DEC, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, \
  108. BL_STEP, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY, X_____X, \
  109. BL_TOGG, TO(_MOUSE), _______, _______, _______, _______, _______, _______, TO(_QWERTY), X_____X \
  110. ),
  111. /* movement layer (hold semicolon) */
  112. [_MOVE] = LAYOUT_ortho_4x12_2x2u( \
  113. TO(_QWERTY), X_____X, X_____X, X_____X, X_____X, X_____X, KC_HOME, KC_PGDN, KC_PGUP, KC_END, X_____X, X_____X, \
  114. _______, X_____X, LGUI(KC_LBRC), LGUI(LSFT(KC_LBRC)), LGUI(LSFT(KC_RBRC)), LGUI(KC_RBRC), KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, X_____X, \
  115. _______, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, _______, \
  116. _______, _______, _______, _______, _______, _______, _______, _______, _______, X_____X \
  117. ),
  118. /* mouse layer
  119. */
  120. [_MOUSE] = LAYOUT_ortho_4x12_2x2u( \
  121. TO(_QWERTY), X_____X, X_____X, KC_MS_UP, X_____X, X_____X, KC_MS_WH_LEFT, KC_MS_WH_DOWN, KC_MS_WH_UP, KC_MS_WH_RIGHT, X_____X, X_____X , \
  122. _______, X_____X, KC_MS_LEFT, KC_MS_DOWN, KC_MS_RIGHT, X_____X, X_____X, KC_MS_BTN1, KC_MS_BTN2, KC_MS_BTN3, X_____X, X_____X, \
  123. _______, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, X_____X, _______, \
  124. _______, TO(_QWERTY), _______, _______, _______, _______, _______, _______, TO(_QWERTY), X_____X \
  125. ),
  126. /* vim command layer.
  127. */
  128. [_CMD] = LAYOUT_ortho_4x12_2x2u( \
  129. X_____X, X_____X, VIM_W, VIM_E, X_____X, X_____X, VIM_Y, VIM_U, VIM_I, VIM_O, VIM_P, X_____X, \
  130. VIM_ESC, VIM_A, VIM_S, VIM_D, X_____X, VIM_G, VIM_H, VIM_J, VIM_K, VIM_L, X_____X, X_____X, \
  131. VIM_SHIFT, X_____X, VIM_X, VIM_C, VIM_V, VIM_B, X_____X, X_____X, VIM_COMMA, VIM_PERIOD, X_____X, VIM_SHIFT, \
  132. _______, TO(_QWERTY), _______, _______, X_____X, X_____X, _______, _______, TO(_QWERTY), X_____X \
  133. )
  134. };
  135. uint32_t layer_state_set_user(uint32_t state) {
  136. return update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST);
  137. }