keymap.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* Copyright 2019 Danny Nguyen <danny@keeb.io>
  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 encoder_names {
  18. _LEFT,
  19. _RIGHT,
  20. _MIDDLE,
  21. };
  22. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  23. /*
  24. | Knob 1: Vol Dn/Up | | Knob 2: Page Dn/Up |
  25. | Press: Mute | Home | Press: Play/Pause |
  26. | Hold: Layer 2 | Up | RGB Mode |
  27. | Left | Down | Right |
  28. */
  29. [0] = LAYOUT(
  30. KC_MUTE, KC_HOME, KC_MPLY,
  31. MO(1) , KC_UP , RGB_MOD,
  32. KC_LEFT, KC_DOWN, KC_RGHT
  33. ),
  34. /*
  35. | QK_BOOT | N/A | Media Stop |
  36. | Held: Layer 2 | Home | RGB Mode |
  37. | Media Previous | End | Media Next |
  38. */
  39. [1] = LAYOUT(
  40. QK_BOOT , BL_STEP, KC_STOP,
  41. _______, KC_HOME, RGB_MOD,
  42. KC_MPRV, KC_END , KC_MNXT
  43. ),
  44. };
  45. bool encoder_update_user(uint8_t index, bool clockwise) {
  46. if (index == _LEFT) {
  47. if (clockwise) {
  48. tap_code(KC_VOLU);
  49. } else {
  50. tap_code(KC_VOLD);
  51. }
  52. }
  53. else if (index == _MIDDLE) {
  54. if (clockwise) {
  55. tap_code(KC_DOWN);
  56. } else {
  57. tap_code(KC_UP);
  58. }
  59. }
  60. else if (index == _RIGHT) {
  61. if (clockwise) {
  62. tap_code(KC_PGDN);
  63. } else {
  64. tap_code(KC_PGUP);
  65. }
  66. }
  67. return false;
  68. }