keymap.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /* Copyright 2020 Dane Evans
  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. // MINI MACRO 5
  17. #include QMK_KEYBOARD_H
  18. enum layers {
  19. _MAIN,
  20. _MEDIA,
  21. _DISCORD,
  22. _PHOTOSHOP
  23. };
  24. // Tap Dance declarations
  25. enum tap_dances{
  26. TD_TO_DISCORD,
  27. TD_TO_PHOTOSHOP,
  28. TD_TO_MEDIA,
  29. TD_TO_MAIN,
  30. TD_RESET_SLIDER
  31. };
  32. void encoder_update_user(uint8_t index, bool clockwise) {
  33. if (index == 0) { /* First encoder*/
  34. switch(biton32(layer_state)){
  35. case _MAIN:
  36. if (clockwise) {
  37. tap_code(KC_VOLU);
  38. } else {
  39. tap_code(KC_VOLD);
  40. }
  41. break;
  42. case _MEDIA:
  43. if (clockwise) {
  44. tap_code(KC_VOLU);
  45. } else {
  46. tap_code(KC_VOLD);
  47. }
  48. break;
  49. case _DISCORD:
  50. if (clockwise) {
  51. tap_code(KC_VOLU);
  52. } else {
  53. tap_code(KC_VOLD);
  54. }
  55. break;
  56. case _PHOTOSHOP:
  57. if (clockwise) {
  58. tap_code(KC_UP);
  59. } else {
  60. tap_code(KC_DOWN);
  61. }
  62. break;
  63. default:
  64. if (clockwise) {
  65. tap_code(KC_VOLU);
  66. } else {
  67. tap_code(KC_VOLD);
  68. }
  69. break;
  70. }
  71. }
  72. }
  73. //
  74. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { //buttion closest to usb is first
  75. [_MAIN] = LAYOUT_ortho_1x5(
  76. TD(TD_TO_DISCORD), TO(_DISCORD), KC_C, RGB_TOG, TD(TD_TO_PHOTOSHOP)
  77. ),
  78. [_MEDIA] = LAYOUT_ortho_1x5(
  79. TD(TD_TO_MAIN), KC_MEDIA_PREV_TRACK, KC_MEDIA_NEXT_TRACK, KC_MEDIA_PLAY_PAUSE, KC_MEDIA_STOP
  80. ),
  81. [_DISCORD] = LAYOUT_ortho_1x5(
  82. TD(TD_TO_MAIN), TD(TD_TO_MEDIA), KC_Q, KC_R, MEH(KC_UP)
  83. )
  84. ,
  85. [_PHOTOSHOP] = LAYOUT_ortho_1x5(
  86. TD(TD_RESET_SLIDER) , C(KC_Z), C(KC_Y), KC_P, KC_G
  87. )
  88. };
  89. layer_state_t layer_state_set_user(layer_state_t state) {
  90. if (layer_state_cmp(state, _MAIN)) // this one not working
  91. rgblight_sethsv_at(HSV_GREEN, 0);
  92. if (layer_state_cmp(state, _MEDIA))
  93. rgblight_sethsv_at(HSV_RED, 0);
  94. if (layer_state_cmp(state, _DISCORD))
  95. rgblight_sethsv_at(HSV_BLUE, 0);
  96. if (layer_state_cmp(state, _PHOTOSHOP))
  97. rgblight_sethsv_at(HSV_PURPLE, 0);
  98. return state;
  99. }
  100. void keyboard_post_init_user(void) {
  101. //rgblight_mode(1);
  102. rgblight_sethsv_at(HSV_GREEN, 0);
  103. }
  104. // Tap Dance definitions
  105. qk_tap_dance_action_t tap_dance_actions[] = {
  106. // Tap once for Escape, twice for Caps Lock
  107. [TD_TO_DISCORD] = ACTION_TAP_DANCE_LAYER_MOVE(KC_MUTE, _DISCORD),
  108. [TD_TO_PHOTOSHOP] = ACTION_TAP_DANCE_LAYER_MOVE(KC_E, _PHOTOSHOP),
  109. [TD_TO_MEDIA] = ACTION_TAP_DANCE_LAYER_MOVE(KC_E, _MEDIA),
  110. [TD_TO_MAIN] = ACTION_TAP_DANCE_LAYER_MOVE(KC_MUTE, _MAIN),
  111. [TD_RESET_SLIDER] = ACTION_TAP_DANCE_LAYER_MOVE(KC_0, _MAIN)
  112. };