esp_hidd_private.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright 2017-2019 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #pragma once
  14. #include "esp_err.h"
  15. #include "esp_hidd.h"
  16. #include "esp_hid_common.h"
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. typedef union {
  21. struct {
  22. uint16_t notify_enable : 1;
  23. uint16_t indicate_enable : 1;
  24. uint16_t reserved : 14;
  25. };
  26. uint16_t value;
  27. } hidd_le_ccc_value_t;
  28. typedef struct {
  29. uint8_t map_index; // the index of the report map
  30. uint8_t report_id; // the id of the report
  31. uint8_t report_type; // input, output or feature
  32. uint8_t protocol_mode; // boot or report
  33. esp_hid_usage_t usage; // generic, keyboard, mouse, joystick or gamepad
  34. uint16_t value_len; // maximum len of value by report map
  35. // used by gatts
  36. uint8_t index; // index of the value in the gatts attr db
  37. uint16_t handle; // obtained once all attributes are registered
  38. uint16_t ccc_handle; // obtained once all attributes are registered
  39. hidd_le_ccc_value_t ccc; // notifications and/or indications enabled
  40. } hidd_report_item_t;
  41. struct esp_hidd_dev_s {
  42. void *dev;
  43. esp_hid_transport_t transport;
  44. bool (*connected) (void *dev);
  45. esp_err_t (*deinit) (void *dev);
  46. esp_err_t (*disconnect) (void *dev);
  47. esp_err_t (*virtual_unplug) (void *dev);
  48. esp_err_t (*battery_set) (void *dev, uint8_t level);
  49. esp_err_t (*input_set) (void *dev, size_t map_index, size_t report_id, uint8_t *data, size_t length);
  50. esp_err_t (*feature_set) (void *dev, size_t map_index, size_t report_id, uint8_t *data, size_t length);
  51. esp_err_t (*event_handler_register) (void *dev, esp_event_handler_t callback, esp_hidd_event_t event);
  52. esp_err_t (*event_handler_unregister) (void *dev, esp_event_handler_t callback, esp_hidd_event_t event);
  53. };
  54. typedef struct esp_hidd_dev_s esp_hidd_dev_t;
  55. void esp_hidd_process_event_data_handler(void *event_handler_arg, esp_event_base_t event_base, int32_t event_id,
  56. void *event_data);
  57. #ifdef __cplusplus
  58. }
  59. #endif