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