You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
3.4 KiB

  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 | + |
  24. | |---------|---------|---------|---------|
  25. | | 1 | 2 | 3 | * |
  26. |-------------|---------|---------|---------|---------|
  27. | Play/pause | TT(1) | 0 | . | Enter |
  28. \-----------------------------------------------------'
  29. */
  30. [0] = LAYOUT(
  31. KC_P7, KC_P8, KC_P9, KC_BSPC,
  32. KC_P4, KC_P5, KC_P6, KC_KP_PLUS,
  33. KC_P1, KC_P2, KC_P3, KC_KP_ASTERISK,
  34. KC_MPLY, TT(1), KC_P0, KC_PDOT, KC_KP_ENTER
  35. ),
  36. /*
  37. SUB LAYER
  38. /-----------------------------------------------------`
  39. | | | | | Numlock |
  40. | |---------|---------|---------|---------|
  41. | | | | | - |
  42. | |---------|---------|---------|---------|
  43. | | | | | / |
  44. |-------------|---------|---------|---------|---------|
  45. | MUTE | | | | = |
  46. \-----------------------------------------------------'
  47. */
  48. [1] = LAYOUT(
  49. _______, _______, _______, KC_NLCK,
  50. _______, _______, _______, KC_KP_MINUS,
  51. _______, _______, _______, KC_KP_SLASH,
  52. KC_MUTE, _______, _______, _______, KC_KP_EQUAL
  53. ),
  54. };
  55. void encoder_update_user(uint8_t index, bool clockwise) {
  56. /* Custom encoder control - handles CW/CCW turning of encoder
  57. * Default behavior:
  58. * main layer:
  59. * CW: volume up
  60. * CCW: volume down
  61. * other layers:
  62. * CW: next track
  63. * CCW: previous track
  64. */
  65. if (index == 0) {
  66. switch (get_highest_layer(layer_state)) {
  67. case 0:
  68. // main layer - volume up (CW) and volume down (CCW)
  69. if (clockwise) {
  70. tap_code(KC_VOLU);
  71. } else {
  72. tap_code(KC_VOLD);
  73. }
  74. break;
  75. default:
  76. // other layers - media next (CW) and media previous (CCW)
  77. if (clockwise) {
  78. tap_code(KC_MNXT);
  79. } else {
  80. tap_code(KC_MPRV);
  81. }
  82. break;
  83. }
  84. }
  85. }