logo

qmk_firmware

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

keymap.c (2461B)


  1. /* Copyright 2021 Valdydesu_
  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 planck_layers {
  18. _1,
  19. _2,
  20. _3,
  21. _4
  22. };
  23. #define L1 PDF(_1)
  24. #define L2 PDF(_2)
  25. #define L3 PDF(_3)
  26. #define LOWER MO(_4)
  27. #define IND_1 D4
  28. #define IND_2 C6
  29. #define IND_3 D7
  30. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  31. [_1] = LAYOUT(
  32. KC_ESC, KC_F1, KC_F2,
  33. LOWER, KC_Z, KC_X),
  34. [_2] = LAYOUT(
  35. LALT(KC_TAB), LGUI(KC_TAB), LCTL(KC_S),
  36. LOWER, LCTL(KC_C), LCTL(KC_V)),
  37. [_3] = LAYOUT(
  38. KC_TRNS, KC_TRNS, KC_TRNS,
  39. KC_TRNS, KC_TRNS, KC_TRNS),
  40. [_4] = LAYOUT(
  41. L1, L2, L3,
  42. _______, _______, _______),
  43. };
  44. layer_state_t layer_state_set_user(layer_state_t state) {
  45. state = update_tri_layer_state(state, _4, X_PAUSE, X_PAUSE);
  46. gpio_write_pin(IND_1, layer_state_cmp(state, 1));
  47. gpio_write_pin(IND_2, layer_state_cmp(state, 2));
  48. gpio_write_pin(IND_3, layer_state_cmp(state, 3));
  49. return state;
  50. }
  51. void matrix_init_user(void) {
  52. //init the Pro Micro on-board LEDs
  53. gpio_set_pin_output(IND_1);
  54. gpio_set_pin_output(IND_2);
  55. gpio_set_pin_output(IND_3);
  56. //set to off
  57. gpio_write_pin_high(IND_1);
  58. gpio_write_pin_high(IND_2);
  59. gpio_write_pin_high(IND_3);
  60. }
  61. bool encoder_update_user(uint8_t index, bool clockwise) {
  62. if (layer_state_is(_1)) {
  63. if (clockwise) {
  64. tap_code(KC_UP);
  65. } else {
  66. tap_code(KC_DOWN);
  67. }
  68. } else if (layer_state_is(_2)) {
  69. if (clockwise) {
  70. tap_code(KC_RGHT);
  71. } else {
  72. tap_code(KC_LEFT);
  73. }
  74. } else if (layer_state_is(_3)) {
  75. if (clockwise) {
  76. tap_code(KC_VOLU);
  77. } else {
  78. tap_code(KC_VOLD);
  79. }
  80. }
  81. return true;
  82. }