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.

95 lines
3.5 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. #include "imchipwood.h"
  18. enum custom_layers {
  19. _BASE,
  20. _SUB,
  21. };
  22. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  23. /*
  24. BASE LAYER
  25. /-----------------------------------------------------`
  26. | | 7 | 8 | 9 | Bkspc |
  27. | |---------|---------|---------|---------|
  28. | | 4 | 5 | 6 | + |
  29. | |---------|---------|---------|---------|
  30. | | 1 | 2 | 3 | * |
  31. |-------------|---------|---------|---------|---------|
  32. | Play/Pause | TT(SUB) | 0 | . | Enter |
  33. \-----------------------------------------------------'
  34. */
  35. [_BASE] = LAYOUT(
  36. KC_P7, KC_P8, KC_P9, KC_BSPC,
  37. KC_P4, KC_P5, KC_P6, KC_KP_PLUS,
  38. KC_P1, KC_P2, KC_P3, KC_KP_ASTERISK,
  39. MEH_T(KC_MPLY), TT(_SUB), KC_P0, KC_PDOT, KC_KP_ENTER
  40. ),
  41. /*
  42. SUB LAYER
  43. /-----------------------------------------------------`
  44. | | F7 | F8 | F9 | Del/NLK |
  45. | |---------|---------|---------|---------|
  46. | | F4 | F5 | F6 | - |
  47. | |---------|---------|---------|---------|
  48. | | F1 | F2 | F3 | / |
  49. |-------------|---------|---------|---------|---------|
  50. | MUTE | | LSFT | LCTL | = |
  51. \-----------------------------------------------------'
  52. */
  53. [_SUB] = LAYOUT(
  54. TD(ALT_F7), KC_F8, KC_F9, TD(DEL_NLCK),
  55. KC_F4, TD(CTL_F5), KC_F6, KC_KP_MINUS,
  56. KC_F1, TD(ALT_F2), KC_F3, KC_KP_SLASH,
  57. KC_MUTE, _______, OSM(MOD_LSFT), OSM(MOD_LCTL), KC_KP_EQUAL
  58. )
  59. };
  60. bool encoder_update_user(uint8_t index, bool clockwise) {
  61. if (index == 0) {
  62. switch (get_highest_layer(layer_state)) {
  63. case _BASE:
  64. // main layer - volume up/down
  65. if (clockwise) {
  66. tap_code(KC_VOLU);
  67. } else {
  68. tap_code(KC_VOLD);
  69. }
  70. break;
  71. case _SUB:
  72. // sub layer - next/previous track
  73. if (clockwise) {
  74. tap_code(KC_MNXT);
  75. } else {
  76. tap_code(KC_MPRV);
  77. }
  78. break;
  79. default:
  80. // default - volume up/down
  81. if (clockwise) {
  82. tap_code(KC_VOLU);
  83. } else {
  84. tap_code(KC_VOLD);
  85. }
  86. break;
  87. }
  88. }
  89. return true;
  90. }