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.

61 lines
2.0 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. #include <stdint.h>
  15. #include "report.h"
  16. #include "host.h"
  17. #include "timer.h"
  18. #include "print.h"
  19. #include "debug.h"
  20. #include "pointing_device.h"
  21. static report_mouse_t mouseReport = {};
  22. __attribute__ ((weak))
  23. void pointing_device_init(void){
  24. //initialize device, if that needs to be done.
  25. }
  26. __attribute__ ((weak))
  27. void pointing_device_send(void){
  28. //If you need to do other things, like debugging, this is the place to do it.
  29. host_mouse_send(&mouseReport);
  30. //send it and 0 it out except for buttons, so those stay until they are explicity over-ridden using update_pointing_device
  31. mouseReport.x = 0;
  32. mouseReport.y = 0;
  33. mouseReport.v = 0;
  34. mouseReport.h = 0;
  35. }
  36. __attribute__ ((weak))
  37. void pointing_device_task(void){
  38. //gather info and put it in:
  39. //mouseReport.x = 127 max -127 min
  40. //mouseReport.y = 127 max -127 min
  41. //mouseReport.v = 127 max -127 min (scroll vertical)
  42. //mouseReport.h = 127 max -127 min (scroll horizontal)
  43. //mouseReport.buttons = 0x1F (decimal 31, binary 00011111) max (bitmask for mouse buttons 1-5, 1 is rightmost, 5 is leftmost) 0x00 min
  44. //send the report
  45. pointing_device_send();
  46. }
  47. report_mouse_t pointing_device_get_report(void){
  48. return mouseReport;
  49. }
  50. void pointing_device_set_report(report_mouse_t newMouseReport){
  51. mouseReport = newMouseReport;
  52. }