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.

84 lines
2.0 KiB

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