logo

qmk_firmware

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

keymap.c (4318B)


  1. /* Copyright 2021 Jay Greco
  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. // clang-format off
  18. enum layers {
  19. _BASE = 0,
  20. _FUNC
  21. };
  22. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  23. [_BASE] = LAYOUT_iso(
  24. KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_PAUS,
  25. KC_F13, KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_HOME,
  26. KC_F14, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_ENT, KC_END,
  27. KC_F15, KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_BSLS, KC_PGUP,
  28. KC_F16, KC_LSFT, KC_NUHS, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN,
  29. KC_F17, KC_LCTL, KC_LGUI, KC_LALT, MO(_FUNC), KC_SPC, KC_SPC, MO(_FUNC), KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT
  30. ),
  31. [_FUNC] = LAYOUT_iso(
  32. QK_BOOT, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  33. UG_TOGG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  34. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  35. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  36. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  37. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_MPLY, KC_MNXT
  38. ),
  39. };
  40. // clang-format on
  41. // RGB config, for changing RGB settings on non-VIA firmwares
  42. #ifdef RGBLIGHT_ENABLE
  43. void change_RGB(bool clockwise) {
  44. bool shift = get_mods() & MOD_MASK_SHIFT;
  45. bool alt = get_mods() & MOD_MASK_ALT;
  46. bool ctrl = get_mods() & MOD_MASK_CTRL;
  47. #ifdef CONSOLE_ENABLE
  48. dprintf("Mods: %u\n", get_mods());
  49. #endif
  50. if (clockwise) {
  51. if (alt) {
  52. rgblight_increase_hue();
  53. } else if (ctrl) {
  54. rgblight_increase_val();
  55. } else if (shift) {
  56. rgblight_increase_sat();
  57. } else {
  58. rgblight_step();
  59. }
  60. } else {
  61. if (alt) {
  62. rgblight_decrease_hue();
  63. } else if (ctrl) {
  64. rgblight_decrease_val();
  65. } else if (shift) {
  66. rgblight_decrease_sat();
  67. } else {
  68. rgblight_step_reverse();
  69. }
  70. }
  71. }
  72. #endif
  73. bool encoder_update_user(uint8_t index, bool clockwise) {
  74. if (layer_state_is(1)) {
  75. // change RGB settings
  76. #ifdef RGBLIGHT_ENABLE
  77. change_RGB(clockwise);
  78. #endif
  79. } else {
  80. if (index == 0) {
  81. // Left encoder: Volume control
  82. if (clockwise) {
  83. tap_code(KC_VOLU);
  84. } else {
  85. tap_code(KC_VOLD);
  86. }
  87. } else if (index == 1) {
  88. // Right encoder: skip forward/back
  89. if (clockwise) {
  90. tap_code(KC_MNXT);
  91. } else {
  92. tap_code(KC_MPRV);
  93. }
  94. }
  95. }
  96. return true;
  97. }