logo

qmk_firmware

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

lynepad.c (1864B)


  1. /*
  2. Copyright 2020 KemoNine
  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. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include "quantum.h"
  15. void keyboard_pre_init_kb(void) {
  16. // Encoder pins
  17. gpio_set_pin_input(PIN_TW_SW);
  18. gpio_set_pin_input(PIN_RJ_SW);
  19. gpio_set_pin_input(PIN_RJ_DIR_A);
  20. gpio_set_pin_input(PIN_RJ_DIR_C);
  21. gpio_set_pin_input(PIN_RJ_DIR_B);
  22. gpio_set_pin_input(PIN_RJ_DIR_D);
  23. keyboard_pre_init_user();
  24. }
  25. int16_t enc1Center = 1;
  26. int16_t enc1CenterPrev = 1;
  27. int16_t enc2Center = 1;
  28. int16_t enc2CenterPrev = 1;
  29. int16_t enc2Up = 1;
  30. int16_t enc2UpPrev = 1;
  31. int16_t enc2Down = 1;
  32. int16_t enc2DownPrev = 1;
  33. int16_t enc2Left = 1;
  34. int16_t enc2LeftPrev = 1;
  35. int16_t enc2Right = 1;
  36. int16_t enc2RightPrev = 1;
  37. void matrix_scan_kb(void) {
  38. enc1CenterPrev = enc1Center;
  39. enc1Center = gpio_read_pin(PIN_TW_SW);
  40. enc2CenterPrev = enc2Center;
  41. enc2Center = gpio_read_pin(PIN_RJ_SW);
  42. enc2UpPrev = enc2Up;
  43. enc2Up = gpio_read_pin(PIN_RJ_DIR_A);
  44. enc2DownPrev = enc2Down;
  45. enc2Down = gpio_read_pin(PIN_RJ_DIR_C);
  46. enc2LeftPrev = enc2Left;
  47. enc2Left = gpio_read_pin(PIN_RJ_DIR_B);
  48. enc2RightPrev = enc2Right;
  49. enc2Right = gpio_read_pin(PIN_RJ_DIR_D);
  50. // Ensure any user customizations are called (for some reason this wasn't happening by default)
  51. matrix_scan_user();
  52. }