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.

106 lines
4.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. #elif defined(POINTING_DEVICE_DRIVER_pmw3389)
  45. # include "spi_master.h"
  46. # include "drivers/sensors/pmw3389.h"
  47. #else
  48. void pointing_device_driver_init(void);
  49. report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report);
  50. uint16_t pointing_device_driver_get_cpi(void);
  51. void pointing_device_driver_set_cpi(uint16_t cpi);
  52. #endif
  53. typedef struct {
  54. void (*init)(void);
  55. report_mouse_t (*get_report)(report_mouse_t mouse_report);
  56. void (*set_cpi)(uint16_t);
  57. uint16_t (*get_cpi)(void);
  58. } pointing_device_driver_t;
  59. typedef enum {
  60. POINTING_DEVICE_BUTTON1,
  61. POINTING_DEVICE_BUTTON2,
  62. POINTING_DEVICE_BUTTON3,
  63. POINTING_DEVICE_BUTTON4,
  64. POINTING_DEVICE_BUTTON5,
  65. POINTING_DEVICE_BUTTON6,
  66. POINTING_DEVICE_BUTTON7,
  67. POINTING_DEVICE_BUTTON8,
  68. } pointing_device_buttons_t;
  69. void pointing_device_init(void);
  70. void pointing_device_task(void);
  71. void pointing_device_send(void);
  72. report_mouse_t pointing_device_get_report(void);
  73. void pointing_device_set_report(report_mouse_t mouse_report);
  74. uint16_t pointing_device_get_cpi(void);
  75. void pointing_device_set_cpi(uint16_t cpi);
  76. void pointing_device_init_kb(void);
  77. void pointing_device_init_user(void);
  78. report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report);
  79. report_mouse_t pointing_device_task_user(report_mouse_t mouse_report);
  80. uint8_t pointing_device_handle_buttons(uint8_t buttons, bool pressed, pointing_device_buttons_t button);
  81. report_mouse_t pointing_device_adjust_by_defines(report_mouse_t mouse_report);
  82. #if defined(SPLIT_POINTING_ENABLE)
  83. void pointing_device_set_shared_report(report_mouse_t report);
  84. uint16_t pointing_device_get_shared_cpi(void);
  85. # if !defined(POINTING_DEVICE_TASK_THROTTLE_MS)
  86. # define POINTING_DEVICE_TASK_THROTTLE_MS 1
  87. # endif
  88. # if defined(POINTING_DEVICE_COMBINED)
  89. void pointing_device_set_cpi_on_side(bool left, uint16_t cpi);
  90. report_mouse_t pointing_device_combine_reports(report_mouse_t left_report, report_mouse_t right_report);
  91. report_mouse_t pointing_device_task_combined_kb(report_mouse_t left_report, report_mouse_t right_report);
  92. report_mouse_t pointing_device_task_combined_user(report_mouse_t left_report, report_mouse_t right_report);
  93. report_mouse_t pointing_device_adjust_by_defines_right(report_mouse_t mouse_report);
  94. # endif // defined(POINTING_DEVICE_COMBINED)
  95. #endif // defined(SPLIT_POINTING_ENABLE)