keymap.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* Copyright 2020 imchipwood
  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. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  18. /*
  19. BASE LAYER
  20. /-----------------------------------------------------`
  21. | | 7 | 8 | 9 | Bkspc |
  22. | |---------|---------|---------|---------|
  23. | | 4 | 5 | 6 | Esc |
  24. | |---------|---------|---------|---------|
  25. | | 1 | 2 | 3 | Tab |
  26. |-------------|---------|---------|---------|---------|
  27. | Left mouse | TT(1) | 0 | . | Enter |
  28. \-----------------------------------------------------'
  29. */
  30. [0] = LAYOUT(
  31. KC_7, KC_8, KC_9, KC_BSPC,
  32. KC_4, KC_5, KC_6, KC_ESC,
  33. KC_1, KC_2, KC_3, KC_TAB,
  34. KC_BTN1, TT(1), KC_0, LSFT_T(KC_DOT), KC_ENTER
  35. ),
  36. /*
  37. SUB LAYER
  38. /-----------------------------------------------------`
  39. | | | | | Reset |
  40. | |---------|---------|---------|---------|
  41. | | | | | + |
  42. | |---------|---------|---------|---------|
  43. | | | | | - |
  44. |-------------|---------|---------|---------|---------|
  45. | LOCK | | | | = |
  46. \-----------------------------------------------------'
  47. */
  48. [1] = LAYOUT(
  49. _______, _______, _______, QK_BOOT,
  50. _______, _______, _______, KC_KP_PLUS,
  51. _______, _______, _______, KC_KP_MINUS,
  52. QK_LOCK, _______, _______, _______, KC_EQL
  53. ),
  54. };
  55. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  56. // If console is enabled, it will print the matrix position and status of each key pressed
  57. /*
  58. #ifdef CONSOLE_ENABLE
  59. uprintf("KL: kc: %u, col: %u, row: %u, pressed: %u\n", keycode, record->event.key.col, record->event.key.row, record->event.pressed);
  60. #endif
  61. */
  62. return true;
  63. }
  64. void keyboard_post_init_user(void) {
  65. // Customise these values to desired behaviour
  66. //debug_enable = true;
  67. //debug_matrix = true;
  68. //debug_keyboard = true;
  69. //debug_mouse = true;
  70. }
  71. bool encoder_update_user(uint8_t index, bool clockwise) {
  72. /* Custom encoder control - handles CW/CCW turning of encoder
  73. * Default behavior:
  74. * main layer:
  75. * CW: move mouse right
  76. * CCW: move mouse left
  77. * other layers:
  78. * CW: = (equals/plus - increase slider in Adobe products)
  79. * CCW: - (minus/underscore - decrease slider in adobe products)
  80. */
  81. if (index == 0) {
  82. switch (get_highest_layer(layer_state)) {
  83. case 0:
  84. // main layer - move mouse right (CW) and left (CCW)
  85. if (clockwise) {
  86. tap_code(KC_MS_R);
  87. } else {
  88. tap_code(KC_MS_L);
  89. }
  90. break;
  91. default:
  92. // other layers - =/+ (quals/plus) (CW) and -/_ (minus/underscore) (CCW)
  93. if (clockwise) {
  94. tap_code(KC_EQL);
  95. } else {
  96. tap_code(KC_MINS);
  97. }
  98. break;
  99. }
  100. }
  101. return true;
  102. }