logo

qmk_firmware

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

analog_joystick.h (1772B)


  1. /* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
  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. #pragma once
  17. #include <stdbool.h>
  18. #include <stdint.h>
  19. #include "pointing_device.h"
  20. #ifndef ANALOG_JOYSTICK_X_AXIS_PIN
  21. # error No pin specified for X Axis
  22. #endif
  23. #ifndef ANALOG_JOYSTICK_Y_AXIS_PIN
  24. # error No pin specified for Y Axis
  25. #endif
  26. #ifndef ANALOG_JOYSTICK_AXIS_MIN
  27. # define ANALOG_JOYSTICK_AXIS_MIN 0
  28. #endif
  29. #ifndef ANALOG_JOYSTICK_AXIS_MAX
  30. # define ANALOG_JOYSTICK_AXIS_MAX 1023
  31. #endif
  32. #ifndef ANALOG_JOYSTICK_SPEED_REGULATOR
  33. # define ANALOG_JOYSTICK_SPEED_REGULATOR 20
  34. #endif
  35. #ifndef ANALOG_JOYSTICK_READ_INTERVAL
  36. # define ANALOG_JOYSTICK_READ_INTERVAL 10
  37. #endif
  38. #ifndef ANALOG_JOYSTICK_SPEED_MAX
  39. # define ANALOG_JOYSTICK_SPEED_MAX 2
  40. #endif
  41. const pointing_device_driver_t analog_joystick_pointing_device_driver;
  42. typedef struct {
  43. int8_t x;
  44. int8_t y;
  45. bool button;
  46. } report_analog_joystick_t;
  47. report_analog_joystick_t analog_joystick_read(void);
  48. void analog_joystick_init(void);
  49. report_mouse_t analog_joystick_get_report(report_mouse_t mouse_report);