You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
3.2 KiB

  1. /*
  2. Copyright 2017 Joshua Broekhuijsen <snipeye+qmk@gmail.com>
  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. #pragma once
  15. #include <stdint.h>
  16. #include "host.h"
  17. #include "report.h"
  18. #if defined(POINTING_DEVICE_DRIVER_adns5050)
  19. # include "drivers/sensors/adns5050.h"
  20. #elif defined(POINTING_DEVICE_DRIVER_adns9800)
  21. # include "spi_master.h"
  22. # include "drivers/sensors/adns9800.h"
  23. #elif defined(POINTING_DEVICE_DRIVER_analog_joystick)
  24. # include "analog.h"
  25. # include "drivers/sensors/analog_joystick.h"
  26. #elif defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_i2c) || defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_spi)
  27. # include "drivers/sensors/cirque_pinnacle.h"
  28. #elif defined(POINTING_DEVICE_DRIVER_pimoroni_trackball)
  29. # include "i2c_master.h"
  30. # include "drivers/sensors/pimoroni_trackball.h"
  31. // support for legacy pimoroni defines
  32. # ifdef PIMORONI_TRACKBALL_INVERT_X
  33. # define POINTING_DEVICE_INVERT_X
  34. # endif
  35. # ifdef PIMORONI_TRACKBALL_INVERT_Y
  36. # define POINTING_DEVICE_INVERT_Y
  37. # endif
  38. # ifdef PIMORONI_TRACKBALL_ROTATE
  39. # define POINTING_DEVICE_ROTATION_90
  40. # endif
  41. #elif defined(POINTING_DEVICE_DRIVER_pmw3360)
  42. # include "spi_master.h"
  43. # include "drivers/sensors/pmw3360.h"
  44. #else
  45. void pointing_device_driver_init(void);
  46. report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report);
  47. uint16_t pointing_device_driver_get_cpi(void);
  48. void pointing_device_driver_set_cpi(uint16_t cpi);
  49. #endif
  50. typedef struct {
  51. void (*init)(void);
  52. report_mouse_t (*get_report)(report_mouse_t mouse_report);
  53. void (*set_cpi)(uint16_t);
  54. uint16_t (*get_cpi)(void);
  55. } pointing_device_driver_t;
  56. typedef enum {
  57. POINTING_DEVICE_BUTTON1,
  58. POINTING_DEVICE_BUTTON2,
  59. POINTING_DEVICE_BUTTON3,
  60. POINTING_DEVICE_BUTTON4,
  61. POINTING_DEVICE_BUTTON5,
  62. POINTING_DEVICE_BUTTON6,
  63. POINTING_DEVICE_BUTTON7,
  64. POINTING_DEVICE_BUTTON8,
  65. } pointing_device_buttons_t;
  66. void pointing_device_init(void);
  67. void pointing_device_task(void);
  68. void pointing_device_send(void);
  69. report_mouse_t pointing_device_get_report(void);
  70. void pointing_device_set_report(report_mouse_t newMouseReport);
  71. bool has_mouse_report_changed(report_mouse_t new, report_mouse_t old);
  72. uint16_t pointing_device_get_cpi(void);
  73. void pointing_device_set_cpi(uint16_t cpi);
  74. void pointing_device_init_kb(void);
  75. void pointing_device_init_user(void);
  76. report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report);
  77. report_mouse_t pointing_device_task_user(report_mouse_t mouse_report);
  78. uint8_t pointing_device_handle_buttons(uint8_t buttons, bool pressed, pointing_device_buttons_t button);