/* * SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 *//* ... */#pragmaonce#ifdef__cplusplusextern"C"{#endif#include<stdint.h>#include<stddef.h>#include<stdio.h>/* HID Report Map Values */#defineHID_RM_INPUT0x80#defineHID_RM_OUTPUT0x90#defineHID_RM_FEATURE0xb0#defineHID_RM_COLLECTION0xa0#defineHID_RM_END_COLLECTION0xc0#defineHID_RM_USAGE_PAGE0x04#defineHID_RM_LOGICAL_MINIMUM0x14#defineHID_RM_LOGICAL_MAXIMUM0x24#defineHID_RM_PHYSICAL_MINIMUM0x34#defineHID_RM_PHYSICAL_MAXIMUM0x44#defineHID_RM_UNIT_EXPONENT0x54#defineHID_RM_UNIT0x64#defineHID_RM_REPORT_SIZE0x74#defineHID_RM_REPORT_ID0x84#defineHID_RM_REPORT_COUNT0x94#defineHID_RM_PUSH0xa4#defineHID_RM_POP0xb4#defineHID_RM_USAGE0x08#defineHID_RM_USAGE_MINIMUM0x18#defineHID_RM_USAGE_MAXIMUM0x28#defineHID_RM_DESIGNATOR_INDEX0x38#defineHID_RM_DESIGNATOR_MINIMUM0x48#defineHID_RM_DESIGNATOR_MAXIMUM0x58#defineHID_RM_STRING_INDEX0x78#defineHID_RM_STRING_MINIMUM0x88#defineHID_RM_STRING_MAXIMUM0x98#defineHID_RM_DELIMITER0xa8/* HID Usage Pages and Usages */#defineHID_USAGE_PAGE_GENERIC_DESKTOP0x01#defineHID_USAGE_KEYBOARD0x06#defineHID_USAGE_MOUSE0x02#defineHID_USAGE_JOYSTICK0x04#defineHID_USAGE_GAMEPAD0x05#defineHID_USAGE_PAGE_CONSUMER_DEVICE0x0C#defineHID_USAGE_CONSUMER_CONTROL0x01/* HID BT COD Peripheral Min Values Main Role */#defineESP_HID_COD_MIN_KEYBOARD0x10#defineESP_HID_COD_MIN_MOUSE0x20/* HID BLE Appearances */#defineESP_HID_APPEARANCE_GENERIC0x03C0#defineESP_HID_APPEARANCE_KEYBOARD0x03C1#defineESP_HID_APPEARANCE_MOUSE0x03C2#defineESP_HID_APPEARANCE_JOYSTICK0x03C3#defineESP_HID_APPEARANCE_GAMEPAD0x03C4/* HID Report Types */#defineESP_HID_REPORT_TYPE_INPUT1#defineESP_HID_REPORT_TYPE_OUTPUT2#defineESP_HID_REPORT_TYPE_FEATURE3/* HID Protocol Modes */#defineESP_HID_PROTOCOL_MODE_BOOT0x00// Boot Protocol Mode#defineESP_HID_PROTOCOL_MODE_REPORT0x01// Report Protocol Mode/* HID information flags */#defineESP_HID_FLAGS_REMOTE_WAKE0x01// RemoteWake#defineESP_HID_FLAGS_NORMALLY_CONNECTABLE0x02// NormallyConnectable/* Control point commands */#defineESP_HID_CONTROL_SUSPEND0x00// Suspend#defineESP_HID_CONTROL_EXIT_SUSPEND0x01// Exit Suspend/* Client Characteristic Configuration values */#defineESP_HID_CCC_NOTIFICATIONS_ENABLED0x01// Notifications enabled#defineESP_HID_CCC_INDICATIONS_ENABLED0x02// Indications enabled52 defines/* HID Transports */typedefenum{ESP_HID_TRANSPORT_BT,ESP_HID_TRANSPORT_BLE,ESP_HID_TRANSPORT_USB,ESP_HID_TRANSPORT_MAX}{ ... }esp_hid_transport_t;/* HID Usage Types */typedefenum{ESP_HID_USAGE_GENERIC=0,ESP_HID_USAGE_KEYBOARD=1,ESP_HID_USAGE_MOUSE=2,ESP_HID_USAGE_JOYSTICK=4,ESP_HID_USAGE_GAMEPAD=8,ESP_HID_USAGE_TABLET=16,ESP_HID_USAGE_CCONTROL=32,ESP_HID_USAGE_VENDOR=64}{ ... }esp_hid_usage_t;/* HID BT COD Peripheral Min Values. Mask of (keyboard|mouse|ESP_HIDH_COD_*) */typedefenum{ESP_HID_COD_MIN_GENERIC,ESP_HID_COD_MIN_JOYSTICK,ESP_HID_COD_MIN_GAMEPAD,ESP_HID_COD_MIN_REMOTE,ESP_HID_COD_MIN_SENSOR,ESP_HID_COD_MIN_TABLET,ESP_HID_COD_MIN_CARD_READER,ESP_HID_COD_MIN_MAX}{ ... }esp_hid_cod_min_t;/* HID transaction Types */typedefenum{ESP_HID_TRANS_HANDSHAKE=0,ESP_HID_TRANS_CONTROL=1,ESP_HID_TRANS_GET_REPORT=4,ESP_HID_TRANS_SET_REPORT=5,ESP_HID_TRANS_GET_PROTOCOL=6,ESP_HID_TRANS_SET_PROTOCOL=7,ESP_HID_TRANS_GET_IDLE=8,ESP_HID_TRANS_SET_IDLE=9,ESP_HID_TRANS_DATA=10,ESP_HID_TRANS_DATAC=11,ESP_HID_TRANS_MAX}{ ... }esp_hid_trans_type_t;/** * @brief HID report item structure *//* ... */typedefstruct{uint8_tmap_index;/*!< HID report map index */uint8_treport_id;/*!< HID report id */uint8_treport_type;/*!< HID report type */uint8_tprotocol_mode;/*!< HID protocol mode */esp_hid_usage_tusage;/*!< HID usage type */uint16_tvalue_len;/*!< HID report length in bytes */}{ ... }esp_hid_report_item_t;/** * @brief HID parsed report map structure *//* ... */typedefstruct{esp_hid_usage_tusage;/*!< Dominant HID usage. (keyboard > mouse > joystick > gamepad > generic) */uint16_tappearance;/*!< Calculated HID Appearance based on the dominant usage */uint8_treports_len;/*!< Number of reports discovered in the report map */esp_hid_report_item_t*reports;/*!< Reports discovered in the report map */}{ ... }esp_hid_report_map_t;/** * @brief HID raw report map structure *//* ... */typedefstruct{constuint8_t*data;/*!< Pointer to the HID report map data */uint16_tlen;/*!< HID report map data length */}{ ... }esp_hid_raw_report_map_t;/** * @brief HID device config structure *//* ... */typedefstruct{uint16_tvendor_id;/*!< HID Vendor ID */uint16_tproduct_id;/*!< HID Product ID */uint16_tversion;/*!< HID Product Version */constchar*device_name;/*!< HID Device Name */constchar*manufacturer_name;/*!< HID Manufacturer */constchar*serial_number;/*!< HID Serial Number */esp_hid_raw_report_map_t*report_maps;/*!< Array of the raw HID report maps */uint8_treport_maps_len;/*!< number of raw report maps in the array */}{ ... }esp_hid_device_config_t;/** * @brief HID device address *//* ... */typedefunion{uint8_tbda[6];/*!< Bluetooth device address */uint8_tusb_addr;/*!< USB address */}{ ... }esp_hid_address_t;/* * @brief Parse RAW HID report map * It is a responsibility of the user to free the parsed report map, * when it's no longer needed. Use esp_hid_free_report_map * @param hid_rm : pointer to the hid report map data * @param hid_rm_len : length to the hid report map data * * @return: pointer to the parsed report map *//* ... */esp_hid_report_map_t*esp_hid_parse_report_map(constuint8_t*hid_rm,size_thid_rm_len);/* * @brief Free parsed HID report map * @param map : pointer to the parsed hid report map *//* ... */voidesp_hid_free_report_map(esp_hid_report_map_t*map);/** * @brief Calculate the HID Device usage type from the BLE Apperance * @param appearance : BLE Apperance value * * @return: the hid usage type *//* ... */esp_hid_usage_tesp_hid_usage_from_appearance(uint16_tappearance);/** * @brief Calculate the HID Device usage type from the BT CoD * @param cod : BT CoD value * * @return: the hid usage type *//* ... */esp_hid_usage_tesp_hid_usage_from_cod(uint32_tcod);/** * @brief Convert device usage type to string * @param usage : The HID usage type to convert * * @return: a pointer to the string or NULL *//* ... */constchar*esp_hid_usage_str(esp_hid_usage_tusage);/** * @brief Convert HID protocol mode to string * @param protocol_mode : The HID protocol mode to convert * BOOT/REPORT * * @return: a pointer to the string or NULL *//* ... */constchar*esp_hid_protocol_mode_str(uint8_tprotocol_mode);/** * @brief Convert HID report type to string * @param report_type : The HID report type to convert * INPUT/OUTPUT/FEATURE * * @return: a pointer to the string or NULL *//* ... */constchar*esp_hid_report_type_str(uint8_treport_type);/** * @brief Convert BT CoD major to string * @param cod_major : The CoD major value to convert * * @return: a pointer to the string or NULL *//* ... */constchar*esp_hid_cod_major_str(uint8_tcod_major);/** * @brief Print BT CoD minor value * @param cod_min : The CoD minor value to print * @param fp : pointer to the output file *//* ... */voidesp_hid_cod_minor_print(uint8_tcod_min,FILE*fp);/** * @brief Convert BLE disconnect reason to string * @param reason : The value of the reason * * @return: a pointer to the string or NULL *//* ... */constchar*esp_hid_disconnect_reason_str(esp_hid_transport_ttransport,intreason);#ifdef__cplusplus}{...}#endif
Details
Show: from
Types: Columns:
All items filtered out
All items filtered out
This file uses the notable symbols shown below. Click anywhere in the file to view more details.