digitizer.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* Copyright 2021
  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 "quantum.h"
  18. #include <stdbool.h>
  19. #include <stdint.h>
  20. /**
  21. * \defgroup digitizer
  22. *
  23. * HID Digitizer
  24. * \{
  25. */
  26. typedef struct {
  27. bool in_range : 1;
  28. bool tip : 1;
  29. bool barrel : 1;
  30. float x;
  31. float y;
  32. bool dirty;
  33. } digitizer_t;
  34. extern digitizer_t digitizer_state;
  35. /**
  36. * \brief Send the digitizer report to the host if it is marked as dirty.
  37. */
  38. void digitizer_flush(void);
  39. /**
  40. * \brief Assert the "in range" indicator, and flush the report.
  41. */
  42. void digitizer_in_range_on(void);
  43. /**
  44. * \brief Deassert the "in range" indicator, and flush the report.
  45. */
  46. void digitizer_in_range_off(void);
  47. /**
  48. * \brief Assert the tip switch, and flush the report.
  49. */
  50. void digitizer_tip_switch_on(void);
  51. /**
  52. * \brief Deassert the tip switch, and flush the report.
  53. */
  54. void digitizer_tip_switch_off(void);
  55. /**
  56. * \brief Assert the barrel switch, and flush the report.
  57. */
  58. void digitizer_barrel_switch_on(void);
  59. /**
  60. * \brief Deassert the barrel switch, and flush the report.
  61. */
  62. void digitizer_barrel_switch_off(void);
  63. /**
  64. * \brief Set the absolute X and Y position of the digitizer contact, and flush the report.
  65. *
  66. * \param x The X value of the contact position, from 0 to 1.
  67. * \param y The Y value of the contact position, from 0 to 1.
  68. */
  69. void digitizer_set_position(float x, float y);
  70. void host_digitizer_send(digitizer_t *digitizer);
  71. /** \} */