logo

qmk_firmware

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

keymap.c (1545B)


  1. /* Copyright 2021 QMK
  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 <math.h>
  18. enum custom_keycodes {
  19. DG_TIP = SAFE_RANGE,
  20. };
  21. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  22. LAYOUT_ortho_1x1(DG_TIP)
  23. };
  24. uint32_t timer = 0;
  25. void keyboard_post_init_user(void) {
  26. digitizer_in_range_on();
  27. }
  28. void matrix_scan_user(void) {
  29. if (timer_elapsed32(timer) < 200) {
  30. return;
  31. }
  32. timer = timer_read32();
  33. float x = 0.5 - 0.2 * cos(timer / 250. / 6.28);
  34. float y = 0.5 - 0.2 * sin(timer / 250. / 6.28);
  35. digitizer_set_position(x, y);
  36. }
  37. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  38. switch (keycode) {
  39. case DG_TIP:
  40. if (record->event.pressed) {
  41. digitizer_tip_switch_on();
  42. } else {
  43. digitizer_tip_switch_off();
  44. }
  45. return false;
  46. }
  47. return true;
  48. }