logo

qmk_firmware

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

keymap.c (3459B)


  1. /* Copyright 2020 KemoNine
  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. /* Keymap (Base Layer) Default Layer
  19. * |----------------------------|
  20. * | 1 | 2 | 3 | 4 | |
  21. * | 5 | 6 | 7 | 8 | |
  22. * | 9 | 10 | 11 | |
  23. * |----------------------------|
  24. */
  25. [0] = LAYOUT(
  26. KC_MS_BTN4, KC_MS_BTN2, KC_MS_UP, KC_MS_BTN1,
  27. KC_MS_BTN5, KC_MS_LEFT, KC_MS_DOWN, KC_MS_RIGHT,
  28. KC_MS_ACCEL0, KC_MS_ACCEL1, KC_MS_ACCEL2
  29. )
  30. };
  31. // Standard encoder functionality
  32. bool encoder_update_user(uint8_t index, bool clockwise) {
  33. // Process encoder rotational movements
  34. if (index == 0) { /* First encoder */
  35. if (clockwise) {
  36. tap_code(KC_AUDIO_VOL_DOWN);
  37. } else {
  38. tap_code(KC_AUDIO_VOL_UP);
  39. }
  40. } else if (index == 1) { /* Second encoder */
  41. if (clockwise) {
  42. tap_code(KC_MS_WH_UP);
  43. } else {
  44. tap_code(KC_MS_WH_DOWN);
  45. }
  46. }
  47. return true;
  48. }
  49. // Encoder press / tilt event handling
  50. // the core lynepad implementation will update the below variables on each matrix scan
  51. // Update the various codes below for customizing the tilt / push config
  52. extern int16_t enc1Center;
  53. extern int16_t enc1CenterPrev;
  54. extern int16_t enc2Center;
  55. extern int16_t enc2CenterPrev;
  56. extern int16_t enc2Up;
  57. extern int16_t enc2UpPrev;
  58. extern int16_t enc2Down;
  59. extern int16_t enc2DownPrev;
  60. extern int16_t enc2Left;
  61. extern int16_t enc2LeftPrev;
  62. extern int16_t enc2Right;
  63. extern int16_t enc2RightPrev;
  64. void matrix_scan_user(void) {
  65. if (enc1Center != enc1CenterPrev) {
  66. if (enc1Center < ENC_TILT_THRESHOLD) {
  67. }
  68. else {
  69. reset_keyboard();
  70. }
  71. }
  72. if (enc2Center != enc2CenterPrev) {
  73. if (enc2Center < ENC_TILT_THRESHOLD) {
  74. register_code16(KC_MS_BTN3);
  75. }
  76. else {
  77. unregister_code16(KC_MS_BTN3);
  78. }
  79. /*
  80. * Encoder sets ALL values when center is pressed so bail out at this point
  81. * to avoid the rest of the encoder buttons registering events
  82. */
  83. return;
  84. }
  85. if (enc2Up != enc2UpPrev) {
  86. if (enc2Up < ENC_TILT_THRESHOLD) {
  87. }
  88. else {
  89. rgblight_increase_val_noeeprom();
  90. }
  91. }
  92. if (enc2Down != enc2DownPrev) {
  93. if (enc2Down < ENC_TILT_THRESHOLD) {
  94. }
  95. else {
  96. rgblight_decrease_val_noeeprom();
  97. }
  98. }
  99. if (enc2Left != enc2LeftPrev) {
  100. if (enc2Left < ENC_TILT_THRESHOLD) {
  101. }
  102. else {
  103. rgblight_toggle_noeeprom();
  104. }
  105. }
  106. if (enc2Right != enc2RightPrev) {
  107. if (enc2Right < ENC_TILT_THRESHOLD) {
  108. }
  109. else {
  110. rgblight_step_noeeprom();
  111. }
  112. }
  113. }