logo

qmk_firmware

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

pointing_device.h (5702B)


  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 <stdbool.h>
  16. #include <stdint.h>
  17. #include "host.h"
  18. #include "report.h"
  19. typedef struct {
  20. void (*init)(void);
  21. report_mouse_t (*get_report)(report_mouse_t mouse_report);
  22. void (*set_cpi)(uint16_t);
  23. uint16_t (*get_cpi)(void);
  24. } pointing_device_driver_t;
  25. #ifdef POINTING_DEVICE_AUTO_MOUSE_ENABLE
  26. # include "pointing_device_auto_mouse.h"
  27. #endif
  28. #if defined(POINTING_DEVICE_DRIVER_adns5050)
  29. # include "drivers/sensors/adns5050.h"
  30. # define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
  31. #elif defined(POINTING_DEVICE_DRIVER_pmw3320)
  32. # include "drivers/sensors/pmw3320.h"
  33. # define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
  34. #elif defined(POINTING_DEVICE_DRIVER_adns9800)
  35. # include "spi_master.h"
  36. # include "drivers/sensors/adns9800.h"
  37. # define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
  38. #elif defined(POINTING_DEVICE_DRIVER_analog_joystick)
  39. # include "analog.h"
  40. # include "drivers/sensors/analog_joystick.h"
  41. # define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
  42. #elif defined(POINTING_DEVICE_DRIVER_azoteq_iqs5xx)
  43. # include "i2c_master.h"
  44. # include "drivers/sensors/azoteq_iqs5xx.h"
  45. #elif defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_i2c) || defined(POINTING_DEVICE_DRIVER_cirque_pinnacle_spi)
  46. # include "drivers/sensors/cirque_pinnacle.h"
  47. # include "pointing_device_gestures.h"
  48. #elif defined(POINTING_DEVICE_DRIVER_paw3204)
  49. # include "drivers/sensors/paw3204.h"
  50. # define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
  51. #elif defined(POINTING_DEVICE_DRIVER_pimoroni_trackball)
  52. # include "i2c_master.h"
  53. # include "drivers/sensors/pimoroni_trackball.h"
  54. // support for legacy pimoroni defines
  55. # ifdef PIMORONI_TRACKBALL_INVERT_X
  56. # define POINTING_DEVICE_INVERT_X
  57. # endif
  58. # ifdef PIMORONI_TRACKBALL_INVERT_Y
  59. # define POINTING_DEVICE_INVERT_Y
  60. # endif
  61. # ifdef PIMORONI_TRACKBALL_ROTATE
  62. # define POINTING_DEVICE_ROTATION_90
  63. # endif
  64. # define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
  65. #elif defined(POINTING_DEVICE_DRIVER_pmw3360) || defined(POINTING_DEVICE_DRIVER_pmw3389)
  66. # include "spi_master.h"
  67. # include "drivers/sensors/pmw33xx_common.h"
  68. # define POINTING_DEVICE_MOTION_PIN_ACTIVE_LOW
  69. #else
  70. void pointing_device_driver_init(void);
  71. report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report);
  72. uint16_t pointing_device_driver_get_cpi(void);
  73. void pointing_device_driver_set_cpi(uint16_t cpi);
  74. #endif
  75. typedef enum {
  76. POINTING_DEVICE_BUTTON1,
  77. POINTING_DEVICE_BUTTON2,
  78. POINTING_DEVICE_BUTTON3,
  79. POINTING_DEVICE_BUTTON4,
  80. POINTING_DEVICE_BUTTON5,
  81. POINTING_DEVICE_BUTTON6,
  82. POINTING_DEVICE_BUTTON7,
  83. POINTING_DEVICE_BUTTON8,
  84. } pointing_device_buttons_t;
  85. #ifdef MOUSE_EXTENDED_REPORT
  86. typedef int32_t xy_clamp_range_t;
  87. #else
  88. typedef int16_t xy_clamp_range_t;
  89. #endif
  90. #ifdef WHEEL_EXTENDED_REPORT
  91. typedef int32_t hv_clamp_range_t;
  92. #else
  93. typedef int16_t hv_clamp_range_t;
  94. #endif
  95. #define CONSTRAIN_HID(amt) ((amt) < INT8_MIN ? INT8_MIN : ((amt) > INT8_MAX ? INT8_MAX : (amt)))
  96. #define CONSTRAIN_HID_XY(amt) ((amt) < MOUSE_REPORT_XY_MIN ? MOUSE_REPORT_XY_MIN : ((amt) > MOUSE_REPORT_XY_MAX ? MOUSE_REPORT_XY_MAX : (amt)))
  97. void pointing_device_init(void);
  98. bool pointing_device_task(void);
  99. bool pointing_device_send(void);
  100. report_mouse_t pointing_device_get_report(void);
  101. void pointing_device_set_report(report_mouse_t mouse_report);
  102. uint16_t pointing_device_get_cpi(void);
  103. void pointing_device_set_cpi(uint16_t cpi);
  104. void pointing_device_init_kb(void);
  105. void pointing_device_init_user(void);
  106. report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report);
  107. report_mouse_t pointing_device_task_user(report_mouse_t mouse_report);
  108. uint8_t pointing_device_handle_buttons(uint8_t buttons, bool pressed, pointing_device_buttons_t button);
  109. report_mouse_t pointing_device_adjust_by_defines(report_mouse_t mouse_report);
  110. void pointing_device_keycode_handler(uint16_t keycode, bool pressed);
  111. #ifdef POINTING_DEVICE_HIRES_SCROLL_ENABLE
  112. uint16_t pointing_device_get_hires_scroll_resolution(void);
  113. #endif
  114. #if defined(SPLIT_POINTING_ENABLE)
  115. void pointing_device_set_shared_report(report_mouse_t report);
  116. uint16_t pointing_device_get_shared_cpi(void);
  117. # if !defined(POINTING_DEVICE_TASK_THROTTLE_MS)
  118. # define POINTING_DEVICE_TASK_THROTTLE_MS 1
  119. # endif
  120. # if defined(POINTING_DEVICE_COMBINED)
  121. void pointing_device_set_cpi_on_side(bool left, uint16_t cpi);
  122. report_mouse_t pointing_device_combine_reports(report_mouse_t left_report, report_mouse_t right_report);
  123. report_mouse_t pointing_device_task_combined_kb(report_mouse_t left_report, report_mouse_t right_report);
  124. report_mouse_t pointing_device_task_combined_user(report_mouse_t left_report, report_mouse_t right_report);
  125. report_mouse_t pointing_device_adjust_by_defines_right(report_mouse_t mouse_report);
  126. # endif // defined(POINTING_DEVICE_COMBINED)
  127. #endif // defined(SPLIT_POINTING_ENABLE)